fix(shoppingTrolley): 修复购物车切换分类后页面初始化问题

- 在切换票种分类后,重置当前选中的票种
- 优化 z-tabs 组件,确保切换分类时正确更新视图
main
Tuzki 7 months ago
parent a88a4a3488
commit a7681e5854
  1. 3
      pages/shoppingTrolley/shoppingTrolley.vue
  2. 62
      uni_modules/z-tabs/components/z-tabs/z-tabs.vue

@ -202,6 +202,7 @@
this.getTicketSortList() this.getTicketSortList()
this.$refs.paging.reload(true) this.$refs.paging.reload(true)
this.current = 0 this.current = 0
this.ticketsort = null
this.$refs.zTab.updateSubviewLayout() this.$refs.zTab.updateSubviewLayout()
} }
} }
@ -1099,4 +1100,4 @@
} }
} }
} }
</style> </style>

@ -14,7 +14,7 @@
<view class="z-tabs-list" :style="[tabsListStyle, {marginTop: -finalBottomSpace+'px'}]"> <view class="z-tabs-list" :style="[tabsListStyle, {marginTop: -finalBottomSpace+'px'}]">
<view :ref="`z-tabs-item-${index}`" :id="`z-tabs-item-${index}`" class="z-tabs-item" :style="[tabStyle]" v-for="(item,index) in list" :key="index" @click="tabsClick(index,item)"> <view :ref="`z-tabs-item-${index}`" :id="`z-tabs-item-${index}`" class="z-tabs-item" :style="[tabStyle]" v-for="(item,index) in list" :key="index" @click="tabsClick(index,item)">
<view class="z-tabs-item-title-container"> <view class="z-tabs-item-title-container">
<text :class="{'z-tabs-item-title-rpx':unit==='rpx','z-tabs-item-title-px':unit==='px','z-tabs-item-title-disabled':item.disabled}" <text :class="{'z-tabs-item-title-rpx':unit==='rpx','z-tabs-item-title-px':unit==='px','z-tabs-item-title-disabled':item.disabled}"
:style="[{color:item.disabled?disabledColor:(currentIndex===index?activeColor:inactiveColor)},item.disabled?disabledStyle:(currentIndex===index?activeStyle:inactiveStyle)]"> :style="[{color:item.disabled?disabledColor:(currentIndex===index?activeColor:inactiveColor)},item.disabled?disabledStyle:(currentIndex===index?activeStyle:inactiveStyle)]">
{{item[nameKey]||item}} {{item[nameKey]||item}}
</text> </text>
@ -31,14 +31,14 @@
:style="[{background:activeColor},finalDotStyle]" :style="[{background:activeColor},finalDotStyle]"
<!-- #endif --> <!-- #endif -->
/> />
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<view class="z-tabs-right"> <view class="z-tabs-right">
<slot name="right" /> <slot name="right" />
</view> </view>
</view> </view>
</template> </template>
@ -48,7 +48,7 @@
const weexAnimation = weex.requireModule('animation'); const weexAnimation = weex.requireModule('animation');
// #endif // #endif
import zTabsConfig from './config/index' import zTabsConfig from './config/index'
// #ifdef APP-HARMONY // #ifdef APP-HARMONY
let screenWidth = 0; let screenWidth = 0;
// #endif // #endif
@ -79,7 +79,7 @@
return uni.upx2px(rpx); return uni.upx2px(rpx);
// #endif // #endif
} }
/** /**
* z-tabs 标签 * z-tabs 标签
* @description 一个简单轻量的tabs标签全平台兼容支持nvuevue3 * @description 一个简单轻量的tabs标签全平台兼容支持nvuevue3
@ -120,7 +120,7 @@
bottomDotXForIndex: 0, bottomDotXForIndex: 0,
showBottomDot: false, showBottomDot: false,
shouldSetDx: true, shouldSetDx: true,
barCalcedWidth: 0, barCalcedWidth: 0,
pxBarWidth: 0, pxBarWidth: 0,
scrollLeft: 0, scrollLeft: 0,
@ -296,7 +296,8 @@
handler(newVal) { handler(newVal) {
this._handleListChange(newVal); this._handleListChange(newVal);
}, },
immediate: false immediate: false,
deep:true
}, },
bottomDotX(newVal) { bottomDotX(newVal) {
if(newVal >= 0){ if(newVal >= 0){
@ -346,7 +347,7 @@
stl['width'] = this.finalTabWidth + 'px'; stl['width'] = this.finalTabWidth + 'px';
}else{ }else{
delete stl.width; delete stl.width;
} }
return stl; return stl;
}, },
tabsListStyle(){ tabsListStyle(){
@ -441,7 +442,7 @@
// #endif // #endif
setTimeout(() => { setTimeout(() => {
this._getNodeClientRect('.z-tabs-scroll-view-conatiner').then(res=>{ this._getNodeClientRect('.z-tabs-scroll-view-conatiner').then(res=>{
if (res){ if (res){
if (!res[0].width && tryCount < 10) { if (!res[0].width && tryCount < 10) {
setTimeout(() => { setTimeout(() => {
tryCount ++; tryCount ++;
@ -499,7 +500,7 @@
}).exec(); }).exec();
}) })
// #endif // #endif
// #ifdef APP-NVUE // #ifdef APP-NVUE
this._updateDotPosition(index); this._updateDotPosition(index);
// #endif // #endif
@ -555,6 +556,8 @@
// #ifdef MP-BAIDU // #ifdef MP-BAIDU
delayTime = 100; delayTime = 100;
// #endif // #endif
console.log(this.currentIndex);
this.currentIndex = 0
setTimeout(async()=>{ setTimeout(async()=>{
for(let i = 0;i < newVal.length;i++){ for(let i = 0;i < newVal.length;i++){
const nodeRes = await this._getNodeClientRect(`#z-tabs-item-${i}`,true); const nodeRes = await this._getNodeClientRect(`#z-tabs-item-${i}`,true);
@ -571,12 +574,13 @@
} }
} }
this.itemNodeInfos = itemNodeInfos; this.itemNodeInfos = itemNodeInfos;
this.tabsContainerWidth = tabsContainerWidth; // this.tabsContainerWidth =tainerWidth;
this._updateDotPosition(this.currentIndex); this._updateDotPosition(this.currentIndex);
},delayTime) },delayTime)
} }
}) })
if (this.initTriggerChange && this.changeTriggerFailed && newVal.length) { if (this.initTriggerChange && this.changeTriggerFailed && newVal.length) {
if (this.current < newVal.length) { if (this.current < newVal.length) {
this.$emit('change', this.current, newVal[this.current][this.valueKey]); this.$emit('change', this.current, newVal[this.current][this.valueKey]);
@ -653,7 +657,7 @@
return unit === 'rpx' ? value + 'rpx' : (value / 2) + 'px'; return unit === 'rpx' ? value + 'rpx' : (value / 2) + 'px';
} }
} }
} }
</script> </script>
@ -669,7 +673,7 @@
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
} }
.z-tabs-scroll-view-conatiner{ .z-tabs-scroll-view-conatiner{
flex: 1; flex: 1;
position: relative; position: relative;
@ -680,7 +684,7 @@
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
} }
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
.z-tabs-scroll-view ::-webkit-scrollbar { .z-tabs-scroll-view ::-webkit-scrollbar {
display: none; display: none;
@ -690,7 +694,7 @@
background: transparent; background: transparent;
} }
/* #endif */ /* #endif */
.z-tabs-scroll-view{ .z-tabs-scroll-view{
flex-direction: row; flex-direction: row;
position: absolute; position: absolute;
@ -704,21 +708,21 @@
/* #endif */ /* #endif */
flex: 1; flex: 1;
} }
.z-tabs-list-container{ .z-tabs-list-container{
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
height: 100%; height: 100%;
/* #endif */ /* #endif */
} }
.z-tabs-list,.z-tabs-list-container{ .z-tabs-list,.z-tabs-list-container{
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
} }
.z-tabs-item{ .z-tabs-item{
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -728,7 +732,7 @@
align-items: center; align-items: center;
padding: 0px 20rpx; padding: 0px 20rpx;
} }
.z-tabs-item-title-container{ .z-tabs-item-title-container{
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -736,50 +740,50 @@
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
.z-tabs-item-title-rpx{ .z-tabs-item-title-rpx{
font-size: 30rpx; font-size: 30rpx;
} }
.z-tabs-item-title-px{ .z-tabs-item-title-px{
font-size: 15px; font-size: 15px;
} }
.z-tabs-item-title-disabled{ .z-tabs-item-title-disabled{
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
cursor: not-allowed; cursor: not-allowed;
/* #endif */ /* #endif */
} }
.z-tabs-item-badge{ .z-tabs-item-badge{
background-color: #ec5b56; background-color: #ec5b56;
color: white; color: white;
border-radius: 100px; border-radius: 100px;
} }
.z-tabs-item-badge-rpx{ .z-tabs-item-badge-rpx{
margin-left: 8rpx; margin-left: 8rpx;
font-size: 22rpx; font-size: 22rpx;
padding: 0rpx 10rpx; padding: 0rpx 10rpx;
} }
.z-tabs-item-badge-px{ .z-tabs-item-badge-px{
margin-left: 4px; margin-left: 4px;
font-size: 11px; font-size: 11px;
padding: 0px 5px; padding: 0px 5px;
} }
.z-tabs-bottom{ .z-tabs-bottom{
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
} }
.z-tabs-bottom-dot{ .z-tabs-bottom-dot{
border-radius: 100px; border-radius: 100px;
} }
.z-tabs-left,.z-tabs-right{ .z-tabs-left,.z-tabs-right{
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;

Loading…
Cancel
Save