【订单确认】

1. 将 coupon 接入优惠劵列表
pull/1/MERGE
YunaiV 2023-06-29 20:19:40 +08:00
parent 3d4400f198
commit 3ae38b6626
3 changed files with 54 additions and 28 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
},