小程序扫码

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

View File

@ -18,16 +18,6 @@ Page({
var areaid var areaid
if (options.id) { if (options.id) {
areaid = 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({ wx.showLoading({
title: '', title: '',

View File

@ -1,4 +1,5 @@
// pages/bind/binduser.js // pages/bind/binduser.js
var util = require('../../utils/util.js')
Page({ Page({
/** /**
@ -141,8 +142,57 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { 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 var equipmentid
if(options.id){ if(options.id){
equipmentid = 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({ wx.request({
url: getApp().globalData.serverUrl + 'api/equipment?a=detail&id=' + equipmentid, 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, examtestid: examtestid,
}) })
that.getTest() 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 // pages/main/main.js
var util = require('../../utils/util.js') //首屏
Page({ Page({
/** /**
@ -96,6 +97,7 @@ Page({
onShow: function () { onShow: function () {
var that = this var that = this
that.getNew() that.getNew()
if (getApp().globalData.userInfo.companyid == 2681) { if (getApp().globalData.userInfo.companyid == 2681) {
this.setData({ this.setData({
isGjjt: true, isGjjt: true,

View File

@ -16,16 +16,6 @@ Page({
var riskactid var riskactid
if (options.id) { if (options.id) {
riskactid = 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({ wx.showLoading({
title: '', title: '',

View File

@ -17,36 +17,19 @@ Page({
// let pxid = options.pxid // let pxid = options.pxid
console.log(options) console.log(options)
var that = this var that = this
wx.showLoading({
title: '加载中',
mask: true
})
let pxid let pxid
if(options.pxid){ if(options.pxid){
pxid = options.pxid pxid = options.pxid
let isfrom = 1
if(options.fromwx){
isfrom=0
}
that.setData({ that.setData({
pxid: pxid, pxid: pxid,
isfrom:1 isfrom:isfrom
}) })
that.getPx(pxid) 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)
}, },