1. 修复多处页面onTabItemTap事件,使用uni.reLaunch兜底鸿蒙下switchTab静默失败的问题 2. 全局混入onTabItemTap兜底未手动处理的页面 3. 优化路由跳转逻辑,针对鸿蒙环境增加switchTab失败兜底和超时强制跳转 4. 优化可选链调用和空值判断,提升代码健壮性
149 lines
3.3 KiB
Vue
149 lines
3.3 KiB
Vue
<template>
|
|
<view :style="themeColor">
|
|
<block v-if="diyData">
|
|
<block v-for="(item, index) in diyData.value" :key="index">
|
|
<view v-if="item.componentName == 'GoodsCategory'">
|
|
<diy-category @tologin="toLogin" ref="category" :value="item"></diy-category>
|
|
</view>
|
|
</block>
|
|
</block>
|
|
|
|
<ns-login ref="login"></ns-login>
|
|
|
|
<loading-cover ref="loadingCover"></loading-cover>
|
|
|
|
<!-- 隐私弹窗 -->
|
|
<privacy-popup ref="privacyPopup"></privacy-popup>
|
|
|
|
<!-- 底部tabBar -->
|
|
<view id="tab-bar">
|
|
<diy-bottom-nav></diy-bottom-nav>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
diyData: null,
|
|
mpShareData: null //小程序分享数据
|
|
};
|
|
},
|
|
onLoad() {
|
|
this.$util.hideHomeButton();
|
|
//刷新多语言
|
|
this.$langConfig.refresh();
|
|
this.getDiyInfo();
|
|
},
|
|
onShow() {
|
|
this.$util.hideHomeButton();
|
|
if (this.$refs.category) this.$refs.category[0].pageShow();
|
|
|
|
//小程序分享
|
|
// #ifdef MP-WEIXIN
|
|
this.$util.getMpShare('/pages_goods/category').then(res => {
|
|
this.mpShareData = res;
|
|
}).catch(err => {
|
|
// 如果后台没配置,用默认值
|
|
this.mpShareData = {
|
|
appMessage: {
|
|
title: this.$lang('goods.category.shareTitle'),
|
|
path: '/pages_goods/category'
|
|
},
|
|
timeLine: {
|
|
title: this.$lang('goods.category.shareTitle'),
|
|
query: '/pages_goods/category'
|
|
}
|
|
};
|
|
});
|
|
// #endif
|
|
},
|
|
onUnload() {
|
|
!this.storeToken && this.$refs.login?.cancelCompleteInfo?.();
|
|
},
|
|
methods: {
|
|
getDiyInfo() {
|
|
this.$api.sendRequest({
|
|
url: '/api/diyview/info',
|
|
data: {
|
|
name: 'DIY_VIEW_GOODS_CATEGORY'
|
|
},
|
|
success: res => {
|
|
if (res.code == 0 && res.data) {
|
|
this.diyData = res.data;
|
|
if (this.diyData.value) {
|
|
this.diyData = JSON.parse(this.diyData.value);
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
}
|
|
|
|
uni.stopPullDownRefresh();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
toLogin() {
|
|
this.redirectTologin('/pages_goods/category');
|
|
}
|
|
},
|
|
onPullDownRefresh() {
|
|
uni.hideTabBar();
|
|
this.getDiyInfo();
|
|
},
|
|
onShareAppMessage() {
|
|
return this.mpShareData?.appMessage || {
|
|
title: this.$lang('goods.category.shareTitle'),
|
|
path: '/pages_goods/category'
|
|
};
|
|
},
|
|
onShareTimeline() {
|
|
return this.mpShareData?.timeLine || {
|
|
title: this.$lang('goods.category.shareTitle'),
|
|
query: '/pages_goods/category'
|
|
};
|
|
},
|
|
onAddToFavorites() {
|
|
return {
|
|
title: this.$lang('goods.category.shareTitle'),
|
|
path: '/pages_goods/category'
|
|
};
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
::v-deep .uni-popup__wrapper.uni-center {
|
|
background: rgba(0, 0, 0, 0.6);
|
|
}
|
|
|
|
::v-deep .uni-popup__wrapper-box {
|
|
border-radius: 0 !important;
|
|
}
|
|
|
|
::v-deep .uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box {
|
|
overflow-y: visible;
|
|
}
|
|
|
|
::v-deep .loading-layer {
|
|
background: #fff !important;
|
|
}
|
|
|
|
// 分类四一级展开
|
|
::v-deep .category-template-4 .template-four .uni-popup__wrapper-box {
|
|
border-radius: 0px 0px 14px 14px !important;
|
|
overflow: hidden;
|
|
}
|
|
|
|
::v-deep .category-template-4 .content-wrap .categoty-goods-wrap .goods-list {
|
|
margin-top: 30rpx;
|
|
}
|
|
|
|
::v-deep .category-template-4 .content-wrap .goods-list .goods-item .footer-wrap .right-wrap .num-action {
|
|
width: 46rpx;
|
|
height: 46rpx;
|
|
}
|
|
|
|
::v-deep .uni-page-refresh-inner .uni-page-refresh__path {
|
|
stroke: rgb(1, 1, 1) !important;
|
|
}
|
|
</style> |