!3 完善优惠券功能

Merge pull request !3 from 疯狂的世界/master
pull/4/MERGE
芋道源码 2023-10-03 10:45:57 +00:00 committed by Gitee
commit 6a6f022eac
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 77 additions and 47 deletions

View File

@ -32,7 +32,7 @@ export function setFormId(formId) {
}
/**
* 领取优惠
* 领取优惠
* @param int couponId
*
*/

View File

@ -178,7 +178,7 @@ export function orderConfirm(cartId, isNew, addAgain,secKill,combination,bargain
}
/**
* 获取当前金额能使用的优惠
* 获取当前金额能使用的优惠
* @param string price
*
*/

View File

@ -1,5 +1,6 @@
import request from "@/utils/request.js";
// 领取优惠券
export function takeCoupon(templateId) {
return request.post("app-api/promotion/coupon/take", {
templateId
@ -11,23 +12,21 @@ 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);
}
export function getCouponTemplateList(spuId, useType) {
return request.get("app-api/promotion/coupon-template/list", {
spuId,
useType
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}
// 获得优惠劵模板分页
export function getCouponTemplatePage(data) {
return request.get("app-api/promotion/coupon-template/page", data);
}
// 获得优惠劵模板列表
export function getCouponTemplateList(data) {
return request.get("app-api/promotion/coupon-template/list", data);
}
// 获得未使用的优惠劵数量
export function getUnusedCouponCount() {
return request.get("app-api/promotion/coupon/get-unused-count");

View File

@ -11,7 +11,7 @@
<view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
@click="getCouponUser(index, item.id)" :key='index'>
<!-- 金额 -->
<view class='money acea-row row-column row-center-wrapper' :class='item.takeStatus?"moneyGray":""'>
<view class='money acea-row row-column row-center-wrapper' :class='item.canTake ? "" : "moneyGray"'>
<view>
<text v-if="item.discountType === 1" class='num'>{{ fen2yuan(item.discountPrice) }}</text>
<text v-else class='num'>{{ (item.discountPercent / 10.0).toFixed(1) }} </text>
@ -33,8 +33,8 @@
<view v-else>
{{ formatDate(item.validStartTime) + " - " + formatDate(item.validEndTime) }}
</view>
<view class='bnt gray' v-if="item.takeStatus">{{item.use_title || ''}}</view>
<view class='bnt bg-color' v-else>{{coupon.statusTile || ''}}</view>
<view class='bnt bg-color' v-if="item.canTake">{{coupon.statusTile || ''}}</view>
<view class='bnt gray' v-else>{{item.use_title || ''}}</view>
</view>
</view>
</view>
@ -80,7 +80,7 @@
methods: {
close: function() {
this.type = 1
this.$emit('ChangCouponsClone');
this.$emit('ChangCouponsClose');
},
/**
* 选择优惠劵
@ -88,11 +88,11 @@
getCouponUser: function(index, id) {
//
let list = this.coupon.list;
if (list[index].takeStatus && this.openType === 0) {
return;
}
switch (this.openType) {
case 0: //
if (!list[index].canTake) {
return;
}
CouponApi.takeCoupon(id).then(res => {
this.$util.Tips({
title: "领取成功"

View File

@ -226,7 +226,7 @@
<!-- 优惠劵弹窗 -->
<couponListWindow
:coupon='coupon'
@ChangCouponsClone="ChangCouponsClone"
@ChangCouponsClose="ChangCouponsClose"
@ChangCoupons="ChangCoupons"
@tabCouponType="tabCouponType"
/>
@ -819,7 +819,7 @@
* 获取优惠券
*/
getCouponList(useType) {
CouponApi.getCouponTemplateList(this.id, useType).then(res => {
CouponApi.getCouponTemplateList({spuId: this.id, productScope: useType, count: 10}).then(res => {
this.$set(this.coupon, 'list', res.data);
})
},
@ -837,7 +837,7 @@
/**
* 关闭优惠劵弹窗
*/
ChangCouponsClone: function() {
ChangCouponsClose: function() {
this.$set(this.coupon, 'coupon', false)
},
/**

View File

@ -97,16 +97,16 @@
</navigator>
</view>
<view class="listBox acea-row">
<view class="list" :class='item.takeStatus ? "listHui" : "listActive" '
v-for="(item, index) in couponList.slice(0,2)" :key="index">
<view class="tit line1" :class='item.takeStatus ? "pricehui" : "titActive" '>{{ item.name }}</view>
<view class="price" :class='item.takeStatus ? "pricehui" : "icon-color" '>
<view class="list" :class='item.canTake ? "listActive" : "listHui"'
v-for="(item, index) in couponList" :key="index">
<view class="tit line1" :class='item.canTake ? "titActive" : "pricehui"'>{{ item.name }}</view>
<view class="price" :class='item.canTake ? "icon-color" : "pricehui"'>
<text v-if="item.discountType === 1">{{ fen2yuan(item.discountPrice) }} </text>
<text v-else>{{ (item.discountPercent / 10.0).toFixed(1) }} </text>
</view>
<view class="ling" v-if="!item.takeStatus" :class='item.takeStatus ? "pricehui" : "icon-color" '
<view class="ling icon-color" v-if="item.canTake"
@click="getCoupon(item.id,index)">领取</view>
<view class="ling" v-else :class='item.takeStatus ? "pricehui fonthui" : "icon-color" '>已领</view>
<view class="ling pricehui fonthui" v-else></view>
<view class="priceM">{{ fen2yuan(item.usePrice) }}元可用</view>
</view>
</view>
@ -184,6 +184,7 @@
import * as DecorateApi from '@/api/promotion/decorate.js';
import * as ProductUtil from '@/utils/product.js';
import * as Util from '@/utils/util.js';
export default {
computed: mapGetters(['isLogin', 'uid']),
components: {
@ -381,7 +382,7 @@
* 获得优惠劵列表
*/
getcouponList() {
CouponApi.getCouponTemplateList().then(res => {
CouponApi.getCouponTemplateList({ count: 2 }).then(res => {
this.$set(this, 'couponList', res.data);
}).catch(err => {
return this.$util.Tips({
@ -394,7 +395,8 @@
*/
getCoupon: function(id, index) {
CouponApi.takeCoupon(id).then(res => {
this.$set(this.couponList[index], 'takeStatus', true);
//
this.$set(this.couponList[index], 'canTake', res.data !== true);
this.$util.Tips({
title: '领取成功'
});

View File

@ -50,14 +50,14 @@
<!-- 优惠劵展示 -->
<view class='wrapper borRadius14'>
<view class='item acea-row row-between-wrapper' @tap='couponTap'
v-if="orderInfoVo.type === 1 && productType==='normal'">
v-if="orderInfoVo.type === 0 && productType==='normal'">
<view>优惠券</view>
<view class='discount'>{{couponTitle}}
<text class='iconfont icon-jiantou'></text>
</view>
</view>
<!-- 积分展示 -->
<view class='item acea-row row-between-wrapper' v-if="orderInfoVo.type === 1 && productType==='normal'">
<view class='item acea-row row-between-wrapper' v-if="orderInfoVo.type === 0 && productType==='normal'">
<view>积分抵扣</view>
<view class='discount acea-row row-middle'>
<view> {{pointStatus ? "剩余积分":"当前积分"}}
@ -139,7 +139,7 @@
<!-- 优惠劵的弹窗选择 -->
<couponListWindow
:coupon='coupon'
@ChangCouponsClone="ChangCouponsClone"
@ChangCouponsClose="ChangCouponsClose"
:openType='openType'
@ChangCoupons="ChangCoupons"
:orderShow="orderShow"
@ -389,7 +389,10 @@
*/
getCouponList: function() {
CouponApi.getMatchCouponList({
// TODO
price: this.orderInfoVo.price.payPrice,
spuIds: this.orderInfoVo.items.map(item => item.spuId),
skuIds: this.orderInfoVo.items.map(item => item.skuId),
categoryIds: this.orderInfoVo.items.map(item => item.categoryId)
}).then(res => {
this.$set(this.coupon, 'list', res.data);
// couponId
@ -440,7 +443,7 @@
/**
* 关闭 coupon 优惠劵的选择弹窗
*/
ChangCouponsClone: function() {
ChangCouponsClose: function() {
this.$set(this.coupon, 'coupon', false);
},

View File

@ -9,7 +9,7 @@
<view style="height: 106rpx;"></view>
<view class='coupon-list' v-if="couponsList.length">
<view class='item acea-row row-center-wrapper' v-for="(item,index) in couponsList" :key="index">
<view class='money' :class='item.takeStatus ? "moneyGray" : "" '>
<view class='money' :class='item.canTake ? "" : "moneyGray"'>
<view>
<text v-if="item.discountType === 1" class='num'>{{ fen2yuan(item.discountPrice) }}</text>
<text v-else class='num'>{{ (item.discountPercent / 10.0).toFixed(1) }} </text>
@ -18,11 +18,11 @@
</view>
<view class='text'>
<view class='condition line2'>
<span class='line-title' :class='(item.takeStatus)?"gray":""'
<span class='line-title' :class='item.canTake ? "" : "gray"'
v-if='type === 1'>通用</span>
<span class='line-title' :class='(item.takeStatus)?"gray":""'
<span class='line-title' :class='item.canTake ? "" : "gray"'
v-else-if='type === 3'>品类</span>
<span class='line-title' :class='(item.takeStatus)?"gray":""' v-else></span>
<span class='line-title' :class='item.canTake ? "" : "gray"' v-else></span>
<span>{{item.name}}</span>
</view>
<view class='data acea-row row-between-wrapper'>
@ -30,8 +30,8 @@
<view v-else>
{{ formatDate(item.validStartTime) + " - " + formatDate(item.validEndTime) }}
</view>
<view class='bnt gray' v-if="item.takeStatus"></view>
<view class='bnt bg-color' v-else @click='getCoupon(item.id, index)'>立即领</view>
<view class='bnt bg-color' v-if="item.canTake" @click='getCoupon(item.id, index)'>立即领</view>
<view class='bnt gray' v-else></view>
</view>
</view>
</view>
@ -111,7 +111,8 @@
getCoupon: function(id, index) {
//
CouponApi.takeCoupon(id).then(res => {
this.couponsList[index].takeStatus = true;
//
this.couponsList[index].canTake = res.data;
this.$set(this, 'couponsList', this.couponsList);
this.$util.Tips({
title: '领取成功'
@ -133,7 +134,7 @@
CouponApi.getCouponTemplatePage({
pageNo: this.page,
pageSize: this.limit,
useType: this.type
productScope: this.type
}).then(res => {
const list = res.data.list;
const loadend = list.length < this.limit;

View File

@ -60,7 +60,14 @@
<view class='name line1'> {{item.day}} 天签到积分奖励</view>
<view class='data'>{{ formatDate(item.createTime) }}</view>
</view>
<view class='num font-color'>+{{ item.point }}</view>
<view>
<view class='num font-color' v-if="item.point > 0">
<span class="num-title">积分</span> +{{ item.point }}
</view>
<view class='num font-color' v-if="item.experience > 0">
<span class="num-title">经验</span> +{{ item.experience }}
</view>
</view>
</view>
<view class='loading' @click='goSignList' v-if="signRecordList.length >= 3">
点击加载更多 <text class='iconfont icon-xiangyou' />
@ -73,7 +80,8 @@
<view class='signTipLight loadingpic'></view>
<view class='signTipCon'>
<view class='state'>签到成功</view>
<view class='integral'>获得{{ point }}积分</view>
<view class='integral' v-if="signResult.point > 0">{{ signResult.point }}</view>
<view class='integral' v-if="signResult.experience > 0">{{ signResult.experience }}</view>
<view class='signTipBnt' @click='close'>好的</view>
</view>
</view>
@ -98,7 +106,7 @@
signRecordList: [], //
active: false, //
point: 0, //
signResult: 0, //
};
},
computed: mapGetters(['isLogin', 'userInfo']),
@ -176,7 +184,7 @@
}
SignInApi.createSignInRecord().then(res => {
this.active = true;
this.point = res.data.point;
this.signResult = res.data;
//
this.getSignInfo();
this.getSignList();
@ -420,6 +428,11 @@
margin-top: 9rpx;
}
.sign .list3 .item .num-title {
font-size: 10rpx;
margin-right: 8rpx;
}
.sign .list3 .item .num {
font-size: 36rpx;
font-family: 'Guildford Pro';

View File

@ -9,7 +9,14 @@
<view class='name line1'> {{item.day}} 天签到积分奖励</view>
<view>{{ formatDate(item.createTime) }}</view>
</view>
<view class='num font-color'>+{{ item.point }}</view>
<view>
<view class='num font-color' v-if="item.point > 0">
<span class="num-title">积分</span> +{{ item.point }}
</view>
<view class='num font-color' v-if="item.experience > 0">
<span class="num-title">经验</span> +{{ item.experience }}
</view>
</view>
</view>
</view>
</view>
@ -92,4 +99,9 @@
</script>
<style>
.sign-record .list .item .num-title {
font-size: 10rpx;
margin-right: 8rpx;
}
</style>