let orgainPage = Page // 保存原本的Page对象
module.exports = function (data) {
  let orgainOnShare = data.onShareAppMessage
  data.onShareAppMessage = function (e) {
    const app = getApp()
    const defaultShareInfo = {}
    if (orgainOnShare) {
      let returnVal = orgainOnShare.call(this, e)
      if (returnVal) {
        if (returnVal.path.includes('scene=')) {
          // 匹配到有scene的擦书
          returnVal.path = returnVal.path.replace(/scene=.+(&?)/, word => {
            return (
              word +
              '_' +
              'hhs-' +
              app.globalData.hospitalScene +
              (word.includes('&') ? '&' : '')
            )
          })
        } else {
          returnVal.path =
            returnVal.path + '&' + `scene=hhs-${app.globalData.hospitalScene}`
        }
        console.log(returnVal)
        return returnVal
      } else {
        return defaultShareInfo
      }
    } else {
      return defaultShareInfo
    }
  }
  return orgainPage(data)
}
