jiangping
2024-07-24 680028df90e18299ea72d242a28a3ddcd9a0441c
wechat_jiaxuan/pages/sets/index.js
@@ -1,4 +1,9 @@
import { wxLogOff } from '../../api/index'
import {
  wxLogOff,
  wxLoginCustomer
} from '../../api/index'
const { HYEventBus } = require('hy-event-store')
const eventBus = new HYEventBus()
Page({
  /**
@@ -15,26 +20,63 @@
  },
  showLogout() {
    this.setData({show: true})
    this.setData({
      show: true
    })
  },
  onClose() {
    this.setData({show: false})
    this.setData({
      show: false
    })
  },
  onSubLgout() {
    let that = this
    wxLogOff().then(res => {
      wx.removeStorageSync('token')
      wx.removeStorageSync('member')
      wx.removeStorageSync('code')
      wx.showToast({
        title: '注销成功',
      })
      wx.switchTab({
        url: '/pages/index/index',
      wx.clearStorage()
      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)
                wx.showToast({
                  title: '注销成功',
                })
                setTimeout(() => {
                  wx.switchTab({
                    url: '/pages/index/index',
                  })
                }, 500)
                setTimeout(() => {
                  eventBus.emit("reloadHome")
                }, 1000)
              } else {
                console.log('登录失败!')
              }
            })
          } else {}
        },
        fail(err) {
          wx.showToast({
            title: '注销失败',
          })
          wx.switchTab({
            url: '/pages/index/index',
          })
        }
      })
    })
  },
  changeDeal(e){
    const { label } = e.currentTarget.dataset
  changeDeal(e) {
    const {
      label
    } = e.currentTarget.dataset
    wx.navigateTo({
      url: '/pages/sets/protocol?label=' + label,
    })