From 60fcd5f8e203c97511e74d0dda64ba15d3ac1bc2 Mon Sep 17 00:00:00 2001 From: qiaomu <3520484422@qq.com> Date: Thu, 30 May 2024 17:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E5=87=BA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=80=BB=E8=BE=91=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E6=8E=A5=E5=8F=A3=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/my/index.js | 11 ++++++++--- service/user.js | 4 ++++ utils/request.js | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pages/my/index.js b/pages/my/index.js index 3f20428..fd9362c 100644 --- a/pages/my/index.js +++ b/pages/my/index.js @@ -1,6 +1,6 @@ -import { alertInfo } from "../../utils/index"; +import { alertInfo, alertSuccess } from "../../utils/index"; import Dialog from '@vant/weapp/dialog/dialog'; -import { getUserInfo } from "../../service/user"; +import { getUserInfo, logout } from "../../service/user"; import { getDot } from "../../utils/system"; import request from "../../utils/request" const { OK } = request; @@ -78,7 +78,12 @@ Page({ dot }) }, - logout() { + async logout() { + const { code, message } = await logout() + if (code !== OK) { + alertInfo(message) + return; + } wx.clearStorageSync() wx.switchTab({ url: '/pages/home/index', diff --git a/service/user.js b/service/user.js index a96c7f7..e82612a 100644 --- a/service/user.js +++ b/service/user.js @@ -54,4 +54,8 @@ export const getUserParksAndTenementsList = async function() { // 获取所有未阅读的用户数 export const getUnReadApproveNumber = async function() { return await GET('/wx/getApproveNumber'); +} +// 退出登录 +export const logout = async function() { + return await POST('/wx/logout'); } \ No newline at end of file diff --git a/utils/request.js b/utils/request.js index 9e65452..b831914 100644 --- a/utils/request.js +++ b/utils/request.js @@ -20,6 +20,7 @@ const requestWithoutCookie = promisify(wx.request); // 考虑了Cookie的请求 const request = async function (options, config = {}) { console.log('请求参数', 'options', options, 'config', config) + console.log('token', wx.getStorageSync('token'), 'user', wx.getStorageSync('user')) let token = wx.getStorageSync('token'); const result = wx.getAccountInfoSync(); const { envVersion } = result.miniProgram;