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

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='goods-price' v-for="(item,index) in wholesaleList" :key="index">
<div class='goods-price' v-for="(item, index) in wholesaleList" :key="index">
<span>
<span class="goods-price-bigshow">{{
@ -48,7 +48,7 @@
.{{ $options.filters.goodsFormatPrice(item.price)[1] }}
</span>
<span class='wholesale-item'>
{{item.num}}{{goodsDetail.goodsUnit}}
{{ item.num }}{{ goodsDetail.goodsUnit }}
</span>
</div>
</div>
@ -102,7 +102,8 @@
<view class="goods-skus-number flex flex-a-c flex-j-sb">
<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>
</scroll-view>
<!-- 按钮 -->
@ -116,10 +117,10 @@
</div>
</template>
<script>
import * as API_trade from "@/api/trade.js";
import setup from "./popup";
import * as API_trade from "@/api/trade.js";
import setup from "./popup";
export default {
export default {
data() {
return {
setup,
@ -138,7 +139,7 @@
};
},
props: {
wholesaleList:{
wholesaleList: {
type: null,
default: false,
},
@ -172,19 +173,23 @@
},
},
computed: {
wholesalePrice(key){
return this.wholesaleList.length ? this.wholesaleList.map(item=>{ return item.price }) :[]
wholesalePrice(key) {
return this.wholesaleList.length ? this.wholesaleList.map(item => { return item.price }) : []
},
wholesaleNum(key){
return this.wholesaleList.length ? this.wholesaleList.map(item=>{ return item.num }) :[]
wholesaleNum(key) {
return this.wholesaleList.length ? this.wholesaleList.map(item => { return item.num }) : []
}
},
watch: {
num(val){
if(val){
if(val > this.goodsDetail.quantity){
this.val = this.goodsDetail.quantity
num(val) {
if (val) {
//
if (val > this.goodsDetail.quantity) {
this.$nextTick(function () {
this.num = this.goodsDetail.quantity
})
}
}
},
buyType: {
@ -207,7 +212,12 @@
closeMask() {
this.$emit("closeBuy", false);
},
numChange() {
if (this.num > this.goodsDetail.quantity) {
alert(1)
this.num = this.goodsDetail.quantity
}
},
/**点击规格 */
handleClickSpec(val, index, specValue) {
this.currentSelceted[index] = specValue.value;
@ -255,8 +265,7 @@
API_trade.addToCart(data).then((res) => {
if (res.data.success) {
uni.navigateTo({
url: `/pages/order/fillorder?way=${
data.cartType
url: `/pages/order/fillorder?way=${data.cartType
}&addr=${""}&parentOrder=${encodeURIComponent(
JSON.stringify(this.parentOrder)
)}`,
@ -306,8 +315,7 @@
API_trade.addToCart(data).then((res) => {
if (res.data.code == 200) {
uni.navigateTo({
url: `/pages/order/fillorder?way=${data.cartType}&addr=${
this.addr.id || ""
url: `/pages/order/fillorder?way=${data.cartType}&addr=${this.addr.id || ""
}&parentOrder=${encodeURIComponent(JSON.stringify(this.parentOrder))}`,
});
}
@ -386,65 +394,68 @@
mounted() {
this.formatSku(this.goodsSpec);
},
};
};
</script>
<style lang="scss" scoped>
@import "./popup.scss";
.price-row{
@import "./popup.scss";
.price-row {
text-align: center;
}
.buy {
}
.buy {
background-image: linear-gradient(135deg, #ffba0d, #ffc30d 69%, #ffcf0d);
box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2);
}
}
.card {
.card {
background-image: linear-gradient(135deg, #f2140c, #f2270c 70%, #f24d0c);
box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2);
}
}
/deep/.u-icon-plus,
.u-icon-minus,
.u-icon-disabled {
/deep/.u-icon-plus,
.u-icon-minus,
.u-icon-disabled {
height: 30rpx !important;
background: #fff !important;
}
}
.goods-skus-number {
.goods-skus-number {
justify-content: space-between;
display: flex;
>.view-class-title{
>.view-class-title {
flex: 8;
}
>.view-class-input{
flex:1
}
}
/deep/ .uni-scroll-view {
>.view-class-input {
flex: 1
}
}
/deep/ .uni-scroll-view {
overflow: hidden !important;
}
}
.active {
.active {
background: $price-light-color !important;
border: 2rpx solid $price-color;
font-weight: bold;
color: $price-color !important;
box-sizing: border-box;
}
}
.goods-skus-box {
.goods-skus-box {
overflow-y: auto;
height: 610rpx;
// #ifdef MP-WEIXIN
height: 570rpx;
// #endif
margin-bottom: 10rpx;
}
}
.goods-skus-view {
.goods-skus-view {
overflow: hidden;
.skus-view-list {
@ -465,42 +476,44 @@
border-radius: 30rpx;
}
}
}
.wholesale-item{
}
.wholesale-item {
color: #999 !important;
font-size: 24rpx;
margin:0 20rpx;
margin: 0 20rpx;
display: flex;
justify-content: center;
}
}
.goods-header {
.goods-header {
height: 200rpx;
display: flex;
align-items: center;
margin-bottom: 36rpx;
}
}
.goods-box {
.goods-box {
padding: 50rpx 36rpx 0 36rpx;
}
}
.goods-skus {
.goods-skus {
padding: 0 20rpx;
}
}
.goods-price {
.goods-price {
color: $price-color;
line-height: 80rpx;
margin-right: 20rpx;
>* {
color: $price-color;
line-height: 80rpx;
}
}
}
.promotion-box {
.promotion-box {
line-height: 1;
display: flex;
align-items: center;
@ -511,17 +524,17 @@
/deep/ span {
font-size: 30rpx;
}
}
}
.promotion {
.promotion {
font-size: 30rpx;
}
}
.goods-price-promotionShow {
.goods-price-promotionShow {
font-size: 48rpx;
}
}
.goods-check-skus {
.goods-check-skus {
font-size: 24rpx;
color: #999;
@ -532,5 +545,5 @@
>span {
color: #333;
}
}
}
</style>