Merge branch 'gaibao-2821' into dev/1.0

This commit is contained in:
2026-07-14 08:47:48 +08:00
3 changed files with 197 additions and 15 deletions

View File

@@ -119,10 +119,14 @@ const localDevConfig = ({
uniacid: 2485,
domain: 'https://xcx6.aigc-quickapp.com/',
},
'2821': { // 离型纸硅油纸
uniacid: 2821,
domain: 'https://xcx.aigc-quickapp.com/',
},
// })['5g-237']; // 商品分类,没有立即咨询文字
// })['5g-97']; // 大宗商品贸易,支持自定义字体大小、颜色
// })['5g-50']; // 燃气安全产品机器人,购物车无反应
})['2482']; // 低空经济
})['2821']; // 离型纸硅油纸
// })['2485']; // 验证电子表单前后端数据一致性
// })['5g-11']; // 数码
// })['5g-213']; // 选择要使用的环境配置

View File

@@ -5,17 +5,44 @@
<image :src="$util.img(category.image_adv)" mode="widthFix" show-menu-by-longpress />
</view>
<block v-if="value.level == 2">
<view class="category-title">{{ category.category_name }}</view>
<view class="category-list">
<view class="category-item" v-for="(one, oneIndex) in category.child_list" :key="oneIndex"
@tap.stop="$util.redirectTo('/pages_goods/list', { category_id: one.category_id })">
<view class="img-box">
<image :src="$util.img(one.image)" mode="widthFix" show-menu-by-longpress />
</view>
<view class="name">{{ one.category_name }}</view>
<block v-if="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 == 3">
@@ -296,6 +323,10 @@ export default {
isList: {
type: Boolean,
default: false
},
lastSecondCategoryName: {
type: String,
default: ''
}
},
mixins: [DiyMinx],
@@ -316,13 +347,27 @@ export default {
scrollTop: 0,
loadType: '',
timeout: {},
cartEditRepeat: false
cartEditRepeat: false,
selectedSecondCategory: null,
secondCategoryGoodsList: []
};
},
created() {
this.type = this.value.template == 1 ? '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.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 +377,18 @@ export default {
if (data) this.contentWrapHeight = data.height;
}).exec();
}, 1000);
if (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 +417,18 @@ export default {
} else if (this.loadType == 'part') {
this.scrollTop = -1;
}
if (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 +808,59 @@ 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 = 'sale_num';
sort = 'desc';
} else if (this.value.sortWay == 'price') {
order = 'discount_price';
sort = 'desc';
} else if (this.value.sortWay == 'news') {
order = 'create_time';
sort = 'desc';
}
}
this.$api.sendRequest({
url: '/api/goodssku/pageByCategory',
data: {
page: 1,
page_size: this.pageSize,
category_id: categoryId,
order: order,
sort: sort
},
success: res => {
if (res.code == 0 && res.data) {
this.secondCategoryGoodsList = res.data.list || [];
this.secondCategoryGoodsList.forEach((item) => {
item.num = this.cartList['goods_' + item.goods_id] ? this.cartList['goods_' + item.goods_id].num : 0;
});
}
this.loading = false;
},
fail: () => {
this.loading = false;
}
});
},
//加载商品在购物车的总数量
loadGoodsCartNum(isRefresh = false) {
this.goodsList.forEach((item) => {
@@ -803,6 +925,58 @@ export default {
}
}
.second-category-btns {
display: flex;
flex-wrap: wrap;
background: #fff;
margin: 0 20rpx;
border-radius: 10rpx;
padding: 20rpx;
gap: 16rpx;
margin-bottom: 20rpx;
.second-category-btn {
padding: 16rpx 32rpx;
background: #f5f5f5;
border-radius: 20rpx;
font-size: 26rpx;
color: #333;
cursor: pointer;
user-select: none;
z-index: 100;
position: relative;
&.selected {
background: var(--color-base-bg, #ff5000);
color: #fff;
}
}
}
.category-goods-list {
padding: 0 20rpx;
margin-bottom: 20rpx;
}
.category-goods-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60rpx 0;
image {
width: 200rpx;
height: 200rpx;
margin-bottom: 20rpx;
}
.tips {
font-size: 26rpx;
color: #999;
}
}
.category-list {
display: flex;
flex-wrap: wrap;

View File

@@ -98,11 +98,12 @@
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" v-if="select == index">
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
:select="select" :oneCategorySelect="oneCategorySelect" :isList="isList"
:lastSecondCategoryName="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;
},