From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交

---
 wechat_jiaxuan/pages/sets/index.js |   66 ++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/wechat_jiaxuan/pages/sets/index.js b/wechat_jiaxuan/pages/sets/index.js
index 8a59b32..7b2701b 100644
--- a/wechat_jiaxuan/pages/sets/index.js
+++ b/wechat_jiaxuan/pages/sets/index.js
@@ -1,4 +1,9 @@
-// pages/sets/index.js
+import {
+  wxLogOff,
+  wxLoginCustomer
+} from '../../api/index'
+const { HYEventBus } = require('hy-event-store')
+const eventBus = new HYEventBus()
 Page({
 
   /**
@@ -15,14 +20,65 @@
 
   },
   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.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
     wx.navigateTo({
-      url: '/pages/sets/protocol',
+      url: '/pages/sets/protocol?label=' + label,
     })
   },
 

--
Gitblit v1.9.3