ll
liukangdong
2024-08-06 d41f1f707dc643b726a42b9d2a63b186dd9e4f28
wechat_jiaxuan/pages/sets/index.js
@@ -1,11 +1,18 @@
// pages/sets/index.js
import {
  wxLogOff,
  wxLoginCustomer
} from '../../api/index'
import {
  eventBus
} from '../../utils/eventBus'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    show: false
    show: false,
    showLogout: false
  },
  /**
@@ -15,14 +22,79 @@
  },
  showLogout() {
    this.setData({show: true})
    this.setData({
      show: true
    })
  },
  onClose() {
    this.setData({show: false})
    this.setData({
      show: false
    })
  },
  changeDeal(){
  onSubLgout() {
    let that = this
    wxLogOff().then(res => {
      wx.clearStorage()
      wx.showToast({
        title: '注销成功',
      })
      that.setData({
        showLogout: true,
        show: false
      })
    })
  },
  appClose() {
    this.setData({
      showLogout: false
    })
  },
  backHome() {
    wx.login({
      timeout: 5000,
      success: (res) => {
        if (res.code) {
          //发起网络请求
          wxLoginCustomer({
            code: res.code
          }).then(res => {
            console.log(res)
            if (res && res.data.token) {
              wx.setStorageSync('sessionKey', res.data.sessionKey)
              wx.setStorageSync('token', res.data.token)
              this.setData({
                showLogout: false
              })
              setTimeout(() => {
                eventBus.emit("reloadHome")
              }, 1000)
              setTimeout(() => {
                wx.switchTab({
                  url: '/pages/index/index',
                })
              }, 500)
            } else {
              console.log('登录失败!')
            }
          })
        } else {}
      },
      fail(err) {
        wx.showToast({
          title: '注销失败',
        })
        wx.switchTab({
          url: '/pages/index/index',
        })
      }
    })
  },
  changeDeal(e) {
    const {
      label
    } = e.currentTarget.dataset
    wx.navigateTo({
      url: '/pages/sets/protocol',
      url: '/pages/sets/protocol?label=' + label,
    })
  },