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,24 +513,25 @@
}, },
// //
confirm() { confirm() {
this.specClass = 'none'; debugger;
// let num = parseInt(this.good._num);
if(num>this.good.num){
// this.selectSpec&&this.specCallback&&this.specCallback(); uni.showToast({
// this.specCallback = false; icon:'error',
// setTimeout(() => { title: "库存不足!"
// this.specClass = 'none'; });
// }, 200); }else{
if (this.action == 'buy') { this.specClass = 'none';
if (this.action == 'buy') {
this.toConfirmation()
} else { this.toConfirmation()
this.$u.api.addtoCart(this.good.id, this.good._num).then(res => { } else {
uni.showToast({ this.$u.api.addtoCart(this.good.id, this.good._num).then(res => {
title: "已加入购物车" uni.showToast({
}); title: "已加入购物车"
}) });
})
}
} }
}, },
discard() { discard() {