TabMine.js 4.5 KB
// components/tabMine/TabMine.js
import api from '~/pages/tabMine/api'
const app = getApp()
import constantData from '../../pages/constant/data'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/mine/'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    navBarHeight: {
      type: Number,
      value: 0
    },
    // 是否显示工资绩效
    showCollege: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    IMG_URL,
    isYqdSuper: '',
    selectedSceneName: '',
    userInfo: {},
    staffBankFlag: false,
    isForbidden: false,
  },

  lifetimes: {
    ready() {
      let userInfo = wx.$util.getUserInfo()
      this.setData({
        isForbidden: !(userInfo?.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5),
        isYqdSuper: app.globalData.isYqdSuper,
        selectedSceneName: constantData?.sceneList?.filter(val => val.sceneType == userInfo?.sceneType)[0]?.sceneName,
        selectedSceneDesc: constantData?.sceneList?.filter(val => val.sceneType == userInfo?.sceneType)[0]?.sceneDesc,
        userInfo
      })
      if (userInfo.createdDate) {
        let date = userInfo.createdDate + ''
        date = date.replace(/-/g, '/').split(' ')[0] // 日期格式处理
        this.setData({
          ['userInfo.createdTime']: date
        })
      }
      this.getStaffBankList()
      this.getVersionInfo()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**跳转至银行卡 */
    toAddBankAccount(e) {
      const {
        score,
        user
      } = this.data
      this.setData({
        showAccountModal: false
      }, () => {
        wx.$router.go('integration.detail', {
          score
        })
      })
    },
    async getStaffBankList() {
      let userInfo = wx.$util.getUserInfo(),
        res = await api.getStaffBankList({
          uuid: userInfo.uuid
        })
      console.log(res)
      if (res.data && res.data.length) {
        this.data.staffBankFlag = true
        const [staffBankInfo] = res.data
        if (staffBankInfo.state == 2 && !this.staffBankInfo) {
          this.staffBankInfo = staffBankInfo
          this.setData({
            showAccountErrorModal: true
          })
        }
      }
    },
    //我的积分
    toPoint() {
      console.log(999)
      //判断是否添加银行卡
      if (!this.data.staffBankFlag) {
        this.setData({
          showAccountModal: true
        })
        return
      }
      // 新的积分兑换页面
      wx.$router.go('integration.index')
    },
    toCloseModal(e) {
      const {
        name
      } = e.currentTarget.dataset
      this.setData({
        [name]: false
      });
    },
    //收款账户
    jumpAccount() {
      const {
        score,
        user
      } = wx.$router.getPageInstance()
      wx.$router.go('integration.list', {
        score,
        user
      })

    },
    // 跳转到工资绩效
    jump(e) {
      let { url } = e.currentTarget.dataset
      const baseUrl = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/html/'
      const path = `${baseUrl}${url}.html`
      wx.navigateTo({
        url: `/pages/webView/webView?url=${encodeURIComponent(path)}`
      })
    },
    // 跳转到商学院
    goCollegeScene() {
      wx.$router.go('packageEquity.collegeScene')
      console.log('跳转到工资绩效')
    },
    // 获取版本信息
    async getVersionInfo() {
      const versionData = await getApp().getVersionInfo()
      this.setData({
        versionData
      })
    },
    // 更新日志
    goVersionPage() {
      wx.$router.go('pages.log')
    },
    // 切换场景
    changeScene() {
      wx.$util.pointRecord(31)
      wx.$router.go('pages.changeScene')
    },

    // 切换账号
    changeAccount() {
      wx.$router.reLaunch('pages.accountItems')
    },
    // 退出登录
    logout() {
      let _this = this
      wx.showModal({
        title: '温馨提示',
        content: '是否退出当前账号?',
        confirmColor: '#347BFF',
        success(res) {
          if (res.confirm) {
            _this.setData({
              flag: true
            })
            wx.showLoading()
            api.logout().then(_res_ => {
              let { code, message } = _res_
              if (code == 0) {
                app.login(false)
              } else {
                _this.setData({
                  flag: false
                })
                wx.showToast(message)
              }
            })
          }
        }
      })
    }
  }
})