// Webview 页面
Page({
  data: {
    webUrl: '',
    title: ''
  },

  onLoad(options) {
    if (options.url) {
      this.setData({
        webUrl: decodeURIComponent(options.url)
      })
    }
    if (options.title) {
      wx.setNavigationBarTitle({
        title: decodeURIComponent(options.title)
      })
      this.setData({ title: decodeURIComponent(options.title) })
    }
  },

  goBack() {
    wx.navigateBack()
  },

  onShareAppMessage() {
    const referralCode = wx.getStorageSync('referralCode') || ''
    const referralCodeParam = referralCode ? `&referralCode=${referralCode}` : ''
    return {
      title: this.data.title || '关于品牌',
      path: `/pages/webview/webview?url=${encodeURIComponent(this.data.webUrl)}&title=${encodeURIComponent(this.data.title || '')}${referralCodeParam}`
    }
  }
})
