parent
3d4400f198
commit
3ae38b6626
|
|
@ -6,6 +6,11 @@ export function takeCoupon(templateId) {
|
|||
});
|
||||
}
|
||||
|
||||
// 获得匹配指定商品的优惠劵列表
|
||||
export function getMatchCouponList(data) {
|
||||
return request.get("app-api/promotion/coupon/match-list", data);
|
||||
}
|
||||
|
||||
export function getCouponPage(data) {
|
||||
return request.get("app-api/promotion/coupon/page", data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view>
|
||||
<view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
|
||||
<view class='coupon-list-window' :class='coupon.coupon === true?"on":""'>
|
||||
<view v-if="!orderShow" class="nav acea-row row-around">
|
||||
<view :class="['acea-row', 'row-middle', type === 1 ? 'on' : '']" @click="setType(1)">通用券</view>
|
||||
<view :class="['acea-row', 'row-middle', type === 2 ? 'on' : '']" @click="setType(2)">商品券</view>
|
||||
|
|
@ -82,11 +82,14 @@
|
|||
this.type = 1
|
||||
this.$emit('ChangCouponsClone');
|
||||
},
|
||||
/**
|
||||
* 选择优惠劵
|
||||
*/
|
||||
getCouponUser: function(index, id) {
|
||||
// 领取优惠劵时,如果已经领取,则直接跳过
|
||||
let list = this.coupon.list;
|
||||
if (list[index].takeStatus && this.openType === 0) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
switch (this.openType) {
|
||||
case 0: // 领取优惠券
|
||||
|
|
@ -98,6 +101,11 @@
|
|||
})
|
||||
break;
|
||||
case 1: // 使用优惠劵
|
||||
// TODO 芋艿:需要额外把不可用优惠劵的样式做了;
|
||||
if (list[index].match === false) {
|
||||
alert('该优惠劵无法使用,原因:' + list[index].description);
|
||||
return;
|
||||
}
|
||||
this.$emit('ChangCoupons', index);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@
|
|||
</template>
|
||||
<script>
|
||||
import {
|
||||
getCouponsOrderPrice,
|
||||
orderCreate,
|
||||
postOrderComputed,
|
||||
wechatOrderPay,
|
||||
|
|
@ -179,7 +178,8 @@
|
|||
loadPreOrderApi
|
||||
} from '@/api/order.js';
|
||||
import * as AddressApi from '@/api/member/address.js';
|
||||
import {
|
||||
import * as CouponApi from '@/api/promotion/coupon.js';
|
||||
import {
|
||||
openPaySubscribe
|
||||
} from '@/utils/SubscribeMessage.js';
|
||||
import * as DeliveryApi from '@/api/trade/delivery.js';
|
||||
|
|
@ -189,6 +189,7 @@
|
|||
import home from '@/components/home';
|
||||
import { toLogin } from '@/libs/login.js';
|
||||
import { mapGetters } from "vuex";
|
||||
import coupon from "../../../../admin/src/views/marketing/coupon";
|
||||
export default {
|
||||
components: {
|
||||
couponListWindow,
|
||||
|
|
@ -344,13 +345,16 @@
|
|||
title: err
|
||||
});
|
||||
})
|
||||
|
||||
// TODO 芋艿:获得优惠劵列表
|
||||
this.getCouponList();
|
||||
},
|
||||
// 计算订单价格
|
||||
computedPrice: function() {
|
||||
let shippingType = this.shippingType;
|
||||
postOrderComputed({
|
||||
addressId: this.address.addressId,
|
||||
useIntegral: this.useIntegral ? true : false,
|
||||
useIntegral: this.useIntegral,
|
||||
couponId: this.couponId,
|
||||
shippingType: parseInt(shippingType) + 1,
|
||||
preOrderNo: this.preOrderNo
|
||||
|
|
@ -405,10 +409,6 @@
|
|||
that.car();
|
||||
}, 500);
|
||||
},
|
||||
couponTap: function() {
|
||||
this.coupon.coupon = true;
|
||||
if(!this.coupon.list.length)this.getCouponList();
|
||||
},
|
||||
car: function() {
|
||||
let that = this;
|
||||
that.animated = false;
|
||||
|
|
@ -778,36 +778,41 @@
|
|||
|
||||
// ========== 优惠劵 ==========
|
||||
/**
|
||||
* 获取当前金额可用优惠券 TODO
|
||||
* 获取当前金额可用优惠券
|
||||
*/
|
||||
getCouponList: function() {
|
||||
getCouponsOrderPrice(this.preOrderNo).then(res => {
|
||||
CouponApi.getMatchCouponList({
|
||||
// TODO 芋艿:这里应该补充下参数
|
||||
}).then(res => {
|
||||
this.$set(this.coupon, 'list', res.data);
|
||||
this.openType = 1;
|
||||
// 设置指定优惠劵已选择;用于 couponId 有参数时,默认选中一下
|
||||
const useCoupon = res.data.find(coupon => coupon.id === this.couponId);
|
||||
if (useCoupon) {
|
||||
useCoupon.use_title = '不使用';
|
||||
useCoupon.isUse = 1;
|
||||
this.couponTitle = useCoupon.name;
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 处理点击优惠券后的事件 TODO
|
||||
* 处理点击优惠券后的事件
|
||||
*/
|
||||
ChangCoupons: function(e) {
|
||||
// this.usableCoupon = e
|
||||
// this.coupon.coupon = false
|
||||
let index = e,
|
||||
list = this.coupon.list,
|
||||
couponTitle = '请选择',
|
||||
couponId = 0;
|
||||
for (let i = 0, len = list.length; i < len; i++) {
|
||||
if (i != index) {
|
||||
ChangCoupons: function(index) {
|
||||
const list = this.coupon.list;
|
||||
// 先标记未使用
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (i !== index) {
|
||||
list[i].use_title = '';
|
||||
list[i].isUse = 0;
|
||||
}
|
||||
}
|
||||
if (list[index].isUse) {
|
||||
//不使用优惠券
|
||||
// 再标记使用中的优惠劵
|
||||
let couponTitle = '请选择';
|
||||
let couponId = 0;
|
||||
if (list[index].isUse) { // 不使用优惠券(就是又点了下,选中的优惠劵)
|
||||
list[index].use_title = '';
|
||||
list[index].isUse = 0;
|
||||
} else {
|
||||
//使用优惠券
|
||||
} else { // 使用优惠券
|
||||
list[index].use_title = '不使用';
|
||||
list[index].isUse = 1;
|
||||
couponTitle = list[index].name;
|
||||
|
|
@ -817,9 +822,17 @@
|
|||
this.couponId = couponId;
|
||||
this.$set(this.coupon, 'coupon', false);
|
||||
this.$set(this.coupon, 'list', list);
|
||||
this.computedPrice();
|
||||
this.getloadPreOrder();
|
||||
},
|
||||
// TODO
|
||||
/**
|
||||
* 打开 coupon 优惠劵的选择弹窗
|
||||
*/
|
||||
couponTap: function() {
|
||||
this.coupon.coupon = true;
|
||||
},
|
||||
/**
|
||||
* 关闭 coupon 优惠劵的选择弹窗
|
||||
*/
|
||||
ChangCouponsClone: function() {
|
||||
this.$set(this.coupon, 'coupon', false);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue