tmp: 部分代码与UnishopV5结合,但是代码有严重缺陷

This commit is contained in:
2025-12-20 15:30:39 +08:00
parent ed5181b382
commit e263a616f6
183 changed files with 31316 additions and 18590 deletions

View File

@@ -153,6 +153,7 @@
}" class="items" @click="change(item_value.sku_id, item_value.spec_id)">
<image v-if="item_value.image" :src="$util.img(item_value.image, { size: 'small' })" @error="valueImageError(index, index_value)" />
<text>{{ item_value.spec_value_name }}</text>
<view class="empty-stock" v-if="item_value.stock == 0">缺货</view>
</view>
</view>
@@ -173,8 +174,8 @@
</view>
</view>
</view>
<ns-form :data="goodsForm" v-if="goodsForm" ref="form"></ns-form>
<ns-form :data="goodsForm" v-if="goodsForm" ref="form" @changeFormVal="changeFormVal"></ns-form>
</scroll-view>
</view>
<view class="footer" @click="confirm()">
@@ -182,7 +183,8 @@
<block v-if="type == 'point'">
<block v-if="goodsDetail.type == 1">
<!-- 兑换商品 -->
<button v-if="goodsDetail.stock && goodsDetail.stock != 0" type="primary">兑换</button>
<button v-if="goodsDetail.point * number > memberPoint" disabled="true" type="primary">积分不足</button>
<button v-else-if="goodsDetail.stock && goodsDetail.stock != 0" type="primary">兑换</button>
<button type="primary" v-else disabled="true">库存不足</button>
</block>
<block v-else-if="goodsDetail.type == 2 || goodsDetail.type == 3">
@@ -195,7 +197,8 @@
<button type="primary" v-else-if="goodsDetail.stock && goodsDetail.stock != 0 && type == 'buy_now'">立即购买</button>
<button type="primary" v-else-if="goodsDetail.stock && goodsDetail.stock != 0 && type == 'confirm'">确认</button>
<template v-else-if="goodsDetail.stock && goodsDetail.stock != 0">
<template v-if="goodsDetail.buy_num">
<!-- 拼团和拼返的buy_num代表最大购买数量不是最小购买数量 -->
<template v-if="type != 'pintuan' && type != 'pinfan' && goodsDetail.buy_num">
<button type="primary" v-if="goodsDetail.buy_num <= goodsDetail.stock">立即抢购</button>
<button type="primary" v-else disabled="true">库存不足</button>
</template>
@@ -226,6 +229,10 @@
type: [Number, String],
default: 0
},
memberPoint: {
type: [Number, String],
default: 0
},
goodsDetail: {
type: Object,
default: null
@@ -244,6 +251,12 @@
minBuy: {
type: Number,
default: 0
},
goodsFormVal: {
type: Array,
default () {
return [];
}
}
},
data() {
@@ -265,7 +278,8 @@
pintuan_num_field: 'pintuan_num',
goodsSkuInfo: null, //所有的商品规格信息
goodsForm: null,
isLoad: false // 是否首次加载
isLoad: false ,// 是否首次加载
skuList: [],//所有规格数据
};
},
created() {
@@ -310,8 +324,8 @@
this.pintuan_num_field = newData.pintuan_num_field;
}
if (this.goodsDetail.goods_form && !this.goodsForm) this.goodsForm = this.goodsDetail.goods_form;
// 切换商品,重新赋值
this.calcSkuStock()
if (newData.goods_id != oldData.goods_id) {
if (this.goodsDetail.pintuan_id) {
this.getPintuanGoodsSkuList();
@@ -378,6 +392,34 @@
}
},
methods: {
calcSkuStock() {
if(this.goodsDetail.goods_spec_format && this.goodsDetail.goods_spec_format.length){
this.goodsDetail.goods_spec_format.forEach(spec => {
spec.value.forEach(val => {
this.skuList.forEach(sku => {
if (val.sku_id == sku.sku_id) {
this.$set(val,'stock',sku.stock);
}
})
})
})
}
},
changeFormVal(e) {
this.$emit('detailChangeVal',e)
},
getGoodsForm(){
this.$api.sendRequest({
url: "/form/api/form/goodsform",
data: {
goods_id: this.goodsDetail.goods_id
},
success: res => {
if (res.code == 0 && res.data) this.$set(this.goodsDetail, 'goods_form', res.data);
if(this.goodsFormVal.length) Object.assign(this.goodsDetail.goods_form,this.goodsFormVal)
}
});
},
//【普通商品】获取所有规格信息
getGeneralGoodsSkuList(callback) {
this.$api.sendRequest({
@@ -387,9 +429,7 @@
},
success: res => {
if (res.code >= 0) {
let data = res.data,
obj = {};
let obj = {};
res.data.forEach((item, index) => {
item = this.handleData(item);
@@ -415,6 +455,8 @@
if (this.skuId == 0) this.skuId = res.data[0].sku_id;
this.goodsSkuInfo = obj;
this.isLoad = false;
this.skuList = res.data;
this.calcSkuStock();
if (callback) callback();
} else {
this.$util.redirectTo('/pages/index/index');
@@ -493,7 +535,7 @@
item = this.handleData(item);
item.show_price = this.goodsDetail.groupbuy_price;
item.save_price = item.price - item.show_price > 0 ? (item.price - item.show_price).toFixed(2) : 0;
//团购buy_num指最少购买数量
if (data.stock > data.buy_num) {
this.number = this.goodsDetail.buy_num;
this.minNumber = this.goodsDetail.buy_num;
@@ -730,6 +772,9 @@
popclose() {
if (this.$refs.skuPopup.showPopup) {
this.$emit('hideSkuPop');
}else{
this.goodsForm = null
this.getGoodsForm()
}
},
//查看规格图片
@@ -766,7 +811,6 @@
}
}
}
this.goodsSkuDetail = this.goodsSkuInfo['sku_' + this.skuId];
this.$emit('refresh', this.goodsSkuDetail);
this.$emit('getSkuId', this.skuId);
@@ -781,6 +825,7 @@
this.confirmDisabled = false;
}
}
this.keyInput(true);
},
showPrice(price) {
@@ -1013,7 +1058,7 @@
return;
}
if (this.goodsDetail.buy_num > this.goodsDetail.stock) {
if (this.type != 'pintuan' && this.type != 'pinfan' && this.goodsDetail.buy_num > this.goodsDetail.stock) {
this.$util.showToast({
title: '库存小于最低购买数量'
});
@@ -1077,7 +1122,7 @@
title: '加入购物车成功'
});
this.cartNum += this.number;
this.$store.dispatch('getCartNumber');
let discount_price = this.goodsDetail.discount_price;
if (this.goodsDetail.member_price > 0 && Number(this.goodsDetail.member_price) <= Number(this.goodsDetail.discount_price)) {
discount_price = this.goodsDetail.member_price;
@@ -1213,28 +1258,29 @@
});
} else if (this.type == 'bargain') {
// 砍价
this.$api.sendRequest({
url: '/bargain/api/bargain/launch',
data: {
id: this.goodsDetail.id
},
success: res => {
this.btnSwitch = false;
if (res.code == 0) {
this.$util.redirectTo(
'/pages_promotion/bargain/detail', {
if (this.callback) {
this.callback();
}else {
this.$api.sendRequest({
url: '/bargain/api/bargain/launch',
data: {
id: this.goodsDetail.id
},
success: res => {
this.btnSwitch = false;
if (res.code == 0) {
this.$util.redirectTo('/pages_promotion/bargain/detail', {
b_id: this.goodsDetail.bargain_id,
l_id: res.data
},
'redirectTo'
);
} else {
this.$util.showToast({
title: res.message
});
}, 'redirectTo');
} else {
this.$util.showToast({
title: res.message
});
}
}
}
});
});
}
} else if (this.type == 'point') {
// 积分兑换
var data = {
@@ -1399,13 +1445,27 @@
.body-item .sku-list-wrap {
padding-bottom: 0rpx;
position: relative;
}
.body-item .sku-list-wrap .title {
padding: 20rpx 0;
display: block;
}
.body-item .sku-list-wrap .empty-stock{
font-size: 18rpx;
line-height: 22rpx;
position: absolute;
right: 0;
top: 0;
border-radius: 4rpx;
transform: translateY(-50%);
padding: 0 2rpx;
color: #989898;
background-color: #f0f1f2;
}
.body-item .sku-list-wrap .items {
position: relative;
display: inline-block;