小程序扫码

This commit is contained in:
caoqianming 2021-05-28 02:20:17 +08:00
parent 94324e1e38
commit 012da46336
8 changed files with 82 additions and 77 deletions

21
app.js
View File

@ -5,11 +5,12 @@ App({
that.mplogin()
setInterval(that.reflesh,10*60*1000)
},
mplogin: function ( redirect = 0) {
mplogin: function () {
var that = this;
wx.showLoading({
title: '账号自动登录中...',
icon:'none'
icon:'none',
mask:true
})
wx.login({
success: res => {
@ -42,7 +43,7 @@ App({
url: that.globalData.serverUrl + 'api/user?a=checkaqy',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
'Cookie': that.globalData.sessionId,
},
data: {},
success: res => {
@ -52,7 +53,14 @@ App({
}
});
wx.hideLoading()
if(redirect==1){
// var pages = getCurrentPages()
// var currentPage = pages[pages.length-1] //获取当前页面的对象
// var url = currentPage.route
if(that.globalData.hopeUrl){
wx.reLaunch({
url: that.globalData.hopeUrl,
})
}else{
wx.reLaunch({
url: '/pages/main/main',
})
@ -80,7 +88,7 @@ App({
url: that.globalData.serverUrl + 'api/check_session',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
'Cookie': that.globalData.sessionId,
},
success: res => {
// if(res.data.code!=1){
@ -115,7 +123,8 @@ App({
//serverUrl: 'http://192.168.0.103:8000/',
//serverUrl:'http://10.0.11.195:8000/',
timer:null,//定时器
sessionId:null
sessionId:null,
hopeUrl:null
},
})

View File

@ -18,16 +18,6 @@ Page({
var areaid
if (options.id) {
areaid = options.id
} else {
let q = decodeURIComponent(options.q)
if (q) {
// console.log("index 生命周期 onload url=" + q)
// console.log("index 生命周期 onload 参数 trainid=" + util.getQueryString(q, 'trainid'))
areaid = util.getQueryString(q, 'id')
this.setData({
fromWx: true
})
}
}
wx.showLoading({
title: '',

View File

@ -1,4 +1,5 @@
// pages/bind/binduser.js
var util = require('../../utils/util.js')
Page({
/**
@ -141,8 +142,57 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let url=null
if(options.q){
let q = decodeURIComponent(options.q)
if (q) {
if(q.indexOf("checktrain")!=-1){
let pxid = util.getQueryString(q, 'trainid')
url = '/pages/train/check?fromwx=1&pxid='+pxid
getApp().globalData.hopeUrl = url
}
else if(q.indexOf("equipment")!=-1){
let id = util.getQueryString(q, 'id')
url = '/pages/equipment/detail?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
else if(q.indexOf("riskact")!=-1){
let id = util.getQueryString(q, 'id')
url = '/pages/riskact/detail?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
else if(q.indexOf("area")!=-1){
let id = util.getQueryString(q, 'id')
url = '/pages/area/detail?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
else if(q.indexOf("examtest")!=-1){
let id = util.getQueryString(q, 'id')
url = '/pages/examtest/note?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
else if(q.indexOf("safelist")!=-1){
let id = util.getQueryString(q, 'id')
url = '/pages/safelist/index?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
}
}
if(getApp().globalData.sessionId){
if(url){
wx.reLaunch({
url: url,
})
}else{
wx.reLaunch({
url: '/pages/main/main',
})
}
return
}
// getApp().mplogin('/pages/main/main')
},
/**

View File

@ -16,16 +16,6 @@ Page({
var equipmentid
if(options.id){
equipmentid = options.id
}else{
let q = decodeURIComponent(options.q)
if (q) {
// console.log("index 生命周期 onload url=" + q)
// console.log("index 生命周期 onload 参数 trainid=" + util.getQueryString(q, 'trainid'))
equipmentid = util.getQueryString(q, 'id')
this.setData({
fromWx:true
})
}
}
wx.request({
url: getApp().globalData.serverUrl + 'api/equipment?a=detail&id=' + equipmentid,
@ -43,6 +33,9 @@ Page({
});
},
getDetail: function() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -27,18 +27,6 @@ Page({
examtestid: examtestid,
})
that.getTest()
} else {
let q = decodeURIComponent(options.q)
if (q) {
examtestid = util.getQueryString(q, 'id')
that.setData({
examtestid:examtestid,
fromWx: true
})
setTimeout(function () {
that.getTest()
}, 1500);
}
}
},

View File

@ -1,4 +1,5 @@
// pages/main/main.js
var util = require('../../utils/util.js') //首屏
Page({
/**
@ -96,6 +97,7 @@ Page({
onShow: function () {
var that = this
that.getNew()
if (getApp().globalData.userInfo.companyid == 2681) {
this.setData({
isGjjt: true,

View File

@ -16,16 +16,6 @@ Page({
var riskactid
if (options.id) {
riskactid = options.id
} else {
let q = decodeURIComponent(options.q)
if (q) {
// console.log("index 生命周期 onload url=" + q)
// console.log("index 生命周期 onload 参数 trainid=" + util.getQueryString(q, 'trainid'))
riskactid = util.getQueryString(q, 'id')
this.setData({
fromWx: true
})
}
}
wx.showLoading({
title: '',

View File

@ -17,36 +17,19 @@ Page({
// let pxid = options.pxid
console.log(options)
var that = this
wx.showLoading({
title: '加载中',
mask: true
})
let pxid
if(options.pxid){
pxid = options.pxid
let isfrom = 1
if(options.fromwx){
isfrom=0
}
that.setData({
pxid: pxid,
isfrom:1
isfrom:isfrom
})
that.getPx(pxid)
}else{
let q = decodeURIComponent(options.q)
if (q) {
// console.log("index 生命周期 onload url=" + q)
// console.log("index 生命周期 onload 参数 trainid=" + util.getQueryString(q, 'trainid'))
pxid = util.getQueryString(q, 'trainid')
that.setData({
pxid: pxid,
isfrom: 0
})
setTimeout(function () {
that.getPx(pxid)
}, 1500);
}
}
console.log(pxid)
},