自动发券模块(管理端加前端展示)
parent
7b7310ed75
commit
efd3ed26df
|
@ -7,6 +7,10 @@ var BASE = {
|
||||||
buyer: "https://buyer-api.pickmall.cn",
|
buyer: "https://buyer-api.pickmall.cn",
|
||||||
seller: "https://store-api.pickmall.cn",
|
seller: "https://store-api.pickmall.cn",
|
||||||
manager: "https://admin-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: {
|
API_PROD: {
|
||||||
common: "https://common-api.pickmall.cn",
|
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>
|
<template>
|
||||||
<div class="container">
|
<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>
|
<drawer></drawer>
|
||||||
<!-- 固定头部 -->
|
<!-- 固定头部 -->
|
||||||
<hover-search class="hover-search" :class="{show: topSearchShow}"></hover-search>
|
<hover-search class="hover-search" :class="{show: topSearchShow}"></hover-search>
|
||||||
|
@ -22,8 +44,8 @@
|
||||||
import Search from '@/components/Search';
|
import Search from '@/components/Search';
|
||||||
import ModelForm from '@/components/indexDecorate/ModelForm';
|
import ModelForm from '@/components/indexDecorate/ModelForm';
|
||||||
import HoverSearch from '@/components/header/hoverSearch';
|
import HoverSearch from '@/components/header/hoverSearch';
|
||||||
import storage from '@/plugins/storage';
|
import storage from "@/plugins/storage";
|
||||||
import { indexData } from '@/api/index.js';
|
import { indexData,getAutoCoup } from '@/api/index.js';
|
||||||
import {seckillByDay} from '@/api/promotion'
|
import {seckillByDay} from '@/api/promotion'
|
||||||
export default {
|
export default {
|
||||||
name: 'Index',
|
name: 'Index',
|
||||||
|
@ -38,9 +60,14 @@ export default {
|
||||||
that.topSearchShow = false;
|
that.topSearchShow = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if(storage.getItem('userInfo')){
|
||||||
|
this.getAutoCoup()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
autoCoupList:[],
|
||||||
|
showCpmodel:false,
|
||||||
modelForm: { list: [] }, // 楼层装修数据
|
modelForm: { list: [] }, // 楼层装修数据
|
||||||
topAdvert: {}, // 顶部广告
|
topAdvert: {}, // 顶部广告
|
||||||
showNav: false, // 是否展示分类栏
|
showNav: false, // 是否展示分类栏
|
||||||
|
@ -49,7 +76,73 @@ export default {
|
||||||
carouselOpacity: false // 不同轮播分类样式
|
carouselOpacity: false // 不同轮播分类样式
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
// created(){
|
||||||
|
|
||||||
|
// },
|
||||||
methods: {
|
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 () {
|
getIndexData () {
|
||||||
// 获取首页装修数据
|
// 获取首页装修数据
|
||||||
indexData({ clientType: 'PC' }).then(async (res) => {
|
indexData({ clientType: 'PC' }).then(async (res) => {
|
||||||
|
@ -94,6 +187,7 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@import '../assets/styles/coupon.scss';
|
||||||
.container {
|
.container {
|
||||||
@include sub_background_color($light_background_color);
|
@include sub_background_color($light_background_color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,7 @@ export default {
|
||||||
this.$Message.success("登录成功");
|
this.$Message.success("登录成功");
|
||||||
storage.setItem("accessToken", res.result.accessToken);
|
storage.setItem("accessToken", res.result.accessToken);
|
||||||
storage.setItem("refreshToken", res.result.refreshToken);
|
storage.setItem("refreshToken", res.result.refreshToken);
|
||||||
|
storage.setItem('getTimes',0)
|
||||||
apiLogin.getMemberMsg().then((res) => {
|
apiLogin.getMemberMsg().then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
storage.setItem("userInfo", res.result);
|
storage.setItem("userInfo", res.result);
|
||||||
|
|
|
@ -12,11 +12,19 @@
|
||||||
<span v-if="couponActivity.couponActivityType === 'REGISTERED'"
|
<span v-if="couponActivity.couponActivityType === 'REGISTERED'"
|
||||||
>新人发券</span
|
>新人发券</span
|
||||||
>
|
>
|
||||||
|
<span v-else-if="couponActivity.couponActivityType === 'AUTO_COUPON'">自动发券</span>
|
||||||
<spin v-else>精确发券</spin>
|
<spin v-else>精确发券</spin>
|
||||||
</FormItem>
|
</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
|
<FormItem
|
||||||
label="活动范围"
|
label="活动范围"
|
||||||
v-if="couponActivity.couponActivityType === 'SPECIFY'"
|
v-if="couponActivity.couponActivityType === 'SPECIFY' || couponActivity.couponActivityType === 'AUTO_COUPON'"
|
||||||
>
|
>
|
||||||
<span v-if="couponActivity.activityScope === 'ALL'">全部会员</span>
|
<span v-if="couponActivity.activityScope === 'ALL'">全部会员</span>
|
||||||
<spin v-else>指定会员</spin>
|
<spin v-else>指定会员</spin>
|
||||||
|
|
|
@ -34,6 +34,22 @@
|
||||||
>
|
>
|
||||||
<Radio label="REGISTERED">新人发券</Radio>
|
<Radio label="REGISTERED">新人发券</Radio>
|
||||||
<Radio label="SPECIFY">精确发券</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>
|
</RadioGroup>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
|
@ -161,6 +177,7 @@ export default {
|
||||||
endTime: "", //结束时间
|
endTime: "", //结束时间
|
||||||
memberDTOS: [], //指定会员范围
|
memberDTOS: [], //指定会员范围
|
||||||
couponActivityItems: [], //优惠券列表
|
couponActivityItems: [], //优惠券列表
|
||||||
|
couponFrequencyEnum:"", //选择周期
|
||||||
},
|
},
|
||||||
submitLoading: false, // 添加或编辑提交状态
|
submitLoading: false, // 添加或编辑提交状态
|
||||||
selectCouponList: [], //选择的优惠券列表
|
selectCouponList: [], //选择的优惠券列表
|
||||||
|
@ -323,7 +340,7 @@ export default {
|
||||||
// 清空原有数据
|
// 清空原有数据
|
||||||
this.form.couponActivityItems = this.selectCouponList.map((item) => {
|
this.form.couponActivityItems = this.selectCouponList.map((item) => {
|
||||||
return {
|
return {
|
||||||
num: 0,
|
num: 1,
|
||||||
couponId: item.id,
|
couponId: item.id,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -341,6 +358,33 @@ export default {
|
||||||
},
|
},
|
||||||
/** 保存平台优惠券 */
|
/** 保存平台优惠券 */
|
||||||
handleSubmit() {
|
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);
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}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.startTime = this.$options.filters.unixToDate(this.rangeTime[0] / 1000);
|
||||||
this.form.endTime = this.$options.filters.unixToDate(this.rangeTime[1] / 1000);
|
this.form.endTime = this.$options.filters.unixToDate(this.rangeTime[1] / 1000);
|
||||||
|
|
||||||
|
@ -359,6 +403,8 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// 关闭当前页面
|
// 关闭当前页面
|
||||||
closeCurrentPage() {
|
closeCurrentPage() {
|
||||||
|
|
|
@ -92,7 +92,9 @@ export default {
|
||||||
render: (h, params) => {
|
render: (h, params) => {
|
||||||
if (params.row.couponActivityType === "REGISTERED") {
|
if (params.row.couponActivityType === "REGISTERED") {
|
||||||
return h("div", ["注册赠券"]);
|
return h("div", ["注册赠券"]);
|
||||||
} else {
|
}else if(params.row.couponActivityType === 'AUTO_COUPON'){
|
||||||
|
return h("div", ["自动发券"]);
|
||||||
|
}else {
|
||||||
return h("div", ["精确发券"]);
|
return h("div", ["精确发券"]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -111,6 +113,25 @@ export default {
|
||||||
return h("div", [text]);
|
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: "活动时间",
|
title: "活动时间",
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
|
@ -121,6 +142,8 @@ export default {
|
||||||
innerHTML: params.row.startTime + "<br/>" + params.row.endTime,
|
innerHTML: params.row.startTime + "<br/>" + params.row.endTime,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
return h("div", '/');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
<FormItem label="有效期" prop="rangeTime">
|
<FormItem label="有效期" prop="rangeTime">
|
||||||
<div v-if="form.getType == 'ACTIVITY'">
|
<div v-if="form.getType == 'ACTIVITY'">
|
||||||
<RadioGroup v-model="rangeTimeType">
|
<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>
|
<Radio :disabled="disabled" :label="0">固定时间</Radio>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</div>
|
</div>
|
||||||
|
@ -144,6 +144,7 @@
|
||||||
<div class="effectiveDays" v-if="rangeTimeType == 0">
|
<div class="effectiveDays" v-if="rangeTimeType == 0">
|
||||||
领取当天开始
|
领取当天开始
|
||||||
<InputNumber
|
<InputNumber
|
||||||
|
:disabled="disabled"
|
||||||
v-model="form.effectiveDays"
|
v-model="form.effectiveDays"
|
||||||
:min="1"
|
:min="1"
|
||||||
style="width: 100px"
|
style="width: 100px"
|
||||||
|
@ -242,6 +243,11 @@ export default {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (val == "FREE") {
|
if (val == "FREE") {
|
||||||
this.rangeTimeType = 1;
|
this.rangeTimeType = 1;
|
||||||
|
}else{
|
||||||
|
this.rangeTimeType = 0;
|
||||||
|
}
|
||||||
|
if(this.rangeTimeType == 0){
|
||||||
|
delete this.formRule.rangeTime
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
|
@ -301,6 +307,7 @@ export default {
|
||||||
promotionGoodsList: [],
|
promotionGoodsList: [],
|
||||||
scopeIdGoods: [],
|
scopeIdGoods: [],
|
||||||
rangeDayType: "",
|
rangeDayType: "",
|
||||||
|
effectiveDays:1,
|
||||||
},
|
},
|
||||||
id: this.$route.query.id, // 优惠券id
|
id: this.$route.query.id, // 优惠券id
|
||||||
submitLoading: false, // 添加或编辑提交状态
|
submitLoading: false, // 添加或编辑提交状态
|
||||||
|
|
Loading…
Reference in New Issue