From d41f1f707dc643b726a42b9d2a63b186dd9e4f28 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 06 八月 2024 16:12:38 +0800
Subject: [PATCH] ll

---
 wechat_jiaxuan/pages/sets/index.js |   83 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/wechat_jiaxuan/pages/sets/index.js b/wechat_jiaxuan/pages/sets/index.js
index 6dab455..45e6bc8 100644
--- a/wechat_jiaxuan/pages/sets/index.js
+++ b/wechat_jiaxuan/pages/sets/index.js
@@ -1,11 +1,18 @@
-import { wxLogOff } from '../../api/index'
+import {
+  wxLogOff,
+  wxLoginCustomer
+} from '../../api/index'
+import {
+  eventBus
+} from '../../utils/eventBus'
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    show: false
+    show: false,
+    showLogout: false
   },
 
   /**
@@ -15,23 +22,77 @@
 
   },
   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.redirectTo({
-        url: '/pages/index/index',
+      wx.clearStorage()
+      wx.showToast({
+        title: '娉ㄩ攢鎴愬姛',
+      })
+      that.setData({
+        showLogout: true,
+        show: false
       })
     })
   },
-  changeDeal(e){
-    const { label } = e.currentTarget.dataset 
+  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?label=' + label,
     })

--
Gitblit v1.9.3