Przeglądaj źródła

✨ 系统设置:接入完成

YunaiV 1 rok temu
rodzic
commit
d95786154c
3 zmienionych plików z 40 dodań i 22 usunięć
  1. 22 17
      pages/public/setting.vue
  2. 14 0
      sheep/api/member/auth.js
  3. 4 5
      sheep/store/user.js

+ 22 - 17
pages/public/setting.vue

@@ -19,14 +19,15 @@
           :border="false"
           class="list-border"
           @tap="onCheckUpdate"
-        ></uni-list-item>
+        />
         <uni-list-item
           title="本地缓存"
           :rightText="storageSize"
           showArrow
           :border="false"
           class="list-border"
-        ></uni-list-item>
+        />
+        <!-- TODO 芋艿:统一的配置界面 -->
         <uni-list-item
           title="关于我们"
           showArrow
@@ -39,8 +40,8 @@
               title: appInfo.about_us.title,
             })
           "
-        ></uni-list-item>
-        <!-- 为了过审 只有iOS-App有注销账号功能 -->
+        />
+        <!-- 为了过审 只有 iOS-App 有注销账号功能 -->
         <uni-list-item
           v-if="isLogin && sheep.$platform.os === 'ios' && sheep.$platform.name === 'App'"
           title="注销账号"
@@ -50,10 +51,10 @@
           :border="false"
           class="list-border"
           @click="onLogoff"
-        ></uni-list-item>
+        />
       </uni-list>
     </view>
-
+    <!-- TODO 芋艿:统一的配置界面 -->
     <view class="set-footer ss-flex-col ss-row-center ss-col-center">
       <view class="agreement-box ss-flex ss-col-center ss-m-b-40">
         <view class="ss-flex ss-col-center ss-m-b-10">
@@ -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');
         }
       },
     });

+ 14 - 0
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;

+ 4 - 5
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();
 				}
 			}