This commit is contained in:
shijing 2022-02-10 09:20:43 +08:00
parent 119d92ea09
commit dce7d15ab1
1 changed files with 24 additions and 34 deletions

View File

@ -46,7 +46,8 @@
</view> </view>
<view class="btn"> <view class="btn">
<view class="joinCart" @tap="joinCart">加入购物车</view> <view class="joinCart" @tap="joinCart">加入购物车</view>
<view class="buy" @tap="buy">立即购买</view> <view v-if="good.num>0" class="buy" @tap="buy">立即购买</view>
<view v-else class="buy">库存不足</view>
</view> </view>
</view> </view>
<!-- share弹窗 --> <!-- share弹窗 -->
@ -102,16 +103,12 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 规格-模态层弹窗 --> <!-- 立即购买-模态层弹窗 -->
<view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="hideSpec"> <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="hideSpec">
<!-- 遮罩层 --> <!-- 遮罩层 -->
<view class="mask"></view> <view class="mask"></view>
<view class="layer" @tap.stop="discard"> <view class="layer" @tap.stop="discard">
<view class="content"> <view class="content">
<!-- <view class="title">选择规格</view>
<view class="sp">
<view v-for="(item,index) in goodsData.spec" :class="[index==selectSpec?'on':'']" @tap="setSelectSpec(index)" :key="index">{{item}}</view>
</view> -->
<view class="length"> <view class="length">
<view class="text">数量</view> <view class="text">数量</view>
<view class="number"> <view class="number">
@ -336,12 +333,11 @@
methods: { methods: {
getGood(id) { getGood(id) {
this.$u.api.getGood(id).then(res => { this.$u.api.getGood(id).then(res => {
let good = res.data let good = res.data;
good._num = 1;//
if (good.content) { if (good.content) {
good.content = richTextUtil.formatRichText(good.content); good.content = richTextUtil.formatRichText(good.content);
good._num = 1;//
} }
// console.log(good)
this.good = good this.good = good
}) })
}, },
@ -399,13 +395,6 @@
buy() { buy() {
this.action = 'buy'; this.action = 'buy';
this.specClass = 'show' this.specClass = 'show'
// this.showSpec()
// if(this.selectSpec==null){
// return this.showSpec(()=>{
// this.toConfirmation();
// });
// }
// this.toConfirmation();
}, },
// //
toRatings() { toRatings() {
@ -524,14 +513,15 @@
}, },
// //
confirm() { confirm() {
debugger;
let num = parseInt(this.good._num);
if(num>this.good.num){
uni.showToast({
icon:'error',
title: "库存不足!"
});
}else{
this.specClass = 'none'; this.specClass = 'none';
//
// this.selectSpec&&this.specCallback&&this.specCallback();
// this.specCallback = false;
// setTimeout(() => {
// this.specClass = 'none';
// }, 200);
if (this.action == 'buy') { if (this.action == 'buy') {
this.toConfirmation() this.toConfirmation()
@ -541,7 +531,7 @@
title: "已加入购物车" title: "已加入购物车"
}); });
}) })
}
} }
}, },
discard() { discard() {