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

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

@ -39,7 +39,7 @@
<!-- 批发价格 --> <!-- 批发价格 -->
<div class='price-row flex' v-if="goodsDetail.salesModel === 'WHOLESALE'"> <div class='price-row flex' v-if="goodsDetail.salesModel === 'WHOLESALE'">
<div class='goods-price' v-for="(item,index) in wholesaleList" :key="index"> <div class='goods-price' v-for="(item, index) in wholesaleList" :key="index">
<span> <span>
<span class="goods-price-bigshow">{{ <span class="goods-price-bigshow">{{
@ -48,7 +48,7 @@
.{{ $options.filters.goodsFormatPrice(item.price)[1] }} .{{ $options.filters.goodsFormatPrice(item.price)[1] }}
</span> </span>
<span class='wholesale-item'> <span class='wholesale-item'>
{{item.num}}{{goodsDetail.goodsUnit}} {{ item.num }}{{ goodsDetail.goodsUnit }}
</span> </span>
</div> </div>
</div> </div>
@ -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>
<!-- 按钮 --> <!-- 按钮 -->
@ -116,10 +117,10 @@
</div> </div>
</template> </template>
<script> <script>
import * as API_trade from "@/api/trade.js"; import * as API_trade from "@/api/trade.js";
import setup from "./popup"; import setup from "./popup";
export default { export default {
data() { data() {
return { return {
setup, setup,
@ -138,7 +139,7 @@
}; };
}, },
props: { props: {
wholesaleList:{ wholesaleList: {
type: null, type: null,
default: false, default: false,
}, },
@ -172,19 +173,23 @@
}, },
}, },
computed: { computed: {
wholesalePrice(key){ wholesalePrice(key) {
return this.wholesaleList.length ? this.wholesaleList.map(item=>{ return item.price }) :[] return this.wholesaleList.length ? this.wholesaleList.map(item => { return item.price }) : []
}, },
wholesaleNum(key){ wholesaleNum(key) {
return this.wholesaleList.length ? this.wholesaleList.map(item=>{ return item.num }) :[] return this.wholesaleList.length ? this.wholesaleList.map(item => { return item.num }) : []
} }
}, },
watch: { watch: {
num(val){ num(val) {
if(val){ if (val) {
if(val > this.goodsDetail.quantity){ //
this.val = this.goodsDetail.quantity if (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))}`,
}); });
} }
@ -386,65 +394,68 @@
mounted() { mounted() {
this.formatSku(this.goodsSpec); this.formatSku(this.goodsSpec);
}, },
}; };
</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);
} }
.card { .card {
background-image: linear-gradient(135deg, #f2140c, #f2270c 70%, #f24d0c); background-image: linear-gradient(135deg, #f2140c, #f2270c 70%, #f24d0c);
box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2); box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2);
} }
/deep/.u-icon-plus, /deep/.u-icon-plus,
.u-icon-minus, .u-icon-minus,
.u-icon-disabled { .u-icon-disabled {
height: 30rpx !important; height: 30rpx !important;
background: #fff !important; background: #fff !important;
} }
.goods-skus-number { .goods-skus-number {
justify-content: space-between; justify-content: space-between;
display: flex; display: flex;
>.view-class-title{ >.view-class-title {
flex: 8; flex: 8;
} }
>.view-class-input{
flex:1
}
}
/deep/ .uni-scroll-view { >.view-class-input {
flex: 1
}
}
/deep/ .uni-scroll-view {
overflow: hidden !important; overflow: hidden !important;
} }
.active { .active {
background: $price-light-color !important; background: $price-light-color !important;
border: 2rpx solid $price-color; border: 2rpx solid $price-color;
font-weight: bold; font-weight: bold;
color: $price-color !important; color: $price-color !important;
box-sizing: border-box; box-sizing: border-box;
} }
.goods-skus-box { .goods-skus-box {
overflow-y: auto; overflow-y: auto;
height: 610rpx; height: 610rpx;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
height: 570rpx; height: 570rpx;
// #endif // #endif
margin-bottom: 10rpx; margin-bottom: 10rpx;
} }
.goods-skus-view { .goods-skus-view {
overflow: hidden; overflow: hidden;
.skus-view-list { .skus-view-list {
@ -465,42 +476,44 @@
border-radius: 30rpx; border-radius: 30rpx;
} }
} }
} }
.wholesale-item{
.wholesale-item {
color: #999 !important; color: #999 !important;
font-size: 24rpx; font-size: 24rpx;
margin:0 20rpx; margin: 0 20rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.goods-header { .goods-header {
height: 200rpx; height: 200rpx;
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 36rpx; margin-bottom: 36rpx;
} }
.goods-box { .goods-box {
padding: 50rpx 36rpx 0 36rpx; padding: 50rpx 36rpx 0 36rpx;
} }
.goods-skus { .goods-skus {
padding: 0 20rpx; padding: 0 20rpx;
} }
.goods-price { .goods-price {
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;
} }
} }
.promotion-box { .promotion-box {
line-height: 1; line-height: 1;
display: flex; display: flex;
align-items: center; align-items: center;
@ -511,17 +524,17 @@
/deep/ span { /deep/ span {
font-size: 30rpx; font-size: 30rpx;
} }
} }
.promotion { .promotion {
font-size: 30rpx; font-size: 30rpx;
} }
.goods-price-promotionShow { .goods-price-promotionShow {
font-size: 48rpx; font-size: 48rpx;
} }
.goods-check-skus { .goods-check-skus {
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #999;
@ -532,5 +545,5 @@
>span { >span {
color: #333; color: #333;
} }
} }
</style> </style>