Kaynağa Gözat

优化:去除无用log,解决mescroll报错问题

haiyang 5 gün önce
ebeveyn
işleme
e3ac4f85bf

+ 4 - 1
env/.env.development

@@ -13,4 +13,7 @@ VITE_SERVER_BASEURL = 'http://192.168.1.28:8082/jeecg-boot'
 
 
 # 静态资源请求地址
-VITE_CDN_DOMAIN = 'https://life.baoxianzhanggui.com/pro-img/securities'
+VITE_CDN_DOMAIN = 'https://life.baoxianzhanggui.com/pro-img/securities'
+
+# 微信小程序码跳转版本
+VITE_WEIXIN_MINIAPP_VERSION = 'trial'

+ 4 - 1
env/.env.production

@@ -15,4 +15,7 @@ VITE_SERVER_BASEURL = 'https://life.baoxianzhanggui.com/locallive-pro-java'
 
 
 # 静态资源请求地址
-VITE_CDN_DOMAIN = 'https://life.baoxianzhanggui.com/pro-img/securities'
+VITE_CDN_DOMAIN = 'https://life.baoxianzhanggui.com/pro-img/securities'
+
+# 微信小程序码跳转版本
+VITE_WEIXIN_MINIAPP_VERSION = 'release'

+ 5 - 1
src/api/receiveCoupon.ts

