storeEffect.js 1.33 KB
// pages/tab/storeEffect/storeEffect.js — 店效(原首页 H5,web-view 页用 cover-tab-bar)
const { setCustomTabBar } = require('~/utils/setCustomTabBar')

Page({
  data: {
    webUrl: '',
    userInfo: {},
  },

  onLoad() {
    this.getUserInfo()
    this.init()
  },

  getUserInfo() {
    const userInfo = wx.$util.getUserInfo()
    this.setData({ userInfo })
  },

  init() {
    let index = 2
    const accountInfo = wx.getAccountInfoSync()
    const envName = accountInfo.miniProgram.envVersion
    const manual = false
    const release = false
    switch (envName) {
      case 'develop':
        break
      case 'trial':
        index = manual ? index : 2
        break
      case 'release':
        index = release ? index : 3
        break
      default:
        index = 3
        break
    }
    const webUrls = {
      develop: 'http://192.168.2.111:9527/dj-scrm-wx-work-main-test/#/?phone=',
      trial: 'https://scrm.test.glsx.com.cn/glsx-bi-report/#/?phone=',
      release: 'https://scrm.glsx.com.cn/glsx-bi-report/#/?phone=',
      preRelease: 'http://192.168.2.111:9527/dj-scrm-wx-work-main-test/#/?phone=',
    }
    const target = ['ip', 'develop', 'trial', 'release', 'preRelease']
    const webUrl = webUrls[target[index]]
    this.setData({ webUrl })
  },

  onShow() {
    setCustomTabBar(this, 1)
    this.getUserInfo()
  },
})