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