自动发券模块(管理端加前端展示)

master
夜良king 2023-01-10 18:27:37 +08:00
parent 7b7310ed75
commit efd3ed26df
8 changed files with 198 additions and 6 deletions

View File

@ -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",

View File

@ -10,6 +10,15 @@ export function indexData(params) {
}); });
} }
// 获取自动发券
export function getAutoCoup(){
return request({
url: "/buyer/promotion/coupon/activity",
method: Method.GET,
needToken: true,
});
}
/** /**
* 获取店铺楼层数据 * 获取店铺楼层数据
*/ */

View File

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

View File

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

View File

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

View File

@ -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() {

View File

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

View File

@ -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, //