【订单确认】

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) { export function getCouponPage(data) {
return request.get("app-api/promotion/coupon/page", data); return request.get("app-api/promotion/coupon/page", data);
} }

View File

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

View File

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