Kaynağa Gözat

📦 绑定微信2

快乐的梦鱼 1 ay önce
ebeveyn
işleme
862524a02a

+ 5 - 3
src/pages/collect/composeable/isBindWx.ts

@@ -1,11 +1,13 @@
 import { useAuthStore } from "@/store/auth";
+import { computed } from "vue";
 
 export function useIsBindWx() {
   const authStore = useAuthStore();
+  const isBindWx = computed(() => {
+    return Boolean(authStore.userInfo?.openId);
+  });
 
   return {
-    isBindWx() {
-      return Boolean(authStore.userInfo?.openId);
-    }
+    isBindWx
   }
 }

+ 1 - 0
src/pages/collect/login.vue

@@ -184,6 +184,7 @@ async function handleSubmit() {
 onMounted(async () => {
   await waitTimeOut(1000);
   if (authStore.isLogged) {
+    console.log(authStore.loginType);
     if (authStore.isCollect) {
       redirectTo('/pages/collect/inheritor');
     } else if (authStore.isCollectReviewer || authStore.isCollectAdmin) {

+ 2 - 0
src/pages/collect/user/bind-wx.vue

@@ -19,6 +19,7 @@ import FlexCol from '@/components/layout/FlexCol.vue';
 import CommonRoot from '@/components/dialog/CommonRoot.vue';
 import Image from '@/components/basic/Image.vue';
 import InheritorContentApi from '@/api/collect/InheritorContent';
+import { useAuthStore } from '@/store/auth';
 
 /**
  *  账号绑定微信页面
@@ -29,6 +30,7 @@ const { querys } = useLoadQuerys({
 });
 const loading = ref(false);
 
+const authStore = useAuthStore();
 async function submit() {
   try {
     loading.value = true;

+ 0 - 1
src/pages/user/login.vue

@@ -34,7 +34,6 @@ function loginWechat() {
     uni.getUserProfile({ desc: '用于完善会员资料' }),
   ])
     .then((res) => {
-      console.log(res);
       //return;
       authStore.loginWechart(res[0].code, res[1]).then(() => {
         toast('登录成功');

+ 9 - 1
src/store/auth.ts

@@ -50,7 +50,15 @@ export const useAuthStore = defineStore('auth', {
         raw_data: JSON.parse(res.rawData),
         signature: res.signature,
       })
-      this.loginResultHandle(loginResult);
+      console.log(loginResult);
+      if (loginResult.inheritor) {
+        this.loginType = LOGIN_TYPE_COLLECT;
+      } else if (loginResult.aub) {
+        this.loginType = LOGIN_TYPE_COLLECT_ADMIN;
+      } else {
+        this.loginType = LOGIN_TYPE_USER;
+      }
+      this.loginResultHandle(loginResult, this.loginType);
     },
     async loginMobile(mobile: string, password: string) {
       const loginResult = await UserApi.loginWithMobile({