快乐的梦鱼 1 mesiac pred
rodič
commit
3a2244cab2
1 zmenil súbory, kde vykonal 58 pridanie a 45 odobranie
  1. 58 45
      src/pages/dig/sharereg/share-reg-page.vue

+ 58 - 45
src/pages/dig/sharereg/share-reg-page.vue

@@ -6,34 +6,39 @@
         v-if="step === 'already'" 
         status="success"
         title="您已经是志愿者"
-        desc="赶快去采编村社文化资源信息吧"
+        description="赶快去采编村社文化资源信息吧"
       >
         <Height :size="20" />
-        <Button type="primary" @click="navTo('/pages/index')">返回首页</Button>
+        <Button type="primary" @click="redirectTo('/pages/index')">返回首页</Button>
       </Result>
       <!--注册-->
-      <FlexCol v-else-if="step === 'register'" center>
-        <FlexCol :padding="30">
-          <DynamicForm
-            ref="registerFormRef"
-            :model="registerFormModel"
-            :options="registerFormDefine"
-            :formGlobalParams="querys"
-          />
-          <Height :height="20" />
-          <Button type="primary" @click="registerSubmit" :loading="registerFormLoading">提交</Button>
-        </FlexCol>
+      <FlexCol v-else-if="step === 'register'" :padding="30">
+        <DynamicForm
+          ref="registerFormRef"
+          :model="registerFormModel"
+          :options="registerFormDefine"
+          :formGlobalParams="querys"
+        />
+        <Height :height="20" />
+        <Button block type="primary" @click="registerSubmit" :loading="registerFormLoading">提交</Button>
       </FlexCol>
       <!--注册完成-->
       <Result 
-        v-if="step === 'finished'" 
+        v-else-if="step === 'finished'" 
         status="success"
         title="注册志愿者成功"
-        desc="请等待管理员审核,在此期间,可以在社区中先逛逛,学习如何采编村社文化资源信息吧"
+        description="请等待管理员审核,在此期间,可以在社区中先逛逛,学习如何采编村社文化资源信息吧"
       >
         <Height :size="20" />
-        <Button type="primary" @click="navTo('/pages/index')">进入首页</Button>
+        <Button type="primary" @click="redirectTo('/pages/index')">进入首页</Button>
       </Result>
+      <!--错误-->
+      <Result 
+        v-else-if="step === 'error'" 
+        status="error"
+        title="分享链接参数有误"
+        description="请联系管理员,或稍后重试"
+      />
       <!--登录-->
       <FlexCol v-else center :height="400">
         
@@ -64,9 +69,11 @@ import Icon from '@/components/basic/Icon.vue';
 import Text from '@/components/basic/Text.vue';
 import CommonRoot from '@/components/dialog/CommonRoot.vue';
 import DynamicForm from '@/components/dynamic/DynamicForm.vue';
-import { navTo } from '@/components/utils/PageAction';
+import { useAppInit } from '@/common/composeabe/AppInit';
+import { UserApi } from '@/api/auth/UserApi';
 import { useAuthStore } from '@/store/auth';
 import { useAliOssUploadCo } from '@/common/components/upload/AliOssUploadCo';
+import { redirectTo } from '@/components/utils/PageAction';
 import { closeToast, toast } from '@/components/dialog/CommonRoot';
 import { showError } from '@/common/composeabe/ErrorDisplay';
 import { useLoadQuerys } from '@/common/composeabe/LoadQuerys';
@@ -80,8 +87,6 @@ import type { PickerIdFieldProps } from '@/components/dynamic/wrappers/PickerIdF
 import type { RadioValueProps } from '@/components/dynamic/wrappers/RadioValue';
 import type { UploaderFieldProps } from '@/components/form/UploaderField.vue';
 import type { FormProps } from '@/components/form/Form.vue';
-import { useAppInit } from '@/common/composeabe/AppInit';
-import { UserApi } from '@/api/auth/UserApi';
 
 /**
  * 分享注册页面
@@ -98,45 +103,53 @@ const { init } = useAppInit();
 const { querys } = useLoadQuerys({ 
   villageId: 0,  
 });
-const step = ref<''|'register'|'finished'|'already'>('');
+const step = ref<''|'register'|'finished'|'already'|'error'>('');
 
-onMounted(() => {
+onMounted(async () => {
+  if (!querys.value.villageId) {
+    step.value = 'error';
+    return;
+  }
   if (authStore.isLogged) {
-    if (authStore.userInfo?.villageVolunteer)
+    try {
+      await VillageApi.getVolunteerInfo();
       step.value = 'already';
-    else 
+    } catch {
       step.value = 'register';
+    }
   }
 });
 
-function loginWechat() {
+async function loginWechat() {
   toast({
     type: 'loading',  
     content: '登录中...',
   })
 
-  Promise.all([
-    uni.login({ provider: 'weixin' }),
-    uni.getUserProfile({ desc: '用于完善会员资料' }),
-  ])
-    .then((res) => {
-      authStore.loginWechart(res[0].code, res[1]).then((res) => {
-        toast({
-          type: 'success',  
-          content: '登录成功',
-        });
+  try {
+    const res = await Promise.all([
+      uni.login({ provider: 'weixin' }),
+      uni.getUserProfile({ desc: '用于完善会员资料' }),
+    ]);
+    await authStore.loginWechart(res[0].code, res[1]);
+    toast({
+      type: 'success',  
+      content: '登录成功',
+    });
 
-        if (res.villageVolunteer) {
-          //有志愿者信息,表示是志愿者,直接跳转
-          step.value = 'already';
-          return;
-        }
-        
-        step.value = 'register';
-      }).catch(showError);
-    })
-    .catch(showError)
-    .finally(() => closeToast());
+    try {
+      await VillageApi.getVolunteerInfo();
+      //有志愿者信息,表示是志愿者,直接跳转
+      step.value = 'already';
+      return;
+    } catch {
+      step.value = 'register';
+    }
+  } catch(e) {
+    showError(e);
+  } finally {
+    closeToast();
+  }
 }
 
 const registerFormLoading = ref(false);