Forráskód Böngészése

🎨 优化乡源树购买后状态刷新

快乐的梦鱼 1 hete
szülő
commit
b75f694ec1

+ 5 - 1
src/components/loader/SimplePageContentLoader.vue

@@ -3,7 +3,7 @@
     v-if="loader?.status.value == 'loading'"
     class="loader-view center"
   >
-    <LoadingPage loadingText="加载中" textSize="18" />
+    <LoadingPage v-if="showLoading" loadingText="加载中" textSize="18" />
   </view>
   <view
     v-else-if="loader?.status.value == 'error'"
@@ -71,6 +71,10 @@ const props = defineProps({
     type: Boolean,
     default: false, 
   },
+  showLoading: {  
+    type: Boolean,
+    default: true, 
+  },
   emptyView: {
     type: Object as PropType<{
       text: string,

+ 2 - 0
src/pages/home/village/bless/my-orders.vue

@@ -53,6 +53,7 @@
 import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
 import { useAuthStore } from '@/store/auth';
 import { useSimplePageListLoader } from '@/components/composeabe/loader/SimplePageListLoader';
+import { callPrevOnPageBack } from '@/components/utils/PageAction';
 import { ref } from 'vue';
 import FlexCol from '@/components/layout/FlexCol.vue';
 import TreeApi, { BlessOrderItem } from '@/api/light/TreeApi';
@@ -82,6 +83,7 @@ function handlePay(item: BlessOrderItem) {
 
 function handlePaySuccess() {
   listLoader.reload();
+  callPrevOnPageBack('blessPaySuccessRefresh', {});
 }
 
 const listLoader = useSimplePageListLoader(20, async (page, pageSize) => {

+ 14 - 5
src/pages/home/village/introd/tree.vue

@@ -147,7 +147,8 @@ import { useRequireLogin } from '@/common/composeabe/RequireLogin';
 import { showError } from '@/common/composeabe/ErrorDisplay';
 import { toast } from '@/components/utils/DialogAction';
 import { navTo } from '@/components/utils/PageAction';
-import { RequestApiError, SimpleTimer } from '@imengyu/imengyu-utils';
+import { RequestApiError, SimpleTimer, waitTimeOut } from '@imengyu/imengyu-utils';
+import { useAuthStore } from '@/store/auth';
 import HomeTitle from '@/common/components/parts/HomeTitle.vue';
 import Text from '@/components/basic/Text.vue';
 import FlexCol from '@/components/layout/FlexCol.vue';
@@ -169,6 +170,7 @@ const GROWTH_FEED_COUNT = 6;
 const DEFAULT_AVATAR = 'https://xy.wenlvti.net/app_static/images/village/PlaceholderVolunteer.png';
 
 const villageStore = useVillageStore();
+const authStore = useAuthStore();
 const { requireLoginAsync } = useRequireLogin();
 
 const blessBuyDialogRef = ref<InstanceType<typeof BlessBuyDialog>>();
@@ -284,9 +286,7 @@ async function handleBuyBlessConfirm() {
         paySign: payInfo.pay.paySign,
         success: () => {
           blessSuccessDialogRef.value?.show();
-          setTimeout(() => {
-            activityLoader.reload();
-          }, 2000);
+          handleBlessPaySuccessRefresh();
         },
         fail: (err) => {
           showError(err);
@@ -305,6 +305,13 @@ function handleGoBless() {
     duration: 300,
   });
 }
+async function handleBlessPaySuccessRefresh() {
+  refreshVillageTreeInfo();
+  await waitTimeOut(600);
+  authStore.refreshUserInfo();
+  await waitTimeOut(2000);
+  activityLoader.reload();
+}
 
 function handleFertilize() {
   handlePickOrWaterOrFertilize('fertilize');
@@ -387,7 +394,9 @@ onBeforeMount(() => {
 });
 defineExpose({
   onPageBack: (name: string, data: Record<string, unknown>) => {
-    
+    if (name === 'blessPaySuccessRefresh') {
+      handleBlessPaySuccessRefresh();
+    }
 
   },
 });

+ 1 - 1
src/pages/home/village/volunteer/detail.vue

@@ -1,6 +1,6 @@
 <template>
   <CommonTopBanner title="志愿者详情">
-    <SimplePageContentLoader :loader="infoLoader">
+    <SimplePageContentLoader :loader="infoLoader" :showLoading="false">
       <FlexCol v-if="infoLoader.content.value" gap="gap.md" padding="padding.md">
         <BackgroundBox 
           backgroundImage="https://xy.wenlvti.net/app_static/images/village/BoxLarge.png"

+ 3 - 0
src/store/auth.ts

@@ -122,6 +122,9 @@ export const useAuthStore = defineStore('auth', {
         loginType: this.loginType,
       }
     },
+    refreshUserInfo() {
+      //TODO: 刷新用户信息
+    },
   },
   getters: {
     /**