0225commit
This commit is contained in:
parent
275ad1018a
commit
95adf23028
6
app.js
6
app.js
|
@ -95,11 +95,11 @@ App({
|
|||
openid:null
|
||||
},
|
||||
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://192.168.0.107:8000/',
|
||||
//serverUrl: 'http://192.168.0.103:8000/',
|
||||
//serverUrl:'http://10.0.11.195:8000/',
|
||||
timepass:null //定时器
|
||||
timer:null //定时器
|
||||
},
|
||||
|
||||
})
|
|
@ -8,7 +8,9 @@ Page({
|
|||
data: {
|
||||
tmIndex: 0,
|
||||
answerChoices:[],
|
||||
ydtm:0
|
||||
ydtm:0,
|
||||
took:0,
|
||||
handdisable:false
|
||||
},
|
||||
tmdata: {
|
||||
|
||||
|
@ -63,8 +65,9 @@ Page({
|
|||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
var that = this
|
||||
if(options.id){
|
||||
this.setData({
|
||||
that.setData({
|
||||
testid:options.id
|
||||
})
|
||||
wx.showLoading({})
|
||||
|
@ -79,13 +82,20 @@ Page({
|
|||
|
||||
console.log(res.data)
|
||||
let tms = res.data
|
||||
this.tmdata = tms
|
||||
that.tmdata = tms
|
||||
console.log(tms.duration)
|
||||
let mil = tms.duration * 60 * 1000
|
||||
console.log(mil)
|
||||
this.begin(mil)
|
||||
this.showTm(0)
|
||||
this.setData({
|
||||
let starttimes = (new Date()).getTime() //时间戳
|
||||
let endtimes = starttimes + mil
|
||||
// console.log(new Date(endtime))
|
||||
// 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,
|
||||
starttime: tms.starttime })
|
||||
wx.hideLoading()
|
||||
|
@ -133,6 +143,7 @@ Page({
|
|||
// }
|
||||
// }
|
||||
// })
|
||||
clearInterval(getApp().globalData.timer)
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -155,26 +166,25 @@ Page({
|
|||
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);
|
||||
this.setData({
|
||||
countdown: temp,
|
||||
});
|
||||
|
||||
if (mil < 1000) {
|
||||
wx.showLoading({
|
||||
title: '时间到,正在交卷..',
|
||||
});
|
||||
this.handtest()
|
||||
return
|
||||
};
|
||||
|
||||
getApp().globalData.timepass=setTimeout(
|
||||
() => {
|
||||
mil -= 1000;
|
||||
this.begin(mil);
|
||||
}, 1000
|
||||
);
|
||||
|
||||
},
|
||||
showTm: function (index) {
|
||||
var that = this
|
||||
|
@ -262,33 +272,42 @@ Page({
|
|||
}
|
||||
},
|
||||
handtest:function(){
|
||||
var data={
|
||||
'testid': this.data.testid,
|
||||
'starttime':this.data.starttime,
|
||||
'endtime': util.formatTime(new Date()),
|
||||
'sheet':this.tmdata.tms
|
||||
}
|
||||
wx.showLoading({
|
||||
title: '自动判卷中..',
|
||||
})
|
||||
wx.request({
|
||||
url: getApp().globalData.serverUrl + 'api/examtestdetail?a=handtest&id=' + this.data.testid,
|
||||
header: {
|
||||
'content-type': 'application/json', // 默认值
|
||||
'Cookie': wx.getStorageSync("sessionid"),
|
||||
},
|
||||
method: 'POST',
|
||||
data: data,
|
||||
success: res => {
|
||||
if (res.statusCode === 200) {
|
||||
wx.hideLoading()
|
||||
wx.redirectTo({
|
||||
url: 'result?' + parseParams(res.data.data),
|
||||
})
|
||||
clearTimeout(getApp().globalData.timepass)
|
||||
}
|
||||
clearInterval(getApp().globalData.timer)
|
||||
if(this.data.handdisable == false){
|
||||
this.setData({
|
||||
handdisable: true
|
||||
})
|
||||
var data = {
|
||||
'testid': this.data.testid,
|
||||
'starttime': this.data.starttime, //服务器时间
|
||||
'endtime': util.formatTime(new Date()),
|
||||
'sheet': this.tmdata.tms,
|
||||
'took': Math.floor(((new Date()).getTime() - this.data.starttimes) / 1000)
|
||||
}
|
||||
});
|
||||
wx.showLoading({
|
||||
title: '自动判卷中..',
|
||||
mask: true
|
||||
})
|
||||
wx.request({
|
||||
url: getApp().globalData.serverUrl + 'api/examtestdetail?a=handtest&id=' + this.data.testid,
|
||||
header: {
|
||||
'content-type': 'application/json', // 默认值
|
||||
'Cookie': wx.getStorageSync("sessionid"),
|
||||
},
|
||||
method: 'POST',
|
||||
data: data,
|
||||
success: res => {
|
||||
if (res.statusCode === 200) {
|
||||
clearInterval(getApp().globalData.timer)
|
||||
wx.hideLoading()
|
||||
wx.redirectTo({
|
||||
url: 'result?' + parseParams(res.data.data),
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
function formatmil(mil) {
|
||||
|
|
|
@ -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" disabled="{{handdisable}}">交卷</button>
|
||||
</view>
|
||||
</view>
|
|
@ -33,6 +33,7 @@ Page({
|
|||
}
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
mask:true
|
||||
})
|
||||
wx.request({
|
||||
url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id='+examtestid,
|
||||
|
|
|
@ -25,6 +25,7 @@ Page({
|
|||
})
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
wx.request({
|
||||
url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id=' + examtestid,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
人参与 更新时间:{{updatetime}}
|
||||
</view>
|
||||
<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">
|
||||
<button type="primary" bindtap="query" >查询</button>
|
||||
</view>
|
||||
|
|
Loading…
Reference in New Issue