0225commit

This commit is contained in:
caoqianming 2020-02-25 08:33:53 +08:00
parent 275ad1018a
commit 95adf23028
6 changed files with 75 additions and 54 deletions

6
app.js
View File

@ -95,11 +95,11 @@ App({
openid:null openid:null
}, },
serverUrl: 'https://safeyun.ctcshe.com/', serverUrl: 'https://safeyun.ctcshe.com/',
//serverUrl: 'http://127.0.0.1:8001/', //serverUrl: 'http://127.0.0.1:8000/',
//serverUrl: 'http://10.21.28.148:8000/', //serverUrl: 'http://10.21.28.148:8000/',
//serverUrl: 'http://192.168.0.107:8000/', //serverUrl: 'http://192.168.0.103:8000/',
//serverUrl:'http://10.0.11.195:8000/', //serverUrl:'http://10.0.11.195:8000/',
timepass:null //定时器 timer:null //定时器
}, },
}) })

View File

@ -8,7 +8,9 @@ Page({
data: { data: {
tmIndex: 0, tmIndex: 0,
answerChoices:[], answerChoices:[],
ydtm:0 ydtm:0,
took:0,
handdisable:false
}, },
tmdata: { tmdata: {
@ -63,8 +65,9 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
var that = this
if(options.id){ if(options.id){
this.setData({ that.setData({
testid:options.id testid:options.id
}) })
wx.showLoading({}) wx.showLoading({})
@ -79,13 +82,20 @@ Page({
console.log(res.data) console.log(res.data)
let tms = res.data let tms = res.data
this.tmdata = tms that.tmdata = tms
console.log(tms.duration) console.log(tms.duration)
let mil = tms.duration * 60 * 1000 let mil = tms.duration * 60 * 1000
console.log(mil) let starttimes = (new Date()).getTime() //时间戳
this.begin(mil) let endtimes = starttimes + mil
this.showTm(0) // console.log(new Date(endtime))
this.setData({ // console.log(mil)
that.data.starttimes = starttimes
that.data.endtimes = endtimes
getApp().globalData.timer = setInterval(function(){
that.startpass()
}, 1000)
that.showTm(0)
that.setData({
tmtotal: tms.tms.length, tmtotal: tms.tms.length,
starttime: tms.starttime }) starttime: tms.starttime })
wx.hideLoading() wx.hideLoading()
@ -133,6 +143,7 @@ Page({
// } // }
// } // }
// }) // })
clearInterval(getApp().globalData.timer)
}, },
/** /**
@ -155,26 +166,25 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
begin: function (mil) { startpass:function(){
var mil = this.data.endtimes - (new Date()).getTime()
console.log('定时器在走!')
if (mil < 2000) {
clearInterval(getApp().globalData.timer)
wx.showLoading({
title: '时间到,正在交卷..',
});
if( this.data.handdisable == false){
this.handtest()
}
return
};
var temp = formatmil(mil); var temp = formatmil(mil);
this.setData({ this.setData({
countdown: temp, countdown: temp,
}); });
if (mil < 1000) {
wx.showLoading({
title: '时间到,正在交卷..',
});
this.handtest()
return
};
getApp().globalData.timepass=setTimeout(
() => {
mil -= 1000;
this.begin(mil);
}, 1000
);
}, },
showTm: function (index) { showTm: function (index) {
var that = this var that = this
@ -262,14 +272,21 @@ Page({
} }
}, },
handtest:function(){ handtest:function(){
var data={ clearInterval(getApp().globalData.timer)
if(this.data.handdisable == false){
this.setData({
handdisable: true
})
var data = {
'testid': this.data.testid, 'testid': this.data.testid,
'starttime':this.data.starttime, 'starttime': this.data.starttime, //服务器时间
'endtime': util.formatTime(new Date()), 'endtime': util.formatTime(new Date()),
'sheet':this.tmdata.tms 'sheet': this.tmdata.tms,
'took': Math.floor(((new Date()).getTime() - this.data.starttimes) / 1000)
} }
wx.showLoading({ wx.showLoading({
title: '自动判卷中..', title: '自动判卷中..',
mask: true
}) })
wx.request({ wx.request({
url: getApp().globalData.serverUrl + 'api/examtestdetail?a=handtest&id=' + this.data.testid, url: getApp().globalData.serverUrl + 'api/examtestdetail?a=handtest&id=' + this.data.testid,
@ -281,15 +298,17 @@ Page({
data: data, data: data,
success: res => { success: res => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
clearInterval(getApp().globalData.timer)
wx.hideLoading() wx.hideLoading()
wx.redirectTo({ wx.redirectTo({
url: 'result?' + parseParams(res.data.data), url: 'result?' + parseParams(res.data.data),
}) })
clearTimeout(getApp().globalData.timepass)
} }
} }
}); });
} }
}
}) })
function formatmil(mil) { function formatmil(mil) {
var allSecond = Math.floor(mil / 1000); var allSecond = Math.floor(mil / 1000);

View File

@ -45,6 +45,6 @@
<button class="weui-btn" type="primary" bindtap="next" disabled="{{tmIndex==tmtotal-1}}">下一题</button> <button class="weui-btn" type="primary" bindtap="next" disabled="{{tmIndex==tmtotal-1}}">下一题</button>
</view> </view>
<view style="width:30%;float:right"> <view style="width:30%;float:right">
<button class="weui-btn" type="primary" bindtap="hand">交卷</button> <button class="weui-btn" type="primary" bindtap="hand" disabled="{{handdisable}}">交卷</button>
</view> </view>
</view> </view>

View File

@ -33,6 +33,7 @@ Page({
} }
wx.showLoading({ wx.showLoading({
title: '加载中', title: '加载中',
mask:true
}) })
wx.request({ wx.request({
url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id='+examtestid, url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id='+examtestid,

View File

@ -25,6 +25,7 @@ Page({
}) })
wx.showLoading({ wx.showLoading({
title: '加载中', title: '加载中',
mask: true
}) })
wx.request({ wx.request({
url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id=' + examtestid, url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id=' + examtestid,

View File

@ -5,7 +5,7 @@
人参与 更新时间:{{updatetime}} 人参与 更新时间:{{updatetime}}
</view> </view>
<view class='search'> <view class='search'>
<input type='text' placeholder='输入姓名查询' confirm-type='search' value="{{inputValue}}" bindinput='inputBind' bindconfirm='query' style="flex: 1;"></input> <input type='text' placeholder='输入姓名/部门查询' confirm-type='search' value="{{inputValue}}" bindinput='inputBind' bindconfirm='query' style="flex: 1;"></input>
<view style="padding:2rpx"> <view style="padding:2rpx">
<button type="primary" bindtap="query" >查询</button> <button type="primary" bindtap="query" >查询</button>
</view> </view>