You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
2.8 KiB
JavaScript
127 lines
2.8 KiB
JavaScript
// pages/scanQrcode/index.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
agencyUserId: '',
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
console.log(options)
|
|
this.setData({
|
|
agencyUserId: options.agencyUserId,
|
|
})
|
|
this.doScan();
|
|
},
|
|
doScan: function() {
|
|
var that = this;
|
|
wx.scanCode({
|
|
success (res) {
|
|
console.log(res.path)
|
|
let path = res.path;
|
|
if(path != null && path != '') {
|
|
let channelContactId = path.substring(path.lastIndexOf("=") + 1);
|
|
console.log(channelContactId, that.data.agencyUserId)
|
|
var url = '/bindAgency';
|
|
|
|
//发起网络请求
|
|
wx.request({
|
|
url: app.globalData.ip + url,
|
|
data: {
|
|
channelContactId: channelContactId,
|
|
agencyUserId: that.data.agencyUserId,
|
|
},
|
|
header: app.globalData.headers,
|
|
method: "GET",
|
|
success: function(res) {
|
|
console.log(res)
|
|
if(res.data.status == 200) {
|
|
console.log(res);
|
|
//绑定成功
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: '绑定成功',
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.data.msg,
|
|
})
|
|
}
|
|
setTimeout(function() {
|
|
wx.navigateToMiniProgram({
|
|
appId: 'wxaf516c59d925481f', //appid
|
|
path: '/pages/myAgent/index',//path
|
|
envVersion: 'trial', //开发版develop 开发版 trial 体验版 release 正式版
|
|
success(res) {
|
|
console.log('成功')
|
|
// 打开成功
|
|
}
|
|
})
|
|
},1000);
|
|
|
|
},
|
|
fail: function(res) {
|
|
console.log("操作失败");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
// onShareAppMessage: function () {
|
|
|
|
// }
|
|
}) |