Commit eeca550a authored by 潘永坪's avatar 潘永坪

券接口修改

parent 3055ff3e
......@@ -16,19 +16,19 @@
</view>
</view>
<!-- -----------------------------有可用优惠券,并且未选中----------------------------------------------------- -->
<!-- <view class="topCoupon" v-if="couponData.usableCouponList&&couponData.usableCouponList.length>0&&chooseCouponObj==''" @click="showCoupon()">
<view class="topCoupon" v-if="couponData.masterSlaveCouponList&&couponData.masterSlaveCouponList.length>0&&chooseCouponObj==''" @click="showCoupon()">
<view class="couponLeft">
<text></text>
<text>{{couponData.usableCouponList[0].couponName}}</text>
<text>{{couponData.masterSlaveCouponList[0].couponName}}</text>
</view>
<view class="couponRight">
<text>未选优惠券</text>
<text class="iconfont icon-you" style="font-size:32rpx;"></text>
</view>
</view> -->
</view>
<!-- -----------------------------有可用优惠券----------------------------------------------------- -->
<!-- <view class="topCoupon" v-if="chooseCouponObj!=''" @click="showCoupon()">
<view class="topCoupon" v-if="chooseCouponObj!=''" @click="showCoupon()">
<view class="couponLeft">
<text></text>
<text>{{chooseCouponObj.couponName}}</text>
......@@ -36,12 +36,12 @@
<view class="couponRight">
<text>-</text>
<text>{{chooseCouponObj.savedMoney.toFixed(2)}}</text>
<text>{{parseFloat(savedMoney.toFixed(2))}}</text>
<text class="iconfont icon-you" style="font-size:32rpx;"></text>
</view>
</view> -->
</view>
<!-- -----------------------------------------------可用优惠券条件--------------------------------------- -->
<!-- <view class="topCoupon" v-if="ableConpon!=''" @click="showCoupon()">
<view class="topCoupon" v-if="ableConpon!=''" @click="showCoupon()">
<view class="couponLeft">
<text></text>
<text>{{ableConpon.couponName}}</text>
......@@ -51,20 +51,6 @@
<text>{{ableConpon.couponRule}}</text>
<text class="iconfont icon-you" style="font-size:32rpx;"></text>
</view>
</view> -->
<view class="topCoupon" v-if="chooseCouponObj">
<view class="couponLeft">
<text></text>
<text>{{chooseCouponObj.couponName}}</text>
</view>
<view class="couponRight">
<text style="font-weight: bold;">
<text style="font-size:26rpx;font-weight:400;"></text>
{{parseFloat(savedMoney.toFixed(2))}}
</text>
</view>
</view>
</view>
......@@ -90,7 +76,7 @@
</view>
</view>
<!-------------------------------------------券弹窗------------------------------>
<!-- <orderCoupon :couponData="couponData" ref="orderCoupon" @couponChoose="couponChoose" :chooseCouponObj="chooseCouponObj"></orderCoupon> -->
<orderCoupon :couponData="couponData" ref="orderCoupon" @couponChoose="couponChoose" :chooseCouponObj="chooseCouponObj"></orderCoupon>
</view>
</template>
......@@ -285,6 +271,11 @@
},
couponChoose(data) { //---------------------------------------------------------------子组件券选择之后触发的事件
this.chooseCouponObj = data
if(this.chooseCouponObj.slaveList.length>0){
this.savedMoney=this.chooseCouponObj.slaveList[0].savedMoney
}else{
this.savedMoney=this.chooseCouponObj.savedMoney
}
},
showCoupon() { //---------------------------------------------------------------------展示券列表
this.$refs.orderCoupon.showCoupon()
......@@ -340,34 +331,34 @@
openid:this.openid
}
this.$request("wechatUser/myPage/usableCouponList",data).then((res) => {
if (res.code == "00") {
this.chooseCouponObj=res.data.masterSlaveCouponList[0]
if(this.chooseCouponObj.slaveList.length>0){
this.savedMoney=this.chooseCouponObj.slaveList[0].savedMoney
}else{
this.savedMoney=this.chooseCouponObj.savedMoney
}
// this.couponData = res.data
// if (res.data.usableCouponList.length > 0) {
// res.data.usableCouponList.forEach((item) => { //获取最优券
// savedMoneyList.push(item.savedMoney)
// })
// let maxMoney = Math.max.apply(null, savedMoneyList)
// let index = res.data.usableCouponList.findIndex((item) => {
// return maxMoney == item.savedMoney
// })
// if(index>-1){
// this.chooseCouponObj = res.data.usableCouponList[index]
// }
// } else {
// if (res.data.unusableCouponList.length > 0) {
// res.data.unusableCouponList.forEach((item, i) => { //没有可用优惠券,有达到条件可以用的优惠券,先显示条件,达到条件时显示可用优惠券
// if (item.isProduct == 1) {
// this.ableConpon = item
// }
// })
// }
// }
if (res.data.code == "00") {
this.couponData = res.data.data
let masterSlaveCouponList=res.data.data.masterSlaveCouponList
if (masterSlaveCouponList.length>0) {
masterSlaveCouponList.forEach((item) => { //获取最优券
savedMoneyList.push(item.savedMoney)
})
let maxMoney = Math.max.apply(null, savedMoneyList)
let index = masterSlaveCouponList.findIndex((item) => {
return maxMoney == item.savedMoney
})
if(index>-1){
this.chooseCouponObj = masterSlaveCouponList[index]
}
if(this.chooseCouponObj.slaveList.length>0){
this.savedMoney=this.chooseCouponObj.slaveList[0].savedMoney
}else{
this.savedMoney=this.chooseCouponObj.savedMoney
}
} else {
if (res.data.data.unusableCouponList.length > 0) {
res.data.data.unusableCouponList.forEach((item, i) => { //没有可用优惠券,有达到条件可以用的优惠券,先显示条件,达到条件时显示可用优惠券
if (item.isProduct == 1) {
this.ableConpon = item
}
})
}
}
}
})
},
......@@ -381,15 +372,27 @@
}
let couponList = []
if (this.chooseCouponObj != '') {
couponList = [ //券列表
{
couponId: this.chooseCouponObj.couponId, //券id
couponPrice: this.chooseCouponObj.savedMoney, //券价格
isMerchant: this.chooseCouponObj.createSource, //是否是商户的券
myCouponId: this.chooseCouponObj.id, //领取人编号
couponType:this.chooseCouponObj.couponType//券类型
}
]
if(this.chooseCouponObj.slaveList.length>0){//有从卷取值从卷,没有从卷取值主劵
couponList=[//券列表
{
couponId:this.chooseCouponObj.slaveList[0].couponId,//券id
couponPrice:this.chooseCouponObj.slaveList[0].savedMoney,//券价格
isMerchant:this.chooseCouponObj.slaveList[0].createSource,//是否是商户的券
myCouponId:this.chooseCouponObj.slaveList[0].id,//领取人编号
couponType:this.chooseCouponObj.slaveList[0].couponType//券类型
}
]
}else{
couponList=[
{
couponId:this.chooseCouponObj.couponId,//券id
couponPrice:this.chooseCouponObj.savedMoney,//券价格
isMerchant:this.chooseCouponObj.createSource,//是否是商户的券
myCouponId:this.chooseCouponObj.id,//领取人编号
couponType:this.chooseCouponObj.couponType//券类型
}
]
}
}
let data = {
companyId: this.companyId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment