|
@@ -68,7 +68,7 @@
|
|
|
<button class="next-button" @click="nextStep" v-if="stepIndex!=2" type="warn">下一步</button>
|
|
|
<view v-else class="pay">
|
|
|
<text>合计:</text>
|
|
|
- <text class="amount">¥10:00</text>
|
|
|
+ <text class="amount">¥{{finalAmount}}</text>
|
|
|
<view class="">
|
|
|
<button @click="toPay" type="warn">去付款</button>
|
|
|
</view>
|
|
@@ -107,6 +107,52 @@
|
|
|
}
|
|
|
],
|
|
|
isRead: '', // 是否同意协议
|
|
|
+ couponList: [
|
|
|
+ {
|
|
|
+ id: 23432445,
|
|
|
+ name: "满100减50",
|
|
|
+ price: 100,
|
|
|
+ yxTime: "2020-05-16",
|
|
|
+ remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3544355,
|
|
|
+ name: "满100减50",
|
|
|
+ price: 100,
|
|
|
+ yxTime: "2020-05-16",
|
|
|
+ remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 234234234,
|
|
|
+ name: "满100减50",
|
|
|
+ price: 100,
|
|
|
+ yxTime: "2020-05-16",
|
|
|
+ remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 66264646,
|
|
|
+ name: "满100减50",
|
|
|
+ price: 100,
|
|
|
+ yxTime: "2020-05-16",
|
|
|
+ remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 9794694698,
|
|
|
+ name: "满100减50",
|
|
|
+ price: 100,
|
|
|
+ yxTime: "2020-05-16",
|
|
|
+ remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
|
|
|
+ checked: false
|
|
|
+ }
|
|
|
+ ], // 用户可用优惠券
|
|
|
+ checkedCoupon: null, // 用户当前所选优惠券
|
|
|
+ amount: 0, // 所选服务项目总金额
|
|
|
+ couponAmount: 0, // 优惠券优惠金额
|
|
|
+ finalAmount: 0, // 用户最终所需支付金额
|
|
|
}
|
|
|
},
|
|
|
onLoad(option) {
|
|
@@ -123,9 +169,15 @@
|
|
|
console.log(this.stepIndex)
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取服务列表
|
|
|
+ getServerList () {
|
|
|
+
|
|
|
+ },
|
|
|
// 选择服务项目
|
|
|
chooseItem(index) {
|
|
|
this.serverIndex = index
|
|
|
+ this.amount = this.itemList[index].price
|
|
|
+ this.getFinalAmount()
|
|
|
},
|
|
|
// 下一步
|
|
|
nextStep() {
|
|
@@ -136,10 +188,50 @@
|
|
|
read (e) {
|
|
|
this.isRead = e.msg
|
|
|
},
|
|
|
+ // 获取用户可用优惠券
|
|
|
+ getCouponList () {
|
|
|
+
|
|
|
+ },
|
|
|
+ // 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
|
|
|
+ formatCouponData (){
|
|
|
+ let arr = []
|
|
|
+ let _this = this
|
|
|
+ this.couponList.map(item => {
|
|
|
+ let data = {}
|
|
|
+ data.id = item.couponReceivesId
|
|
|
+ if (item.couponType == 'DISCOUNT') {
|
|
|
+ console.log(_this.amount, '_this.amount')
|
|
|
+ data.subAmount = Number((_this.amount * (1 - item.subAmount)).toFixed(2))
|
|
|
+ } else {
|
|
|
+ data.subAmount = item.couponType == 'FULLSUB' ? item.subAmount : item.price
|
|
|
+ }
|
|
|
+ arr.push(data)
|
|
|
+ })
|
|
|
+ console.log(arr, 'arr')
|
|
|
+ // 比较数据中优惠金额最大的值 并返回该对象
|
|
|
+ let obj = arr.reduce((p, v) => p.subAmount < v.subAmount ? v : p)
|
|
|
+ console.log(obj)
|
|
|
+ let p = this.couponList.find(item => item.couponReceivesId == obj.id)
|
|
|
+ // 订单金额为0时,默认不使用优惠卷
|
|
|
+ if (this.amount != 0){
|
|
|
+ this.checkedCoupon = p
|
|
|
+ this.couponAmount = obj.subAmount > this.amount ? this.amount : obj.subAmount
|
|
|
+ } else {
|
|
|
+ this.checkedCoupon = null
|
|
|
+ this.couponAmount = 0
|
|
|
+ }
|
|
|
+ // 计算合计
|
|
|
+ this.getFinalAmount()
|
|
|
+ },
|
|
|
+ // 计算合计
|
|
|
+ getFinalAmount () {
|
|
|
+ let ret = this.amount - this.couponAmount
|
|
|
+ this.finalAmount = ret.toFixed(2)
|
|
|
+ },
|
|
|
// 选择优惠券
|
|
|
intoChooseCoupon () {
|
|
|
uni.navigateTo({
|
|
|
- url: '/pages/coupon/chooseCoupon/chooseCoupon'
|
|
|
+ url: `/pages/coupon/chooseCoupon/chooseCoupon?list=${encodeURIComponent(JSON.stringify(this.couponList))}`
|
|
|
})
|
|
|
},
|
|
|
// 打开服务协议
|