Commit 6bee6688 authored by Z's avatar Z

Z: Dot: Next: Create QRCode in views/voucherInfo/index.vue

parent 51a2c9eb
......@@ -14,6 +14,7 @@
"axios": "^0.19.1",
"core-js": "^3.4.4",
"js-md5": "^0.7.3",
"jssdk": "^0.0.1",
"vant": "^2.3.3",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
......
ybf_wx/public/mainSale/test-city.png

3.42 MB | W: | H:

ybf_wx/public/mainSale/test-city.png

730 KB | W: | H:

ybf_wx/public/mainSale/test-city.png
ybf_wx/public/mainSale/test-city.png
ybf_wx/public/mainSale/test-city.png
ybf_wx/public/mainSale/test-city.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -5,7 +5,7 @@ export function getVoucherList(inData) {
let postData = {
args: inData
}
alert(`--->PostToEA: ea.js: postData =${JSON.stringify(postData)}`)
// alert(`--->PostToEA: ea.js: postData =${JSON.stringify(postData)}`)
return request({
url: '',
method: 'post',
......
......@@ -117,6 +117,11 @@ const routes = [
name: 'newInfo',
component: () => import('@/views/message/newInfo')
},
{
path: '/voucherInfo',
name: 'VoucherInfo',
component: () => import('@/views/voucherInfo/index')
},
// {
// path: '/about',
// name: 'about',
......@@ -133,19 +138,36 @@ const router = new VueRouter({
routes
})
// const whiteList = ['/discount']
// router.beforeEach((to, from ,next) => {
// if (whiteList.indexOf(to.path) !== -1) {
// next()
// } else {
// if(sessionStorage.getItem('unionid')) {
// next()
// } else {
// getUnionId(to)
// // next()
// }
// }
// })
// const whiteList = ['/', '/home','/home/']
const whiteList = ['/discount', 'discount']
// const whiteList = ['/discount', 'discount', '/voucherInfo', 'voucherInfo']
router.beforeEach((to, from ,next) => {
// alert(`--->route: beforeEach: to =${JSON.stringify(to)}. from =${from}. next =${JSON.stringify(next)}`)
if(whiteList.indexOf(to.path) != -1) {
// alert(`--->route: beforeEach: If: UnIn whiteList.`)
if(sessionStorage.getItem('zConfigWx') === 'Pass'){
next()
} else {
configWx(to)
}
} else {
// alert(`--->route: beforeEach: If: In whiteList.`)
next()
}
// if (whiteList.indexOf(to.path) !== -1) {
// next()
// } else {
// if(sessionStorage.getItem('unionid')) {
// next()
// } else {
// getUnionId(to)
// // next()
// }
// }
})
// async function getUnionId (to) {
// await getXToken()
......
......@@ -52,26 +52,37 @@ function isIosOrAndroid() {
Vue.prototype.getAgentAuth = function () {
zlog('%c--->IN: getAgentAuth: location.href =', 'color: orange;', location.href)
// alert(`--->zCommon.js: IN.`)
let postData = {
// businessId: sessionStorage.getItem('businessId'),
// pageUrl: encodeURIComponent(this.isIosOrAndroid() === 'android' ? location.href.split('#')[0] : window.initUrl)
pageUrl: encodeURIComponent(location.href.split('#')[0])
}
// alert(`--->zCommon.js: postData =${JSON.stringify(postData)}`)
let header = {
token: sessionStorage.getItem('XToken'),
corpId: INFO.corpId,
agentId: INFO.agentId,
}
// alert(`--->zCommon.js: header =${JSON.stringify(header)}`)
console.log('%c--->getAgentAuth: getJsSdkSignature: PD =', 'background: orange;', header)
wxRequest('/workWx/auth/base/getJsSdkSignature', qs.stringify(postData), header).then(res => {
wxRequest('/workWx/auth/base/getJsSdkSignature', qs.stringify(postData), header)
.then(res => {
// alert(`--->zCommon.js: getJsSdkSignature: then.`)
// alert(`--->zCommon.js: getJsSdkSignature: then: res =${JSON.stringify(res)}`)
if (res.result === 'success') {
console.log('%c--->getAgentAuth: getJsSdkSignature: RD =', 'background: limegreen;', res.data)
// alert(`--->zCommon.js: getJsSdkSignature: then: res.result === "success".`)
let config = res.data
wx.config({
beta: true,
debug: false, //调试的时候可以开启
debug: true, //调试的时候可以开启
appId: config.jsApiSignature.appId, // 必填,公众号的唯一标识
timestamp: config.jsApiSignature.timestamp, // 必填,生成签名的时间戳
nonceStr: config.jsApiSignature.nonceStr, // 必填,生成签名的随机串
......@@ -79,8 +90,11 @@ Vue.prototype.getAgentAuth = function () {
// 根据自己的需求,填写 jsapilist 内容
jsApiList: ['agentConfig']
})
// alert(`--->zCommon.js: getJsSdkSignature: then: wx.config: end.`)
wx.ready(function () {
zlog('%c--->getAgentAuth: getJsSdkSignature: Ready.', 'color: red;')
// alert(`--->zCommon.js: getJsSdkSignature: then: wx.ready: IN.`)
// JS-SDK配置信息验证失败时会进入此方法
wx.error(function (res) {
......@@ -88,14 +102,22 @@ Vue.prototype.getAgentAuth = function () {
})
// 配置成功后验证API接口在当前客户端是否支持:判断当前客户端版本是否支持指定JS接口
wx.checkJsApi({
wx.checkJsApi(
{
jsApiList: ['agentConfig', 'sendChatMessage'],
success: function (res) {
// alert(`--->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: success.`)
// alert(`--->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: success. res =${JSON.stringify(res)}`)
if (res.errMsg != "checkJsApi:ok") {
alert("JS-SDK接口检测失败:" + JSON.stringify(res));
return false;
} else {
wxRequest('/workWx/auth/base/getAgentJsSdkSignature', qs.stringify(data), header).then(res => {
wxRequest('/workWx/auth/base/getAgentJsSdkSignature', qs.stringify(postData), header)
.then(res => {
// alert(`!-->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: getAgentJsSdkSignature: res.`)
// alert(`!-->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: getAgentJsSdkSignature: res =${JSON.stringify(res)}`)
// alert('getAgentJsSdkSignature:ok')
if (res.result === 'success') {
let agentConfig = res.data
......@@ -107,6 +129,8 @@ Vue.prototype.getAgentAuth = function () {
signature: agentConfig.agentJsApiSignature.signature,// 必填,签名,agentConfig所以为应用签名
jsApiList: ['sendChatMessage'], //必填
success: function (res) {
// alert(`!-->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: getAgentJsSdkSignature: wx.agentConfig: res.`)
// alert(`!-->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: getAgentJsSdkSignature: wx.agentConfig: res =${JSON.stringify(res)}`)
// alert('agentConfig:ok')
// router.push(to)
// 回调
......@@ -124,9 +148,14 @@ Vue.prototype.getAgentAuth = function () {
}
})
.catch(err => {
// alert(`--->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: getAgentJsSdkSignature: err.`)
// alert(`--->zCommon.js: getJsSdkSignature: then: wx.ready: wx.checkJsApi: getAgentJsSdkSignature: err =${JSON.stringify(err)}`)
})
}
}
})
}
)
})
} else {
this.$message({
......@@ -134,7 +163,10 @@ Vue.prototype.getAgentAuth = function () {
message: res.errorMsg
})
}
}).catch(err => {
})
.catch(err => {
// alert(`--->zCommon.js: getJsSdkSignature: catch.`)
// alert(`--->zCommon.js: getJsSdkSignature: catch: err =${JSON.stringify(err)}`)
console.log(err, 'err')
})
}
......@@ -161,7 +193,7 @@ function configWx(to) {
nonceStr: config.jsApiSignature.nonceStr, // 必填,生成签名的随机串
signature: config.jsApiSignature.signature, // 必填,签名
// 根据自己的需求,填写 jsapilist 内容
jsApiList: ['agentConfig','getCurExternalContact']
jsApiList: ['agentConfig', 'getCurExternalContact']
})
wx.ready(function () {
// JS-SDK配置信息验证失败时会进入此方法
......@@ -172,6 +204,9 @@ function configWx(to) {
wx.checkJsApi({
jsApiList: ['agentConfig', 'getCurExternalContact'],
success: function (res) {
// alert(`--->wx.checkJsApi: success. res =${JSON.stringify(res)}`);
// router.push(to)
if (res.errMsg != "checkJsApi:ok") {
alert("JS-SDK接口检测失败:" + JSON.stringify(res));
return false;
......@@ -179,9 +214,18 @@ function configWx(to) {
}
})
wxRequest('/workWx/auth/base/getAgentJsSdkSignature', qs.stringify(data), header).then(res => {
// alert(`--->configWx/getJsSdkSignature: next: getAgentJsSdkSignature.`)
// alert(`--->configWx/getJsSdkSignature: next: getAgentJsSdkSignature: data =${qs.stringify(postData)}. header =${JSON.stringify(header)}`)
wxRequest('/workWx/auth/base/getAgentJsSdkSignature', qs.stringify(postData), header)
.then(res => {
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: then: IN.`)
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: then: res =${JSON.stringify(res)}`)
if (res.result == 'success') {
let agentConfig = res.data
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: then: res.result == 'success'.`)
wx.agentConfig({
corpid: agentConfig.agentJsApiSignature.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: agentConfig.agentId, // 必填,企业微信的应用id
......@@ -191,14 +235,21 @@ function configWx(to) {
jsApiList: ['getCurExternalContact'], //必填
success: function (res) {
// alert('agentConfig:ok')
// router.push(to)
getUnionid(to)
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: then: agentConfig: res =${res}`)
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: then: agentConfig: to =${JSON.stringify(to)}`)
sessionStorage.setItem('zConfigWx', 'Pass')
router.push(to)
// getUnionid(to)
// 回调
//1、发起申请申请时后,审批状态发生变化时
//2、发起申请申请时后,在“审批中”状态,有任意审批人进行审批操作时
// alert('wx.agentConfig 回调'+res.errMsg);
},
fail: function (res) {
// alert(`--->A: err =${res}`)
// alert(`--->A: err =${JSON.stringify(res)}`)
if (res.errMsg.indexOf('is not a function') > -1) {
alert('<i class="weui-icon-warn">版本过低请升级</i>')
}
......@@ -206,6 +257,10 @@ function configWx(to) {
})
}
})
.catch(err => {
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: catch: err.`)
// alert(`--->configWx/getJsSdkSignature/getAgentJsSdkSignature: catch: err =${JSON.stringify(err)}`)
})
})
} else {
this.$message({
......
......@@ -92,6 +92,7 @@ export default {
// this.zTestGetNowUrlInfo();
},
created() {
// alert(`--->home: created.`)
this.zReadyUserId()
// this.zReadyUserId();
// this.zTestGetNowUrlInfo();
......@@ -103,6 +104,7 @@ export default {
"color: orange;",
this.$route.query.code
);
if (this.$route.query.code === undefined) {
this.zTestPreAuthCode();
} else {
......@@ -126,6 +128,7 @@ export default {
// 测试-获取预授权码
// redirectUrI: encodeURIComponent(location.href.split('#')[0]),
zTestPreAuthCode() {
// alert(`--->home: zTestPreAuthCode: IN.`)
const basicInfo = {
head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
appId: "wwd1cdbca7b8b2b6c4",
......
......@@ -28,7 +28,7 @@
<div v-if="zlist.voucherUrl !== ''" class="voucherUrl">
<div @click="zpick">小程序Url: {{ zlist.voucherUrl }}</div>
</div>
</div> -->
</div>-->
</div>
<div
......@@ -61,8 +61,15 @@
<div class="zListActive">
<div class="lists">
<div v-if="zlist.voucherUrl !== ''" class="voucherUrl">
<div @click="zpick">小程序Url:</div>
<div @click="zpick">{{ zlist.voucherUrl }}</div>
<div @click="zpick">小程序Url:{{ String(zlist.voucherUrl).slice(-2) }}</div>
<div
v-if="String(zlist.voucherUrl).slice(-2) === '97'"
@click="zpick('text', String(zlist.voucherUrl))"
>{{ zlist.voucherUrl }}</div>
<div
v-if="String(zlist.voucherUrl).slice(-2) !== '97'"
@click="zpick('h5', String(zlist.voucherUrl))"
>{{ zlist.voucherUrl }}</div>
</div>
</div>
</div>
......@@ -126,11 +133,13 @@ export default {
},
created() {
zlog("%c--->Created.", "color: orange");
// alert(`--->discount: IN.`);
// configWx()
this.zcache.userId = this.$route.params.userId;
// zlog('%c--->userId =', this.zcache.userId)
this.zReadyGetUserFromId();
// this.zReadySetVoucherList();
this.getAgentAuth();
},
mounted() {
// zlog("%c--->Mounted.", "color: orange");
......@@ -218,26 +227,84 @@ export default {
zVoucherPick(inActiveId, inVoucherId) {
this.zVoucherUrlDel();
const postData = {
appCode: "0697",
action_id: Number(inActiveId),
coupon_id: Number(inVoucherId)
};
zlog("%c--->VoucherWxUrl: PD =", "background: red;", postData);
getVoucherWxUrl(postData).then(res => {
zlog("%c--->VoucherWxUrl: RD =", "background: green;", res);
this.zVoucherUrlSet(res.result.link);
});
},
zpick() {
zlog(
"%c--->Click: Url =",
"background: orange;",
String(this.zlist.voucherUrl)
zpick(inMsgType, inUrl) {
alert(`--->discount.vue: zpick: IN.`);
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(
`--->discount.vue: zpick: text 分享失败: res =${res.err_msg}`
);
window.wx.miniProgram.navigateTo({
url: this.zlist.voucherUrl
});
}
}
);
break;
case "h5":
wx.invoke(
"sendChatMessage",
{
msgtype: "text", //消息类型,必填
news: {
link: "http://qywx2.100smartdata.com/voucherInfo", //H5消息页面url 必填
title: "Z: h5消息标题", //H5消息标题
desc: inUrl, //H5消息摘要
// imgUrl: "http://qywx2.100smartdata.com/hi.jpg" //H5消息封面图片URL
imgUrl: inUrl //H5消息封面图片URL
}
},
function(res) {
if (res.err_msg == "sendChatMessage:ok") {
alert("--->discount.vue: zpick: h5 分享成功!");
} else if (res.err_msg != "sendChatMessage:ok") {
alert(`--->discount.vue: zpick: h5 分享失败: res =${res}`);
alert(
`--->discount.vue: zpick: h5 分享失败: res =${res.err_msg}`
);
}
}
);
break;
default:
break;
}
// zlog(
// "%c--->Click: Url =",
// "background: orange;",
// String(this.zlist.voucherUrl)
// );
// window.wx.miniProgram.navigateTo({
// url: this.zlist.voucherUrl
// });
},
zVoucherSet(inArray) {
this.zlist.voucher = inArray;
......
<template>
<div class="main">
<div>Hola World.</div>
<img src="../../assets/qrcode.jpeg" alt="Please Scan QRCode." />
<button @click="redirect">redirect</button>
</div>
</template>
<script>
const zlog = console.log.bind(console);
export default {
name: "voucherInfo",
data() {
return {};
},
created() {
alert("--->voucherInfo: Created.");
// wx.miniProgram.navigateTo({url: '/path/to/page'})
// wx.miniProgram.navigateTo({url: '/pages/coupon/detail/detailid=100000338&actionid=97'})
},
mounted() {},
methods: {
redirect() {
// wx.miniProgram.navigateTo({url: '/pages/coupon/detail/detailid=100000338&actionid=97'})
alert('--->voucherInfo: redirect: IN.')
window.location.href = 'https://mp.weixin.qq.com/a/~PLEzZIqxoasdl5QDu_HZEw~~';
// wx.navigateToMiniProgram({
// appId: "1000004",
// path: "page/index/index?id=123",
// extraData: {
// foo: "bar"
// },
// success(res) {
// alert(`--->voucherInfo: navigateToMiniProgram: res.`)
// alert(`--->voucherInfo: navigateToMiniProgram: res =${JSON.stringify(res)}`)
// // 打开成功
// },
// fail(err) {
// alert(`--->voucherInfo: navigateToMiniProgram: err.`)
// alert(`--->voucherInfo: navigateToMiniProgram: err =${JSON.stringify(err)}`)
// // 打开成功
// }
// });
}
}
};
</script>
<style scoped>
.main {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
</style>
......@@ -4789,6 +4789,11 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.10.0"
jssdk@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/jssdk/-/jssdk-0.0.1.tgz#923d8163c63e223f8d60f1305014201964e1aaf0"
integrity sha1-kj2BY8Y+Ij+NYPEwUBQgGWThqvA=
killable@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892"
......
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