Commit 58f5213c authored by xd's avatar xd

优惠券修改,侧边栏发券成功跳转小程序

parent 766f1d3d
<template> <template>
<div class="container"> <div class="container">
<van-loading size="80px" color="#1989fa" class="ld" v-if="overlayShow">正在处理...</van-loading>
<van-overlay :show="overlayShow" />
<van-radio-group v-model="radio" class="nobr" @change="handleStoreChange"> <van-radio-group v-model="radio" class="nobr" @change="handleStoreChange">
<van-cell-group > <van-cell-group >
<van-cell v-for="(item,index) in list" :key="index" > <van-cell v-for="(item,index) in list" :key="index" >
...@@ -20,27 +22,32 @@ ...@@ -20,27 +22,32 @@
</template> </template>
<script> <script>
import { getStoreList } from "@/api/sidebar/voucher" import { getStoreList,getMemberListByCode } from "@/api/sidebar/voucher"
import axios from "axios";
import { log } from 'util'; import { log } from 'util';
export default { export default {
data() { data() {
return { return {
radio: '', radio: '',
userId: '', userId: '',
list: [] list: [],
overlayShow: false,
oyStallCode: ''
} }
}, },
created() { created() {
this.radio = sessionStorage.getItem('oyStallCode')
this.getList()
},
methods: {
getList() {
if(this.$route.query.userId !== '') { if(this.$route.query.userId !== '') {
this.userId = this.$route.query.userId this.userId = this.$route.query.userId
}else { }else {
this.userId = sessionStorage.getItem('userId') this.userId = sessionStorage.getItem('userId')
} }
this.radio = sessionStorage.getItem('oyStallCode')
// this.radio = 111
this.getList()
// this.userId = '10000190'
},
methods: {
getList() {
let params = { let params = {
user_id: this.userId user_id: this.userId
} }
...@@ -49,20 +56,169 @@ export default { ...@@ -49,20 +56,169 @@ export default {
this.list = res.data this.list = res.data
}) })
}, },
///
// 获取店铺的所有店员
getAllNewFans(oyStallCode) {
let params = {
oyStallCode: oyStallCode
}
getMemberListByCode(params).then(res => {
this.getAllInfo(res.data)
}).catch(err => {
console.log(err);
})
},
// 获取个人粉丝
getFans() {
let headerData = {
agentId: "1000033",
corpId: "ww4df265003b43fa0d"
}
return new Promise((resolve, reject) => {
axios({
url:
"http://139.155.48.151:8085/workWx/auth/contact/listExternalContacts?userId=" + this.userId,
method: "get",
headers: headerData
})
.then(res => {
if(res.data.data != null) {
sessionStorage.setItem("personalFan", res.data.data.length)
resolve(res.data.data.length)
}else {
console.log('zheli');
if(res.errorCode == "84061") {
sessionStorage.setItem("personalFan", 0)
resolve(0)
}else {
sessionStorage.setItem("personalFan", '')
resolve('')
}
}
})
.catch(err => {
reject(err)
})
})
},
// 获取店铺所有粉丝
getAllFans() {
let headerData = {
agentId: "1000033",
corpId: "ww4df265003b43fa0d"
}
return new Promise((resolve, reject) => {
axios({
url: "http://139.155.48.151:8085/workWx/auth/contact/getCustomerInfoByOyStallCode?oyStallCode=" + this.oyStallCode,
method: "get",
headers: headerData
})
.then(res => {
let newList = []
res.data.data.forEach(item => {
if(item != null) {
newList.push(item)
}
})
sessionStorage.setItem("allFans", newList.length)
resolve(newList.length)
})
.catch(err => {
reject(err)
})
})
},
getAddFans(flag, userId) {
let JsonStr = {}
if (flag == 1) {
JsonStr.userid = [userId];
} else {
JsonStr.userid = userId
}
let timeNow = Math.round(new Date() / 1000);
JsonStr.start_time = timeNow - 24 * 60 * 60;
JsonStr.end_time = timeNow;
return new Promise((resolve, reject) => {
axios({
url:
"http://139.155.48.151:8085/workWx/auth/contact/getUserBehaviorData",
method: "post",
headers: {
"Content-Type": "application/json",
agentId: "1000033",
corpId: "ww4df265003b43fa0d"
},
data: JsonStr
}).then(res => {
let data = JSON.parse(res.data.data);
if (flag == 1) {
// 获取个人新增粉丝
console.log(data,'个人新增粉丝')
if(data != null) {
let newFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
sessionStorage.setItem("newFans", newFans)
resolve(newFans)
}else {
sessionStorage.setItem("newFans", '')
resolve('')
}
} else {
console.log(data,'全部新增粉丝');
if(data != null) {
let allNewFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
sessionStorage.setItem("allNewFans", allNewFans);
resolve(allNewFans)
}else {
sessionStorage.setItem("allNewFans", '')
resolve('')
}
}
})
.catch(err => {
reject(err)
})
})
},
getAllInfo(list) {
console.log('getAllInfo');
Promise.all([this.getFans(), this.getAllFans(),this.getAddFans(1,this.userId),this.getAddFans(2,list)]).then(res => {
console.log('进来了');
console.log(res,'promise修改');
this.overlayShow = false
this.$toast("切换成功")
})
},
///
handleStoreChange(val) { handleStoreChange(val) {
this.overlayShow = true
console.log(val,'修改后的oyStallCode') console.log(val,'修改后的oyStallCode')
this.oyStallCode = val
sessionStorage.setItem('oyStallCode',val) sessionStorage.setItem('oyStallCode',val)
let obj = this.list.find(function (obj) { let obj = this.list.find(function (obj) {
return obj.oyStallCode == val return obj.oyStallCode == val
}) })
console.log(obj,'obj')
sessionStorage.setItem("barName", obj.name) sessionStorage.setItem("barName", obj.name)
this.getAllNewFans(val)
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.ld >>> .van-loading__text {
color: #fff;
}
.ld {
z-index: 1000;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.container { .container {
height: auto; height: auto;
background-color: #fff; background-color: #fff;
......
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
}, },
handlePushInfo() { handlePushInfo() {
if(this.info == 1) { if(this.info == 1) {
this.$router.push('pushStoreInfo') this.$router.push('noSet')
}else { }else {
let url = `http://oysales.oywanhao.com:8087/counterPageHome?oyStallCode=${this.oyStallCode}` let url = `http://oysales.oywanhao.com:8087/counterPageHome?oyStallCode=${this.oyStallCode}`
wx.invoke("shareToExternalContact", { wx.invoke("shareToExternalContact", {
......
...@@ -5,12 +5,21 @@ ...@@ -5,12 +5,21 @@
<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">
<div class="npbr">
<van-field <van-field
v-model="addForm.cxcode" :value="addForm.cxcode"
placeholder="请输入欧亚活动编码" placeholder="请输入欧亚活动编码"
class="right" class="right"
readonly
style="font-size:14px;" style="font-size:14px;"
@touchstart.native.stop="codeShow = true"
/> />
<van-number-keyboard
v-model="addForm.cxcode"
:show="codeShow"
@blur="codeShow = false"
/>
</div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="商户类型" style="font-size:14px;"> <van-cell title="商户类型" style="font-size:14px;">
...@@ -70,21 +79,7 @@ ...@@ -70,21 +79,7 @@
</van-cell> </van-cell>
<van-cell title="金额" style="font-size:14px;"> <van-cell title="金额" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="npbr"> <van-stepper v-model="addForm.unit" step="1"/>
<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> </template>
</van-cell> </van-cell>
<van-cell title="开始时间" style="font-size:14px;"> <van-cell title="开始时间" style="font-size:14px;">
...@@ -101,6 +96,7 @@ ...@@ -101,6 +96,7 @@
<van-datetime-picker <van-datetime-picker
v-model="startTime" v-model="startTime"
type="date" type="date"
:min-date="minStartDate"
@cancel="startShow = false" @cancel="startShow = false"
@confirm="handleStartTime" @confirm="handleStartTime"
@change="startTimeChange" @change="startTimeChange"
...@@ -123,6 +119,7 @@ ...@@ -123,6 +119,7 @@
<van-datetime-picker <van-datetime-picker
v-model="endTime" v-model="endTime"
type="date" type="date"
:min-date="minEndDate"
@cancel="endShow = false" @cancel="endShow = false"
@confirm="handleEndTime" @confirm="handleEndTime"
@change="endTimeChange" @change="endTimeChange"
...@@ -141,36 +138,28 @@ ...@@ -141,36 +138,28 @@
/> />
</template> </template>
</van-cell> </van-cell>
<van-cell title="优惠券Id" style="font-size:14px;"> <van-cell title="优惠券ID" style="font-size:14px;">
<template slot="default">
<van-field
v-model="addForm.couponId"
placeholder="请输入优惠券Id"
class="right"
style="font-size:14px;"
/>
</template>
</van-cell>
<van-cell title="总限制次数" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="npbr"> <div class="npbr">
<van-field <van-field
class="right noborder" class="right noborder"
readonly readonly
clickable clickable
:value="addForm.limitOfUse" :value="addForm.couponId"
placeholder="请输入总限制次数" placeholder="请输入优惠券ID"
@touchstart.native.stop="allLimitShow = true" @touchstart.native.stop="unitShow = true"
/> />
<van-number-keyboard <van-number-keyboard
v-model="addForm.limitOfUse" v-model="addForm.couponId "
:show="allLimitShow" :show="unitShow"
:maxlength="6" @blur="unitShow = false"
@blur=" allLimitShow = false"
/> />
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="总限制次数" style="font-size:14px;">
<van-stepper v-model="addForm.limitOfUse" step="1"/>
</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
...@@ -182,66 +171,16 @@ ...@@ -182,66 +171,16 @@
</template> </template>
</van-cell> </van-cell>
<van-cell title="编码券使用上限(次)" style="font-size:14px;"> <van-cell title="编码券使用上限(次)" style="font-size:14px;">
<template slot="default"> <van-stepper v-model="addForm.usageMax" step="1"/>
<div class="npbr">
<van-field
class="right noborder"
readonly
clickable
:value="addForm.usageMax"
placeholder="请输入编码券使用上限"
@touchstart.native.stop="show = true"
/>
<van-number-keyboard
v-model="addForm.usageMax "
:show="show"
:maxlength="6"
@blur="show = false"
/>
</div>
</template>
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
<div class="title">编码券使用规则明细</div> <div class="title">编码券使用规则明细</div>
<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"> <van-stepper v-model="addForm.salesAmount" step="1" :min="addForm.usageAmount"/>
<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>
<van-cell title="用券金额" style="font-size:14px;"> <van-cell title="用券金额" style="font-size:14px;">
<template slot="default"> <van-stepper v-model="addForm.usageAmount" step="1"/>
<div class="npbr">
<van-field
:value="addForm.usageAmount"
placeholder="请输入用券金额"
class="right"
style="font-size:14px;"
readonly
@touchstart.native.stop="usageAmountShow = true"
/>
<van-number-keyboard
v-model="addForm.usageAmount"
:show="usageAmountShow"
:maxlength="6"
@blur="usageAmountShow = false"
/>
</div>
</template>
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
</div> </div>
...@@ -258,6 +197,8 @@ import { addCoupon } from "@/api/sidebar/voucher" ...@@ -258,6 +197,8 @@ import { addCoupon } from "@/api/sidebar/voucher"
export default { export default {
data() { data() {
return { return {
minStartDate: null,
minEndDate: null,
allLimitShow: false, allLimitShow: false,
show: false, show: false,
show2: false, show2: false,
...@@ -275,6 +216,7 @@ export default { ...@@ -275,6 +216,7 @@ export default {
endDate: '', endDate: '',
cxsh: '', cxsh: '',
cxshShow: false, cxshShow: false,
codeShow: false,
// //
addForm: { addForm: {
cxcode: '', cxcode: '',
...@@ -291,7 +233,6 @@ export default { ...@@ -291,7 +233,6 @@ export default {
usageMax: '', usageMax: '',
salesAmount: '', salesAmount: '',
usageAmount: '', usageAmount: '',
usageMax: '',
deptId: '', deptId: '',
cxcode: '' cxcode: ''
}, },
...@@ -304,7 +245,9 @@ export default { ...@@ -304,7 +245,9 @@ export default {
}; };
}, },
mounted() { mounted() {
this.addForm.deptId = Number(sessionStorage.getItem("oyStallCode")) this.addForm.deptId = sessionStorage.getItem("oyStallCode")
this.minStartDate = new Date((new Date()/1000+3600)*1000)
this.minEndDate = new Date((new Date()/1000+86400)*1000)
}, },
methods: { methods: {
timeFormat(time) { timeFormat(time) {
...@@ -412,7 +355,7 @@ export default { ...@@ -412,7 +355,7 @@ export default {
addCoupon(this.addForm).then(res => { addCoupon(this.addForm).then(res => {
console.log(res,'res') console.log(res,'res')
if(res.errorCode == "fail") { if(res.errorCode == "fail") {
this.$toast("活动编码不能重复!") this.$toast("活动创建失败!")
}else { }else {
this.$router.push('coupon') this.$router.push('coupon')
} }
......
...@@ -74,24 +74,6 @@ ...@@ -74,24 +74,6 @@
</div> </div>
</div> </div>
</template> </template>
<!-- <div class="actives-main">
<div class="active-logos">
<img class="active-logo" :src="test.activeInfo.icon['2']" />
</div>
<div class="active-infos">
<div class="active-title">现金券发放</div>
<div class="active-dsc">{{test.cache.actDsc}}</div>
</div>
</div>
<div class="actives-main">
<div class="active-logos">
<img class="active-logo" :src="test.activeInfo.icon['3']" />
</div>
<div class="active-infos">
<div class="active-title">集卡</div>
<div class="active-dsc">{{test.cache.actDsc}}</div>
</div>
</div>-->
<div v-if="currentActives.length > 3 && !finished" class="actives-mores" @click="handleMore"> <div v-if="currentActives.length > 3 && !finished" class="actives-mores" @click="handleMore">
<div class="mores-title">查看更多</div> <div class="mores-title">查看更多</div>
<img class="mores-icon" :src="test.cache.arrowRightDark" /> <img class="mores-icon" :src="test.cache.arrowRightDark" />
...@@ -232,10 +214,7 @@ export default { ...@@ -232,10 +214,7 @@ export default {
}; };
}, },
created() { created() {
// this.overlayShow = true
this.checkNowMenuBar() this.checkNowMenuBar()
// this.zcache.userId = 'ShanDian'
// this.getUserFromId(this.zcache.userId)
if (sessionStorage.getItem("userId")) { if (sessionStorage.getItem("userId")) {
if (sessionStorage.getItem("avatar")) { if (sessionStorage.getItem("avatar")) {
this.test.manInfo.logoUrl = sessionStorage.getItem("avatar"); this.test.manInfo.logoUrl = sessionStorage.getItem("avatar");
...@@ -307,14 +286,17 @@ export default { ...@@ -307,14 +286,17 @@ export default {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios({ axios({
url: url: "http://139.155.48.151:8085/workWx/auth/user/get?userId=" + this.zcache.userId,
"http://139.155.48.151:8085/workWx/auth/user/get?userId=" + this.zcache.userId,
method: "get", method: "get",
headers: headerData headers: headerData
}) })
.then(res => { .then(res => {
if(res.data != null) {
sessionStorage.setItem("avatar", res.data.data.avatar) sessionStorage.setItem("avatar", res.data.data.avatar)
resolve(res.data.data.avatar) resolve(res.data.data.avatar)
}else {
resolve('')
}
}) })
.catch(err => { .catch(err => {
reject(err) reject(err)
...@@ -336,8 +318,28 @@ export default { ...@@ -336,8 +318,28 @@ export default {
headers: headerData headers: headerData
}) })
.then(res => { .then(res => {
console.log(res);
if(res.data.data != null) {
if(res.data != []) {
sessionStorage.setItem("personalFan", res.data.data.length) sessionStorage.setItem("personalFan", res.data.data.length)
resolve(res.data.data.length) resolve(res.data.data.length)
}else {
sessionStorage.setItem("personalFan", '')
resolve('')
}
}else {
console.log('zheli');
if(res.data.errorCode == "84061") {
sessionStorage.setItem("personalFan", 0)
resolve(0)
}else {
console.log('?');
sessionStorage.setItem("personalFan", '')
resolve('')
}
}
}) })
.catch(err => { .catch(err => {
reject(err) reject(err)
...@@ -373,20 +375,6 @@ export default { ...@@ -373,20 +375,6 @@ export default {
}) })
}, },
// 获取店铺所有新增粉丝
// getAllNewFans() {
// let params = {
// oyStallCode: this.oyStallCode
// }
// return new Promise((resolve, reject) => {
// getMemberListByCode(params).then(res => {
// resolve(res.data)
// }).catch(err => {
// reject(err)
// })
// })
// },
getAllNewFans() { getAllNewFans() {
let params = { let params = {
oyStallCode: this.oyStallCode oyStallCode: this.oyStallCode
...@@ -404,7 +392,6 @@ export default { ...@@ -404,7 +392,6 @@ export default {
JsonStr.userid = [userId]; JsonStr.userid = [userId];
} else { } else {
JsonStr.userid = userId JsonStr.userid = userId
console.log(userId,'拿到吗')
} }
let timeNow = Math.round(new Date() / 1000); let timeNow = Math.round(new Date() / 1000);
JsonStr.start_time = timeNow - 24 * 60 * 60; JsonStr.start_time = timeNow - 24 * 60 * 60;
...@@ -424,17 +411,23 @@ export default { ...@@ -424,17 +411,23 @@ export default {
let data = JSON.parse(res.data.data); let data = JSON.parse(res.data.data);
if (flag == 1) { if (flag == 1) {
// 获取个人新增粉丝 // 获取个人新增粉丝
if(data != null) {
let newFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt; let newFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
// this.test.barInfo.newFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
sessionStorage.setItem("newFans", newFans); sessionStorage.setItem("newFans", newFans);
resolve(newFans) resolve(newFans)
}else {
sessionStorage.setItem("newFans", '')
resolve('')
}
} else { } else {
console.log(data,'全部粉丝'); if(data != null) {
let allNewFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt; let allNewFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
console.log(allNewFans,'allNewFans ');
// this.test.barInfo.allNewFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
sessionStorage.setItem("allNewFans", allNewFans); sessionStorage.setItem("allNewFans", allNewFans);
resolve(allNewFans) resolve(allNewFans)
}else {
sessionStorage.setItem("allNewFans", '');
resolve('')
}
} }
}) })
.catch(err => { .catch(err => {
...@@ -471,11 +464,6 @@ export default { ...@@ -471,11 +464,6 @@ export default {
this.test.barInfo.allNewFans = res[4] this.test.barInfo.allNewFans = res[4]
this.test.manInfo.barName = res[5] this.test.manInfo.barName = res[5]
this.overlayShow = false this.overlayShow = false
// this.getAddFans(2,this.memberList).then(res => {
// this.test.barInfo.allNewFans = res
// this.overlayShow = false
// })
//
}) })
}, },
checkNowMenuBar() { checkNowMenuBar() {
...@@ -605,6 +593,8 @@ export default { ...@@ -605,6 +593,8 @@ export default {
}, },
// 获取店铺code // 获取店铺code
getUserFromId(id) { getUserFromId(id) {
console.log(1);
let userName = id; let userName = id;
getUserInfoByUserId({ userName }).then(res => { getUserInfoByUserId({ userName }).then(res => {
sessionStorage.setItem("oyStallCode", res.data[0].oyStallCode) sessionStorage.setItem("oyStallCode", res.data[0].oyStallCode)
......
...@@ -130,7 +130,8 @@ export default { ...@@ -130,7 +130,8 @@ export default {
{ max: 50, message: "长度在50个字符以内", trigger: "blur" } { max: 50, message: "长度在50个字符以内", trigger: "blur" }
], ],
parentId: [{ required: true, message: "请选择上级部门", trigger: "change" }], parentId: [{ required: true, message: "请选择上级部门", trigger: "change" }],
oyStallCode: [{ required: true, validator: idNumber, trigger: "blur" }] oyStallCode: [{ required: true, validator: idNumber, trigger: "blur" }],
clerkId: [{ required: true, message: "主管不能为空", trigger: "blur" }]
}, },
deptOption: { deptOption: {
value: 'id', value: 'id',
......
...@@ -134,7 +134,8 @@ export default { ...@@ -134,7 +134,8 @@ export default {
{ max: 50, message: "长度在50个字符以内", trigger: "blur" }, { max: 50, message: "长度在50个字符以内", trigger: "blur" },
], ],
parentId: [{ required: true, message: "请选择上级部门", trigger: "change" }], parentId: [{ required: true, message: "请选择上级部门", trigger: "change" }],
oyStallCode: [{ required: true, validator: idNumber, trigger: "blur" }] oyStallCode: [{ required: true, validator: idNumber, trigger: "blur" }],
clerkId: [{ required: true, message: "主管不能为空", trigger: "blur" }]
}, },
deptOption: { deptOption: {
value: 'id', value: 'id',
......
...@@ -137,7 +137,6 @@ ...@@ -137,7 +137,6 @@
font-size: 2rem; font-size: 2rem;
font-weight: bold; font-weight: bold;
} }
.main>.cards>.card02>.tips>.rules {}
.main>.cards>.card02>.tips>.rules>.rule { .main>.cards>.card02>.tips>.rules>.rule {
font-size: 2rem; font-size: 2rem;
} }
......
<template> <template>
<div class="main"> <div class="main">
<div class="contents"> <div class="contents">
<div class="zListActive"> <!-- <div class="zListActive">
<div class="inputs"> <div class="inputs">
<div class="button" @click="zReadySetVoucherList">ReLoad</div> <div class="button" @click="zReadyGetUserFromId">ReLoad</div>
</div>
</div> </div>
</div> -->
<div v-for="item of zlist.voucher" :key="item.coupon_id" > <div v-for="item of zlist.voucher" :key="item.coupon_id" >
<div class="content"> <div class="content">
<div class="content-imgs"> <div class="content-imgs">
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div class="main-money">{{item.coupon_title}}</div> <div class="main-money">{{item.coupon_title}}</div>
</div> </div>
<div class="buttons"> <div class="buttons">
<button class="button-send" @click="zVoucherPick(item.action_id, item.coupon_id)">推送</button> <button class="button-send" @click="handlePush(item.coupon_link)">推送</button>
</div> </div>
</div> </div>
<div class="infos-tips"> <div class="infos-tips">
...@@ -97,178 +97,152 @@ export default { ...@@ -97,178 +97,152 @@ export default {
this.getAgentAuth(); this.getAgentAuth();
// this.zReadySetVoucherList() // this.zReadySetVoucherList()
}, },
mounted() {
},
methods: { methods: {
// 测试-获取预授权码 // 获取店铺数据
zTestPreAuthCode() {
const basicInfo = {
head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
// appId: "wwd1cdbca7b8b2b6c4",
appId: "ww4df265003b43fa0d",
redirectUrI: encodeURIComponent("oysales.oywanhao.com"),
responseType: "code",
scope: "snsapi_base",
state: "ztest",
tail: "#wechat_redirect"
};
let url =
basicInfo.head +
"appid=" +
basicInfo.appId +
"&redirect_uri=" +
basicInfo.redirectUrI +
"&response_type=" +
basicInfo.responseType +
"&scope=" +
basicInfo.scope +
"&state=" +
basicInfo.state +
basicInfo.tail;
zlog("%c--->zTestPreAuthCode: Url =", "background: orange", url);
// window.location.href = url
},
zReadyGetUserFromId() { zReadyGetUserFromId() {
let postData = { let postData = {
userName: this.zcache.userId userName: this.zcache.userId
} }
getUserInfoByUserId(postData) getUserInfoByUserId(postData)
.then(res => { .then(res => {
// alert(`--->userInfoFromId: res = ${JSON.stringify(res.data)}`); if(res.data.length == 0) {
// this.zcache.userInfo = String(res.data[0].departmentId);
if(res.data[0].oyStallCode == '') {
alert('您当前没有绑定店铺') alert('您当前没有绑定店铺')
}else { }else {
this.zcache.storeId = res.data[0].oyStallCode // this.zcache.storeId = res.data[0].oyStallCode
// this.zcache.storeId = Number(res.data[0].stall); res.data.forEach(item => {
this.zReadySetVoucherList() this.zReadySetVoucherList(item.oyStallCode)
})
} }
}) })
.catch(err => {}) .catch(err => {})
}, },
// 获取优惠券列表 // 获取优惠券列表
zReadySetVoucherList() { zReadySetVoucherList(mdid) {
this.zReadyDelVoucherList();
const postData = { const postData = {
appCode: "0696", // j接口编码 appCode: "0696", // j接口编码
mdid: this.zcache.storeId mdid: mdid
} }
getVoucherList(postData).then(res => { getVoucherList(postData).then(res => {
if(res.result.coupons.length == 0) { console.log(res,'优惠券列表');
alert('当前店铺暂无优惠券可发放') if(res.errCode == 0) {
}else { if(res.result.coupons.length != 0) {
this.zVoucherSet(res.result.coupons) this.zlist.voucher.push(...res.result.coupons)
}
console.log(this.zlist.voucher,'this.zlist.voucher')
} }
}) })
.catch(err => { .catch(err => {
}) })
}, },
zReadyDelVoucherList() { // 推送链接
this.zVoucherDel() handlePush(link) {
this.zVoucherUrlDel()
},
zVoucherPick(inActiveId, inVoucherId) {
this.zcache.now.activeId = String(inActiveId)
this.zcache.now.voucherId = String(inVoucherId)
this.zVoucherUrlDel()
const postData = {
appCode: "0697",
action_id: Number(inActiveId),
coupon_id: Number(inVoucherId)
}
getVoucherWxUrl(postData).then(res => {
this.zVoucherUrlSet(res.result.link)
});
},
zpick(inMsgType, inUrl) {
switch (inMsgType) {
case "text":
wx.invoke(
"sendChatMessage",
{
msgtype: "text", //消息类型,必填
text: {
content: inUrl
}
},
function(res) {
if (res.err_msg == "sendChatMessage:ok") {
// alert("--->discount.vue: zpick: text 分享成功!")
} else if (res.err_msg != "sendChatMessage:ok") {
// alert('分享失败')
}
}
);
break;
case "h5":
// alert(`--->discount.vue: zpick: H5: IN.`);
// alert('zpick')
wx.invoke( wx.invoke(
"sendChatMessage", "sendChatMessage",
{ {
msgtype: "news", //消息类型,必填 msgtype: "news", //消息类型,必填
news: { news: {
link: `http://oysales.oywanhao.com/qrCode?Url=${inUrl}&activeId=${this.zcache.now.activeId}&voucherId=${this.zcache.now.voucherId}&unionId=1234`, //H5消息页面url 必填 link: `http://oysales.oywanhao.com/qrCode?Url=${link}`, //H5消息页面url 必填
title: "领取优惠券", //H5消息标题 title: "领取优惠券", //H5消息标题
desc: inUrl, //H5消息摘要 desc: '', //H5消息摘要
imgUrl: inUrl //H5消息封面图片URL imgUrl: '' //H5消息封面图片URL
} }
}, },
function(res) { function(res) {
// alert('sendChatMessage')
if (res.err_msg == "sendChatMessage:ok") { if (res.err_msg == "sendChatMessage:ok") {
// alert("--->discount.vue: zpick: h5 分享成功!")
} else if (res.err_msg != "sendChatMessage:ok") { } else if (res.err_msg != "sendChatMessage:ok") {
// alert(`--->discount.vue: zpick: h5 分享失败.`)
// alert(
// `--->discount.vue: zpick: h5 分享失败: res =${res.err_msg}`
// );
}
} }
);
break;
default:
break;
} }
)
}, },
zVoucherSet(inArray) {
// alert('zVoucherSet')
this.zlist.voucher = inArray;
}, // zVoucherPick(inActiveId, inVoucherId) {
zVoucherDel() { // this.zcache.now.activeId = String(inActiveId)
this.zlist.voucher = []; // this.zcache.now.voucherId = String(inVoucherId)
}, // this.zlist.voucherUrl = "";
zVoucherUrlSet(inData) {
this.zlist.voucherUrl = String(inData); // const postData = {
this.zpick('h5', String(inData)) // appCode: "0697",
}, // action_id: Number(inActiveId),
zVoucherUrlDel() { // coupon_id: Number(inVoucherId)
this.zlist.voucherUrl = ""; // }
}, // getVoucherWxUrl(postData).then(res => {
// console.log(res,'指向小程序的链接')
testEaPost() { // this.zlist.voucherUrl = String(res.result.link);
let postData = { // this.zpick('h5', String(inData))
appCode: "0696", // // this.zVoucherUrlSet(res.result.link)
mdid: 1 // });
}; // },
ApiEaActiveList(postData).then(res => {
// console.log(res); // zpick(inMsgType, inUrl) {
}); // switch (inMsgType) {
}, // case "text":
// wx.invoke(
buttonSingleMarketingClick() { // "sendChatMessage",
// this.$router.push(""); // {
}, // msgtype: "text", //消息类型,必填
buttonMainMarketingClick() { // text: {
this.$router.push("MainSale"); // content: inUrl
} // }
// },
// function(res) {
// if (res.err_msg == "sendChatMessage:ok") {
// // alert("--->discount.vue: zpick: text 分享成功!")
// } else if (res.err_msg != "sendChatMessage:ok") {
// // alert('分享失败')
// }
// }
// );
// break;
// case "h5":
// // alert(`--->discount.vue: zpick: H5: IN.`);
// // alert('zpick')
// wx.invoke(
// "sendChatMessage",
// {
// msgtype: "news", //消息类型,必填
// news: {
// link: `http://oysales.oywanhao.com/qrCode?Url=${inUrl}`, //H5消息页面url 必填
// title: "领取优惠券", //H5消息标题
// desc: inUrl, //H5消息摘要
// imgUrl: inUrl //H5消息封面图片URL
// }
// },
// function(res) {
// // alert('sendChatMessage')
// if (res.err_msg == "sendChatMessage:ok") {
// // alert("--->discount.vue: zpick: h5 分享成功!")
// } else if (res.err_msg != "sendChatMessage:ok") {
// // alert(`--->discount.vue: zpick: h5 分享失败.`)
// // alert(
// // `--->discount.vue: zpick: h5 分享失败: res =${res.err_msg}`
// // );
// }
// }
// );
// break;
// default:
// break;
// }
// },
// zVoucherUrlSet(inData) {
// this.zlist.voucherUrl = String(inData);
// this.zpick('h5', String(inData))
// },
// testEaPost() {
// let postData = {
// appCode: "0696",
// mdid: 1
// };
// ApiEaActiveList(postData).then(res => {
// // console.log(res);
// });
// },
// buttonSingleMarketingClick() {
// },
// buttonMainMarketingClick() {
// this.$router.push("MainSale");
// }
} }
}; };
</script> </script>
......
...@@ -97,39 +97,68 @@ export default { ...@@ -97,39 +97,68 @@ export default {
this.getAgentAuth(); this.getAgentAuth();
// this.zReadySetVoucherList() // this.zReadySetVoucherList()
}, },
mounted() {
},
methods: { methods: {
// 测试-获取预授权码
zTestPreAuthCode() {
const basicInfo = {
head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
// appId: "wwd1cdbca7b8b2b6c4",
appId: "ww4df265003b43fa0d",
redirectUrI: encodeURIComponent("oysales.oywanhao.com"),
responseType: "code",
scope: "snsapi_base",
state: "ztest",
tail: "#wechat_redirect"
};
let url =
basicInfo.head +
"appid=" +
basicInfo.appId +
"&redirect_uri=" +
basicInfo.redirectUrI +
"&response_type=" +
basicInfo.responseType +
"&scope=" +
basicInfo.scope +
"&state=" +
basicInfo.state +
basicInfo.tail;
zlog("%c--->zTestPreAuthCode: Url =", "background: orange", url);
// window.location.href = url
},
zReadyGetUserFromId() { zReadyGetUserFromId() {
let postData = { let postData = {
userName: this.zcache.userId userName: this.zcache.userId
} }
getUserInfoByUserId(postData) getUserInfoByUserId(postData)
.then(res => { .then(res => {
if(res.data.length == 0) { // alert(`--->userInfoFromId: res = ${JSON.stringify(res.data)}`);
// this.zcache.userInfo = String(res.data[0].departmentId);
if(res.data[0].oyStallCode == '') {
alert('您当前没有绑定店铺') alert('您当前没有绑定店铺')
}else { }else {
// this.zcache.storeId = res.data[0].oyStallCode this.zcache.storeId = res.data[0].oyStallCode
res.data.forEach(item => { // this.zcache.storeId = Number(res.data[0].stall);
this.zReadySetVoucherList(item.id) this.zReadySetVoucherList()
})
} }
}) })
.catch(err => {}) .catch(err => {})
}, },
// 获取优惠券列表 // 获取优惠券列表
zReadySetVoucherList(mdid) { zReadySetVoucherList() {
// this.zReadyDelVoucherList() this.zReadyDelVoucherList();
const postData = { const postData = {
appCode: "0696", // j接口编码 appCode: "0696", // j接口编码
mdid: mdid mdid: this.zcache.storeId
} }
getVoucherList(postData).then(res => { getVoucherList(postData).then(res => {
if(res.errCode == 0) { if(res.result.coupons.length == 0) {
if(res.result.coupons.length != 0) { alert('当前店铺暂无优惠券可发放')
this.zlist.voucher.push(...res.result.coupons) }else {
} this.zVoucherSet(res.result.coupons)
console.log(this.zlist.voucher,'this.zlist.voucher')
} }
}) })
.catch(err => { .catch(err => {
...@@ -143,7 +172,8 @@ export default { ...@@ -143,7 +172,8 @@ export default {
zVoucherPick(inActiveId, inVoucherId) { zVoucherPick(inActiveId, inVoucherId) {
this.zcache.now.activeId = String(inActiveId) this.zcache.now.activeId = String(inActiveId)
this.zcache.now.voucherId = String(inVoucherId) this.zcache.now.voucherId = String(inVoucherId)
this.zlist.voucherUrl = "";
this.zVoucherUrlDel()
const postData = { const postData = {
appCode: "0697", appCode: "0697",
...@@ -151,15 +181,13 @@ export default { ...@@ -151,15 +181,13 @@ export default {
coupon_id: Number(inVoucherId) coupon_id: Number(inVoucherId)
} }
getVoucherWxUrl(postData).then(res => { getVoucherWxUrl(postData).then(res => {
console.log(res,'指向小程序的链接') this.zVoucherUrlSet(res.result.link)
this.zlist.voucherUrl = String(res.result.lin);
this.zpick('h5', String(inData))
// this.zVoucherUrlSet(res.result.link)
}); });
}, },
zpick(inMsgType, inUrl) { zpick(inMsgType, inUrl) {
switch (inMsgType) { switch (inMsgType) {
case "text": case "text":
wx.invoke( wx.invoke(
"sendChatMessage", "sendChatMessage",
...@@ -186,7 +214,7 @@ export default { ...@@ -186,7 +214,7 @@ export default {
{ {
msgtype: "news", //消息类型,必填 msgtype: "news", //消息类型,必填
news: { news: {
link: `http://oysales.oywanhao.com/qrCode?Url=${inUrl}`, //H5消息页面url 必填 link: `http://oysales.oywanhao.com/qrCode?Url=${inUrl}&activeId=${this.zcache.now.activeId}&voucherId=${this.zcache.now.voucherId}&unionId=1234`, //H5消息页面url 必填
title: "领取优惠券", //H5消息标题 title: "领取优惠券", //H5消息标题
desc: inUrl, //H5消息摘要 desc: inUrl, //H5消息摘要
imgUrl: inUrl //H5消息封面图片URL imgUrl: inUrl //H5消息封面图片URL
...@@ -209,6 +237,11 @@ export default { ...@@ -209,6 +237,11 @@ export default {
break; break;
} }
}, },
zVoucherSet(inArray) {
// alert('zVoucherSet')
this.zlist.voucher = inArray;
},
zVoucherDel() { zVoucherDel() {
this.zlist.voucher = []; this.zlist.voucher = [];
}, },
...@@ -216,6 +249,10 @@ export default { ...@@ -216,6 +249,10 @@ export default {
this.zlist.voucherUrl = String(inData); this.zlist.voucherUrl = String(inData);
this.zpick('h5', String(inData)) this.zpick('h5', String(inData))
}, },
zVoucherUrlDel() {
this.zlist.voucherUrl = "";
},
testEaPost() { testEaPost() {
let postData = { let postData = {
appCode: "0696", appCode: "0696",
......
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