Commit 58f5213c authored by xd's avatar xd

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

parent 766f1d3d
<template>
<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-cell-group >
<van-cell v-for="(item,index) in list" :key="index" >
......@@ -20,27 +22,32 @@
</template>
<script>
import { getStoreList } from "@/api/sidebar/voucher"
import { getStoreList,getMemberListByCode } from "@/api/sidebar/voucher"
import axios from "axios";
import { log } from 'util';
export default {
data() {
return {
radio: '',
userId: '',
list: []
list: [],
overlayShow: false,
oyStallCode: ''
}
},
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
}else {
this.userId = sessionStorage.getItem('userId')
}
}
this.radio = sessionStorage.getItem('oyStallCode')
// this.radio = 111
this.getList()
// this.userId = '10000190'
},
methods: {
getList() {
let params = {
user_id: this.userId
}
......@@ -49,20 +56,169 @@ export default {
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) {
console.log(val,'修改后的oyStallCode')
this.overlayShow = true
console.log(val,'修改后的oyStallCode')
this.oyStallCode = val
sessionStorage.setItem('oyStallCode',val)
let obj = this.list.find(function (obj) {
return obj.oyStallCode == val
})
console.log(obj,'obj')
})
sessionStorage.setItem("barName", obj.name)
this.getAllNewFans(val)
}
}
}
</script>
<style scoped>
.ld >>> .van-loading__text {
color: #fff;
}
.ld {
z-index: 1000;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.container {
height: auto;
background-color: #fff;
......
......@@ -94,7 +94,7 @@ export default {
},
handlePushInfo() {
if(this.info == 1) {
this.$router.push('pushStoreInfo')
this.$router.push('noSet')
}else {
let url = `http://oysales.oywanhao.com:8087/counterPageHome?oyStallCode=${this.oyStallCode}`
wx.invoke("shareToExternalContact", {
......
......@@ -5,13 +5,22 @@
<van-cell-group class="all">
<van-cell title="欧亚活动编码" style="font-size:14px;">
<template slot="default">
<van-field
v-model="addForm.cxcode"
placeholder="请输入欧亚活动编码"
class="right"
style="font-size:14px;"
/>
</template>
<div class="npbr">
<van-field
:value="addForm.cxcode"
placeholder="请输入欧亚活动编码"
class="right"
readonly
style="font-size:14px;"
@touchstart.native.stop="codeShow = true"
/>
<van-number-keyboard
v-model="addForm.cxcode"
:show="codeShow"
@blur="codeShow = false"
/>
</div>
</template>
</van-cell>
<van-cell title="商户类型" style="font-size:14px;">
<template slot="default">
......@@ -70,21 +79,7 @@
</van-cell>
<van-cell title="金额" style="font-size:14px;">
<template slot="default">
<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>
<van-stepper v-model="addForm.unit" step="1"/>
</template>
</van-cell>
<van-cell title="开始时间" style="font-size:14px;">
......@@ -101,6 +96,7 @@
<van-datetime-picker
v-model="startTime"
type="date"
:min-date="minStartDate"
@cancel="startShow = false"
@confirm="handleStartTime"
@change="startTimeChange"
......@@ -123,6 +119,7 @@
<van-datetime-picker
v-model="endTime"
type="date"
:min-date="minEndDate"
@cancel="endShow = false"
@confirm="handleEndTime"
@change="endTimeChange"
......@@ -141,36 +138,28 @@
/>
</template>
</van-cell>
<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;">
<van-cell title="优惠券ID" style="font-size:14px;">
<template slot="default">
<div class="npbr">
<van-field
class="right noborder"
readonly
clickable
:value="addForm.limitOfUse"
placeholder="请输入总限制次数"
@touchstart.native.stop="allLimitShow = true"
:value="addForm.couponId"
placeholder="请输入优惠券ID"
@touchstart.native.stop="unitShow = true"
/>
<van-number-keyboard
v-model="addForm.limitOfUse"
:show="allLimitShow"
:maxlength="6"
@blur=" allLimitShow = false"
v-model="addForm.couponId "
:show="unitShow"
@blur="unitShow = false"
/>
</div>
</div>
</template>
</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;">
<template slot="default">
<van-field
......@@ -182,66 +171,16 @@
</template>
</van-cell>
<van-cell title="编码券使用上限(次)" style="font-size:14px;">
<template slot="default">
<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-stepper v-model="addForm.usageMax" step="1"/>
</van-cell>
</van-cell-group>
<div class="title">编码券使用规则明细</div>
<van-cell-group class="all">
<van-cell title="销售金额" style="font-size:14px;">
<template slot="default">
<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 title="销售金额" style="font-size:14px;" >
<van-stepper v-model="addForm.salesAmount" step="1" :min="addForm.usageAmount"/>
</van-cell>
<van-cell title="用券金额" style="font-size:14px;">
<template slot="default">
<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-stepper v-model="addForm.usageAmount" step="1"/>
</van-cell>
</van-cell-group>
</div>
......@@ -258,6 +197,8 @@ import { addCoupon } from "@/api/sidebar/voucher"
export default {
data() {
return {
minStartDate: null,
minEndDate: null,
allLimitShow: false,
show: false,
show2: false,
......@@ -275,6 +216,7 @@ export default {
endDate: '',
cxsh: '',
cxshShow: false,
codeShow: false,
//
addForm: {
cxcode: '',
......@@ -291,7 +233,6 @@ export default {
usageMax: '',
salesAmount: '',
usageAmount: '',
usageMax: '',
deptId: '',
cxcode: ''
},
......@@ -304,7 +245,9 @@ export default {
};
},
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: {
timeFormat(time) {
......@@ -412,7 +355,7 @@ export default {
addCoupon(this.addForm).then(res => {
console.log(res,'res')
if(res.errorCode == "fail") {
this.$toast("活动编码不能重复!")
this.$toast("活动创建失败!")
}else {
this.$router.push('coupon')
}
......
......@@ -74,24 +74,6 @@
</div>
</div>
</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 class="mores-title">查看更多</div>
<img class="mores-icon" :src="test.cache.arrowRightDark" />
......@@ -232,10 +214,7 @@ export default {
};
},
created() {
// this.overlayShow = true
this.checkNowMenuBar()
// this.zcache.userId = 'ShanDian'
// this.getUserFromId(this.zcache.userId)
if (sessionStorage.getItem("userId")) {
if (sessionStorage.getItem("avatar")) {
this.test.manInfo.logoUrl = sessionStorage.getItem("avatar");
......@@ -307,14 +286,17 @@ export default {
}
return new Promise((resolve, reject) => {
axios({
url:
"http://139.155.48.151:8085/workWx/auth/user/get?userId=" + this.zcache.userId,
url: "http://139.155.48.151:8085/workWx/auth/user/get?userId=" + this.zcache.userId,
method: "get",
headers: headerData
})
.then(res => {
sessionStorage.setItem("avatar", res.data.data.avatar)
resolve(res.data.data.avatar)
.then(res => {
if(res.data != null) {
sessionStorage.setItem("avatar", res.data.data.avatar)
resolve(res.data.data.avatar)
}else {
resolve('')
}
})
.catch(err => {
reject(err)
......@@ -336,8 +318,28 @@ export default {
headers: headerData
})
.then(res => {
sessionStorage.setItem("personalFan", res.data.data.length)
resolve(res.data.data.length)
console.log(res);
if(res.data.data != null) {
if(res.data != []) {
sessionStorage.setItem("personalFan", 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 => {
reject(err)
......@@ -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() {
let params = {
oyStallCode: this.oyStallCode
......@@ -404,7 +392,6 @@ export default {
JsonStr.userid = [userId];
} else {
JsonStr.userid = userId
console.log(userId,'拿到吗')
}
let timeNow = Math.round(new Date() / 1000);
JsonStr.start_time = timeNow - 24 * 60 * 60;
......@@ -424,17 +411,23 @@ export default {
let data = JSON.parse(res.data.data);
if (flag == 1) {
// 获取个人新增粉丝
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);
resolve(newFans)
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,'全部粉丝');
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);
resolve(allNewFans)
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 => {
......@@ -470,12 +463,7 @@ export default {
this.test.barInfo.newFans = res[3]
this.test.barInfo.allNewFans = res[4]
this.test.manInfo.barName = res[5]
this.overlayShow = false
// this.getAddFans(2,this.memberList).then(res => {
// this.test.barInfo.allNewFans = res
// this.overlayShow = false
// })
//
this.overlayShow = false
})
},
checkNowMenuBar() {
......@@ -604,7 +592,9 @@ export default {
});
},
// 获取店铺code
getUserFromId(id) {
getUserFromId(id) {
console.log(1);
let userName = id;
getUserInfoByUserId({ userName }).then(res => {
sessionStorage.setItem("oyStallCode", res.data[0].oyStallCode)
......
......@@ -130,7 +130,8 @@ export default {
{ max: 50, message: "长度在50个字符以内", trigger: "blur" }
],
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: {
value: 'id',
......
......@@ -134,7 +134,8 @@ export default {
{ max: 50, message: "长度在50个字符以内", trigger: "blur" },
],
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: {
value: 'id',
......
......@@ -137,7 +137,6 @@
font-size: 2rem;
font-weight: bold;
}
.main>.cards>.card02>.tips>.rules {}
.main>.cards>.card02>.tips>.rules>.rule {
font-size: 2rem;
}
......
......@@ -97,43 +97,72 @@ export default {
this.getAgentAuth();
// this.zReadySetVoucherList()
},
mounted() {
},
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() {
let postData = {
userName: this.zcache.userId
}
getUserInfoByUserId(postData)
.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('您当前没有绑定店铺')
}else {
// this.zcache.storeId = res.data[0].oyStallCode
res.data.forEach(item => {
this.zReadySetVoucherList(item.id)
})
this.zcache.storeId = res.data[0].oyStallCode
// this.zcache.storeId = Number(res.data[0].stall);
this.zReadySetVoucherList()
}
})
.catch(err => {})
},
// 获取优惠券列表
zReadySetVoucherList(mdid) {
// this.zReadyDelVoucherList()
zReadySetVoucherList() {
this.zReadyDelVoucherList();
const postData = {
appCode: "0696", // j接口编码
mdid: mdid
mdid: this.zcache.storeId
}
getVoucherList(postData).then(res => {
if(res.errCode == 0) {
if(res.result.coupons.length != 0) {
this.zlist.voucher.push(...res.result.coupons)
}
console.log(this.zlist.voucher,'this.zlist.voucher')
}
})
.catch(err => {
})
if(res.result.coupons.length == 0) {
alert('当前店铺暂无优惠券可发放')
}else {
this.zVoucherSet(res.result.coupons)
}
})
.catch(err => {
})
},
zReadyDelVoucherList() {
this.zVoucherDel()
......@@ -143,7 +172,8 @@ export default {
zVoucherPick(inActiveId, inVoucherId) {
this.zcache.now.activeId = String(inActiveId)
this.zcache.now.voucherId = String(inVoucherId)
this.zlist.voucherUrl = "";
this.zVoucherUrlDel()
const postData = {
appCode: "0697",
......@@ -151,15 +181,13 @@ export default {
coupon_id: Number(inVoucherId)
}
getVoucherWxUrl(postData).then(res => {
console.log(res,'指向小程序的链接')
this.zlist.voucherUrl = String(res.result.lin);
this.zpick('h5', String(inData))
// this.zVoucherUrlSet(res.result.link)
this.zVoucherUrlSet(res.result.link)
});
},
zpick(inMsgType, inUrl) {
switch (inMsgType) {
case "text":
wx.invoke(
"sendChatMessage",
......@@ -186,7 +214,7 @@ export default {
{
msgtype: "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消息标题
desc: inUrl, //H5消息摘要
imgUrl: inUrl //H5消息封面图片URL
......@@ -209,6 +237,11 @@ export default {
break;
}
},
zVoucherSet(inArray) {
// alert('zVoucherSet')
this.zlist.voucher = inArray;
},
zVoucherDel() {
this.zlist.voucher = [];
},
......@@ -216,6 +249,10 @@ export default {
this.zlist.voucherUrl = String(inData);
this.zpick('h5', String(inData))
},
zVoucherUrlDel() {
this.zlist.voucherUrl = "";
},
testEaPost() {
let postData = {
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