提交 bd29225d 编写于 作者: guangjun.yang's avatar guangjun.yang

请选择优惠券

上级 90e54c92
......@@ -5,7 +5,10 @@
<div class="left">
<p class="name" :class="{'status': !item.showStatus}">{{item.couponName}}</p>
<div class="other">
<p v-if="item.validTimeType == 2" class="time-end" :class="{'status': !item.showStatus}">距离到期仅剩<span class="coupon-pc"> {{item.validTimeSpan}} </span></p>
<p v-if="item.validTimeType == 2" class="time-end" :class="{'status': !item.showStatus}">
<span v-if="item.couponStatus == 0">领取后<span class="coupon-pc"> {{item.validTimeSpan}} </span>天内有效</span>
<span v-else>距离到期仅剩<span class="coupon-pc"> {{item.validTimeSpan}} </span></span>
</p>
<p v-else class="time-end" :class="{'status': !item.showStatus}">{{parseTime(item.startTime)}}{{parseTime(item.expireTime)}}</p>
<p v-show="!item.isAll" class="rules">
<span :class="{'status': !item.showStatus}" @click="toggleRules(item)">使用规则</span>
......
......@@ -5,8 +5,8 @@
<span>优惠券</span>
<img @click="cancle" src="../../images/cme/close.png" />
</article>
<article v-if="true" class="list-wrapper">
<p v-if="currentCoupon.couponId || goodsInfo4Coupon.count">
<article v-if="selectCouponList.length" class="list-wrapper">
<p v-if="currentCoupon.couponId">
已选择1张优惠券,共抵扣
<span class="sc thin">¥{{yuan(currentCoupon.discountAmount)}}</span>
</p>
......@@ -52,7 +52,7 @@
</article>
<no-coupon v-else></no-coupon>
<article class="bottom">
<article v-if="selectCouponList.length" class="bottom">
<van-button @click="confirm" size="large" round color="#449284">确定使用</van-button>
</article>
</section>
......
......@@ -15,7 +15,7 @@
</template>
<script>
import CommonNavbar from "@/components/common/common-navbar";
import CouponList from "@/components/coupon/com-coupon-list";
import CouponList from "@/components/coupon/component-list";
import NoCoupon from "@/components/coupon/no-coupon";
import { getWebPageUrl, getHactiveUrl } from "@/utils";
import { mapGetters, mapActions } from "vuex";
......@@ -93,7 +93,9 @@ export default {
return;
}
if (token && !info.id) {
this.$store.dispatch("getUserInfo");
this.commonCheckToken(() => {
this.$store.dispatch("getUserInfo");
});
return;
}
// 从登陆页面过来的
......@@ -210,7 +212,7 @@ export default {
if (item.couponStatus == 1) {
let pageUrl = "";
if(item.couponMappingModelList.length > 1) {
pageUrl = getHactiveUrl(`/message_push/#/study-card`);
pageUrl = getHactiveUrl(`/message_push/#/study-card?origin=1`);
this.jumpForCoupon(pageUrl);
} else {
item.couponMappingModelList.length && this.getCardInfoByProvinceId(item.couponMappingModelList[0], item);
......
......@@ -101,7 +101,7 @@
import { Swipe, SwipeItem } from "vant";
import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog";
import CouponSelectList from "@/components/coupon/com-coupon-select-list";
import CouponSelectList from "@/components/coupon/component-select-list";
import { wxConfig, chooseWXPay } from "@/utils/wxShare";
import {
......@@ -143,7 +143,8 @@ export default {
showLoading: false,
isShowDialog: false,
isShowCoupon: false, //是否展示激活弹框,
courseUrl: ""
courseUrl: "",
defaultCouponId: "",
};
},
computed: {
......@@ -194,7 +195,7 @@ export default {
this.projectId = this.$route.query.projectId;
this.goodsId = this.$route.query.goodsId || 74;
this.courseUrl = this.$route.query.courseUrl || ""; //
// this.couponIdFromGL = this.$route.query.couponId || ""; //
// this.couponIdFromGoodsList = this.$route.query.couponId || ""; //
this.shareUrl = getWebPageUrl(
`profexam/#/goods-detail?goodsId=${this.goodsId}`
);
......@@ -244,7 +245,9 @@ export default {
if (this.isWeb) {
const { token, info } = this.$store.state.user;
if (token && !info.id) {
this.$store.dispatch("getUserInfo");
this.commonCheckToken(() => {
this.$store.dispatch("getUserInfo");
});
return;
}
// 从登陆页面过来时
......@@ -285,23 +288,29 @@ export default {
this.GET(`trade/coupon/app/goodsCoupons`, { goodsType, cardType }).then(
res => {
if (res.code == "000000") {
this.handlerCouponList(res.data || [], params.price, !!this.couponId);
// 设置优惠券个数
params.count = (res.data || []).length;
this.setGoodsInfo4Coupon(params);
this.handlerCouponList(res.data || [], params.price);
// 设置优惠券个数
} else {
params.count = 0;
this.setGoodsInfo4Coupon(params);
this.setCurrentCoupon({});
this.setSelectCouponList([]);
}
}
);
},
// 处理数据,并且先排序,再将不可用的放在最后
handlerCouponList(couponList, goodsPrice, isFromGoodsList) {
handlerCouponList(couponList, goodsPrice) {
if (!couponList.length) return [];
let newList = [],
obj = {},
firstCanCoupon = null,
firstCanCouponIndex = 0,
item = {};
item = {},
count = 0;
couponList.sort( (a, b) => {
return b.discountAmount - a.discountAmount;
});
......@@ -310,6 +319,9 @@ export default {
// couponList.forEach(item => {
// 要根据商品价格及券适用类型来计算
item.disabled = !this.isCanSelect(item, goodsPrice);
if(!item.disabled) {
count ++;
}
// 是否已经选择
item.isChecked = false;
// console.log('firstCanCoupon, item.disabled', firstCanCoupon, item.disabled);
......@@ -337,6 +349,20 @@ export default {
// }
// }
// 商品详情接口已经选择了一张, 则使用默认的
if(this.defaultCouponId) {
let cCoupon = couponList.find( item => {
return item.couponId == this.defaultCouponId;
});
if(cCoupon && cCoupon.isChecked) {
firstCanCoupon = cCoupon;
} else {
firstCanCoupon = {};
couponList[firstCanCouponIndex].isChecked = false;
}
}
// 将不可用的放在最后
let sortArray = [], c = {};
for(let i = 0; i < newList.length; i ++) {
......@@ -348,8 +374,10 @@ export default {
}
}
this.setCurrentCoupon(firstCanCoupon || {});
this.setCurrentCoupon( JSON.parse(JSON.stringify(firstCanCoupon)) || {});
this.setSelectCouponList(newList.concat(sortArray));
this.goodsInfo4Coupon.count = count;
this.setGoodsInfo4Coupon(this.goodsInfo4Coupon);
return newList;
},
......@@ -415,7 +443,9 @@ export default {
// 显示优惠券弹框
showCouponPopup() {
this.isShowCoupon = true;
this.commonCheckToken(() => {
this.isShowCoupon = true;
})
},
// 设置当前选中的优惠券
......@@ -425,7 +455,7 @@ export default {
this.getCPText();
this.isShowCoupon = false;
// 要重新调用计算价格接口
this.getTotalPrice(currentCoupon);
// this.getTotalPrice(currentCoupon);
},
// tab切换
......@@ -447,6 +477,7 @@ export default {
let price =
goods.couponPrice || goods.preferentialPrice || goods.costPrice;
this.goods = goods;
this.defaultCouponId = goods.couponId;
// 获取到商品后,再获取优惠券
this.getCanUseCoupons({
goodsType: goods.goodsType,
......@@ -520,7 +551,7 @@ export default {
// TODO,要多传优惠券id参数
getTotalPrice(coupon) {
console.log('coupon', coupon);
const couponId = this.currentCoupon.couponId || 0;
// const couponId = this.currentCoupon.couponId || 0;
const num = this.curtGoodsNum;
// this.GET(`trade/goods/getPrice/${this.goodsId}/${num}/${couponId}`, {}).then(res => {
this.GET(`trade/goods/getPrice/${this.goodsId}/${num}`, {}).then(res => {
......@@ -672,6 +703,7 @@ export default {
return;
}
const orderData = {
// couponId: couponDTO ? couponDTO.couponId : 0,
couponId: couponDTO ? couponDTO.couponId : 0,
goodsId: id,
goodsQuantity: this.goodsNum,
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册