|
|
@@ -17,35 +17,14 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
query */
|
|
|
- onLoad: function () {
|
|
|
- const query = {
|
|
|
- q: 'https://www.cnd3b.com/qr?type=partner&fbrand=测试品牌名&tagentsid=36112'
|
|
|
- // q: 'https://www.cnd3b.com/qr?type=shop&fbrand=测试品牌名&tagentsid=36112'
|
|
|
- };
|
|
|
- if (query.q) {
|
|
|
- const q = decodeURIComponent(query.q) // 获取到二维码原始链接内容、
|
|
|
- const data = {
|
|
|
- type: q.slice(q.indexOf("type=") + 5, q.indexOf('&')),
|
|
|
- id: q.slice(q.lastIndexOf('=') + 1),
|
|
|
- name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&'))
|
|
|
- }
|
|
|
- if (!wx.getStorageSync('userData').token) {
|
|
|
- wx.setStorageSync('qrCodeMsg', data);
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '当前未登录,请登录后进入',
|
|
|
- showCancel: false,
|
|
|
- success: (res => {
|
|
|
- if (res.confirm) wx.navigateTo({
|
|
|
- url: '/pages/login/index',
|
|
|
- })
|
|
|
- })
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.setData({
|
|
|
- codeMsg: data
|
|
|
- })
|
|
|
- }
|
|
|
+ onLoad: function (query) {
|
|
|
+ console.log(query)
|
|
|
+ if (query.url) {
|
|
|
+ const q = decodeURIComponent(query.url);
|
|
|
+ return this.setDataUrl(q)
|
|
|
+ } else if (query.q) { // 获取到二维码原始链接内容、
|
|
|
+ const q = decodeURIComponent(query.q);
|
|
|
+ return this.setDataUrl(q)
|
|
|
} else {
|
|
|
this.setData({
|
|
|
codeMsg: wx.getStorageSync('qrCodeMsg')
|
|
|
@@ -54,6 +33,32 @@ Page({
|
|
|
console.log(wx.getStorageSync('qrCodeMsg'))
|
|
|
}
|
|
|
},
|
|
|
+ setDataUrl(url) {
|
|
|
+ let q = url;
|
|
|
+ console.log("q", q)
|
|
|
+ const data = {
|
|
|
+ type: q.slice(q.indexOf("type=") + 5, q.indexOf('&')),
|
|
|
+ id: q.slice(q.lastIndexOf('=') + 1),
|
|
|
+ name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&'))
|
|
|
+ }
|
|
|
+ if (!wx.getStorageSync('userData').token) {
|
|
|
+ wx.setStorageSync('qrCodeMsg', data);
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '当前未登录,请登录后进入',
|
|
|
+ showCancel: false,
|
|
|
+ success: (res => {
|
|
|
+ if (res.confirm) wx.navigateTo({
|
|
|
+ url: '/pages/login/index',
|
|
|
+ })
|
|
|
+ })
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ codeMsg: data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
/* 确定 */
|
|
|
confirm() {
|
|
|
const that = this;
|