test part2

This commit is contained in:
caoqianming 2020-03-18 22:58:46 +08:00
parent e11d011c7f
commit 8d68e1cf92
4 changed files with 109 additions and 27 deletions

View File

@ -35,7 +35,7 @@ Page({
})
that.showTm(that.data.tmIndex)
}
} catch (e) { }
} catch (e) { wx.navigateBack({}) }
try {
const res = wx.getSystemInfoSync()
that.setData({
@ -43,6 +43,14 @@ Page({
})
} catch (e) {
}
let mil = that.data.monitest.limit * 60 * 1000
let starttimes = (new Date()).getTime() //时间戳
let endtimes = starttimes + mil
that.data.starttimes = starttimes
that.data.endtimes = endtimes
getApp().globalData.timer = setInterval(function () {
that.startpass()
}, 1000)
},
/**
* 生命周期函数--监听页面初次渲染完成
@ -69,6 +77,7 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
clearInterval(getApp().globalData.timer)
},
/**
@ -91,7 +100,18 @@ Page({
onShareAppMessage: function () {
},
startpass: function () {
var mil = this.data.endtimes - (new Date()).getTime()
if (mil < 2000) {
clearInterval(getApp().globalData.timer)
this.handtest()
};
var temp = util.formatmil(mil);
this.setData({
countdown: temp,
});
},
showTm: function (index) {
var that = this
var currentTm = that.data.tms[index]
@ -101,29 +121,27 @@ Page({
})
that.showOptions()
},
// panTi: function () {
// var that = this
// let currentTm = that.data.currentTm
// let isright = false
// if (currentTm.type == 2) {
// if (currentTm.userChecked) {
// if (currentTm.userChecked.sort().toString() == currentTm.right.sort().toString()) {
// isright = true
// }
// }
panTi: function (currentTm) {
let isright = false
if (currentTm.type == 2) {
if (currentTm.userChecked) {
if (currentTm.userChecked.sort().toString() == currentTm.right.sort().toString()) {
isright = true
}
}
// } else {
// isright = currentTm.right == currentTm.userChecked
// }
// if (isright == false && currentTm.userChecked != undefined) {
// currentTm.dtime = util.formatTime(new Date())
// that.data.ctms.unshift(currentTm)
// if (that.data.ctms.length > 40) {
// that.data.ctms.length = 40
// }
// }
// return isright
// },
} else {
isright = currentTm.right == currentTm.userChecked
}
if (isright == false && currentTm.userChecked != undefined) {
currentTm.dtime = util.formatTime(new Date())
that.data.ctms.unshift(currentTm)
if (that.data.ctms.length > 40) {
that.data.ctms.length = 40
}
}
return isright
},
next: function () {
var that = this
var tmIndex = that.data.tmIndex + 1
@ -154,4 +172,41 @@ Page({
options: options
})
},
hand: function () {
var that = this
for (i = 0, len = that.data.tms.length; i < len; i++) {
let tm = that.data.tms[i]
if (tm.userChecked == undefined || tm.length == 0){
wx.showModal({
title: '警告',
content: '答卷未完成,可点击答题卡复查!',
confirmText: "仍旧提交",
cancelText: "取消",
success: function (res) {
if (res.confirm) {
that.handtest()
}
}
})
return
}
}
wx.showModal({
content: '确定提交?',
confirmText: "确定",
cancelText: "取消",
success: function (res) {
if (res.confirm) {
that.handtest()
}
}
})
},
handtest: function (){
wx.showLoading({
title: '正在判卷中...',
mask:true
})
}
})

View File

@ -1,5 +1,11 @@
<view class="head">
题量: {{tmIndex+1}}/{{tmtotal}}
<view style="width:50%">
倒计时 {{countdown}}
</view>
<view style="width:50%;text-align:right">
题量:{{tmIndex+1}}/{{tmtotal}}
</view>
</view>
<scroll-view scroll-y="true" style="height: {{scrollHeight}}px;">
<view class="weui-article">

View File

@ -3,7 +3,9 @@
height:30px;
color:#fff;
background-color: cornflowerblue;
text-align: center;
text-align: left;
display:flex;
flex-direction: row;
}
.btns{
height:40px;

View File

@ -14,6 +14,25 @@ const formatNumber = n => {
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
function formatmil(mil) {
var allSecond = Math.floor(mil / 1000);
var h = Math.floor(allSecond / 3600);
var m = Math.floor((allSecond - h * 3600) / 60);
var s = Math.floor(allSecond - h * 3600 - m * 60);
h = toTow(h);
m = toTow(m);
s = toTow(s);
return h + ":" + m + ":" + s;
}
function toTow(num) {
if (num < 10) {
return "0" + num;
} else {
return num;
}
}
module.exports = {
formatTime: formatTime,
formatmil: formatmil
}