|
@ -38,15 +38,15 @@ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<!-- 优惠券 --> |
|
|
<!-- 优惠券 --> |
|
|
<view @click="goOrderCoupon" class="tickets-container flex-between top-line"> |
|
|
<view @click="goOrderCoupon" class="tickets-container flex-between top-line" v-if="!isShoppingCart"> |
|
|
<view class="order-title">优惠券</view> |
|
|
<view class="order-title">优惠券</view> |
|
|
<view class="coupon-btn" v-if="coupon==''"> |
|
|
<view class="coupon-btn" v-if="coupon==''"> |
|
|
<view class="select">选择优惠券</view> |
|
|
<view class="select">选择优惠券</view> |
|
|
<uni-icons style="height: 42rpx;" color="#999999" type="right" size="18"></uni-icons> |
|
|
<uni-icons style="height: 42rpx;" color="#999999" type="right" size="18"></uni-icons> |
|
|
</view> |
|
|
</view> |
|
|
<div class="coupon-price" v-else> |
|
|
<div class="coupon-price" v-else> |
|
|
<span v-if="coupon.percent == 0">-¥{{coupon.discounts/100}}</span> |
|
|
<span v-if="coupon.activity.fold == 0">-¥{{coupon.activity.money/100}}</span> |
|
|
<span v-else>-{{coupon.percent}}%</span> |
|
|
<span v-else>-{{coupon.activity.fold*10}}%</span> |
|
|
<span style="margin:0 31rpx 0 8rpx;color: #6C7A94;">></span> |
|
|
<span style="margin:0 31rpx 0 8rpx;color: #6C7A94;">></span> |
|
|
</div> |
|
|
</div> |
|
|
</view> |
|
|
</view> |
|
@ -86,6 +86,7 @@ |
|
|
components: {}, |
|
|
components: {}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
|
|
|
isShoppingCart: false, |
|
|
// 下单产品 |
|
|
// 下单产品 |
|
|
orderList: [], |
|
|
orderList: [], |
|
|
phone: '', |
|
|
phone: '', |
|
@ -95,23 +96,28 @@ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onLoad(options) { |
|
|
onLoad(options) { |
|
|
|
|
|
if (options.isShoppingCart) { |
|
|
|
|
|
this.isShoppingCart = options.isShoppingCart |
|
|
|
|
|
} |
|
|
// this.getList(); |
|
|
// this.getList(); |
|
|
this.$store.commit("choseCoupon", ""); |
|
|
this.$store.commit("choseCoupon", ""); |
|
|
this.initPageData() |
|
|
this.initPageData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
onShow() { |
|
|
onShow() { |
|
|
this.coupon = this.$store.state.user.coupon |
|
|
if (!this.isShoppingCart) { |
|
|
|
|
|
this.coupon = this.$store.state.user.coupon |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
methods: { |
|
|
methods: { |
|
|
goOrderCoupon () { |
|
|
goOrderCoupon () { |
|
|
let allPrice = 0 |
|
|
let allPrice = 0 |
|
|
let skuIds= [] |
|
|
let skuIds= [] |
|
|
this.pInfo.specifications.forEach(v=>{ |
|
|
this.orderList.forEach(v=>{ |
|
|
allPrice+= v.price*v.buyNum |
|
|
allPrice+= v.sInfo.price*v.sInfo.buyNum |
|
|
if (v.buyNum>0) { |
|
|
if (v.sInfo.buyNum>0) { |
|
|
skuIds.push(v.id) |
|
|
skuIds.push(v.sInfo.id) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
uni.navigateTo({ |
|
|
uni.navigateTo({ |
|
@ -121,17 +127,26 @@ |
|
|
|
|
|
|
|
|
// 获取最大优惠券 |
|
|
// 获取最大优惠券 |
|
|
async getMaxCouponData () { |
|
|
async getMaxCouponData () { |
|
|
|
|
|
// 购物车不需要 |
|
|
|
|
|
if (this.isShoppingCart) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
let allPrice = 0 |
|
|
let allPrice = 0 |
|
|
this.pInfo.specifications.forEach(v=>{ |
|
|
let skuIds= [] |
|
|
allPrice+= v.price*v.buyNum |
|
|
this.orderList.forEach(v=>{ |
|
|
|
|
|
allPrice+= v.sInfo.price*v.sInfo.buyNum |
|
|
|
|
|
if (v.sInfo.buyNum>0) { |
|
|
|
|
|
skuIds.push(v.sInfo.id) |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
let param = {money:allPrice,sku_ids:this.sInfo.id} |
|
|
let param = {sku_ids: skuIds.join(','), money: allPrice} |
|
|
let res = await this.getMaxCoupon(param) |
|
|
let res = await this.getMaxCoupon(param) |
|
|
if (res.id) { |
|
|
if (res.id) { |
|
|
this.coupon = res |
|
|
this.coupon = res |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initPageData () { |
|
|
initPageData () { |
|
|
let data = uni.getStorageSync('foodOrder'); |
|
|
let data = uni.getStorageSync('foodOrder'); |
|
|
try{ |
|
|
try{ |
|
@ -142,7 +157,7 @@ |
|
|
} catch(e){ |
|
|
} catch(e){ |
|
|
console.log(e) |
|
|
console.log(e) |
|
|
} |
|
|
} |
|
|
// this.getMaxCouponData() |
|
|
this.getMaxCouponData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
clearTel () {this.phone = ''}, |
|
|
clearTel () {this.phone = ''}, |
|
@ -173,15 +188,15 @@ |
|
|
}) |
|
|
}) |
|
|
this.allprice = allPrice |
|
|
this.allprice = allPrice |
|
|
if (this.coupon) { |
|
|
if (this.coupon) { |
|
|
if (this.coupon.percent == 0) { |
|
|
if (this.coupon.activity.fold == 0) { |
|
|
if (this.coupon.discounts>allPrice) { |
|
|
if (this.coupon.activity.money>allPrice) { |
|
|
price =0 |
|
|
price =0 |
|
|
}else{ |
|
|
}else{ |
|
|
price = allPrice - (this.coupon.discounts) |
|
|
price = allPrice - (this.coupon.activity.money) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else{ |
|
|
} else{ |
|
|
price = allPrice - allPrice * (this.coupon.percent/100) |
|
|
price = allPrice - allPrice * (this.coupon.activity.fold*10/100) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
price = allPrice |
|
|
price = allPrice |
|
@ -212,24 +227,21 @@ |
|
|
let canSubmit = true |
|
|
let canSubmit = true |
|
|
this.orderList.filter(v=>v.sInfo.buyNum>0).forEach(item=>{ |
|
|
this.orderList.filter(v=>v.sInfo.buyNum>0).forEach(item=>{ |
|
|
let sku = item.sInfo |
|
|
let sku = item.sInfo |
|
|
let use_date = item.allSeldDate[item.seldDateIndex].date |
|
|
|
|
|
let start_time =(item.timesArr[item.seldTimeIndex]||{}).start_time |
|
|
|
|
|
let end_time = (item.timesArr[item.seldTimeIndex]||{}).end_time |
|
|
|
|
|
let param = { |
|
|
let param = { |
|
|
specifications_id: sku.id, |
|
|
type: item.pInfo.type, |
|
|
num: sku.buyNum, |
|
|
product_id: item.pInfo.id, |
|
|
date: use_date, |
|
|
sku_id: sku.id, |
|
|
start_time: start_time||'', |
|
|
product_num: sku.buyNum, |
|
|
end_time: end_time||'', |
|
|
remark: sku.remark, |
|
|
reserve_mobile: this.phone, |
|
|
phone: this.phone, |
|
|
} |
|
|
} |
|
|
goods.push(param) |
|
|
goods.push(param) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = { |
|
|
let data = { |
|
|
goods: goods, |
|
|
product_list: goods, |
|
|
coupon: this.coupon ? this.coupon.id : "", |
|
|
coupon_id: this.coupon ? this.coupon.id : "", |
|
|
} |
|
|
} |
|
|
console.log('data数据',data); |
|
|
console.log('data数据',data); |
|
|
this.Post({ |
|
|
this.Post({ |
|
@ -237,7 +249,7 @@ |
|
|
data: JSON.stringify(data) |
|
|
data: JSON.stringify(data) |
|
|
}, '/api/order/create').then(res => { |
|
|
}, '/api/order/create').then(res => { |
|
|
if (res.code == 1) { |
|
|
if (res.code == 1) { |
|
|
uni.removeStorageSync('ticketOrder') |
|
|
|
|
|
console.log(res.data.order_id); |
|
|
console.log(res.data.order_id); |
|
|
let order_id = res.data.order_id |
|
|
let order_id = res.data.order_id |
|
|
this.$store.commit("choseCoupon", ""); |
|
|
this.$store.commit("choseCoupon", ""); |
|
|