From 9afa52f9a5e0c55ff683bfe8f8b4be0dba01fec7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 8 Nov 2019 23:05:32 +0800 Subject: [PATCH] denglu bug --- app.js | 27 ++++- pages/examtest/index.js | 5 - pages/examtest/main.wxml | 54 ++++----- pages/examtest/main.wxss | 26 +++- pages/exercise/main.js | 199 ++++++++++++++++++++----------- pages/exercise/main.wxml | 12 +- pages/exercise/main.wxss | 26 +++- pages/inspect/add.wxml | 10 +- pages/observe/addobserve.js | 10 +- pages/riskact/check.wxml | 2 +- pages/trouble/accesstrouble.js | 9 +- pages/trouble/accesstrouble.wxml | 11 +- 12 files changed, 265 insertions(+), 126 deletions(-) diff --git a/app.js b/app.js index 2036e08..e64aaf7 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,7 @@ App({ onLaunch: function () { var that = this that.mplogin() + setInterval(that.reflesh,20*60*1000) }, mplogin: function () { var that = this; @@ -16,19 +17,26 @@ App({ }, method: 'POST', header: { - 'content-type': 'application/json' + 'Content-Type': 'application/x-www-form-urlencoded' }, success: function (res) { if (res.data.code == 1) { //console.log(res.header["Set-Cookie"]) - //console.log(res) + console.log(res) wx.setStorageSync('userid', res.data.userid) wx.setStorageSync('username', res.data.username) - wx.setStorageSync('sessionid', res.header["Set-Cookie"]) + if (res.header.hasOwnProperty('Set-Cookie')){ + wx.setStorageSync('sessionid', res.header["Set-Cookie"]) + }else{ + wx.setStorageSync('sessionid', res.header["set-cookie"]) + } wx.setStorageSync('mpopenid', res.data.mpopenid) + //console.log(res.header["Set-Cookie"]) + //console.log(wx.getStorageSync("sessionid")) if (that.callback) { //这个函数名字和你定义的一样即可 that.callback() //执行定义的回调函数 } + //获取是否是安全员 wx.request({ url: that.globalData.serverUrl + 'api/user?a=checkaqy', @@ -72,6 +80,19 @@ App({ } }) }, + reflesh: function(){//刷新session + var that = this + wx.request({ + url: that.globalData.serverUrl + 'api/check_session', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + } + }); + }, globalData: { userInfo: null, serverUrl: 'https://safeyun.ctcshe.com/', diff --git a/pages/examtest/index.js b/pages/examtest/index.js index e9e7031..d777d0e 100644 --- a/pages/examtest/index.js +++ b/pages/examtest/index.js @@ -108,11 +108,6 @@ Page({ } else { list = this.data.todokslist.concat(res.data.rows) } - for(var n=0;n 0 ? true : false; - list[n].isActive = isActive; - } this.setData({ todototal: res.data.total, todokslist: list diff --git a/pages/examtest/main.wxml b/pages/examtest/main.wxml index 809eb2d..ada2187 100644 --- a/pages/examtest/main.wxml +++ b/pages/examtest/main.wxml @@ -1,13 +1,12 @@ -倒计时 {{countdown}} - -答题卡: {{ydtm}}/{{tmtotal}} - - - + 倒计时 {{countdown}} + + 答题卡: {{ydtm}}/{{tmtotal}} + + {{tmIndex+1}}. 单选题 @@ -17,27 +16,28 @@ {{currentTm.question__title}} - - + + + + + + @@ -45,6 +45,6 @@ - + \ No newline at end of file diff --git a/pages/examtest/main.wxss b/pages/examtest/main.wxss index e51debe..11cf019 100644 --- a/pages/examtest/main.wxss +++ b/pages/examtest/main.wxss @@ -1,6 +1,12 @@ .head{ + z-index: 1; + position: fixed; + top: 0rpx; + width:100%; + height:60rpx; color:#fff; background-color: cornflowerblue; + /* text-align: center; */ } .txlabel{ color:#fff; @@ -9,10 +15,26 @@ } .weui-btn{ width:auto; - margin: 5px; + margin: 5rpx; } .sheet{ color:#fff; background-color: red; - float:right + float:right; + height:64rpx; +} +.body-v{ + position: fixed; + z-index: -1; + top:64rpx; + bottom:124rpx; +} +.footer{ + z-index: 1; + position: fixed; + bottom: 0rpx; + width:100%; + height:120rpx; + text-align: center; + border-top:1rpx solid red; } \ No newline at end of file diff --git a/pages/exercise/main.js b/pages/exercise/main.js index 2b282a5..b7cdbf6 100644 --- a/pages/exercise/main.js +++ b/pages/exercise/main.js @@ -8,14 +8,14 @@ Page({ data: { tmIndex: 0, answerChoices: [], - answerP:false + answerP: false }, tmdata: { - tms:[], - ydtms:[] + tms: [], + ydtms: [] }, - radioChange: function (e) { - console.log('radio发生change事件,携带value值为:', e.detail.value); + radioChange: function(e) { + //console.log('radio发生change事件,携带value值为:', e.detail.value); var answerChoices = this.data.answerChoices; for (var i = 0, len = answerChoices.length; i < len; ++i) { answerChoices[i].checked = answerChoices[i].value == e.detail.value; @@ -30,10 +30,11 @@ Page({ }) this.showanswer() }, - checkboxChange: function (e) { - console.log('checkbox发生change事件,携带value值为:', e.detail.value); + checkboxChange: function(e) { + //console.log('checkbox发生change事件,携带value值为:', e.detail.value); - var answerChoices = this.data.answerChoices, values = e.detail.value; + var answerChoices = this.data.answerChoices, + values = e.detail.value; for (var i = 0, lenI = answerChoices.length; i < lenI; ++i) { answerChoices[i].checked = false; @@ -53,11 +54,11 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { + onLoad: function(options) { var that = this wx.getStorage({ key: 'questioncats', - success: function (res) { + success: function(res) { let lst = res.data let nst = [] let nst1 = [] @@ -68,7 +69,7 @@ Page({ } } that.setData({ - tmlxs:nst1 + tmlxs: nst1 }) wx.getStorage({ key: 'ydtms', @@ -76,16 +77,16 @@ Page({ that.tmdata.ydtms = res.data that.getTms() }, - fail:function(){ + fail: function() { that.getTms() } }) - + }, }) - + }, - getTms: function () { + getTms: function(callback) { var that = this wx.showLoading({}) wx.request({ @@ -95,17 +96,38 @@ Page({ 'Cookie': wx.getStorageSync("sessionid"), }, method: 'POST', - data: { 'tmlx': that.data.tmlxs,'ydtms':that.tmdata.ydtms }, + data: { + 'tmlx': that.data.tmlxs, + 'ydtms': that.tmdata.ydtms + }, success: res => { if (res.statusCode === 200) { wx.hideLoading() - console.log(res.data) + //console.log(res.data) let tms = res.data.rows - that.tmdata.tms = that.tmdata.tms.concat(tms) - that.showTm(that.data.tmIndex) //展示题目 - that.setData({ - tmtotal: res.data.total, - }) + if(tms.length==0){ + + wx.showModal({ + title: '提示', + content: '无更多新题,返回重新开始', + showCancel: false, + success: function (res) { + if (res.confirm) { + wx.navigateBack({ + + }) + } + } + }) + + }else{ + that.tmdata.tms = that.tmdata.tms.concat(tms) + that.showTm(that.data.tmIndex) //展示题目和答案 + that.setData({ + tmtotal: res.data.total, + }) + } + } } @@ -114,74 +136,87 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () { + onReady: function() { }, /** * 生命周期函数--监听页面显示 */ - onShow: function () { + onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ - onHide: function () { - }, + onHide: function() {}, /** * 生命周期函数--监听页面卸载 */ - onUnload: function () { -wx.setStorage({ - key: 'ydtms', - data: this.tmdata.ydtms, -}) + onUnload: function() { + wx.setStorage({ + key: 'ydtms', + data: this.tmdata.ydtms, + }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh: function () { + onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ - onReachBottom: function () { + onReachBottom: function() { }, /** * 用户点击右上角分享 */ - onShareAppMessage: function () { + onShareAppMessage: function() { }, - showTm: function (index) { + showTm: function(index) { var that = this var currentTm = that.tmdata.tms[index] - console.log(currentTm) - that.setData({ 'currentTm': currentTm }) + //console.log(currentTm) + that.setData({ + 'currentTm': currentTm + }) var answer = currentTm.answer var sorder = Object.keys(answer).sort(); var answerChoices = [] //对正确答案进行排序 - for(var i=0;ithat.tmdata.tms.length){ + if (tmIndex + 1 > that.tmdata.tms.length) { that.getTms() - }else{ + } else { that.showTm(tmIndex) } - that.showChecked(tmIndex) + }, - previous: function () { + previous: function() { var that = this var tmIndex = that.data.tmIndex - 1 - that.showTm(tmIndex) that.setData({ tmIndex: tmIndex, answerP: false }) - that.showChecked(tmIndex) + that.showTm(tmIndex) }, -}) + judgeResultFun: function(arr1, arr2) { + let flag = true + if (arr1.length !== arr2.length) { + flag = false + } else { + arr1.forEach(item => { + if (arr2.indexOf(item) === -1) { + flag = false + } + }) + } + return flag; + } +}) \ No newline at end of file diff --git a/pages/exercise/main.wxml b/pages/exercise/main.wxml index b03aae6..217f8b7 100644 --- a/pages/exercise/main.wxml +++ b/pages/exercise/main.wxml @@ -3,8 +3,8 @@ 题量 {{tmIndex+1}}/{{tmtotal}} - - + + {{tmIndex+1}}. 单选题 @@ -16,9 +16,10 @@ + 回答正确! + 回答错误! 正确答案是{{currentTm.right}},你的答案是{{currentTm.userchecked}} @@ -44,7 +47,8 @@ 解析: - + + diff --git a/pages/exercise/main.wxss b/pages/exercise/main.wxss index e51debe..3e17d0b 100644 --- a/pages/exercise/main.wxss +++ b/pages/exercise/main.wxss @@ -1,6 +1,12 @@ .head{ + z-index: 1; + position: fixed; + top: 0rpx; + width:100%; + height:60rpx; color:#fff; background-color: cornflowerblue; + /* text-align: center; */ } .txlabel{ color:#fff; @@ -9,10 +15,26 @@ } .weui-btn{ width:auto; - margin: 5px; + margin: 5rpx; } .sheet{ color:#fff; background-color: red; float:right -} \ No newline at end of file +} +.body-v{ + position: fixed; + z-index: -1; + top:64rpx; + bottom:124rpx; +} +.footer{ + z-index: 1; + position: fixed; + bottom: 0rpx; + width:100%; + height:120rpx; + text-align: center; + border-top:1rpx solid red; +} + diff --git a/pages/inspect/add.wxml b/pages/inspect/add.wxml index ee86cec..1986ea6 100644 --- a/pages/inspect/add.wxml +++ b/pages/inspect/add.wxml @@ -14,14 +14,14 @@ 检查项目 + - - {{item.step}}-{{item.result}} - {{item.hazard}} + {{item.step}}-{{item.result}} + {{item.hazard}} - + 巡检记录 @@ -31,7 +31,7 @@ 设备异常 - +