diff --git a/app.js b/app.js index a7c63db..07c1025 100644 --- a/app.js +++ b/app.js @@ -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,12 +53,19 @@ App({ } }); wx.hideLoading() - if(redirect==1){ - wx.reLaunch({ - url: '/pages/main/main', - }) - } - + // 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', + }) + } + } else { wx.hideLoading() wx.showToast({ @@ -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 }, }) \ No newline at end of file diff --git a/pages/area/detail.js b/pages/area/detail.js index 03f7aed..8adc94a 100644 --- a/pages/area/detail.js +++ b/pages/area/detail.js @@ -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: '', diff --git a/pages/bind/binduser.js b/pages/bind/binduser.js index 090dba7..7ab59b1 100644 --- a/pages/bind/binduser.js +++ b/pages/bind/binduser.js @@ -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') }, /** diff --git a/pages/equipment/detail.js b/pages/equipment/detail.js index 3c65ae6..e6196db 100644 --- a/pages/equipment/detail.js +++ b/pages/equipment/detail.js @@ -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() { + + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/pages/examtest/note.js b/pages/examtest/note.js index 7bb43cc..21c36b5 100644 --- a/pages/examtest/note.js +++ b/pages/examtest/note.js @@ -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); - } } }, diff --git a/pages/main/main.js b/pages/main/main.js index 8f1751c..c6421d7 100644 --- a/pages/main/main.js +++ b/pages/main/main.js @@ -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, diff --git a/pages/riskact/detail.js b/pages/riskact/detail.js index 3b0d369..8b3fb0f 100644 --- a/pages/riskact/detail.js +++ b/pages/riskact/detail.js @@ -16,17 +16,7 @@ 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: '', }) diff --git a/pages/train/check.js b/pages/train/check.js index 46bde5a..42cbef9 100644 --- a/pages/train/check.js +++ b/pages/train/check.js @@ -17,37 +17,20 @@ 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) - }, getPx: function (id) {