diff --git a/App.vue b/App.vue index 17f4174..dbda976 100644 --- a/App.vue +++ b/App.vue @@ -73,11 +73,58 @@ }, onLaunch: function() { - // uni.addInterceptor('request',{ - // invoke(e){ - // console.log(e,"e") - // } - // }) + /* + 路由拦截 + */ + + // const methodToPatch = ['navigateTo', 'redirectTo', 'switchTab', 'navigateBack']; + const methodToPatch = ['navigateTo', 'redirectTo', 'switchTab', ]; + + let arr = [ + "/subPages/recharge-centre/recharge-centre",//话费充值 + "/pages/user/mineCoupons/mineCoupons",//卡券中心 + "/pages/user/myPromotion/myPromotion",//我的推广 + "/subPages/cardsList/cardsList",//卡管理 + "/pages/user/deposit/deposit",//积分充值 + "/physical-merchants/address/address",//我的地址 + "/pages/goods/recording/recording",//积分记录 + "../../../subPages/cardsList/cardsList",//卡管理 + "../../user/order_list/order_list",//我的订单 + "../../user/coupon/coupon",//优惠券 + "/pages/user/payActivity/payActivity",//活动券 + "../../login/updatePas/updatePas",//支付密码 + "/physical-merchants/classify/cart/cart",//我的购物车 + + "../order/confirmation",//兑换 + "../coupon-comfirmation/coupon-comfirmation",//天天好券 + + ]; + + + methodToPatch.map(item => { + uni.addInterceptor(item,{ + invoke(e){ + console.log(e,"e",arr.includes(e.url.split('?')[0])); + if(!uni.getStorageSync('token')&&arr.includes(e.url.split('?')[0])){ + // #ifdef H5 + uni.navigateTo({ + url: '/pages/login/register' + }) + // #endif + // #ifdef MP + uni.navigateTo({ + url: '/pages/userLogin/userLogin' + }) + // #endif + + return false + } + + + } + }) + + }) }, onShow: function() { diff --git a/components/goods-list/goods-list.vue b/components/goods-list/goods-list.vue index 111680a..ae98295 100644 --- a/components/goods-list/goods-list.vue +++ b/components/goods-list/goods-list.vue @@ -197,7 +197,7 @@ }, created() { - this.refreshCartNum(); + // this.refreshCartNum(); }, mounted() { diff --git a/pages/tabBar/classify/classify.vue b/pages/tabBar/classify/classify.vue index c6344b7..a9c7e19 100644 --- a/pages/tabBar/classify/classify.vue +++ b/pages/tabBar/classify/classify.vue @@ -160,7 +160,7 @@ }, onShow(){ this.$nextTick(()=>{ - if(this.$refs.goodsList){ + if(this.$refs.goodsList&&app.globalData.userInfo){ this.$refs.goodsList.refreshCartNum() } diff --git a/physical-merchants/classify/cart/cart.vue b/physical-merchants/classify/cart/cart.vue index 1f3aa38..666fc8f 100644 --- a/physical-merchants/classify/cart/cart.vue +++ b/physical-merchants/classify/cart/cart.vue @@ -6,7 +6,7 @@ + :key="item.id" @click="goGoodsDetail(item.goodsId,item.loseEfficacy)">