|
@@ -1,23 +1,24 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券" ></u-navbar>
|
|
|
+ <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券"></u-navbar>
|
|
|
<view class="coupon-title">可用优惠券:{{listNum}}</view>
|
|
|
<view class="coupon-list">
|
|
|
- <u-radio-group v-model="radiovalue1" placement="column">
|
|
|
+ <u-radio-group v-model="radiovalue1" placement="column" @change="changeChechk()">
|
|
|
<view class="flex coupon-list-item" v-for="(item,index) in list" :key="index">
|
|
|
<view class="flex coupon-list-item-info">
|
|
|
<view class="money">
|
|
|
- <view class="">¥<text>{{item.discount}}</text></view>
|
|
|
+ <view class="">¥<text>{{ item.discount / 100 }}</text></view>
|
|
|
</view>
|
|
|
<view class="flex content">
|
|
|
- <view class="txt title">{{item.title}}</view>
|
|
|
+ <view class="txt title">{{ item.title }}</view>
|
|
|
<view class="txt">
|
|
|
使用期限:{{ $parseTime(item.validStart, '{y}.{m}.{d}')}}-{{$parseTime(item.validEnd, '{y}.{m}.{d}')}}
|
|
|
</view>
|
|
|
- <view class="txt">适用范围:{{item.useAreaDesc || '-'}}</view>
|
|
|
+ <view class="txt">适用范围:{{ item.useAreaDesc || '-' }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <u-radio :customStyle="{marginBottom: '8px'}" :name="index"> </u-radio>
|
|
|
+ <u-radio :customStyle="{ marginBottom: '8px' }" :name="item.id" activeColor="#E96737" size="24">
|
|
|
+ </u-radio>
|
|
|
</view>
|
|
|
</u-radio-group>
|
|
|
</view>
|
|
@@ -45,15 +46,28 @@
|
|
|
pageNum: 1,
|
|
|
total: 0,
|
|
|
list: [],
|
|
|
-
|
|
|
- listNum: '',//可用优惠券数量
|
|
|
- radiovalue1: 0, //被选中的下标
|
|
|
+ listNum: '', //可用优惠券数量
|
|
|
+ radiovalue1: '', //选中项的下标
|
|
|
+ couponId: '', //选中项的id
|
|
|
+ boxId: '',
|
|
|
};
|
|
|
},
|
|
|
onShow() {
|
|
|
- this.getList()
|
|
|
+ this.pageList()
|
|
|
+ },
|
|
|
+ onLoad(opthios) {
|
|
|
+ this.boxId = opthios.boxId
|
|
|
+ if (opthios.couponId) {
|
|
|
+ this.couponId = opthios.couponId
|
|
|
+ this.radiovalue1 = opthios.couponId
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
+ pageList() {
|
|
|
+ this.list = []
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+
|
|
|
getList() {
|
|
|
uni.showLoading({
|
|
|
title: '加载中'
|
|
@@ -61,30 +75,51 @@
|
|
|
$http.post('/api/v1/mp/user/ticket/order/coupon/list', {}).then(
|
|
|
res => {
|
|
|
uni.hideLoading();
|
|
|
- console.log(res)
|
|
|
if (res.code == 0) {
|
|
|
this.listNum = res.data.length
|
|
|
res.data.forEach(item => {
|
|
|
let useAreaDesc = JSON.parse(item.useArea)
|
|
|
item.useAreaDesc = useAreaDesc.desc
|
|
|
})
|
|
|
- this.list = this.list.concat(res.data)
|
|
|
- console.log(this.list)
|
|
|
+ this.list = res.data
|
|
|
}
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
uni.hideLoading();
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ // 点击切换事件
|
|
|
+ changeChechk(e) {
|
|
|
+ this.couponId = e
|
|
|
+ },
|
|
|
+
|
|
|
// 点击确认事件
|
|
|
exchange() {
|
|
|
- for (var i = 0; i < this.list.length; i++) {
|
|
|
- if(i == this.radiovalue1){
|
|
|
- console.log(this.list[i])
|
|
|
- uni.navigateBack({data:this.list[i]})
|
|
|
- }
|
|
|
+ let data = {
|
|
|
+ userCouponIds: [this.couponId],
|
|
|
+ autoCoupon: 0,
|
|
|
+ boxId: this.boxId,
|
|
|
+ orderNum: 1
|
|
|
}
|
|
|
-
|
|
|
+ $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ let pages = getCurrentPages()
|
|
|
+ let page = pages[pages.length - 2]
|
|
|
+ let payInfo = {
|
|
|
+ ...res.data,
|
|
|
+ picUrl: env.filePublic + res.data.picUrl,
|
|
|
+ couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
|
|
|
+ .data.couponList[0].title,
|
|
|
+ couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
|
|
|
+ .couponList[0].id
|
|
|
+ }
|
|
|
+ page.$vm.payInfo = payInfo
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|