Bläddra i källkod

💊 优化新用户进入细节逻辑

快乐的梦鱼 5 dagar sedan
förälder
incheckning
28c19df9c2
4 ändrade filer med 31 tillägg och 16 borttagningar
  1. 0 1
      src/api/auth/UserApi.ts
  2. 5 5
      src/pages/dig/forms/bind.ts
  3. 21 8
      src/pages/dig/forms/submits.vue
  4. 5 2
      src/pages/user/login.vue

+ 0 - 1
src/api/auth/UserApi.ts

@@ -144,7 +144,6 @@ export class UserApi extends AppServerRequestModule<DataModel> {
     return (await this.post('/ich/inheritor/refresh', '刷新token', {}, undefined, LoginResult)).data as LoginResult;
   }
   async checkUserAuthed() {
-    return await this.post('/village/village/getVillageList', '检查用户是否登录', {});
   }  
 
   

+ 5 - 5
src/pages/dig/forms/bind.ts

@@ -3,16 +3,16 @@ import { confirm } from "@/components/dialog/CommonRoot";
 import type { RequestApiError } from "@imengyu/imengyu-utils";
 
 export function checkIsNotVolunteerError(e: unknown) {
+
   return (e as RequestApiError).errorMessage.includes('请认领')
 }
-export async function checkAndGoBindVolunteer() {
+export async function checkAndGoBindVolunteer() : Promise<"index" | "bind" | undefined> {
   //检查是否有志愿者信息,跳转至不同的页面
   //已认领志愿者,跳转至首页
   //未认领志愿者,跳转至绑定账号页面
   try {
     await VillageApi.getVolunteerInfo();
   } catch(e) {
-
     //已登录但是没绑定志愿者信息,提示用户绑定
     if (checkIsNotVolunteerError(e)) {
       const goBind = await confirm({
@@ -23,11 +23,11 @@ export async function checkAndGoBindVolunteer() {
         width: 580,
       });
       if (goBind) {
-        uni.redirectTo({ url: '/pages/dig/sharereg/bind' });
-        return true;
+        return 'bind';
       }
+      return 'index';
     }
     throw e;
   }
-  return false;
+  return undefined;
 }

+ 21 - 8
src/pages/dig/forms/submits.vue

@@ -113,7 +113,7 @@ import Tag from '@/components/display/Tag.vue';
 import Icon from '@/components/basic/Icon.vue';
 import DropdownMenu from '@/components/feedback/DropdownMenu.vue';
 import DropdownMenuItem from '@/components/feedback/DropdownMenuItem.vue';
-import VillageApi from '@/api/inhert/VillageApi';
+import VillageApi, { type VillageListItem } from '@/api/inhert/VillageApi';
 import { waitTimeOut } from '@imengyu/imengyu-utils';
 
 const searchText = ref('');
@@ -121,14 +121,26 @@ const filterStatus = ref(-100);
 const filterVillage = ref(0);
 
 const villageListLoader = useSimpleDataLoader(async () => {
-  const res = await VillageApi.getClaimedVallageList()
-  if (filterVillage.value == 0) 
-    filterVillage.value = res[0].villageId;
-  return res.map(item => ({
+  let res = [] as VillageListItem[];
+  try {
+    res = await VillageApi.getClaimedVallageList()
+  } catch (e) {
+    console.log(e);
+  }
+  const list = res.map(item => ({
     text: item.villageName,
     value: item.villageId!,
   }));
-}, true);
+  if (list.length == 0) {
+    list.push({
+      text: '未选择村社',
+      value: -100,
+    });
+  }
+  if (filterVillage.value == 0) 
+    filterVillage.value = list[0].value;
+  return list;
+}, false);
 const listLoader = useSimplePageListLoader<CommonInfoModel>(8, async (page, pageSize) => {
   await waitTimeOut(300);
   let res = await VillageInfoApi.getList(
@@ -148,7 +160,7 @@ const listLoader = useSimplePageListLoader<CommonInfoModel>(8, async (page, page
     list: res,
     total: res.length,
   };
-});
+}, false);
 function goDetail(item: CommonInfoModel) {
   navTo('common', { 
     id: item.id,
@@ -170,7 +182,8 @@ const { querys } = useLoadQuerys({
   villageVolunteerId: 0,
 }, async (querys) => {
   filterVillage.value = querys.villageId || 0;
-  listLoader.loadData(querys)
+  await villageListLoader.loadData();
+  await listLoader.loadData(querys)
 });
 
 watch(filterStatus, () => listLoader.loadData(undefined, true))

+ 5 - 2
src/pages/user/login.vue

@@ -208,8 +208,11 @@ async function loginAfter(isMobileLogin = false) {
   //检查是否有志愿者信息,跳转至不同的页面
   //已认领志愿者,跳转至首页
   //未认领志愿者,跳转至绑定账号页面
-  if (await checkAndGoBindVolunteer())
-    return;
+  const rs = await checkAndGoBindVolunteer()
+  switch (rs) {
+    case 'index': redirectToIndex();  return;
+    case 'bind': uni.redirectTo({ url: '/pages/dig/sharereg/bind' }); return;
+  }
 
   //刷新用户信息
   await init();