Commit c91edc52 authored by xd's avatar xd

优惠券完成未测试

parent b6e580da
......@@ -47,4 +47,20 @@ export function getMemberListByCode(params) {
method: 'get',
params
})
}
\ No newline at end of file
}
// 添加优惠券
export function addCoupon(data) {
return requestCF({
url: '/admin/auth/coupon/newCoupon',
method: 'post',
data: qs.stringify(data)
})
}
// 获取优惠券列表
export function getCouponList(params) {
return requestCF({
url: '/admin/auth/coupon/getAllCouponsByOyStallCode',
method: 'get',
params
})
}
......@@ -31,9 +31,7 @@ export default {
}
},
created() {
this.radio = sessionStorage.getItem('oyStallCode')
console.log(sessionStorage.getItem('oyStallCode'),'切换');
this.radio = sessionStorage.getItem('oyStallCode')
this.getList()
},
methods: {
......@@ -61,7 +59,7 @@ export default {
sessionStorage.setItem("barName", obj.name)
}
}
};
}
</script>
<style scoped>
......
......@@ -18,18 +18,18 @@
<div class="npbr">
<van-field
class="right"
v-model="startTime1"
v-model="addForm.type"
placeholder="选择优惠券类型"
readonly="readonly"
@click="startShow = true"
@click="typeShow = true"
/>
<van-popup v-model="startShow" position="bottom" :overlay="true">
<van-datetime-picker
v-model="startTime"
type="date"
@cancel="startShow = false"
@confirm="handleStartTime"
@change="startTimeChange"
<van-popup v-model="typeShow" position="bottom" :overlay="true">
<van-picker
show-toolbar
title="标题"
:columns="typeList"
@cancel="typeShow = false"
@confirm="onConfirm"
/>
</van-popup>
</div>
......@@ -37,12 +37,21 @@
</van-cell>
<van-cell title="金额" style="font-size:14px;">
<template slot="default">
<van-field
v-model="addForm.unit"
placeholder="请输入金额"
class="right"
style="font-size:14px;"
/>
<div class="npbr">
<van-field
class="right noborder"
readonly
clickable
:value="addForm.unit"
placeholder="请输入金额"
@touchstart.native.stop="unitShow = true"
/>
<van-number-keyboard
v-model="addForm.unit "
:show="unitShow"
@blur="unitShow = false"
/>
</div>
</template>
</van-cell>
<van-cell title="开始时间" style="font-size:14px;">
......@@ -50,7 +59,7 @@
<div class="npbr">
<van-field
class="right"
v-model="addForm.startTime"
v-model="beginDate"
placeholder="选择开始时间"
readonly="readonly"
@click="startShow = true"
......@@ -72,7 +81,7 @@
<div class="npbr">
<van-field
class="right"
v-model="addForm.endDate"
v-model="endDate"
placeholder="选择结束时间"
readonly="readonly"
@click="endShow = true"
......@@ -118,13 +127,13 @@
clickable
:value="addForm.limitOfUse"
placeholder="请输入总限制次数"
@touchstart.native.stop="show = true"
@touchstart.native.stop="allLimitShow = true"
/>
<van-number-keyboard
v-model="addForm.limitOfUse"
:show="show"
:show="allLimitShow"
:maxlength="6"
@blur="show = false"
@blur=" allLimitShow = false"
/>
</div>
</template>
......@@ -133,7 +142,7 @@
<template slot="default">
<van-field
v-model="addForm.remind"
placeholder="请输入使用说明"
placeholder="请输入总限制提示"
class="right"
style="font-size:14px;"
/>
......@@ -164,22 +173,38 @@
<van-cell-group class="all">
<van-cell title="销售金额" style="font-size:14px;">
<template slot="default">
<van-field
v-model="addForm.salesAmount"
placeholder="请输入销售金额"
class="right"
style="font-size:14px;"
/>
<div class="npbr">
<van-field
class="right noborder"
readonly
clickable
:value="addForm.salesAmount"
placeholder="请输入销售金额"
@touchstart.native.stop="salesAmountShow = true"
/>
<van-number-keyboard
v-model="addForm.salesAmount "
:show="salesAmountShow"
@blur="salesAmountShow = false"
/>
</div>
</template>
</van-cell>
<van-cell title="用券金额" style="font-size:14px;">
<template slot="default">
<van-field
v-model="addForm.usageMax"
:value="addForm.usageAmount"
placeholder="请输入用券金额"
class="right"
style="font-size:14px;"
@touchstart.native.stop="usageAmountShow = true"
/>
<van-number-keyboard
v-model="addForm.usageAmount"
:show="usageAmountShow"
:maxlength="6"
@blur="usageAmountShow = false"
/>
</template>
</van-cell>
</van-cell-group>
......@@ -193,9 +218,11 @@
</template>
<script>
export default {
import { addCoupon } from "@/api/sidebar/voucher"
export default {
data() {
return {
allLimitShow: false,
show: false,
show2: false,
startTime: new Date(),
......@@ -204,11 +231,17 @@ export default {
endTime1: "",
startShow: false,
endShow: false,
typeShow: false,
salesAmountShow: false,
usageAmountShow:false,
unitShow: false,
beginDate: '',
endDate: '',
//
addForm: {
name: "",
endDate: '',
startDate: '',
begin_date: '',
end_date: '',
type: '',
unit: '',
instruction: '',
......@@ -217,48 +250,108 @@ export default {
remind: '',
usageMax: '',
salesAmount: '',
usageMax: ''
}
usageAmount: '',
usageMax: '',
deptId: ''
},
typeList: ['现金券']
};
},
mounted() {
this.addForm.deptId = sessionStorage.getItem("oyStallCode")
// this.addForm.deptId = 3
},
methods: {
timeFormat(time) {
let year = 1900 + time.getYear();
let month = "0" + (time.getMonth() + 1);
let date = "0" + time.getDate();
let hour = time.getHours()
let minute = time.getMinutes()
return (
year +
"-" +
month.substring(month.length - 2, month.length) +
"-" +
date.substring(date.length - 2, date.length) +
" "
year + "-" + month.substring(month.length - 2, month.length) + "-" + date.substring(date.length - 2, date.length)
);
},
startTimeChange(e) {
let startTimeArr = e.getValues();
this.addForm.startTime = `${startTimeArr[0]}-${startTimeArr[1]}-${startTimeArr[2]}`;
let startTimeArr = e.getValues();
console.log(startTimeArr,'startTimeArr')
this.addForm.begin_date = this.beginDate = `${startTimeArr[0]}-${startTimeArr[1]}-${startTimeArr[2]}`
},
handleStartTime(value) {
this.addForm.startTime = this.timeFormat(value);
this.addForm.begin_date = this.beginDate = this.timeFormat(value)
this.startShow = false;
},
handleEndTime(value) {
this.addForm.endDate = this.timeFormat(value);
this.addForm.end_date = this.endDate = this.timeFormat(value);
this.endShow = false;
},
endTimeChange(e) {
let endTimeArr = e.getValues();
this.addForm.endDate = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`;
endTimeChange(e) {
let endTimeArr = e.getValues()
this.addForm.end_date = this.endDate = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`
},
onConfirm(val,index) {
this.typeShow = false
this.addForm.type = val
},
handleCancel() {
this.$router.push('coupon')
},
handleSave() {
if(!this.addForm.name ){
this.$toast("请输入优惠券名称")
return false
}
if(!this.addForm.type){
this.$toast("请输入优惠券类型")
return false
}
if(!this.addForm.unit){
this.$toast("请输入优惠券金额")
return false
}
if(!this.beginDate){
this.$toast("请输入开始时间")
return false
}
if(!this.endDate){
this.$toast("请输入结束时间")
return false
}
if(!this.addForm.couponId){
this.$toast("请输入优惠券ID")
return false
}
if(!this.addForm.limitOfUse){
this.$toast("请输入总限制次数")
return false
}
if(!this.addForm.remind ){
this.$toast("请输入限制提示")
return false
}
if(!this.addForm.usageMax){
this.$toast("请输入编码券使用上限")
return false
}
if(!this.addForm.salesAmount){
this.$toast("请输入销售金额")
return false
}
if(!this.addForm.usageAmount){
this.$toast("请输入用券金额")
return false
}
addCoupon(this.addForm).then(res => {
console.log(res,'res')
if(res.result == 'success') {
this.$router.push('coupon')
}
})
}
},
mounted() {}
}
};
</script>
<style></style>
......@@ -282,7 +375,7 @@ export default {
display: none !important;
}
.creat {
width: 96%;
width: 100%;
display: flex;
height: 40px;
background: rgba(117, 178, 253, 1);
......
......@@ -6,12 +6,12 @@
<div class="price">¥{{ form.unit }}</div>
</div>
<div class="right">
<div>{{ form.usageAmount }}元可用</div>
<div>{{ form.salesUnit }}元可用</div>
<div>
<div>有效期:</div>
<div>
<span>{{ form.beginDate }}</span>~
<span>{{ form.endDate }}</span>
<span>{{ form.begin_date }}</span>~
<span>{{ form.end_date }}</span>
</div>
</div>
<div>全店通用</div>
......@@ -19,24 +19,55 @@
<i></i>
</div>
<div class="txt">{{ form.type }}</div>
<div class="txt">此优惠券仅限于 <span>{{ form.store }}</span> 使用</div>
<div class="txt">此优惠券仅限于 <span>{{ store }}</span> 使用</div>
</div>
</div>
</template>
<script>
import { getCouponList } from "@/api/sidebar/voucher"
export default {
data() {
return {
form: {
store: 'only',
unit: '100',
type: '老用户回馈券',
usageAmount: '500',
beginDate: '2020/2/3',
endDate: '2020/4/5'
}
begin_date: '2020/2/3',
end_date: '2020/4/5'
},
store: '',
id: '',
deptId: ''
}
},
mounted() {
this.deptId = sessionStorage.getItem('oyStallCode')
// this.deptId = 3
this.id = this.$route.query.id
console.log(this.id);
this.getList()
},
methods: {
getList() {
let params = {
deptId: this.deptId
}
getCouponList(params).then(res => {
res.data.forEach(item => {
item.begin_date = item.begin_date.substr(0,4)+'-'+item.begin_date.substr(4,2)+'-'+item.begin_date.substr(6,2)
item.end_date = item.end_date.substr(0,4)+'-'+item.end_date.substr(4,2)+'-'+item.end_date.substr(6,2)
})
let obj = res.data.find(x => {
console.log(x,'x')
return x.id === this.id
})
console.log(obj,'obj')
this.form = obj
this.store = sessionStorage.getItem("barName")
})
},
}
}
</script>
......
<template>
<div class="contain">
<div class="box" @click="handleCoupon">
<div class="left">
<div class="price">¥{{ form.unit }}</div>
<div class="type">{{ form.type }}</div>
<div class="box" v-for="(item,index) in list" :key="index" @click="handleCoupon(item.id)">
<div class="left" >
<div class="price">¥{{ item.unit }}</div>
<div class="type">{{ item.type }}</div>
</div>
<div class="right">
<div>{{ form.usageAmount }}元可用</div>
<div>{{ item.salesUnit }}元可用</div>
<div class="time">
<div>有效期:</div>
<span>{{ form.beginDate }}</span>~
<span>{{ form.endDate }}</span>
<span>{{ item.begin_date }}</span>~
<span>{{ item.end_date }}</span>
</div>
</div>
</div>
......@@ -19,6 +19,7 @@
</template>
<script>
import { getCouponList } from "@/api/sidebar/voucher"
export default {
data() {
return {
......@@ -26,14 +27,38 @@ export default {
unit: '100',
type: '老用户回馈券',
usageAmount: '500',
beginDate: '2020/2/3',
endDate: '2020/4/5'
}
begin_date: '2020/2/3',
end_date: '2020/4/5'
},
deptId: '',
list: []
}
},
mounted() {
this.deptId = sessionStorage.getItem('oyStallCode')
// this.deptId = 3
this.getList()
},
methods: {
handleCoupon() {
this.$router.push("yhqDetail")
getList() {
let params = {
deptId: this.deptId
}
getCouponList(params).then(res => {
this.list = res.data
res.data.forEach(item => {
item.begin_date = item.begin_date.substr(0,4)+'-'+item.begin_date.substr(4,2)+'-'+item.begin_date.substr(6,2)
item.end_date = item.end_date.substr(0,4)+'-'+item.end_date.substr(4,2)+'-'+item.end_date.substr(6,2)
})
})
},
handleCoupon(id) {
this.$router.push({
path: "yhqDetail",
query: {
id: id
}
})
},
handleAddCoupon() {
this.$router.push("couponAdd")
......@@ -46,6 +71,8 @@ export default {
.contain {
background-color: rgb(237, 239, 243);
height: 100%;
flex-direction: column;
justify-content: flex-start;
}
.left,.right {
font-size: 16px;
......
......@@ -46,7 +46,7 @@
<img class="menu-logo" :src="test.menuInfo.icon['6']" />
<div class="menu-text">商品管理</div>
</div>
<div class="menu" @click="handleCoupon">
<div class="menu" @click="handleCoupon" v-if="flag == 1">
<img class="menu-logo" :src="test.menuInfo.icon['1']" />
<div class="menu-text">优惠券管理</div>
</div>
......@@ -115,7 +115,7 @@
<script>
import axios from "axios";
import { getStoreDetail, getMemberListByCode } from "@/api/sidebar/voucher";
import { getStoreDetail, getMemberListByCode, getDirector } from "@/api/sidebar/voucher";
import { configWx, getUserInfo } from "@/utils/aCommon";
import { getUserInfoByUserId } from "@/api/sidebar/voucher";
import { log } from 'util';
......@@ -208,8 +208,9 @@ export default {
userId: "",
userInfoResOld: "",
userInfoResNew: ""
}
};
},
flag: 1
}
},
created() {
this.checkNowMenuBar()
......@@ -232,19 +233,32 @@ export default {
if(sessionStorage.getItem('allNewFans')) {
this.test.barInfo.allNewFans = sessionStorage.getItem('allNewFans')
}
if(sessionStorage.getItem('role')) {
this.flag = sessionStorage.getItem('role')
}
}else {
// this.zReadyUserId()
this.zTestGetNowUrlInfo()
}
},
methods: {
// 获取用户角色
getDirector(userId) {
getDirector({userId}).then(res => {
if(res.data == true) {
this.flag = 1
}else {
this.flag = 2
}
sessionStorage.setItem("role", this.flag)
})
},
// 获取用户信息
getUserInfo() {
let headerData = {
agentId: "1000033",
corpId: "ww4df265003b43fa0d"
};
}
axios({
url:
"http://139.155.48.151:8085/workWx/auth/user/get?userId=" +
......@@ -470,9 +484,7 @@ export default {
};
this.zcache.userInfoResOld = "PostData:" + JSON.stringify(postData);
axios({
url:
"http://139.155.48.151:8085/workWx/auth/oauth2/getUserInfo?code=" +
this.zcache.code,
url: "http://139.155.48.151:8085/workWx/auth/oauth2/getUserInfo?code=" + this.zcache.code,
method: "post",
headers: headerData
})
......@@ -482,6 +494,7 @@ export default {
this.getUserFromId(this.zcache.userId);
this.getUserInfo();
this.getNewFans()
this.getDirector(res.data.data.userId)
})
.catch(err => {
console.log(err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment