feat: 购买量是起订量的倍数

This commit is contained in:
黄泽群
2025-09-08 17:22:44 +08:00
parent e12623d607
commit 27a5cfe7b7
+151 -164
View File
@@ -2,9 +2,7 @@
<view class="product_info_warp">
<!-- 头部产品描述图 -->
<view class="product_info_header_warp">
<up-swiper :list="swiperList" class="product_info_header_swiper" @click="onSwiper"
@change="e => currentNum = e.current">
<up-swiper :list="swiperList" class="product_info_header_swiper" @click="onSwiper" @change="(e) => (currentNum = e.current)">
<template #indicator>
<view class="indicator-num">
<text class="indicator-num__text">{{ currentNum + 1 }}/{{ swiperList.length }}</text>
@@ -12,12 +10,10 @@
</template>
</up-swiper>
<view class="img_comm left_warp">
<up-image src="/static/common/left_b_st.png" width="30" height="30" bgColor="#f1f6ff00"
@click="jumpLeft"></up-image>
<up-image src="/static/common/left_b_st.png" width="30" height="30" bgColor="#f1f6ff00" @click="jumpLeft"></up-image>
</view>
<view class="img_comm right_warp">
<up-image src="/static/common/share_st.png" width="30" height="30" bgColor="#f1f6ff00"
@click="jumpShare"></up-image>
<up-image src="/static/common/share_st.png" width="30" height="30" bgColor="#f1f6ff00" @click="jumpShare"></up-image>
</view>
</view>
<!-- 数据详情 -->
@@ -26,10 +22,8 @@
<view class="content_data">
<view class="content_data_price">
<text>¥</text>
<text style="font-size: 60rpx;" v-if="orderInfo.minPrice && orderInfo.maxPrice">
{{ orderInfo.minPrice }} - {{ orderInfo.maxPrice }}
</text>
<text style="font-size: 60rpx;" v-else>{{ orderInfo.minPrice }}</text>
<text style="font-size: 60rpx" v-if="orderInfo.minPrice && orderInfo.maxPrice">{{ orderInfo.minPrice }} - {{ orderInfo.maxPrice }}</text>
<text style="font-size: 60rpx" v-else>{{ orderInfo.minPrice }}</text>
<text class="price_o">¥{{ orderInfo.adPrice }}</text>
</view>
<view class="content_data_title">
@@ -37,8 +31,7 @@
</view>
<view class="content_data_series">
<!-- 暂时隐藏 -->
<view>
</view>
<view></view>
<!-- 销量还需要改 -->
<view>销量{{ orderInfo.sales }}件</view>
</view>
@@ -61,7 +54,7 @@
<view class="concrete_item_value">
<view class="address_warp">
<up-image src="/static/common/address2.png" width="10" height="10" bgColor="#f1f6ff00"></up-image>
<view style="margin-left: 10rpx;">请填写地址</view>
<view style="margin-left: 10rpx">请填写地址</view>
</view>
<view class="address_72_warp">现货{{ getValue(PRODUCT_DELIVERY_TIME, orderInfo.deliveryTime) }}</view>
</view>
@@ -97,30 +90,25 @@
<view class="product_but_warp">
<view class="product_but_left">
<view class="left_item">
<up-image src="/static/product/home.png" width="20" height="20" bgColor="#f1f6ff00"
@click="jumpOther('home')"></up-image>
<up-image src="/static/product/home.png" width="20" height="20" bgColor="#f1f6ff00" @click="jumpOther('home')"></up-image>
<view>首页</view>
</view>
<view class="left_item">
<up-image src="/static/product/kefu.png" width="20" height="20" bgColor="#f1f6ff00"
@click="onZiXun"></up-image>
<up-image src="/static/product/kefu.png" width="20" height="20" bgColor="#f1f6ff00" @click="onZiXun"></up-image>
<view>咨询</view>
</view>
<view class="left_item" v-if="!ji">
<up-image src="/static/product/cart.png" width="24" height="20" bgColor="#f1f6ff00"
@click="jumpOther('cart')"></up-image>
<up-image src="/static/product/cart.png" width="24" height="20" bgColor="#f1f6ff00" @click="jumpOther('cart')"></up-image>
<view>购物车</view>
</view>
</view>
<view class="product_but_right">
<view v-if="!ji" class="but_comm join_warp" @click="checkSpecification(true, 'addCart')">加入购物车</view>
<view class="but_comm buy_warp" :class="{ 'border-16': ji }" @click="checkSpecification(true, 'buy')">立即购买
</view>
<view class="but_comm buy_warp" :class="{ 'border-16': ji }" @click="checkSpecification(true, 'buy')">立即购买</view>
</view>
</view>
<!-- 选择规格的弹框 -->
<up-popup :show="specificationShow" :round="10" :closeOnClickOverlay="false" :closeable="true"
@close="specificationShow = false" mode="bottom">
<up-popup :show="specificationShow" :round="10" :closeOnClickOverlay="false" :closeable="true" @close="specificationShow = false" mode="bottom">
<view class="specification_warp">
<!-- 选择地址 -->
<view class="specification_adress_warp">
@@ -142,20 +130,17 @@
<view class="price_warp">
<view class="price_content_warp">
<view>¥</view>
<text style="font-size: 50rpx;"
v-if="selectSpecificationTempl && Object.keys(selectSpecificationTempl).length !== 0">
<text style="font-size: 50rpx" v-if="selectSpecificationTempl && Object.keys(selectSpecificationTempl).length !== 0">
{{ selectSpecificationTempl.price }}
</text>
<view style="font-size: 50rpx" v-else>
{{ orderInfo.minPrice }}
<text v-if="orderInfo.maxPrice">- {{ orderInfo.maxPrice }}</text>
</view>
<view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
优惠卷{{ orderInfo.couponPrice }}</view>
<view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">优惠卷{{ orderInfo.couponPrice }}</view>
</view>
<view class="oOrice_content_warp">¥{{ orderInfo.adPrice }}</view>
<view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
优惠卷已优惠¥{{ orderInfo.couponPrice }}</view>
<view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">优惠卷已优惠¥{{ orderInfo.couponPrice }}</view>
</view>
<view class="inventory_warp">
<view>库存</view>
@@ -171,7 +156,10 @@
<view class="specification_item_warp">
<view
:class="oItem.inventory === 0 ? 'item_Warp item_Warp_no_warp' : item.selectVal === oItem.n ? 'item_Warp item_Warp_yes_warp' : 'item_Warp'"
v-for="(oItem, oIndex) in item.items" :key="oItem.n" @click="clickSpecification(index, oItem)">
v-for="(oItem, oIndex) in item.items"
:key="oItem.n"
@click="clickSpecification(index, oItem)"
>
{{ oItem.n }}
</view>
</view>
@@ -188,11 +176,9 @@
</view>
</view>
<view v-if="specificationShowType === 'buy'" class="specification_buy_but" @click="addCart(true)">去支付</view>
<view v-else-if="specificationShowType === 'addCart'" class="specification_buy_but" @click="addCart(false)">
加入购物车
</view>
<view v-else-if="specificationShowType === 'addCart'" class="specification_buy_but" @click="addCart(false)">加入购物车</view>
<view v-else class="product_but_right popup_but">
<view class='but_comm join_warp' @click="addCart(false)">加入购物车</view>
<view class="but_comm join_warp" @click="addCart(false)">加入购物车</view>
<view class="but_comm buy_warp" @click="addCart(true)">立即购买</view>
</view>
</view>
@@ -201,21 +187,16 @@
<!-- 我的客服 -->
<up-modal :show="serviceShow" :showConfirmButton="false">
<view class="slot-content">
<view class="close_warp" @click="serviceShow = false;">
<view class="close_warp" @click="serviceShow = false">
<up-image src="/static/common/close.png" width="20" height="20" bgColor="#f1f6ff00"></up-image>
</view>
<view class="content_">
<view class="content_1">{{ source === "supply_chain" ? '云仓客服' : '平台客服' }}</view>
<view class="content_3">{{ source === "supply_chain"
? CLOUD_SERVICE_PHONE_NUMBER : CUSTOMER_SERVICE_PHONE_NUMBER }}
</view>
<view class="content_1">{{ source === 'supply_chain' ? '云仓客服' : '平台客服' }}</view>
<view class="content_3">{{ source === 'supply_chain' ? CLOUD_SERVICE_PHONE_NUMBER : CUSTOMER_SERVICE_PHONE_NUMBER }}</view>
</view>
<view class="but_">
<view class="but_copy"
@click="copyMobile(source === 'supply_chain' ? CLOUD_SERVICE_PHONE_NUMBER : CUSTOMER_SERVICE_PHONE_NUMBER)">
复制号码
</view>
<view class="but_close" @click="serviceShow = false;">取消</view>
<view class="but_copy" @click="copyMobile(source === 'supply_chain' ? CLOUD_SERVICE_PHONE_NUMBER : CUSTOMER_SERVICE_PHONE_NUMBER)">复制号码</view>
<view class="but_close" @click="serviceShow = false">取消</view>
</view>
</view>
</up-modal>
@@ -225,9 +206,7 @@
<view class="uni-banner">
<view class="banner_box">
<view class="title_">温馨提示</view>
<view class="msg_">
该商家暂未开通供应链权限,请联系供应链客服开通授权。
</view>
<view class="msg_">该商家暂未开通供应链权限,请联系供应链客服开通授权。</view>
<view class="phone_">{{ CLOUD_SERVICE_PHONE_NUMBER }}</view>
<view class="but_">
<view class="but_b" @click="copyMobile(CLOUD_SERVICE_PHONE_NUMBER)">立即联系</view>
@@ -242,7 +221,7 @@
<script>
import { getGoodsDetail, addGoods, getGoodsSpecs } from '@/api/product.js';
import { getValue, PRODUCT_DELIVERY_TIME } from '@/utils/enumUtils.js';
import { copyData } from '@/utils/index.js'
import { copyData } from '@/utils/index.js';
import { CUSTOMER_SERVICE_PHONE_NUMBER, CLOUD_SERVICE_PHONE_NUMBER } from '@/utils/config.js';
export default {
@@ -255,7 +234,7 @@ export default {
},
CLOUD_SERVICE_PHONE_NUMBER() {
return CLOUD_SERVICE_PHONE_NUMBER;
},
}
},
data() {
return {
@@ -263,17 +242,17 @@ export default {
swiperList: [],
currentNum: 0,
specificationShow: false,
specificationShowType: '',// 弹框类型
specificationShowType: '', // 弹框类型
orderInfo: {},
specificationList: [],//规格
selectSpecification: [],// 选择的规格
specificationTempl: [],// 规格模版数据
selectSpecificationTempl: {},// 选择规格模版数据
serviceShow: false,// 联系客服弹框
specificationList: [], //规格
selectSpecification: [], // 选择的规格
specificationTempl: [], // 规格模版数据
selectSpecificationTempl: {}, // 选择规格模版数据
serviceShow: false, // 联系客服弹框
openShow: false,
source: null,// 来源:供应链,自营
source: null, // 来源:供应链,自营
ji: 0
}
};
},
onLoad(options) {
const id = options.id;
@@ -288,13 +267,12 @@ export default {
this.getById();
}
}
},
methods: {
onZiXun(){
onZiXun() {
uni.navigateTo({
url:'/pages/rwa_package/setting/kefu?type=5260'
})
url: '/pages/rwa_package/setting/kefu?type=5260'
});
},
getValue,
onSwiper(index) {
@@ -316,17 +294,20 @@ export default {
},
jumpOther(type) {
if (type === 'home') {
uni.switchTab({// 首页
url: '/pages/home/home',
})
} else if (type === "share") {// 分享
uni.navigateTo({
url: '/pages/other_package/invite_friends/invite_friends',
})
} else if (type === "cart") {// 购物车
uni.switchTab({
url: '/pages/shopping_cart/shopping_cart',
})
// 首页
url: '/pages/home/home'
});
} else if (type === 'share') {
// 分享
uni.navigateTo({
url: '/pages/other_package/invite_friends/invite_friends'
});
} else if (type === 'cart') {
// 购物车
uni.switchTab({
url: '/pages/shopping_cart/shopping_cart'
});
}
},
/**
@@ -334,21 +315,20 @@ export default {
*/
async getById() {
const params = {
id: this.id,
}
id: this.id
};
const resp = await getGoodsDetail(params);
if (resp && resp.bizcode === 100) {
const data = resp.data;
this.ji = data.type == 3 ? 1 : 0;
// 商品图
if (data.goodsGraph) {
this.swiperList = data.goodsGraph.split(",");
this.swiperList = data.goodsGraph.split(',');
}
data.addressObj = {}// 收件人地址
data.quantity = 1// 数量
data.inventory = 0// 库存
data.addressObj = {}; // 收件人地址
data.quantity = 1; // 数量
data.inventory = 0; // 库存
this.orderInfo = data;
}
},
/**
@@ -357,45 +337,45 @@ export default {
getSupplyChainById() {
const params = {
goods_id: this.id,
app_id: "2024111300164927",
sign_type: "MD5",
sign: "d04be0cedd49608e758458325faecf90",
}
app_id: '2024111300164927',
sign_type: 'MD5',
sign: 'd04be0cedd49608e758458325faecf90'
};
uni.request({
url: "https://cyysc.gscm.top/outside/1/atm/goods/detail",
method: "get",
url: 'https://cyysc.gscm.top/outside/1/atm/goods/detail',
method: 'get',
data: params,
header: {
},
header: {},
success: (res) => {
const data = res.data;
if (data && data.result === 1) {
const objData = data.data;
const content = objData.content.replace(/&amp;/g, '&')
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&quot;/g, "\'")
.replace(/&#39;/g, '\"')
.replace(/\n/g, "<br>");
const content = objData.content
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, "'")
.replace(/&#39;/g, '"')
.replace(/\n/g, '<br>');
const orderInfo = {
detailInfo: content,
minPrice: objData.min_price,
// maxPrice:objData.max_price,
adPrice: objData.price,
sales: objData.virtual_sales,
}
const domain = "https://cyysc.gscm.top";
sales: objData.virtual_sales
};
const domain = 'https://cyysc.gscm.top';
let currentThumb = objData.thumb;
if (objData.thumb.indexOf('https://') === -1 && objData.thumb.indexOf('http://') === -1) {
currentThumb = domain + "/static/upload/" + objData.thumb;
currentThumb = domain + '/static/upload/' + objData.thumb;
}
this.swiperList = [currentThumb];// 封面图
this.swiperList = [currentThumb]; // 封面图
this.orderInfo = orderInfo;
}
},
fail: (error) => {
console.log("error", error);
},
console.log('error', error);
}
});
},
async checkSpecification(val, type) {
@@ -403,20 +383,20 @@ export default {
if (type == 'n' && this.ji == 1) {
type = 'buy';
}
console.log('afsdfsd', source, type)
if (source && source === "supply_chain") {
console.log('afsdfsd', source, type);
if (source && source === 'supply_chain') {
this.openShow = true;
return;
}
// 需要查询一下最新的规格
if (val) {
await this.querySpecification()
await this.querySpecification();
const data = this.orderInfo;
this.getSpecification(data.specs);
} else {
this.specificationList = [];//规格
this.selectSpecification = [];// 选择的规格
this.specificationTempl = [];// 规格模版数据
this.specificationList = []; //规格
this.selectSpecification = []; // 选择的规格
this.specificationTempl = []; // 规格模版数据
}
this.specificationShow = val;
this.specificationShowType = type;
@@ -426,30 +406,30 @@ export default {
const optionArr = [];
if (specs) {
const arr = JSON.parse(specs);
arr.map(item => {
arr.map((item) => {
optionArr.push({
type: item.type,
items: item.items,
selectVal: null,
})
})
selectVal: null
});
});
}
this.specificationList = optionArr;
},
// 获取规格模版数据
async querySpecification() {
const params = {
id: this.id,
}
id: this.id
};
const resp = await getGoodsSpecs(params);
if (resp && resp.bizcode === 100) {
const data = resp.data;
let stock = 0;
data.map(item => {
data.map((item) => {
stock = stock + item.stock;
})
});
this.specificationTempl = data;
this.orderInfo.inventory = stock;// 库存
this.orderInfo.inventory = stock; // 库存
}
},
//改变规格的样式
@@ -470,35 +450,41 @@ export default {
const newLength = this.selectSpecification.length;
// 开始做校验
if (oldLength === newLength) {
const newLengthStr = this.selectSpecification.join("♧");
const newLengthStr = this.selectSpecification.join('♧');
const specificationTempl = this.specificationTempl;
let selectTempl = {};
specificationTempl.map(item => {
specificationTempl.map((item) => {
if (item.combNames === newLengthStr) {
selectTempl = item
selectTempl = item;
return;
}
});
this.selectSpecificationTempl = selectTempl;
this.orderInfo.inventory = selectTempl.stock;// 库存
this.orderInfo.inventory = selectTempl.stock; // 库存
}
},
// 改变数量
quantityFun(type) {
let currentQuantity = this.orderInfo.quantity;// 当前数量
if (type === "minus") {
if (currentQuantity === 1) {
let currentQuantity = this.orderInfo.quantity; // 当前数量
const minBuyNum = this.selectSpecificationTempl.minBuyNum || 1; // 当前起订量,默认为1
// 确保起订量至少为1
const step = Math.max(minBuyNum, 1);
if (type === 'minus') {
// 计算减少后的数量,确保不低于最小起订量且是其倍数
const newQuantity = currentQuantity - step;
if (newQuantity < minBuyNum) {
this.$refs.uToastRef.show({
type: 'error',
message: "不能低于最低购买数量",
message: `不能低于最低购买数量${minBuyNum}`
});
} else {
currentQuantity = currentQuantity - 1;
currentQuantity = newQuantity;
}
} else if (type === "add") {
// 需要判断一下库存
currentQuantity = currentQuantity + 1;
} else if (type === 'add') {
currentQuantity = currentQuantity + step;
}
this.orderInfo.quantity = currentQuantity;
},
@@ -513,26 +499,33 @@ export default {
});
return;
}
if (!(selectTempl.minBuyNum > 0 && this.orderInfo.quantity >= selectTempl.minBuyNum && this.orderInfo.quantity % selectTempl.minBuyNum === 0)) {
uni.showToast({
title: `购买数量需要大于等于起订量${selectTempl.minBuyNum}`,
icon: 'none', // 可选 success/loading/none
duration: 2000 // 持续时长,单位ms
});
return;
}
const params = {
id: this.id,
specsId: selectTempl.id,// 规格ID
goodsNum: this.orderInfo.quantity,// 商品数量
}
console.log('selectTempl', selectTempl)
specsId: selectTempl.id, // 规格ID
goodsNum: this.orderInfo.quantity // 商品数量
};
console.log('selectTempl', selectTempl);
if (this.ji == 1) {
params['specsId'] = selectTempl;
uni.navigateTo({
url: `/pages/order_package/order_submit/order_submit?sed=${JSON.stringify(params)}`,
})
url: `/pages/order_package/order_submit/order_submit?sed=${JSON.stringify(params)}`
});
return;
}
const resp = await addGoods(params);
if (resp && resp.bizcode === 100) {
if (isBy) {
uni.navigateTo({
url: `/pages/order_package/order_submit/order_submit?ids=${resp.data}`,
})
url: `/pages/order_package/order_submit/order_submit?ids=${resp.data}`
});
} else {
this.specificationShow = false;
uni.showToast({
@@ -547,12 +540,9 @@ export default {
}
},
// 跳转到分享页面
jumpShare() {
jumpShare() {}
}
}
}
};
</script>
<style lang="scss" scoped>
@@ -656,7 +646,7 @@ export default {
.content_concrete {
padding: 20rpx;
background: #FFFFFF;
background: #ffffff;
border-radius: 30rpx;
margin-top: 20rpx;
@@ -673,7 +663,7 @@ export default {
}
.concrete_item_but {
border-bottom: 1rpx solid #EEEEEEFF;
border-bottom: 1rpx solid #eeeeeeff;
}
.concrete_item_title {
@@ -683,7 +673,7 @@ export default {
.concrete_item_value {
font-weight: 500;
color: #1A1A1A;
color: #1a1a1a;
width: calc(100% - 140rpx);
.address_warp {
@@ -712,7 +702,7 @@ export default {
}
.content_details {
background: #FFFFFF;
background: #ffffff;
border-radius: 24rpx;
padding: 10rpx 10rpx 30rpx;
margin-top: 30rpx;
@@ -728,14 +718,13 @@ export default {
}
}
.product_but_warp {
padding: 20rpx;
position: fixed;
bottom: 0;
height: 160rpx;
width: calc(100% - 40rpx);
background-color: #FFFFFF;
background-color: #ffffff;
display: flex;
justify-content: space-between;
@@ -753,7 +742,6 @@ export default {
color: #666666;
}
}
}
.product_but_right {
@@ -763,12 +751,12 @@ export default {
.but_comm {
text-align: center;
padding: 20rpx 40rpx;
color: #FFFFFF;
color: #ffffff;
height: 46rpx;
}
.join_warp {
background: #E4D6FD;
background: #e4d6fd;
border-radius: 16rpx 0rpx 0rpx 16rpx;
color: $app-zt-color;
}
@@ -784,7 +772,7 @@ export default {
.specification_adress_warp {
padding: 30rpx;
background: #FFFFFF;
background: #ffffff;
border-radius: 24rpx;
}
@@ -805,7 +793,7 @@ export default {
.address_title {
font-weight: 500;
font-size: 26rpx;
color: #BBBBBB;
color: #bbbbbb;
margin-bottom: 10rpx;
margin-right: 20rpx;
width: 592rpx;
@@ -823,7 +811,7 @@ export default {
.specification_product_warp {
display: flex;
background: #FFFFFF;
background: #ffffff;
border-radius: 24rpx;
padding: 30rpx;
margin-top: 20rpx;
@@ -876,7 +864,7 @@ export default {
}
.specification_list_warp {
background: #FFFFFF;
background: #ffffff;
border-radius: 24rpx;
padding: 30rpx;
margin-top: 20rpx;
@@ -888,7 +876,7 @@ export default {
.list_title_warp {
font-weight: 500;
font-size: 30rpx;
color: #1A1A1A;
color: #1a1a1a;
line-height: 48rpx;
}
@@ -913,7 +901,7 @@ export default {
}
.item_Warp_no_warp {
background: #F5F5F5;
background: #f5f5f5;
color: #999999;
text-decoration-line: line-through;
}
@@ -921,12 +909,12 @@ export default {
.item_Warp_yes_warp {
border: 1px solid $app-bt-bj;
color: $app-bt-bj;
background: #FFFFFF;
background: #ffffff;
}
}
.specification_but {
background: #FFFFFF;
background: #ffffff;
border-radius: 24rpx;
padding: 30rpx;
margin-top: 30rpx;
@@ -943,18 +931,18 @@ export default {
padding: 20rpx 0;
text-align: center;
background-color: $app-bt-bj;
color: #FFFFFF;
color: #ffffff;
margin-top: 20rpx;
font-weight: 500;
font-size: 28rpx;
color: #FFFFFF;
color: #ffffff;
border-radius: 16rpx;
}
}
}
.popup_but {
background-color: #FFFFFF;
background-color: #ffffff;
.but_comm {
width: 40%;
@@ -962,7 +950,6 @@ export default {
}
.open_Show {
/* 弹出层形式的广告 */
.uni-banner {
display: flex;
@@ -1016,10 +1003,10 @@ export default {
margin-top: 50rpx;
.but_b {
background: #03AD27;
background: #03ad27;
border-radius: 41rpx;
font-size: 32rpx;
color: #FFFFFF;
color: #ffffff;
width: 70%;
text-align: center;
padding: 20rpx 0;