chore:增加新功能只在template == 99里生效
This commit is contained in:
@@ -5,6 +5,46 @@
|
||||
<image :src="$util.img(category.image_adv)" mode="widthFix" show-menu-by-longpress />
|
||||
</view>
|
||||
|
||||
<block v-if="value.template == 99 && parseInt(value.level) == 2">
|
||||
<view class="second-category-btns">
|
||||
<view class="second-category-btn"
|
||||
v-for="(one, oneIndex) in category.child_list"
|
||||
:key="oneIndex"
|
||||
:class="{ selected: selectedSecondCategory == one.category_id }"
|
||||
@tap="selectSecondCategory(one)">
|
||||
{{ one.category_name }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="category-goods-list" v-if="selectedSecondCategory">
|
||||
<view class="goods-list double-column show" :data-template="value.template" v-if="secondCategoryGoodsList.length">
|
||||
<view class="goods-item" v-for="(item, index) in secondCategoryGoodsList" :key="index">
|
||||
<view class="goods-img" @tap.stop="toDetail(item)">
|
||||
<image :src="goodsImg(item.goods_image)" mode="widthFix" @error="imgError(index)" show-menu-by-longpress />
|
||||
<view class="color-base-bg goods-tag" v-if="item.label_name">{{ item.label_name }}</view>
|
||||
</view>
|
||||
<view class="info-wrap">
|
||||
<view class="name-wrap" @tap.stop="toDetail(item)">
|
||||
<view class="goods-name">{{ isEnEnv ? item.en_goods_name : item.goods_name }}</view>
|
||||
</view>
|
||||
<view class="price-wrap">
|
||||
<view class="discount-price">
|
||||
<block v-if="item.isinformation == 0">
|
||||
<text class="unit price-style small">{{ $lang('common.currencySymbol') }}</text>
|
||||
<text class="price price-style large">{{ parseFloat(showPrice(item)).toFixed(2).split('.')[0] }}</text>
|
||||
<text class="unit price-style small">.{{ parseFloat(showPrice(item)).toFixed(2).split('.')[1] }}</text>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="category-goods-empty" v-if="selectedSecondCategory && !secondCategoryGoodsList.length && !loading">
|
||||
<image :src="$util.img('public/uniapp/category/empty.png')" mode="widthFix" show-menu-by-longpress></image>
|
||||
<view class="tips">{{ $lang('components-diy.diy-category.noCategory') }}</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block v-if="value.level == 2">
|
||||
<view class="category-title">{{ category.category_name }}</view>
|
||||
<view class="category-list">
|
||||
@@ -296,6 +336,10 @@ export default {
|
||||
isList: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
lastSecondCategoryName: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
mixins: [DiyMinx],
|
||||
@@ -316,13 +360,27 @@ export default {
|
||||
scrollTop: 0,
|
||||
loadType: '',
|
||||
timeout: {},
|
||||
cartEditRepeat: false
|
||||
cartEditRepeat: false,
|
||||
selectedSecondCategory: null,
|
||||
secondCategoryGoodsList: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.type = this.value.template == 1 ? 'category' : 'goods';
|
||||
this.type = this.value.template == 1 || this.value.template == 99 ? 'category' : 'goods';
|
||||
if (this.index == this.select && this.pageIndex == 0) this.getGoodsList();
|
||||
this.loadType = this.value.goodsLevel == 1 && this.value.loadType == 'all' ? 'all' : 'part';
|
||||
if (this.value.template == 99 && this.index == this.select && parseInt(this.value.level) == 2 && this.category.child_list && this.category.child_list.length > 0) {
|
||||
let targetCategory = null;
|
||||
if (this.lastSecondCategoryName) {
|
||||
targetCategory = this.category.child_list.find(item => item.category_name === this.lastSecondCategoryName);
|
||||
}
|
||||
if (!targetCategory) {
|
||||
targetCategory = this.category.child_list[0];
|
||||
}
|
||||
this.selectedSecondCategory = targetCategory.category_id;
|
||||
this.secondCategoryGoodsList = [];
|
||||
this.getSecondCategoryGoods(targetCategory.category_id);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
@@ -332,6 +390,18 @@ export default {
|
||||
if (data) this.contentWrapHeight = data.height;
|
||||
}).exec();
|
||||
}, 1000);
|
||||
if (this.value.template == 99 && parseInt(this.value.level) == 2 && this.category.child_list && this.category.child_list.length > 0) {
|
||||
let targetCategory = null;
|
||||
if (this.lastSecondCategoryName) {
|
||||
targetCategory = this.category.child_list.find(item => item.category_name === this.lastSecondCategoryName);
|
||||
}
|
||||
if (!targetCategory) {
|
||||
targetCategory = this.category.child_list[0];
|
||||
}
|
||||
this.selectedSecondCategory = targetCategory.category_id;
|
||||
this.secondCategoryGoodsList = [];
|
||||
this.getSecondCategoryGoods(targetCategory.category_id);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
oneCategorySelect: function () {
|
||||
@@ -360,6 +430,18 @@ export default {
|
||||
} else if (this.loadType == 'part') {
|
||||
this.scrollTop = -1;
|
||||
}
|
||||
if (this.value.template == 99 && parseInt(this.value.level) == 2 && this.category.child_list && this.category.child_list.length > 0) {
|
||||
let targetCategory = null;
|
||||
if (this.lastSecondCategoryName) {
|
||||
targetCategory = this.category.child_list.find(item => item.category_name === this.lastSecondCategoryName);
|
||||
}
|
||||
if (!targetCategory) {
|
||||
targetCategory = this.category.child_list[0];
|
||||
}
|
||||
this.selectedSecondCategory = targetCategory.category_id;
|
||||
this.secondCategoryGoodsList = [];
|
||||
this.getSecondCategoryGoods(targetCategory.category_id);
|
||||
}
|
||||
},
|
||||
'globalStoreInfo.store_id': {
|
||||
handler(nval, oval) {
|
||||
@@ -739,6 +821,48 @@ export default {
|
||||
if (!link) return;
|
||||
this.$util.diyRedirectTo(JSON.parse(link));
|
||||
},
|
||||
selectSecondCategory(category) {
|
||||
if (this.selectedSecondCategory === category.category_id) {
|
||||
this.selectedSecondCategory = null;
|
||||
this.secondCategoryGoodsList = [];
|
||||
} else {
|
||||
this.selectedSecondCategory = category.category_id;
|
||||
this.secondCategoryGoodsList = [];
|
||||
this.getSecondCategoryGoods(category.category_id);
|
||||
this.$emit('saveSecondCategory', category.category_name);
|
||||
}
|
||||
},
|
||||
getSecondCategoryGoods(categoryId) {
|
||||
this.loading = true;
|
||||
let order = '';
|
||||
let sort = '';
|
||||
if (this.value.sortWay) {
|
||||
if (this.value.sortWay == 'default') {
|
||||
order = '';
|
||||
sort = '';
|
||||
} else if (this.value.sortWay == 'sales') {
|
||||
order = 'sales';
|
||||
sort = 'desc';
|
||||
} else if (this.value.sortWay == 'price') {
|
||||
order = 'min_price';
|
||||
sort = this.value.sortType == 'desc' ? 'desc' : 'asc';
|
||||
}
|
||||
}
|
||||
this.$api.goods.getGoodsList({
|
||||
category_id: categoryId,
|
||||
page: this.pageIndex,
|
||||
page_size: this.pageSize,
|
||||
order: order,
|
||||
sort: sort
|
||||
}).then(res => {
|
||||
this.loading = false;
|
||||
if (res.data.data.list) {
|
||||
this.secondCategoryGoodsList = res.data.data.list;
|
||||
}
|
||||
}).catch(err => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
//加载商品在购物车的总数量
|
||||
loadGoodsCartNum(isRefresh = false) {
|
||||
this.goodsList.forEach((item) => {
|
||||
|
||||
@@ -92,17 +92,18 @@
|
||||
</scroll-view>
|
||||
|
||||
<view class="right-flex-wrap">
|
||||
<scroll-view scroll-y="true" class="content-wrap" v-if="value.template == 1 || loadType == 'all'"
|
||||
<scroll-view scroll-y="true" class="content-wrap" v-if="value.template == 1 || value.template == 99 || loadType == 'all'"
|
||||
ref="contentWrap" :scroll-into-view="categoryId" :scroll-with-animation="true"
|
||||
@scroll="listenScroll" @touchstart="touchStart" :refresher-enabled="true"
|
||||
refresher-default-style="none" :refresher-triggered="triggered" @refresherrefresh="onRefresh"
|
||||
@refresherrestore="onRestore">
|
||||
<view class="child-category" v-for="(item, index) in categoryTree" :key="index"
|
||||
:id="'category-' + index">
|
||||
:id="'category-' + index" :style="{ display: value.template == 99 && select != index ? 'none' : 'block' }">
|
||||
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
|
||||
:select="select" :oneCategorySelect="oneCategorySelect" :isList="isList"
|
||||
:lastSecondCategoryName="value.template == 99 ? lastSecondCategoryName : ''"
|
||||
@tologin="toLogin" @selectsku="selectSku($event, index)" @addCart="addCartPoint"
|
||||
@loadfinish="getHeightArea"></diy-category-item>
|
||||
@loadfinish="getHeightArea" @saveSecondCategory="saveSecondCategoryName"></diy-category-item>
|
||||
</view>
|
||||
<view class="end-tips" ref="endTips" :style="{ opacity: endTips }">{{ $lang('components-diy.diy-category.reachedBottom') }}</view>
|
||||
</scroll-view>
|
||||
@@ -194,7 +195,8 @@ export default {
|
||||
loadType: '',
|
||||
templateFourData: [],
|
||||
isList: false,
|
||||
lang: uni.getStorageSync("lang")//en-us 英文
|
||||
lang: uni.getStorageSync("lang"),
|
||||
lastSecondCategoryName: ''
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -373,9 +375,11 @@ export default {
|
||||
if (index >= this.categoryTree.length) return;
|
||||
this.select = index;
|
||||
this.categoryId = 'category-' + index;
|
||||
// 阻止切换分类之后滚动事件也立即执行
|
||||
this.scrollLock = true;
|
||||
},
|
||||
saveSecondCategoryName(name) {
|
||||
this.lastSecondCategoryName = name;
|
||||
},
|
||||
touchStart() {
|
||||
this.scrollLock = false;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user