修改退出登录逻辑,新增访问接口退出
This commit is contained in:
parent
7ac104d1b8
commit
60fcd5f8e2
|
@ -1,6 +1,6 @@
|
||||||
import { alertInfo } from "../../utils/index";
|
import { alertInfo, alertSuccess } from "../../utils/index";
|
||||||
import Dialog from '@vant/weapp/dialog/dialog';
|
import Dialog from '@vant/weapp/dialog/dialog';
|
||||||
import { getUserInfo } from "../../service/user";
|
import { getUserInfo, logout } from "../../service/user";
|
||||||
import { getDot } from "../../utils/system";
|
import { getDot } from "../../utils/system";
|
||||||
import request from "../../utils/request"
|
import request from "../../utils/request"
|
||||||
const { OK } = request;
|
const { OK } = request;
|
||||||
|
@ -78,7 +78,12 @@ Page({
|
||||||
dot
|
dot
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
logout() {
|
async logout() {
|
||||||
|
const { code, message } = await logout()
|
||||||
|
if (code !== OK) {
|
||||||
|
alertInfo(message)
|
||||||
|
return;
|
||||||
|
}
|
||||||
wx.clearStorageSync()
|
wx.clearStorageSync()
|
||||||
wx.switchTab({
|
wx.switchTab({
|
||||||
url: '/pages/home/index',
|
url: '/pages/home/index',
|
||||||
|
|
|
@ -55,3 +55,7 @@ export const getUserParksAndTenementsList = async function() {
|
||||||
export const getUnReadApproveNumber = async function() {
|
export const getUnReadApproveNumber = async function() {
|
||||||
return await GET('/wx/getApproveNumber');
|
return await GET('/wx/getApproveNumber');
|
||||||
}
|
}
|
||||||
|
// 退出登录
|
||||||
|
export const logout = async function() {
|
||||||
|
return await POST('/wx/logout');
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ const requestWithoutCookie = promisify(wx.request);
|
||||||
// 考虑了Cookie的请求
|
// 考虑了Cookie的请求
|
||||||
const request = async function (options, config = {}) {
|
const request = async function (options, config = {}) {
|
||||||
console.log('请求参数', 'options', options, 'config', config)
|
console.log('请求参数', 'options', options, 'config', config)
|
||||||
|
console.log('token', wx.getStorageSync('token'), 'user', wx.getStorageSync('user'))
|
||||||
let token = wx.getStorageSync('token');
|
let token = wx.getStorageSync('token');
|
||||||
const result = wx.getAccountInfoSync();
|
const result = wx.getAccountInfoSync();
|
||||||
const { envVersion } = result.miniProgram;
|
const { envVersion } = result.miniProgram;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user