购买数量超过库存后修改为库存数量

master
chc 2022-11-29 11:19:37 +08:00
parent 7f71614781
commit 2b5f57dfab
1 changed files with 391 additions and 378 deletions

View File

@ -102,7 +102,8 @@
<view class="goods-skus-number flex flex-a-c flex-j-sb"> <view class="goods-skus-number flex flex-a-c flex-j-sb">
<view class="view-class-title">数量</view> <view class="view-class-title">数量</view>
<u-input class="view-class-input" input-align="right" v-model="num" type="number" /> <u-input class="view-class-input" input-align="right" v-model="num" type="number"
@change="numChange()" />
</view> </view>
</scroll-view> </scroll-view>
<!-- 按钮 --> <!-- 按钮 -->
@ -182,9 +183,13 @@
watch: { watch: {
num(val) { num(val) {
if (val) { if (val) {
//
if (val > this.goodsDetail.quantity) { if (val > this.goodsDetail.quantity) {
this.val = this.goodsDetail.quantity this.$nextTick(function () {
this.num = this.goodsDetail.quantity
})
} }
} }
}, },
buyType: { buyType: {
@ -207,7 +212,12 @@
closeMask() { closeMask() {
this.$emit("closeBuy", false); this.$emit("closeBuy", false);
}, },
numChange() {
if (this.num > this.goodsDetail.quantity) {
alert(1)
this.num = this.goodsDetail.quantity
}
},
/**点击规格 */ /**点击规格 */
handleClickSpec(val, index, specValue) { handleClickSpec(val, index, specValue) {
this.currentSelceted[index] = specValue.value; this.currentSelceted[index] = specValue.value;
@ -255,8 +265,7 @@
API_trade.addToCart(data).then((res) => { API_trade.addToCart(data).then((res) => {
if (res.data.success) { if (res.data.success) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/order/fillorder?way=${ url: `/pages/order/fillorder?way=${data.cartType
data.cartType
}&addr=${""}&parentOrder=${encodeURIComponent( }&addr=${""}&parentOrder=${encodeURIComponent(
JSON.stringify(this.parentOrder) JSON.stringify(this.parentOrder)
)}`, )}`,
@ -306,8 +315,7 @@
API_trade.addToCart(data).then((res) => { API_trade.addToCart(data).then((res) => {
if (res.data.code == 200) { if (res.data.code == 200) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/order/fillorder?way=${data.cartType}&addr=${ url: `/pages/order/fillorder?way=${data.cartType}&addr=${this.addr.id || ""
this.addr.id || ""
}&parentOrder=${encodeURIComponent(JSON.stringify(this.parentOrder))}`, }&parentOrder=${encodeURIComponent(JSON.stringify(this.parentOrder))}`,
}); });
} }
@ -390,10 +398,12 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./popup.scss"; @import "./popup.scss";
.price-row { .price-row {
text-align: center; text-align: center;
} }
.buy { .buy {
background-image: linear-gradient(135deg, #ffba0d, #ffc30d 69%, #ffcf0d); background-image: linear-gradient(135deg, #ffba0d, #ffc30d 69%, #ffcf0d);
box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2); box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2);
@ -418,6 +428,7 @@
>.view-class-title { >.view-class-title {
flex: 8; flex: 8;
} }
>.view-class-input { >.view-class-input {
flex: 1 flex: 1
} }
@ -466,6 +477,7 @@
} }
} }
} }
.wholesale-item { .wholesale-item {
color: #999 !important; color: #999 !important;
font-size: 24rpx; font-size: 24rpx;
@ -493,6 +505,7 @@
color: $price-color; color: $price-color;
line-height: 80rpx; line-height: 80rpx;
margin-right: 20rpx; margin-right: 20rpx;
>* { >* {
color: $price-color; color: $price-color;
line-height: 80rpx; line-height: 80rpx;