|
@@ -23,6 +23,7 @@
|
|
|
:showBackTop="showBackTop"
|
|
:showBackTop="showBackTop"
|
|
|
@backTop="scrollToTop"
|
|
@backTop="scrollToTop"
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
<!-- <view class="page-index" :class="{ bgf: navIndex > 0 }"> -->
|
|
<!-- <view class="page-index" :class="{ bgf: navIndex > 0 }"> -->
|
|
|
<view class="page-index">
|
|
<view class="page-index">
|
|
|
<view class="top-box jianbianBG">
|
|
<view class="top-box jianbianBG">
|
|
@@ -178,7 +179,7 @@
|
|
|
<script setup>
|
|
<script setup>
|
|
|
// 获取实时金价
|
|
// 获取实时金价
|
|
|
import useRealGoldPrice from "@/hooks/useRealGoldPrice";
|
|
import useRealGoldPrice from "@/hooks/useRealGoldPrice";
|
|
|
-import { onLoad, onShow, onReachBottom,onPageScroll } from "@dcloudio/uni-app";
|
|
|
|
|
|
|
+import { onLoad, onShow, onReachBottom,onPageScroll,onPullDownRefresh } from "@dcloudio/uni-app";
|
|
|
import {ref, onMounted, reactive, computed, getCurrentInstance, watch, nextTick} from "vue";
|
|
import {ref, onMounted, reactive, computed, getCurrentInstance, watch, nextTick} from "vue";
|
|
|
import { getIndexData, getCoupons, setCouponReceive, getMerchantBannerList } from "@/api/api.js";
|
|
import { getIndexData, getCoupons, setCouponReceive, getMerchantBannerList } from "@/api/api.js";
|
|
|
import {
|
|
import {
|
|
@@ -273,7 +274,6 @@ const calculatedProducts = computed(() => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
onLoad(async (options) => {
|
|
onLoad(async (options) => {
|
|
|
- console.log('onLOAD')
|
|
|
|
|
const params = await getSceneInfo(options,'index');
|
|
const params = await getSceneInfo(options,'index');
|
|
|
// 2. 设置商户ID
|
|
// 2. 设置商户ID
|
|
|
const isLogin = appStore.isLogin;
|
|
const isLogin = appStore.isLogin;
|
|
@@ -300,27 +300,26 @@ onLoad(async (options) => {
|
|
|
onShow(async () => {
|
|
onShow(async () => {
|
|
|
// 隐藏原生 tabBar,使用自定义 tabBar
|
|
// 隐藏原生 tabBar,使用自定义 tabBar
|
|
|
uni.hideTabBar();
|
|
uni.hideTabBar();
|
|
|
- console.log('appStore.userInfo',appStore.userInfo)
|
|
|
|
|
const isLogin = appStore.isLogin;
|
|
const isLogin = appStore.isLogin;
|
|
|
if(isLogin){
|
|
if(isLogin){
|
|
|
rightsStore.getUserBenefits(appStore.userInfo?.userId);
|
|
rightsStore.getUserBenefits(appStore.userInfo?.userId);
|
|
|
getUserBenefits();
|
|
getUserBenefits();
|
|
|
}
|
|
}
|
|
|
if (appStore.merchantId && appStore.merchantId !== '') {
|
|
if (appStore.merchantId && appStore.merchantId !== '') {
|
|
|
- console.log('111111111')
|
|
|
|
|
merchantId.value = appStore.merchantId;
|
|
merchantId.value = appStore.merchantId;
|
|
|
if (!isLogin) {
|
|
if (!isLogin) {
|
|
|
toLogin();
|
|
toLogin();
|
|
|
return; // 登录后页面会刷新,避免继续执行
|
|
return; // 登录后页面会刷新,避免继续执行
|
|
|
}
|
|
}
|
|
|
}else if(appStore?.userInfo?.lastVisitedMerchantId){
|
|
}else if(appStore?.userInfo?.lastVisitedMerchantId){
|
|
|
- console.log('2222222222222222')
|
|
|
|
|
merchantId.value = appStore?.userInfo?.lastVisitedMerchantId;
|
|
merchantId.value = appStore?.userInfo?.lastVisitedMerchantId;
|
|
|
|
|
+ if(!merchantInfo.merchantName){
|
|
|
|
|
+ initPageData();
|
|
|
|
|
+ }
|
|
|
} else if (appStore?.userInfo?.merchant?.id) {
|
|
} else if (appStore?.userInfo?.merchant?.id) {
|
|
|
- console.log('333333333333333')
|
|
|
|
|
merchantId.value = appStore.userInfo.merchant.id;
|
|
merchantId.value = appStore.userInfo.merchant.id;
|
|
|
if(!merchantInfo.merchantName){
|
|
if(!merchantInfo.merchantName){
|
|
|
- getSbmerchantInfoFn()
|
|
|
|
|
|
|
+ initPageData();
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
merchantId.value = '';
|
|
merchantId.value = '';
|
|
@@ -333,6 +332,19 @@ onShow(async () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
+const onRefresh = () => {
|
|
|
|
|
+ refreshing.value = true;
|
|
|
|
|
+
|
|
|
|
|
+ Promise.allSettled([
|
|
|
|
|
+ initPageData()
|
|
|
|
|
+ ]).finally(() => {
|
|
|
|
|
+ // 添加一个短暂延迟,确保 DOM 更新完成
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ refreshing.value = false;
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ }, 50);
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
const initPageData = async () => {
|
|
const initPageData = async () => {
|
|
|
try {
|
|
try {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
@@ -556,6 +568,10 @@ onPageScroll((e) => {
|
|
|
showBackTop.value = false;
|
|
showBackTop.value = false;
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+onPullDownRefresh(async () => {
|
|
|
|
|
+ await initPageData();
|
|
|
|
|
+ uni.stopPullDownRefresh();
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
// 回到顶部
|
|
// 回到顶部
|
|
|
const scrollToTop = () => {
|
|
const scrollToTop = () => {
|