list.js 3.01 KB
// components/list/list.js
const util = require('../../utils/util.js')
const restapi = require('../../utils/restapi.js')
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array
    },
    margin: {
      type: Number,
      value: 20
    },
    flag: {
      type: Boolean,
      value: false
    },
    authToast: {
      type: Boolean,
      value: true
    }
  },

  /**
   * 组件的初始数据
   */
  data: {},

  /**
   * 组件的方法列表
   */
  methods: {
    tap(e) {
      this.jump(e, this)
    },
    jump: util.throttle((e, _this) => {
      console.log(!_this.properties.authToast, '!_this.properties.authToast')
      if (!_this.properties.authToast) {
        let index = e.currentTarget.dataset.index
        let url = _this.properties.list[index].modulePath
        let item = e.currentTarget.dataset.item
        console.log(item)
        let list = _this.properties.list
        if (item.moduleName == '我的消息') {
          list[index].redDot = false
          wx.hideTabBarRedDot({
            index: 1
          })
        }
        if (item.moduleName == '隐私政策') {
          //   let {
          //     url
          // } = e.currentTarget.dataset
          const baseUrl = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/html/'
          const path = `${baseUrl}privacy.html`
          //   private user
          wx.navigateTo({
            url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}`
          })
          // var globalData = app.globalData.extConfig
          // restapi.getMerchantBussiness(globalData.merchantId, function (res) {
          //   // console.log(res);
          //   if (res.returnCode == '0') {
          //     let path = `https://dj.glsx.com.cn/agreement/djUserPolicy.html?merchantName=${globalData.merchantName}&phone=${res.data.phone}`
          //     wx.navigateTo({
          //       url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}`
          //     })
          //   }
          // }, function (res) {
          //   console.log(res);
          // })
          return true
        }
        if (item.moduleType == 'h5') {
          let environment = {
            'https://dj.test.glsx.com.cn': 'uat',
            'https://dj.glsx.com.cn': 'prod'
          }
          let path = item.moduleH5Url[environment[restapi.domain]]
          if (!path) path = 'https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/'
          if (item.moduleParams) {
            path = `${path}?${item.moduleParams}`
          }

          wx.navigateTo({
            url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}`
          })
          return
        }
        _this.setData({
          list: list
        })

        wx.navigateTo({
          url: url
        })
      } else {
        wx.navigateTo({
          url: '/pages/auth/index/index'
        })
        /*
          wx.showToast({
            title: '请登录查看',
            icon: 'none'
          })
          */
      }
    }, 1000)
  }
})