@@ -15,12 +15,16 @@ export function getCouponShareLink(params) {
         params: {
             templateId: params.templateId,
             pathUrl: params.pathUrl,
+            version: import.meta.env.VITE_WEIXIN_MINIAPP_VERSION
         }
     })
 }
 
 export function getWxQcCode(params) {
-    return http.Post('/couponCenter/APP/shareRecord/createQRCode', params, {
+    return http.Post('/couponCenter/APP/shareRecord/createQRCode', {
+        ...params,
+        env_version: import.meta.env.VITE_WEIXIN_MINIAPP_VERSION
+    }, {
         responseType: 'arraybuffer',
         cacheFor: null,
         meta: {

+ 5 - 3
src/custom-components/custom-mescroll/mescroll-body.vue

@@ -30,7 +30,8 @@
 
             <!-- 上拉加载区域 (下拉刷新时不显示, 支付宝小程序子组件传参给子子组件仍报单项数据流的异常,暂时不通过mescroll-up组件实现) -->
             <!-- <mescroll-up v-if="mescroll.optUp.use && !isDownLoading && upLoadType!==3" :option="mescroll.optUp" :type="upLoadType"></mescroll-up> -->
-            <view v-if="mescroll.optUp.use && !isDownLoading && upLoadType !== 3" class="mescroll-upwarp"
+            <view v-if="mescroll.optUp.use && !isDownLoading && !isShowEmpty && upLoadType !== 3"
+                class="mescroll-upwarp"
                 :style="{ background: mescroll.optUp.bgColor, color: mescroll.optUp.textColor }">
                 <!-- 加载中 (此处不能用v-if,否则android小程序快速上拉可能会不断触发上拉回调) -->
                 <!-- <view v-show="upLoadType === 1">
@@ -45,7 +46,8 @@
                     {{ mescroll.optUp.textNoMore }}
                 </view> -->
                 <up-loadmore :status="upLoadType === 1 ? 'loading' : upLoadType === 2 ? 'nomore' : 'loadmore'"
-                    :loading-text="mescroll.optUp.textLoading" :nomore-text="mescroll.optUp.textNoMore" />
+                    :loading-text="mescroll.optUp.textLoading" :nomore-text="mescroll.optUp.textNoMore"
+                    :icon-color="mescroll.optUp.iconLoadingColor" :dashed="false" :line="true" />
             </view>
         </view>
 
@@ -400,7 +402,7 @@
 		destroyed() {
 			// 注销全局配置监听
 			uni.$off("setMescrollGlobalOption")
-		}
+		},
 	};
 </script>
 

+ 7 - 2
src/custom-components/custom-mescroll/mescroll-uni-main.js

@@ -833,6 +833,11 @@ MeScroll.prototype.preventDefault = function (e) {
     // 小程序不支持e.preventDefault, 已在wxs中禁止
     // app的bounce只能通过配置pages.json的style.app-plus.bounce为"none"来禁止, 或使用renderjs禁止
     // cancelable:是否可以被禁用; defaultPrevented:是否已经被禁用
-    if (e && e.cancelable && !e.defaultPrevented)
-        e.preventDefault()
+    if (e && typeof e.cancelable !== 'undefined' && e.cancelable && !e.defaultPrevented) {
+        try {
+            e.preventDefault()
+        } catch (error) {
+            console.log('忽略取消不可取消的事件', error)
+        }
+    }
 }

+ 2 - 1
src/pages-A/incomePage/index.vue

@@ -16,6 +16,7 @@ definePage({
 })
 
 const topSafeAreaHeight = safeAreaInsets?.top || 0
+const bottomSafeAreaHeight = safeAreaInsets?.bottom || 0
 const activeIndex = ref(0)
 const showLoading = ref(false)
 const pickerDate = ref(Date.now())
@@ -182,7 +183,7 @@ async function pickerConfirm() {
                 </view>
             </view>
             <view class="income-content-list"
-                :style="{ height: `calc(100vh - ${topSafeAreaHeight}px - 88rpx - 88rpx - 72rpx)` }">
+                :style="{ height: `calc(100vh - ${topSafeAreaHeight}px - ${bottomSafeAreaHeight}px - 88rpx - 88rpx - 72rpx)` }">
                 <mescroll-uni id="mescrollContainer" :down="downOption" :up="upOption" :fixed="false"
                     :is-show-empty="true" offset="70" @init="mescrollInit" @down="downCallback" @up="upCallback"
                     @emptyclick="reload">

+ 0 - 1
src/pages/home/home.vue

@@ -102,7 +102,6 @@ function getNavigationBarHeight() {
     uni.getSystemInfo({
         success: (res) => {
             const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
-            console.log('顶部导航栏高度:', res.statusBarHeight, menuButtonInfo)
             // 顶部导航栏高度 = 状态栏高度 + 胶囊的高度
             navigationBarHeight.value = res.statusBarHeight + menuButtonInfo.height + 12
         },

+ 21 - 5
src/pages/income/income.vue

@@ -58,7 +58,7 @@ onPageScroll((e) => {
     scrollTop.value = e.scrollTop
 })
 
-const { send, data: incomeData, pageCount, loading, page, pageSize, isLastPage, refresh, reload, onSuccess, onError } = usePagination((page, pageSize) => getCouponIssuerAccountByPageMap({
+const { send: getIncomeData, data: incomeData, pageCount, loading, page, pageSize, isLastPage, refresh, reload, onSuccess, onError } = usePagination((page, pageSize) => getCouponIssuerAccountByPageMap({
     pageNo: page,
     pageSize,
     type: 1,
@@ -94,6 +94,12 @@ watch(() => headerOverlayOpacity.value, (newVal) => {
     }
 })
 
+watch(() => loading.value, (newVal) => {
+    if (newVal && !showLoading.value) {
+        mescroll.showUpScroll()
+    }
+})
+
 // ============ mescroll 配置 ============
 const downOption = reactive({
     use: true,
@@ -122,7 +128,8 @@ const upOption = reactive({
         icon: '/static/images/mescroll-empty.png',
         fixed: false,
     },
-    textNoMore: '--- 已经到底了 ---',
+    textNoMore: '已经到底了',
+    iconLoadingColor: '#ed6b66',
     toTop: {
         src: '/static/images/mescroll-totop.png',
         offset: 1000,
@@ -193,6 +200,9 @@ onSuccess((response) => {
 onError(() => {
     console.log('请求失败')
     mescroll.endErr()
+    console.log(mescroll)
+    mescroll.hideUpScroll()
+    mescroll.showEmpty()
 })
 
 async function tabChange(index) {
@@ -219,18 +229,24 @@ async function pickerConfirm() {
 onShow(async () => {
     // 登录后查询收益数据
     if (hasLogin) {
-        await getAccountCountRequest()
-        await reload()
+        // await getAccountCountRequest()
+        // await reload()
         // 数据会在useScroll的onMounted中自动加载,这里不需要额外调用
     }
 })
 
-onLoad(() => {
+onLoad(async () => {
     // 计算mescroll最小高度
     const systemInfo = uni.getSystemInfoSync()
     const vh100 = systemInfo.screenHeight - systemInfo.safeAreaInsets.bottom
     const tabbarHeight = (systemInfo.screenWidth / 750) * 100
     mescrollHeight.value = vh100 - tabbarHeight
+
+    if (hasLogin) {
+        await getAccountCountRequest()
+        await getIncomeData()
+        // 数据会在useScroll的onMounted中自动加载,这里不需要额外调用
+    }
 })
 
 // 创建分享hook实例

+ 9 - 4
src/pages/my/my.vue

@@ -37,18 +37,23 @@ const { send: getShareStateRequest, data: shareStateData, loading: shareStateLoa
     middleware: delayLoadingMiddleware(0, 500)
 })
 
-
-onShow(async () => {
-    console.log('登录判断:', hasLogin.value)
+onLoad(async () => {
     // 登录后查询收益数据
     if (hasLogin.value) {
-        await userStore.fetchUserInfo()
         await getCouponSituationRequest({ queryType: 'time' })
         await getShareStateRequest()
         deadline.value = Date.now()
     }
 })
 
+onShow(async () => {
+    console.log('登录判断:', hasLogin.value)
+    // 进入页面后刷新用户信息
+    if (hasLogin.value) {
+        await userStore.fetchUserInfo()
+    }
+})
+
 function handleLogout() {
     uni.showModal({
         title: '提示',

+ 0 - 1
src/store/token.ts

@@ -272,7 +272,6 @@ export const useTokenStore = defineStore(
                                                                                                                                                                                      * 检查是否已登录且token有效
                                                                                                                                                                                      */
         const hasValidLogin = computed(() => {
-            console.log('hasValidLogin', hasLoginInfo.value && !isTokenExpired.value, hasLoginInfo.value, !isTokenExpired.value)
             return hasLoginInfo.value && !isTokenExpired.value
         })
 

+ 1 - 1
src/utils/systemInfo.ts

@@ -23,7 +23,7 @@ systemInfo = uni.getSystemInfoSync()
 safeAreaInsets = systemInfo.safeAreaInsets
 // #endif
 
-console.log('systemInfo', systemInfo)
+// console.log('systemInfo', systemInfo)
 // 微信里面打印
 // pixelRatio: 3
 // safeArea: {top: 47, left: 0, right: 390, bottom: 810, width: 390, …}