自动发券模块(管理端加前端展示)
parent
7b7310ed75
commit
efd3ed26df
|
@ -7,6 +7,10 @@ var BASE = {
|
|||
buyer: "https://buyer-api.pickmall.cn",
|
||||
seller: "https://store-api.pickmall.cn",
|
||||
manager: "https://admin-api.pickmall.cn"
|
||||
// common: "http://192.168.0.105:8890",
|
||||
// buyer: "http://192.168.0.105:8888",
|
||||
// seller: "http://192.168.0.105:8889",
|
||||
// manager: "http://192.168.0.105:8887"
|
||||
},
|
||||
API_PROD: {
|
||||
common: "https://common-api.pickmall.cn",
|
||||
|
|
|
@ -10,6 +10,15 @@ export function indexData(params) {
|
|||
});
|
||||
}
|
||||
|
||||
// 获取自动发券
|
||||
export function getAutoCoup(){
|
||||
return request({
|
||||
url: "/buyer/promotion/coupon/activity",
|
||||
method: Method.GET,
|
||||
needToken: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺楼层数据
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
<template>
|
||||
<div class="container">
|
||||
<Modal v-model="showCpmodel" width="350">
|
||||
<template #header>
|
||||
<p style="color:black;text-align:left">
|
||||
<!-- <Icon type="ios-information-circle"></Icon> -->
|
||||
<span>活动优惠券</span>
|
||||
</p>
|
||||
</template>
|
||||
<template>
|
||||
<Scroll :on-reach-bottom="handleReachBottom">
|
||||
<Card dis-hover v-for="(item, index) in autoCoupList" :key="index" style="margin: 10px 15px">
|
||||
<span v-if="item.couponType === 'PRICE'" class="fontsize_12 global_color" style="font-size: 15px;">¥<span class="price">{{item.price | unitPrice}}</span></span>
|
||||
<span v-if="item.couponType === 'DISCOUNT'" class="fontsize_12 global_color" style="font-size: 15px;"><span class="price">{{item.discount}}</span>折</span>
|
||||
<span class="describe" style="font-size: 15px;margin-left: 5px;">满{{item.consumeThreshold}}元可用</span>
|
||||
<p style="font-size: 10px;">使用范围:{{useScope(item.scopeType, item.storeName)}}</p>
|
||||
<p style="font-size: 10px;">有效期:{{item.endTime}}</p>
|
||||
</Card>
|
||||
</Scroll>
|
||||
</template>
|
||||
<template #footer>
|
||||
<Button type="error" @click="showCpmodel=false">确定</Button>
|
||||
</template>
|
||||
</Modal>
|
||||
<drawer></drawer>
|
||||
<!-- 固定头部 -->
|
||||
<hover-search class="hover-search" :class="{show: topSearchShow}"></hover-search>
|
||||
|
@ -22,8 +44,8 @@
|
|||
import Search from '@/components/Search';
|
||||
import ModelForm from '@/components/indexDecorate/ModelForm';
|
||||
import HoverSearch from '@/components/header/hoverSearch';
|
||||
import storage from '@/plugins/storage';
|
||||
import { indexData } from '@/api/index.js';
|
||||
import storage from "@/plugins/storage";
|
||||
import { indexData,getAutoCoup } from '@/api/index.js';
|
||||
import {seckillByDay} from '@/api/promotion'
|
||||
export default {
|
||||
name: 'Index',
|
||||
|
@ -38,9 +60,14 @@ export default {
|
|||
that.topSearchShow = false;
|
||||
}
|
||||
};
|
||||
if(storage.getItem('userInfo')){
|
||||
this.getAutoCoup()
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
autoCoupList:[],
|
||||
showCpmodel:false,
|
||||
modelForm: { list: [] }, // 楼层装修数据
|
||||
topAdvert: {}, // 顶部广告
|
||||
showNav: false, // 是否展示分类栏
|
||||
|
@ -49,7 +76,73 @@ export default {
|
|||
carouselOpacity: false // 不同轮播分类样式
|
||||
};
|
||||
},
|
||||
// created(){
|
||||
|
||||
// },
|
||||
methods: {
|
||||
// 优惠券可用范围
|
||||
useScope (type, storeName) {
|
||||
let shop = '平台';
|
||||
let goods = '全部商品'
|
||||
if (storeName !== 'platform') shop = storeName
|
||||
switch (type) {
|
||||
case 'ALL':
|
||||
goods = '全部商品'
|
||||
break;
|
||||
case 'PORTION_GOODS':
|
||||
goods = '部分商品'
|
||||
break;
|
||||
case 'PORTION_GOODS_CATEGORY':
|
||||
goods = '部分分类商品'
|
||||
break;
|
||||
}
|
||||
return `${shop}${goods}可用`
|
||||
},
|
||||
getAutoCoup(){
|
||||
let data = new Date()
|
||||
let datas = data.getDate()
|
||||
let hours = data.getHours()
|
||||
let flagCoup = storage.getItem('getTimes') //缓存
|
||||
if(flagCoup && flagCoup != undefined && flagCoup != null){ //判断当前是否有缓存
|
||||
if(Number(datas) > Number(flagCoup)){ //判断缓存是否小于当前天数
|
||||
if(Number(hours) >= 6){//超过或等于6时清楚缓存
|
||||
storage.setItem('getTimes',datas)//存储缓存
|
||||
this.getcps()
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// window.localStorage.setItem('getTimes',datas)//存储缓存
|
||||
this.getcps()
|
||||
}
|
||||
},
|
||||
getcps(){
|
||||
console.log(123123)
|
||||
let data = new Date()
|
||||
let datas = data.getDate()
|
||||
getAutoCoup().then(res=>{ //调用自动发券
|
||||
if(res.success){
|
||||
this.autoCoupList.push(...res.result);
|
||||
let objs = {};
|
||||
this.autoCoupList = this.autoCoupList.reduce((cur, next) => {
|
||||
//对象去重
|
||||
if (next.id != undefined) {
|
||||
objs[next.id]
|
||||
? ""
|
||||
: (objs[next.id] = true && cur.push(next));
|
||||
}
|
||||
return cur;
|
||||
}, []);
|
||||
if(this.autoCoupList != '' && this.autoCoupList.length > 0){
|
||||
console.log(1231232132)
|
||||
this.showCpmodel = true;
|
||||
}
|
||||
storage.setItem('getTimes',datas)//存储缓存
|
||||
}
|
||||
})
|
||||
},
|
||||
handleReachBottom(){
|
||||
console.log(111)
|
||||
} ,
|
||||
getIndexData () {
|
||||
// 获取首页装修数据
|
||||
indexData({ clientType: 'PC' }).then(async (res) => {
|
||||
|
@ -94,6 +187,7 @@ export default {
|
|||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '../assets/styles/coupon.scss';
|
||||
.container {
|
||||
@include sub_background_color($light_background_color);
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@ export default {
|
|||
this.$Message.success("登录成功");
|
||||
storage.setItem("accessToken", res.result.accessToken);
|
||||
storage.setItem("refreshToken", res.result.refreshToken);
|
||||
storage.setItem('getTimes',0)
|
||||
apiLogin.getMemberMsg().then((res) => {
|
||||
if (res.success) {
|
||||
storage.setItem("userInfo", res.result);
|
||||
|
|
|
@ -12,11 +12,19 @@
|
|||
<span v-if="couponActivity.couponActivityType === 'REGISTERED'"
|
||||
>新人发券</span
|
||||
>
|
||||
<span v-else-if="couponActivity.couponActivityType === 'AUTO_COUPON'">自动发券</span>
|
||||
<spin v-else>精确发券</spin>
|
||||
</FormItem>
|
||||
<FormItem label="领取频率" v-if="couponActivity.couponFrequencyEnum != '' && couponActivity.couponFrequencyEnum != null && couponActivity.couponFrequencyEnum != undefined">
|
||||
<span v-if="couponActivity.couponFrequencyEnum === 'DAY'"
|
||||
>每日</span
|
||||
>
|
||||
<span v-else-if="couponActivity.couponFrequencyEnum === 'WEEK'">每周一次</span>
|
||||
<span v-else>每月一次</span>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="活动范围"
|
||||
v-if="couponActivity.couponActivityType === 'SPECIFY'"
|
||||
v-if="couponActivity.couponActivityType === 'SPECIFY' || couponActivity.couponActivityType === 'AUTO_COUPON'"
|
||||
>
|
||||
<span v-if="couponActivity.activityScope === 'ALL'">全部会员</span>
|
||||
<spin v-else>指定会员</spin>
|
||||
|
|
|
@ -34,6 +34,22 @@
|
|||
>
|
||||
<Radio label="REGISTERED">新人发券</Radio>
|
||||
<Radio label="SPECIFY">精确发券</Radio>
|
||||
<Radio label="INVITE_NEW">邀新赠券</Radio>
|
||||
<Radio label="AUTO_COUPON">自动赠券</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="领取频率"
|
||||
v-if="form.couponActivityType === 'AUTO_COUPON'"
|
||||
>
|
||||
<RadioGroup
|
||||
type="button"
|
||||
button-style="solid"
|
||||
v-model="form.couponFrequencyEnum"
|
||||
>
|
||||
<Radio label="DAY">每日一次</Radio>
|
||||
<Radio label="WEEK">每周一次</Radio>
|
||||
<Radio label="MONTH">每月一次</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
|
@ -161,6 +177,7 @@ export default {
|
|||
endTime: "", //结束时间
|
||||
memberDTOS: [], //指定会员范围
|
||||
couponActivityItems: [], //优惠券列表
|
||||
couponFrequencyEnum:"", //选择周期
|
||||
},
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
selectCouponList: [], //选择的优惠券列表
|
||||
|
@ -323,7 +340,7 @@ export default {
|
|||
// 清空原有数据
|
||||
this.form.couponActivityItems = this.selectCouponList.map((item) => {
|
||||
return {
|
||||
num: 0,
|
||||
num: 1,
|
||||
couponId: item.id,
|
||||
};
|
||||
});
|
||||
|
@ -341,6 +358,9 @@ export default {
|
|||
},
|
||||
/** 保存平台优惠券 */
|
||||
handleSubmit() {
|
||||
if(this.form.couponFrequencyEnum !== ''){
|
||||
console.log(this.activityScope)
|
||||
if(this.form.activityScope == 'ALL'){
|
||||
this.form.startTime = this.$options.filters.unixToDate(this.rangeTime[0] / 1000);
|
||||
this.form.endTime = this.$options.filters.unixToDate(this.rangeTime[1] / 1000);
|
||||
|
||||
|
@ -359,6 +379,32 @@ export default {
|
|||
});
|
||||
}
|
||||
});
|
||||
}else {
|
||||
this.$Message.info('自动发券只能全用户发送')
|
||||
this.form.couponActivityType = 'SPECIFY'
|
||||
this.form.activityScope = 'ALL'
|
||||
}
|
||||
}else{
|
||||
this.form.startTime = this.$options.filters.unixToDate(this.rangeTime[0] / 1000);
|
||||
this.form.endTime = this.$options.filters.unixToDate(this.rangeTime[1] / 1000);
|
||||
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const params = JSON.parse(JSON.stringify(this.form));
|
||||
this.submitLoading = true;
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete params.id;
|
||||
saveActivityCoupon(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("优惠券活动创建成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
// 关闭当前页面
|
||||
closeCurrentPage() {
|
||||
|
|
|
@ -92,6 +92,8 @@ export default {
|
|||
render: (h, params) => {
|
||||
if (params.row.couponActivityType === "REGISTERED") {
|
||||
return h("div", ["注册赠券"]);
|
||||
}else if(params.row.couponActivityType === 'AUTO_COUPON'){
|
||||
return h("div", ["自动发券"]);
|
||||
}else {
|
||||
return h("div", ["精确发券"]);
|
||||
}
|
||||
|
@ -111,6 +113,25 @@ export default {
|
|||
return h("div", [text]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "领取频率",
|
||||
key: "couponFrequencyEnum",
|
||||
minWidth: 120,
|
||||
render: (h, params) => {
|
||||
console.log(params)
|
||||
let text = ''
|
||||
if (params.row.couponFrequencyEnum === "DAY") {
|
||||
text = "每日";
|
||||
} else if(params.row.couponFrequencyEnum === "WEEK") {
|
||||
text = "每周";
|
||||
} else if(params.row.couponFrequencyEnum === 'MONTH'){
|
||||
text = '每月'
|
||||
} else {
|
||||
text = '/'
|
||||
}
|
||||
return h("div", [text]);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "活动时间",
|
||||
minWidth: 150,
|
||||
|
@ -121,6 +142,8 @@ export default {
|
|||
innerHTML: params.row.startTime + "<br/>" + params.row.endTime,
|
||||
},
|
||||
});
|
||||
}else{
|
||||
return h("div", '/');
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
<FormItem label="有效期" prop="rangeTime">
|
||||
<div v-if="form.getType == 'ACTIVITY'">
|
||||
<RadioGroup v-model="rangeTimeType">
|
||||
<Radio :disabled="disabled" :label="1">起止时间</Radio>
|
||||
<Radio :disabled="disabled" :label="1" v-if="form.getType !== 'ACTIVITY'">起止时间</Radio>
|
||||
<Radio :disabled="disabled" :label="0">固定时间</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
@ -144,6 +144,7 @@
|
|||
<div class="effectiveDays" v-if="rangeTimeType == 0">
|
||||
领取当天开始
|
||||
<InputNumber
|
||||
:disabled="disabled"
|
||||
v-model="form.effectiveDays"
|
||||
:min="1"
|
||||
style="width: 100px"
|
||||
|
@ -242,6 +243,11 @@ export default {
|
|||
handler(val) {
|
||||
if (val == "FREE") {
|
||||
this.rangeTimeType = 1;
|
||||
}else{
|
||||
this.rangeTimeType = 0;
|
||||
}
|
||||
if(this.rangeTimeType == 0){
|
||||
delete this.formRule.rangeTime
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
|
@ -301,6 +307,7 @@ export default {
|
|||
promotionGoodsList: [],
|
||||
scopeIdGoods: [],
|
||||
rangeDayType: "",
|
||||
effectiveDays:1,
|
||||
},
|
||||
id: this.$route.query.id, // 优惠券id
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
|
|
Loading…
Reference in New Issue