denglu bug

This commit is contained in:
caoqianming 2019-11-08 23:05:32 +08:00
parent 135f3ca3a3
commit 9afa52f9a5
12 changed files with 265 additions and 126 deletions

27
app.js
View File

@ -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/',

View File

@ -108,11 +108,6 @@ Page({
} else {
list = this.data.todokslist.concat(res.data.rows)
}
for(var n=0;n<list.length;n++){
let value = new Date(list[n].examtest__endtime) - new Date();
let isActive = value > 0 ? true : false;
list[n].isActive = isActive;
}
this.setData({
todototal: res.data.total,
todokslist: list

View File

@ -1,13 +1,12 @@
<!--pages/examtest/main.wxml-->
<view class="head">
<view style="float:left">倒计时 {{countdown}}</view>
<navigator url="sheet" >
<view class="sheet">答题卡: {{ydtm}}/{{tmtotal}}</view>
</navigator>
</view>
<view >
<view style="float:left">倒计时 {{countdown}}</view>
<navigator url="sheet">
<view class="sheet">答题卡: {{ydtm}}/{{tmtotal}}</view>
</navigator>
</view>
<scroll-view class='body-v' scroll-y>
<view class="weui-article">
<view class="weui-article__h2">{{tmIndex+1}}.
<span wx:if="{{currentTm.question__type==1}}" class="txlabel">单选题</span>
@ -17,27 +16,28 @@
</view>
<view class="weui-article__title">{{currentTm.question__title}}</view>
</view>
<radio-group bindchange="radioChange" wx:if="{{(currentTm.question__type==1 ||currentTm.question__type==3)}}">
<label class="weui-cell weui-check__label" wx:for="{{answerChoices}}" wx:key="value">
<radio class="weui-check" value="{{item.value}}" checked="{{item.checked}}" />
<radio-group bindchange="radioChange" wx:if="{{(currentTm.question__type==1 ||currentTm.question__type==3)}}">
<label class="weui-cell weui-check__label" wx:for="{{answerChoices}}" wx:key="value">
<radio class="weui-check" value="{{item.value}}" checked="{{item.checked}}" />
<view class="weui-cell__bd">{{item.name}}: {{currentTm.question__answer[item.value]}}</view>
<view class="weui-cell__ft weui-cell__ft_in-radio" wx:if="{{item.checked}}">
<icon class="weui-icon-radio" type="success_no_circle" size="16"></icon>
</view>
</label>
</radio-group>
<checkbox-group bindchange="checkboxChange" wx:if="{{currentTm.question__type==2}}">
<label class="weui-cell weui-check__label" wx:for="{{answerChoices}}" wx:key="value">
<checkbox class="weui-check" value="{{item.value}}" checked="{{item.checked}}" />
<view class="weui-cell__bd">{{item.name}}: {{currentTm.question__answer[item.value]}}</view>
<view class="weui-cell__hd weui-check__hd_in-checkbox">
<icon class="weui-icon-checkbox_circle" type="circle" size="23" wx:if="{{!item.checked}}"></icon>
<icon class="weui-icon-checkbox_success" type="success" size="23" wx:if="{{item.checked}}"></icon>
</view>
</label>
</checkbox-group>
<view style="position:fixed;bottom:0;left:0;width:100%;">
<view class="weui-cell__bd">{{item.name}}: {{currentTm.question__answer[item.value]}}</view>
<view class="weui-cell__ft weui-cell__ft_in-radio" wx:if="{{item.checked}}">
<icon class="weui-icon-radio" type="success_no_circle" size="16"></icon>
</view>
</label>
</radio-group>
<checkbox-group bindchange="checkboxChange" wx:if="{{currentTm.question__type==2}}">
<label class="weui-cell weui-check__label" wx:for="{{answerChoices}}" wx:key="value">
<checkbox class="weui-check" value="{{item.value}}" checked="{{item.checked}}" />
<view class="weui-cell__bd">{{item.name}}: {{currentTm.question__answer[item.value]}}</view>
<view class="weui-cell__hd weui-check__hd_in-checkbox">
<icon class="weui-icon-checkbox_circle" type="circle" size="23" wx:if="{{!item.checked}}"></icon>
<icon class="weui-icon-checkbox_success" type="success" size="23" wx:if="{{item.checked}}"></icon>
</view>
</label>
</checkbox-group>
</scroll-view>
<view class="footer">
<view style="width:30%;float:left">
<button class="weui-btn" type="primary" bindtap="previous" disabled="{{tmIndex==0}}">上一题</button>
</view>
@ -45,6 +45,6 @@
<button class="weui-btn" type="primary" bindtap="next" disabled="{{tmIndex==tmtotal-1}}">下一题</button>
</view>
<view style="width:30%;float:right">
<button class="weui-btn" type="primary" bindtap="hand" >交卷</button>
<button class="weui-btn" type="primary" bindtap="hand">交卷</button>
</view>
</view>

View File

@ -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;
}

View File

@ -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;i<sorder.length;i++){
answerChoices.push({ 'name': sorder[i], 'value': sorder[i], 'checked': false })
for (var i = 0; i < sorder.length; i++) {
answerChoices.push({
'name': sorder[i],
'value': sorder[i],
'checked': false
})
}
//console.log(answerChoices)
that.setData({
'answerChoices': answerChoices
})
if (that.tmdata.ydtms.indexOf(currentTm.id)!=-1){ //如果未答过
that.showChecked(index)
that.showanswer()
}
console.log(answerChoices)
that.setData({ 'answerChoices': answerChoices })
that.tmdata.ydtms.push(currentTm.id)
},
showChecked: function (index) {
var tm = this.tmdata.tms[index]
showChecked: function(index) {
let tm = this.tmdata.tms[index]
//console.log(tm)
let choices = this.data.answerChoices
if (tm.userchecked) {
if (tm.question__type = 2) {
if (tm.question__type == 2) {
for (var i = 0, len = choices.length; i < len; i++) {
if (tm.userchecked.indexOf(choices[i].value) != -1) {
choices[i].checked = true
@ -196,52 +231,80 @@ wx.setStorage({
}
this.setData({
answerChoices: choices,
answerP:true
answerP: true
})
}
},
showanswer:function(){
var answerChoices = this.data.answerChoices
var currentTm = this.data.currentTm
for(var i=0;i<answerChoices.length;i++){
if(currentTm.type=2){
if (currentTm.right.indexOf(answerChoices[i].value)!=-1){
answerChoices[i].right=true
}
}else{
if(answerChoices[i].value==currentTm.right){
answerChoices[i].right=true
showanswer: function() {
let answerChoices = this.data.answerChoices
let currentTm = this.data.currentTm
console.log(answerChoices,currentTm)
for (var i = 0; i < answerChoices.length; i++) {
if (currentTm.type == 2) {
if (currentTm.right.indexOf(answerChoices[i].value) != -1) {
answerChoices[i].right = true
}
} else {
if (answerChoices[i].value == currentTm.right) {
answerChoices[i].right = true
}
}
}
}
console.log(answerChoices)
if (currentTm.type == 2) {
if(currentTm.userchecked==undefined){currentTm.userchecked=[]}
var answerright = this.judgeResultFun(currentTm.userchecked, currentTm.right)
this.setData({
answerright: answerright
})
} else {
if(currentTm.userchecked==undefined){currentTm.userchecked=''}
var answerright = currentTm.right == currentTm.userchecked
this.setData({
answerright: answerright
})
}
this.setData({
answerP: true,
answerChoices:answerChoices
answerChoices: answerChoices
})
},
next: function () {
next: function() {
var that = this
var tmIndex = that.data.tmIndex + 1
that.setData({
tmIndex: tmIndex,
answerP:false
answerP: false
})
if(tmIndex+1>that.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;
}
})

View File

@ -3,8 +3,8 @@
<view style="float:left">题量 {{tmIndex+1}}/{{tmtotal}}</view>
</view>
<view>
</view>
<scroll-view class='body-v' scroll-y>
<view class="weui-article">
<view class="weui-article__h2">{{tmIndex+1}}.
<span wx:if="{{currentTm.type==1}}" class="txlabel">单选题</span>
@ -16,9 +16,10 @@
<radio-group bindchange="radioChange" wx:if="{{(currentTm.type==1 ||currentTm.type==3)}}">
<label class="weui-cell weui-check__label" wx:for="{{answerChoices}}" wx:key="value">
<radio class="weui-check" value="{{item.value}}" checked="{{item.checked}}" />
<view wx:if="{{currentTm.answer[item.value]!=''}}">
<view class="weui-cell__bd" wx:if="{{item.right}}" style="color:green;font-weight:bold">{{item.name}}: {{currentTm.answer[item.value]}}</view>
<view class="weui-cell__bd" wx:else>{{item.name}}: {{currentTm.answer[item.value]}}</view>
</view>
<view class="weui-cell__ft weui-cell__ft_in-radio" wx:if="{{item.checked}}">
<icon class="weui-icon-radio" type="success_no_circle" size="16"></icon>
</view>
@ -36,6 +37,8 @@
</label>
</checkbox-group>
<view class="weui-article" wx:if="{{answerP}}">
<view class="weui-article__h2" wx:if="{{answerright}}" style="color:green;font-weight:bold">回答正确!</view>
<view class="weui-article__h2" wx:else style="color:red;font-weight:bold">回答错误!</view>
<view class="weui-article__h2">正确答案是{{currentTm.right}},你的答案是{{currentTm.userchecked}}</view>
<!-- <view class="weui-article__h2" style="color:green" wx:if="{{currentTm.iscore == currentTm.score}}">回答正确</view>
<view class="weui-article__h2" style="color:red" wx:else>回答有误</view> -->
@ -44,7 +47,8 @@
<view class="weui-article__title" wx:else>
<span style="color:blue">解析: </span>无</view>
</view>
<view style="position:fixed;bottom:0;left:0;width:100%;">
</scroll-view>
<view class="footer">
<view style="width:30%;float:left">
<button class="weui-btn" type="primary" bindtap="previous" disabled="{{tmIndex==0}}">上一题</button>
</view>

View File

@ -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
}
}
.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;
}

View File

@ -14,14 +14,14 @@
</view>
</view>
<view class="weui-cells__title">检查项目</view>
<block wx:for="{{steps}}" wx:key="unique">
<view class="weui-cells weui-cells_after-title">
<block wx:for="{{steps}}" wx:key="unique">
<view class="weui-article__p " style="marigin:5px">
<view class="weui-media-box__desc" style="color:black">{{item.step}}-<span style="color:red">{{item.result}}</span></view>
<view class="weui-media-box__desc" style="color:green">{{item.hazard}}</view>
<view style="color:black">{{item.step}}-<span style="color:red">{{item.result}}</span></view>
<view style="color:green">{{item.hazard}}</view>
</view>
</block>
</view>
</block>
<view class="weui-cells__title">巡检记录</view>
<radio-group name="radio-group" class="weui-cell" bindchange="radioChange">
@ -31,7 +31,7 @@
<radio color="#FF0000" value="0" checked="{{state==0}}" />设备异常</label>
</radio-group>
<view class="weui-cells weui-cells_after-title" wx:if="{{state==1}}">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea class="weui-textarea" placeholder="请输入巡检结论" style="height: 5.3em" bindinput="bindcontentInput" />

View File

@ -285,14 +285,18 @@ Page({
getunsafe: function () {
var x = []
var that = this.data;
var items = [that.unsafe24.child, that.unsafe25.child, that.unsafe26.child, that.unsafe27.child, that.unsafe28.child, that.unsafe29.child, that.unsafe30.child]
for (var i = 0, lenI = items.length; i < lenI; i++) {
var y = items[i]
for (var m = 0, lenI = y.length; m < lenI; m++) {
if (y[m].checked) {
x.push(y[m].value)
if(y!=undefined){
for (var m = 0, lenI = y.length; m < lenI; m++) {
if (y[m].checked) {
x.push(y[m].value)
}
}
}
}
return x
},

View File

@ -10,7 +10,7 @@
<span wx:if="{{item.level == '重大风险'}}" style="background-color:red;color:white">重大风险</span>
{{item.step}}
</view>
<view class="weui-media-box__desc">
<view>
<span style="background-color:orange;color:white">标准/危害因素</span>
{{item.hazard}}
</view>

View File

@ -91,7 +91,14 @@ Page({
bindzgcsInput: function (e) {
this.data.zgcs = e.detail.value
},
shChange:function(e){
console.log('switch 发生 change 事件,携带值为', e.detail.value)
if(e.detail.value){
this.data.shresult = 'reject'
}else{
this.data.shresult = 'pass'
}
},
getYh: function (troubleid) {
wx.showLoading({
title: '加载中',

View File

@ -384,18 +384,19 @@
</view>
</view>
<view class="weui-cell weui-cell_switch" wx:if="{{yhzt ==4||yhzt==5}}">
<view class="weui-cell__bd">是否通过</view>
</view>
<view class="weui-cell weui-cell_switch" wx:if="{{yhzt ==4||yhzt==5}}">
<view class="weui-cell__bd">驳回</view>
<view class="weui-cell__ft">
<switch checked bindchange="shChange" />
<switch bindchange="shChange" />
</view>
</view>
</view>
</view>
<view class="weui-cells weui-cells_after-title" wx:if="{{yhzt==0||shresult=='reject'}}">
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>退回原因</view>
<view>回原因</view>
<view class="weui-cell__bd" wx:if="{{yhzt==0}}">
{{pgyj}}
</view>