Commit c91edc52 authored by xd's avatar xd

优惠券完成未测试

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