mine.js 2.5 KB
// pages/tab/mine/mine.js
import api from './api.js'
const app = getApp()
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
Page({
  /**
   * 页面的初始数据
   */
  data: {
		IMG_URL,
		navBarHeight: 84,
    navStyle: 'background-color: rgba(0,0,0,0);box-shadow:none;',
    isForbidden: false
  },
	goMySpecialTask() {
		wx.navigateTo({
			url: '/packageIndex/pages/mySpecialTaskList/mySpecialTaskList'
		})
	},
  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)}`
    })
	},
	onTabItemTap(e) {
    // 点击埋点
    wx.$track.setTrackData(0, 'supervisor_mine_page', {}, '')
  },
  navbarReady(e) {
    let navBarHeight = e.detail.height
    this.setData({
      showNavBar: true,
      navBarHeight
    })
  },
  noScroll() { },
  logout() {
    let _this = this
    wx.showModal({
      title: '温馨提示',
      content: '是否退出当前账号?',
      confirmColor: '#2C66F7',
      success(res) {
        if (res.confirm) {
          _this.setData({
            flag: true
          })
          wx.$util.showLoading()
          api.logout().then(_res_ => {
            let {
              code,
              message
            } = _res_
            if (code == 0) {
              app.login(false)
            } else {
              _this.setData({
                flag: false
              })
              _this.showToast(message)
            }
          })
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },
  // jump: e => wx.$router.jump(e),

  onPageScroll({
    scrollTop
  }) {
    this.setData({
      navStyle: scrollTop > 90 ? 'background-color: #FFFFFF;box-shadow:none;' : 'background-color: rgba(0,0,0,0);box-shadow:none;'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () { },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () { },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () { },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () { },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () { },
})