From 8d50f332ec8ad2c48c10aa71e6206c1891d5407e Mon Sep 17 00:00:00 2001
From: FrancisHu <2756004617@qq.com>
Date: Fri, 31 May 2024 16:11:44 +0800
Subject: [PATCH] =?UTF-8?q?5.31=E5=AE=81=E5=A4=8F=E9=A2=86=E6=96=99?=
=?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/deviceDetail/deviceDetail.vue | 69 +++++++++++++++++------------
1 file changed, 40 insertions(+), 29 deletions(-)
diff --git a/pages/deviceDetail/deviceDetail.vue b/pages/deviceDetail/deviceDetail.vue
index 91740ea..7ccb5de 100644
--- a/pages/deviceDetail/deviceDetail.vue
+++ b/pages/deviceDetail/deviceDetail.vue
@@ -18,6 +18,7 @@
:clear="false"
>
+
当前型号剩余库存:{{ leftNum }}
预约数量
@@ -56,6 +57,7 @@ import { basePath } from '../../public';
specRange: [
],
+ leftNum: '',
companyId: '',
status: '',
baseUrl: 'http://112.29.103.165:21624/dev-api/system'
@@ -79,6 +81,7 @@ import { basePath } from '../../public';
this.status = this.specRange[e].status
this.typeId = this.specRange[e].typeId
this.specVal = this.specRange[e].leasePrice
+ this.leftNum = this.specRange[e].leftNum
this.devicePrice = '¥' + (Math.round((e * this.deviceNum) * 100)/100)
},
numChange (e) {
@@ -93,33 +96,40 @@ import { basePath } from '../../public';
title: '请选择规格!'
})
} else {
- console.log(this.typeId, this.deviceNum, this.companyId);
+ console.log(this.typeId, this.deviceNum, this.companyId, this.leftNum);
// 向购物车内添加商品
- that.$api.fetchMaterial.addItemToCart({
- typeId: this.typeId,
- bookNum: this.deviceNum,
- companyId: this.companyId
- }).then(res => {
- console.log(res);
- if (res.data.code == 200) {
- uni.showToast({
- icon: 'none',
- title: '加入预约车成功!',
- success: () => {
- uni.navigateTo({
- url: '/pages/orderCart/orderCart'
- })
- }
- })
- } else {
- uni.showToast({
- icon: 'none',
- title: '添加预约车失败,请稍后再试!'
- })
- }
- }).catch(err => {
- console.log(err);
- })
+ if (this.deviceNum > this.leftNum) {
+ uni.showToast({
+ icon: 'none',
+ title: '当前领料数量大于库存数量!'
+ })
+ } else {
+ that.$api.fetchMaterial.addItemToCart({
+ typeId: this.typeId,
+ bookNum: this.deviceNum,
+ companyId: this.companyId
+ }).then(res => {
+ console.log(res);
+ if (res.data.code == 200) {
+ uni.showToast({
+ icon: 'none',
+ title: '加入预约车成功!',
+ success: () => {
+ uni.navigateTo({
+ url: '/pages/orderCart/orderCart'
+ })
+ }
+ })
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: '添加预约车失败,请稍后再试!'
+ })
+ }
+ }).catch(err => {
+ console.log(err);
+ })
+ }
/* let localGoodList = uni.getStorageSync('goodList')
localGoodList.push({
pic: this.bgList[0],
@@ -167,7 +177,8 @@ import { basePath } from '../../public';
value: index,
status: item['status'],
typeId: item['typeId'],
- leasePrice: item['leasePrice']
+ leasePrice: item['leasePrice'],
+ leftNum: item['num']
}
})
} else {
@@ -199,14 +210,14 @@ import { basePath } from '../../public';
width: 90%;
font-weight: normal;
font-size: 14px;
- margin: 1vh auto;
+ margin: 2vh auto;
display: flex;
justify-content: space-between;
}
.drop-menu, .select-num{
width: 90%;
margin: 0 auto;
- margin-bottom: 6vh;
+ margin-bottom: 2vh;
}
.operation{
width: 100%;