diff --git a/pages/public/setting.vue b/pages/public/setting.vue index b39914fc..91722e37 100644 --- a/pages/public/setting.vue +++ b/pages/public/setting.vue @@ -19,14 +19,15 @@ :border="false" class="list-border" @tap="onCheckUpdate" - > + /> + /> + - + /> + + /> - + @@ -116,32 +117,36 @@ // H5实时更新无需检查 // App 1.跳转应用市场更新 2.手动热更新 3.整包更新 } + + // 注销账号 function onLogoff() { uni.showModal({ title: '提示', content: '确认注销账号?', success: async function (res) { - if (res.confirm) { - const { error } = await sheep.$api.user.logoff(); - if (error === 0) { - sheep.$store('user').logout(); - sheep.$router.go('/pages/index/user'); - } + if (!res.confirm) { + return; + } + const result = await sheep.$store('user').logout(); + if (result) { + sheep.$router.go('/pages/index/user'); } }, }); } + // 退出账号 function onLogout() { uni.showModal({ title: '提示', content: '确认退出账号?', success: async function (res) { - if (res.confirm) { - const result = await sheep.$store('user').logout(); - if (result) { - sheep.$router.go('/pages/index/user'); - } + if (!res.confirm) { + return; + } + const result = await sheep.$store('user').logout(); + if (result) { + sheep.$router.go('/pages/index/user'); } }, }); diff --git a/sheep/api/member/auth.js b/sheep/api/member/auth.js new file mode 100644 index 00000000..7128dcf2 --- /dev/null +++ b/sheep/api/member/auth.js @@ -0,0 +1,14 @@ +import request2 from '@/sheep/request2'; + +const AuthUtil = { + // 登出系统 + logout: () => { + return request2({ + url: '/app-api/member/auth/logout', + method: 'POST' + }); + }, + +}; + +export default AuthUtil; diff --git a/sheep/store/user.js b/sheep/store/user.js index f460565f..07e855b7 100644 --- a/sheep/store/user.js +++ b/sheep/store/user.js @@ -14,6 +14,7 @@ import app from './app'; import { showAuthModal } from '@/sheep/hooks/useModal'; +import AuthUtil from '@/sheep/api/member/auth'; // 默认用户信息 const defaultUserInfo = { @@ -58,7 +59,7 @@ const user = defineStore({ } = await userApi.profile(); // 为了兼容 获取用户余额 可能还会用到其他参数 - // 优惠券数量,积分数量 应该在这里 + // 优惠券数量,积分数量 应该在这里 const { code: code2, data: data2 @@ -169,10 +170,8 @@ const user = defineStore({ // 登出 async logout(force = false) { if (!force) { - const { - error - } = await userApi.logout(); - if (error === 0) { + const { code } = AuthUtil.logout(); + if (code === 0) { this.resetUserData(); } }