index.js 1.82 KB
import { IMG_URL } from '~/config';
Page({

  data: {
    list: [{
      id: 1,
    }, {
      id: 2,
    }, {
      id: 3,
    }, {
      id: 4,
    }, {
      id: 5,
    },],
    showModal: false,
    IMG_URL: IMG_URL
  },


  onShow() {
    this.toCheckMember()
  },
 async toJump(e) {
    const flag = await this.checkLogin()
    if (flag) return
    const { id } = e.currentTarget.dataset
    let url = ''
    const shareCode = '5759S2m7h'
    switch (id) {
      case 1:
        url = `plugin://collectionPlugin/sbkHome?shareCode=${shareCode}&extra=wuye`
        break;
      case 2:
        url = `plugin://collectionPlugin/mdlHome?shareCode=${shareCode}&extra=wuye`
        break;
      case 3:
        url = `plugin://collectionPlugin/naixueHome?shareCode=${shareCode}&extra=wuye`
        break;
      case 4:
        url = `plugin://ticketPlugin/home?shareCode=${shareCode}&reLocation=true&extra=wuye`
        break;
      case 5:
        url = `plugin://express-plugin/home?shareCode=${shareCode}&extra=wuye`
        break;

      default:
        break;
    }
    wx.navigateTo({
      url,
    })

  },
  // 检查是否已登录/会员
  async checkLogin() {
    const authStatus = await wx.p.router.intercept()
    if (authStatus) return authStatus
    if (!this.open) {
      this.setData({
        showModal: true
      })
      return true
    }
    return false
  },
  async toCheckMember() {
    const authStatus = await wx.p.router.intercept(false)
    if (authStatus) return
    wx.p.api.equityApi.checkOpenMember().then(res => {
      let flag = false
      if (res.code == 0 && res.data) {
        flag = true
      }
      this.open = flag
    })
  },
  closeModal() {
    this.setData({
      showModal: false,
    });
  },
  toOpenPage() {
    wx.p.router.go('/packageSaveMoney/pages/open/open', {
      notIntercept: true
    })
  },
})