优惠券
This commit is contained in:
@@ -133,7 +133,7 @@
|
||||
<u-icon v-if="v.icon" name="map-fill" color="#018F89" size="23"
|
||||
style="display: inline-block"></u-icon>
|
||||
|
||||
<text> {{ v.text }}</text><template v-if="v.type == 3">
|
||||
<text> {{ v.text }}</text><template v-if="v.type == 4">
|
||||
<text style="color: #aaa; margin-left: 10rpx">
|
||||
(全部积分:{{ initData.user.jf }})</text>
|
||||
</template>
|
||||
@@ -147,12 +147,29 @@
|
||||
}}</text>
|
||||
</template>
|
||||
<template v-if="v.type == 3">
|
||||
<template v-if="!curCoupon.id">
|
||||
<template v-if="couponHistoryList.length > 0">
|
||||
<text style="color: #999" @click="showCouponPup = true">可用({{couponHistoryList.length}})张</text>
|
||||
<text @click="showCouponPup = true" style="display: inline-block; margin-left: 20rpx; background-color: #fe6035; color: #fff; border-radius: 30rpx;font-size: 26rpx; border: 4rpx #fe6035 solid; ">选择优惠券</text>
|
||||
</template>
|
||||
<template v-else>
|
||||
<text style="color: #999">暂无可用优惠券</text>
|
||||
</template>
|
||||
<!-- <text style="color: #fe6035"> -¥{{ jfNumberShow }}</text> -->
|
||||
</template>
|
||||
<template v-else>
|
||||
<text style="color: #fe6035" >- ¥ {{curCoupon.couponEntity.couponAmount}}</text>
|
||||
<text @click="showCouponPup = true" style="display: inline-block; margin-left: 20rpx; background-color: #fe6035; color: #fff; border-radius: 30rpx;font-size: 26rpx; border: 4rpx #fe6035 solid; ">重新选择</text>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template v-if="v.type == 4">
|
||||
<text style="color: #fe6035"> -¥{{ jfNumberShow }}</text>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom jf_box" v-if="v.type == 3">
|
||||
<view class="bottom jf_box" v-if="v.type == 4">
|
||||
<view class="jf_box">
|
||||
<text style="color: #258feb; font-weight: 600">可用积分({{ jfNumberMax }}分)</text>
|
||||
<view class="jf_input">
|
||||
@@ -360,12 +377,14 @@
|
||||
@click="onHandleClickBuy" @buttonClick="onHandleClickBuy" />
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</u-popup>
|
||||
<order-coupon v-if="showCouponPup" :sumMeony="totalPrice" :curCouponId="curCouponId" :list="couponHistoryList" ref="orderCoupon" @confirmCoupon="confirmCoupon" @close="closeCoupon"></order-coupon>
|
||||
<!-- <z-navigation></z-navigation> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import orderCoupon from "@/components/orderCoupon.vue";
|
||||
import courseDescription from "@/pages/component/commonComponents/list";
|
||||
import {
|
||||
setPay,
|
||||
@@ -382,6 +401,7 @@
|
||||
export default {
|
||||
components: {
|
||||
courseDescription, //课程说明
|
||||
orderCoupon, // 优惠券弹出
|
||||
},
|
||||
watch: {
|
||||
isDefaultCurrency: {
|
||||
@@ -567,6 +587,10 @@
|
||||
haveCourse: false, // 结算队列是否有课程类型的商品
|
||||
isAndorid: null, //操作系统
|
||||
beizhuShow: false, // 是否显示天医币说明?
|
||||
couponHistoryList:[], // 可用优惠券
|
||||
showCouponPup:false, // 是否显示优惠券弹窗
|
||||
curCoupon:{}, // 选中的优惠券信息
|
||||
curCouponId:undefined
|
||||
};
|
||||
},
|
||||
async onLoad(options) {
|
||||
@@ -607,6 +631,7 @@
|
||||
// this.searchList = []
|
||||
},
|
||||
async onShow() {
|
||||
this.curCouponId = undefined
|
||||
console.log("调用了onShow方法");
|
||||
var that = this;
|
||||
await uni.$on("returnData", function(data) {
|
||||
@@ -625,6 +650,7 @@
|
||||
console.log("没有接受到数据");
|
||||
}
|
||||
});
|
||||
await this.getActiveCouponList()
|
||||
// this.selectPayIndex = 0;
|
||||
console.log("this.addressData at line 416:", this.addressData);
|
||||
// #ifdef APP-PLUS
|
||||
@@ -635,6 +661,72 @@
|
||||
...mapState(["userInfo"]),
|
||||
},
|
||||
methods: {
|
||||
closeCoupon(){
|
||||
this.showCouponPup = false
|
||||
},
|
||||
confirmCoupon(data){
|
||||
console.log('选中的优惠券是',data);
|
||||
if(data){
|
||||
this.curCoupon = data
|
||||
this.curCouponId = data.couponEntity.id
|
||||
// this.getTotalPrice()
|
||||
}else{
|
||||
this.curCoupon = {}
|
||||
this.curCouponId = undefined
|
||||
}
|
||||
this.getTotalPrice()
|
||||
},
|
||||
// 查询商品可用优惠券
|
||||
async getActiveCouponList(){
|
||||
console.log('this.goodsDataList',this.goodsDataList);
|
||||
if(this.goodsDataList.length <= 0){
|
||||
uni.showToast({
|
||||
title:'商品参数错误,无法获取优惠券',
|
||||
icon:'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
var idsString = (this.goodsDataList.map( item => item.productId)).join(',')
|
||||
console.log('idsString',idsString);
|
||||
// var idsString = ''
|
||||
this.$http
|
||||
.request({
|
||||
// url: "book/buyOrder/buySave",
|
||||
url: 'common/coupon/getCouponListPayment',
|
||||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||||
data:{
|
||||
shopProductIds:idsString
|
||||
},
|
||||
header: {
|
||||
//默认 无 说明:请求头
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
|
||||
.then(async (res) => {
|
||||
|
||||
if(res.code != 0){
|
||||
uni.showToast({
|
||||
title:res.errMsg,
|
||||
icon:'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (res.code == 0) {
|
||||
console.log("可用优惠券列表", res);
|
||||
this.couponHistoryList = res.couponHistoryList
|
||||
}
|
||||
this.$forceUpdate();
|
||||
|
||||
// await that.getDetailInfo();
|
||||
}).catch(e=>{
|
||||
console.log("可用优惠券列表报错", e);
|
||||
uni.showToast({
|
||||
title:e.errMsg,
|
||||
icon:'none'
|
||||
})
|
||||
});
|
||||
},
|
||||
// 获得操作系统
|
||||
getOS() {
|
||||
let oprateOs = ''
|
||||
@@ -668,9 +760,13 @@
|
||||
// value = value.replace(/[^\d]/g, "");
|
||||
this.jfNumber = Number(value);
|
||||
this.jfNumberShow = this.jfNumber.toFixed(2);
|
||||
}
|
||||
|
||||
this.actualPayment = this.totalPrice - this.jfNumber + this.freightNum;
|
||||
}
|
||||
var couponAmount = 0
|
||||
if(this.curCouponId && this.curCoupon.couponEntity.id){
|
||||
couponAmount = this.curCoupon.couponEntity.couponAmount
|
||||
}
|
||||
// that.actualPayment = that.actualPayment - that.couponAmount; // 减去优惠券的金额
|
||||
this.actualPayment = this.totalPrice - couponAmount - this.jfNumber + this.freightNum;
|
||||
|
||||
if (this.actualPayment == 0) {
|
||||
this.isDefaultCurrency = true;
|
||||
@@ -712,6 +808,11 @@
|
||||
imgUrl: "",
|
||||
type: 2,
|
||||
},
|
||||
{
|
||||
text: "优惠券",
|
||||
imgUrl: "",
|
||||
type: 3,
|
||||
}
|
||||
];
|
||||
// this.goodsDataList
|
||||
console.log("this.goodsDataList at line 595:", this.goodsDataList);
|
||||
@@ -744,13 +845,12 @@
|
||||
console.log("res at line 374:", res);
|
||||
if (res.code == 0) {
|
||||
this.initData = res.data;
|
||||
|
||||
this.isShowAddress = res.data.is_course ? false : true;
|
||||
if (!this.isShowAddress) {
|
||||
this.priceBreakdownList.push({
|
||||
text: "积分",
|
||||
imgUrl: require("@/static/icon/jifen.png"),
|
||||
type: 3,
|
||||
type: 4,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -897,12 +997,18 @@
|
||||
} else {
|
||||
that.jfNumberShow = that.jfNumber.toFixed(2);
|
||||
that.actualPayment = that.totalPrice - that.jfNumber;
|
||||
}
|
||||
}
|
||||
that.actualPayment = that.actualPayment + that.freightNum;
|
||||
} else {
|
||||
that.actualPayment = that.totalPrice + that.freightNum;
|
||||
}
|
||||
|
||||
var couponAmount = 0
|
||||
if(that.curCouponId && that.curCoupon.couponEntity.id){
|
||||
couponAmount = that.curCoupon.couponEntity.couponAmount
|
||||
}
|
||||
console.log('couponAmount优惠券金额',couponAmount);
|
||||
that.actualPayment = that.actualPayment - couponAmount; // 减去优惠券的金额
|
||||
|
||||
if (this.actualPayment == 0 && !this.isShowAddress) {
|
||||
this.isDefaultCurrency = true;
|
||||
} else {
|
||||
@@ -997,9 +1103,9 @@
|
||||
realMoney: this.actualPayment, //实收金额
|
||||
shippingMoney: this.freightNum, //运费
|
||||
remark: this.remark, //备注
|
||||
couponId: null, //优惠券Id
|
||||
couponId: this.curCouponId ? this.curCoupon.id : null, //优惠券Id
|
||||
// isSend: this.isSend,
|
||||
couponName: "", //优惠券名称
|
||||
couponName: this.curCouponId && this.curCoupon.id ? this.curCoupon.couponEntity.couponName : '', //优惠券名称
|
||||
districtMoney: 0, //优惠金额
|
||||
|
||||
productList: this.goodsDataList.map((e) => {
|
||||
|
||||
Reference in New Issue
Block a user