路由拦截

ymt-db-dev
游梦婷 1 year ago
parent f2b4abb72a
commit 536dd4f10b
  1. 57
      App.vue
  2. 2
      components/goods-list/goods-list.vue
  3. 2
      pages/tabBar/classify/classify.vue
  4. 8
      physical-merchants/classify/cart/cart.vue
  5. 2
      physical-merchants/classify/goods-search/goods-search.vue
  6. 5
      physical-merchants/classify/goodsDetail/goodsDetail.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() {

@ -197,7 +197,7 @@
},
created() {
this.refreshCartNum();
// this.refreshCartNum();
},
mounted() {

@ -160,7 +160,7 @@
},
onShow(){
this.$nextTick(()=>{
if(this.$refs.goodsList){
if(this.$refs.goodsList&&app.globalData.userInfo){
this.$refs.goodsList.refreshCartNum()
}

@ -6,7 +6,7 @@
<!-- 从这里开始遍历-->
<view v-for="(item,index) in cartList"
:class="(item.loseEfficacy?' loseEfficacy ':' ')+'marb10 border-8r backcolorfff pdtlb'"
:key="item.id" @click="goGoodsDetail(item.goodsId)">
:key="item.id" @click="goGoodsDetail(item.goodsId,item.loseEfficacy)">
<!-- :disabled="item.loseEfficacy" -->
<uni-swipe-action-item :auto-close="autoClose" :right-options="swipe_options"
@ -483,7 +483,11 @@
},
//
goGoodsDetail(goodsId){
goGoodsDetail(goodsId,loseEfficacy){
if(loseEfficacy){
return
}
uni.navigateTo({
url: '/physical-merchants/classify/goodsDetail/goodsDetail?goodsId=' + goodsId

@ -63,7 +63,7 @@
},
onShow() {
this.$nextTick(() => {
if (this.$refs.goodsList) {
if (this.$refs.goodsList&&app.globalData.userInfo) {
this.$refs.goodsList.refreshCartNum()
}
})

@ -264,7 +264,10 @@
ccShareMenu,
},
onShow() {
this.refreshCartNum();
if(app.globalData.userInfo){
this.refreshCartNum();
}
// if(this.options[1].shoucang == true){

Loading…
Cancel
Save