Commit 6bee6688 authored by Z's avatar Z

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

parent 51a2c9eb
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"axios": "^0.19.1", "axios": "^0.19.1",
"core-js": "^3.4.4", "core-js": "^3.4.4",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"jssdk": "^0.0.1",
"vant": "^2.3.3", "vant": "^2.3.3",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
......
...@@ -5,7 +5,7 @@ export function getVoucherList(inData) { ...@@ -5,7 +5,7 @@ export function getVoucherList(inData) {
let postData = { let postData = {
args: inData args: inData
} }
alert(`--->PostToEA: ea.js: postData =${JSON.stringify(postData)}`) // alert(`--->PostToEA: ea.js: postData =${JSON.stringify(postData)}`)
return request({ return request({
url: '', url: '',
method: 'post', method: 'post',
......
...@@ -117,6 +117,11 @@ const routes = [ ...@@ -117,6 +117,11 @@ const routes = [
name: 'newInfo', name: 'newInfo',
component: () => import('@/views/message/newInfo') component: () => import('@/views/message/newInfo')
}, },
{
path: '/voucherInfo',
name: 'VoucherInfo',
component: () => import('@/views/voucherInfo/index')
},
// { // {
// path: '/about', // path: '/about',
// name: 'about', // name: 'about',
...@@ -133,19 +138,36 @@ const router = new VueRouter({ ...@@ -133,19 +138,36 @@ const router = new VueRouter({
routes routes
}) })
// const whiteList = ['/discount'] // const whiteList = ['/', '/home','/home/']
// router.beforeEach((to, from ,next) => { const whiteList = ['/discount', 'discount']
// if (whiteList.indexOf(to.path) !== -1) { // const whiteList = ['/discount', 'discount', '/voucherInfo', 'voucherInfo']
// next() router.beforeEach((to, from ,next) => {
// } else { // alert(`--->route: beforeEach: to =${JSON.stringify(to)}. from =${from}. next =${JSON.stringify(next)}`)
// if(sessionStorage.getItem('unionid')) { if(whiteList.indexOf(to.path) != -1) {
// next() // alert(`--->route: beforeEach: If: UnIn whiteList.`)
// } else { if(sessionStorage.getItem('zConfigWx') === 'Pass'){
// getUnionId(to) next()
// // 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) { // async function getUnionId (to) {
// await getXToken() // await getXToken()
......
This diff is collapsed.
...@@ -92,6 +92,7 @@ export default { ...@@ -92,6 +92,7 @@ export default {
// this.zTestGetNowUrlInfo(); // this.zTestGetNowUrlInfo();
}, },
created() { created() {
// alert(`--->home: created.`)
this.zReadyUserId() this.zReadyUserId()
// this.zReadyUserId(); // this.zReadyUserId();
// this.zTestGetNowUrlInfo(); // this.zTestGetNowUrlInfo();
...@@ -103,6 +104,7 @@ export default { ...@@ -103,6 +104,7 @@ export default {
"color: orange;", "color: orange;",
this.$route.query.code this.$route.query.code
); );
if (this.$route.query.code === undefined) { if (this.$route.query.code === undefined) {
this.zTestPreAuthCode(); this.zTestPreAuthCode();
} else { } else {
...@@ -126,6 +128,7 @@ export default { ...@@ -126,6 +128,7 @@ export default {
// 测试-获取预授权码 // 测试-获取预授权码
// redirectUrI: encodeURIComponent(location.href.split('#')[0]), // redirectUrI: encodeURIComponent(location.href.split('#')[0]),
zTestPreAuthCode() { zTestPreAuthCode() {
// alert(`--->home: zTestPreAuthCode: IN.`)
const basicInfo = { const basicInfo = {
head: "https://open.weixin.qq.com/connect/oauth2/authorize?", head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
appId: "wwd1cdbca7b8b2b6c4", appId: "wwd1cdbca7b8b2b6c4",
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div v-if="zlist.voucherUrl !== ''" class="voucherUrl"> <div v-if="zlist.voucherUrl !== ''" class="voucherUrl">
<div @click="zpick">小程序Url: {{ zlist.voucherUrl }}</div> <div @click="zpick">小程序Url: {{ zlist.voucherUrl }}</div>
</div> </div>
</div> --> </div>-->
</div> </div>
<div <div
...@@ -61,8 +61,15 @@ ...@@ -61,8 +61,15 @@
<div class="zListActive"> <div class="zListActive">
<div class="lists"> <div class="lists">
<div v-if="zlist.voucherUrl !== ''" class="voucherUrl"> <div v-if="zlist.voucherUrl !== ''" class="voucherUrl">
<div @click="zpick">小程序Url:</div> <div @click="zpick">小程序Url:{{ String(zlist.voucherUrl).slice(-2) }}</div>
<div @click="zpick">{{ zlist.voucherUrl }}</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> </div>
</div> </div>
...@@ -126,11 +133,13 @@ export default { ...@@ -126,11 +133,13 @@ export default {
}, },
created() { created() {
zlog("%c--->Created.", "color: orange"); zlog("%c--->Created.", "color: orange");
// alert(`--->discount: IN.`);
// configWx() // configWx()
this.zcache.userId = this.$route.params.userId; this.zcache.userId = this.$route.params.userId;
// zlog('%c--->userId =', this.zcache.userId) // zlog('%c--->userId =', this.zcache.userId)
this.zReadyGetUserFromId(); this.zReadyGetUserFromId();
// this.zReadySetVoucherList(); // this.zReadySetVoucherList();
this.getAgentAuth();
}, },
mounted() { mounted() {
// zlog("%c--->Mounted.", "color: orange"); // zlog("%c--->Mounted.", "color: orange");
...@@ -218,26 +227,84 @@ export default { ...@@ -218,26 +227,84 @@ export default {
zVoucherPick(inActiveId, inVoucherId) { zVoucherPick(inActiveId, inVoucherId) {
this.zVoucherUrlDel(); this.zVoucherUrlDel();
const postData = { const postData = {
appCode: "0697", appCode: "0697",
action_id: Number(inActiveId), action_id: Number(inActiveId),
coupon_id: Number(inVoucherId) coupon_id: Number(inVoucherId)
}; };
zlog("%c--->VoucherWxUrl: PD =", "background: red;", postData); zlog("%c--->VoucherWxUrl: PD =", "background: red;", postData);
getVoucherWxUrl(postData).then(res => { getVoucherWxUrl(postData).then(res => {
zlog("%c--->VoucherWxUrl: RD =", "background: green;", res); zlog("%c--->VoucherWxUrl: RD =", "background: green;", res);
this.zVoucherUrlSet(res.result.link); this.zVoucherUrlSet(res.result.link);
}); });
}, },
zpick() {
zlog( zpick(inMsgType, inUrl) {
"%c--->Click: Url =", alert(`--->discount.vue: zpick: IN.`);
"background: orange;",
String(this.zlist.voucherUrl) switch (inMsgType) {
); case "text":
window.wx.miniProgram.navigateTo({ wx.invoke(
url: this.zlist.voucherUrl "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}`
);
}
}
);
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) { zVoucherSet(inArray) {
this.zlist.voucher = 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: ...@@ -4789,6 +4789,11 @@ jsprim@^1.2.2:
json-schema "0.2.3" json-schema "0.2.3"
verror "1.10.0" 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: killable@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892" 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