扫码打开优化

This commit is contained in:
caoqianming 2020-03-10 09:23:36 +08:00
parent c1d6efe796
commit b80ed4c5c9
3 changed files with 43 additions and 24 deletions

9
app.js
View File

@ -39,8 +39,11 @@ App({
/**** KEY PART START ****/
var pages = getCurrentPages() // get all current pages
var currentPage = pages[pages.length - 1] // Get current loading page
currentPage.callback(); // Callback
that.oncallback = false; // Callback called
if (currentPage.callback){
currentPage.callback(); // Callback
that.oncallback = false; // Callback called
}
/**** KEY PART END ****/
//获取是否是安全员
@ -95,7 +98,7 @@ App({
openid:null
},
serverUrl: 'https://safeyun.ctcshe.com/',
// serverUrl: 'http://121.36.23.77:8000/',
//serverUrl: 'http://127.0.0.1:8000/',
//serverUrl: 'http://10.21.28.148:8000/',
//serverUrl: 'http://192.168.0.103:8000/',
//serverUrl:'http://10.0.11.195:8000/',

View File

@ -15,38 +15,46 @@ Page({
*/
onLoad: function (options) {
var examtestid
var that = this
wx.showLoading({
title: '加载中',
mask: true
})
if (options.id) {
examtestid = options.id
that.setData({
examtestid: examtestid,
})
that.getTest()
} else {
let q = decodeURIComponent(options.q)
if (q) {
examtestid = util.getQueryString(q, 'id')
if (getApp().globalData.sessionId.indexOf('sessinid') != -1) {
this.setData({
fromWx: true
})
}else{
getApp().onLaunch()
}
that.setData({
examtestid:examtestid,
fromWx: true
})
setTimeout(function () {
that.getTest()
}, 1500);
}
}
wx.showLoading({
title: '加载中',
mask:true
})
},
getTest: function(){
wx.request({
url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id='+examtestid,
url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id=' + this.data.examtestid,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
if (res.statusCode === 200) {
let ksdata = res.data
ksdata['testdisable'] = false
if (ksdata.notinTime == 1){
if (ksdata.notinTime == 1) {
ksdata['testdisable'] = true
ksdata['msg'] = '不在考试期限范围内!'
}
@ -56,12 +64,11 @@ Page({
}
this.setData(ksdata)
wx.hideLoading()
}
}
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -16,13 +16,19 @@ Page({
onLoad: function (options) {
// let pxid = options.pxid
console.log(options)
var that = this
wx.showLoading({
title: '加载中',
mask: true
})
let pxid
if(options.pxid){
pxid = options.pxid
this.setData({
that.setData({
pxid: pxid,
isfrom:1
})
that.getPx(pxid)
}else{
let q = decodeURIComponent(options.q)
@ -30,16 +36,19 @@ Page({
// console.log("index 生命周期 onload url=" + q)
// console.log("index 生命周期 onload 参数 trainid=" + util.getQueryString(q, 'trainid'))
pxid = util.getQueryString(q, 'trainid')
this.setData({
that.setData({
pxid: pxid,
isfrom: 0
})
setTimeout(function () {
that.getPx(pxid)
}, 1500);
}
}
console.log(pxid)
this.getPx(pxid)
},
getPx: function (id) {
wx.showLoading({
@ -90,7 +99,7 @@ Page({
wx.showToast({
title: '签到成功!',
})
wx.navigateTo({
wx.redirectTo({
url: '../train/train',
})
}