diff --git a/app.js b/app.js index c08a124..71dd99a 100644 --- a/app.js +++ b/app.js @@ -1,21 +1,8 @@ //app.js App({ onLaunch: function () { - // 展示本地存储能力 - //var logs = wx.getStorageSync('logs') || [] - //logs.unshift(Date.now()) - //wx.setStorageSync('logs', logs) - // wx.checkSession({ - // success() { - // //session_key 未过期,并且在本生命周期一直有效 - // console.log(wx.getStorageSync("sessionid")) - // }, - // fail() { - // // session_key 已经失效,需要重新执行登录流程 - // // 登录 - // } - // }) - this.mplogin(); + var that = this + that.mplogin() }, mplogin: function () { var that = this; @@ -93,7 +80,7 @@ App({ globalData: { userInfo: null, //serverUrl: 'https://safeyun.ctcshe.com/', - serverUrl:'http://127.0.0.1:8000/', + serverUrl: 'http://127.0.0.1:8000/', //serverUrl: 'http://192.168.0.102:8000/', //serverUrl:'http://10.7.100.250:8000/', isaqy: 0 diff --git a/app.json b/app.json index 1d6df9f..c9a2d90 100644 --- a/app.json +++ b/app.json @@ -38,7 +38,22 @@ "pages/userSelect/userSelect", "components/footer/footer", "pages/operation/operationadd", - "pages/train/add" + "pages/train/add", + "pages/train/detail", + "pages/train/check", + "pages/train/qrcode", + "pages/operation/list", + "pages/examtest/index", + "pages/examtest/note", + "pages/examtest/main", + "pages/examtest/sheet", + "pages/examtest/result", + "pages/examtest/detail", + "pages/safecert/index", + "pages/safecert/detail", + "pages/exercise/index", + "pages/questioncat/index", + "pages/exercise/main" ], "window": { "backgroundTextStyle": "light", @@ -65,5 +80,6 @@ "selectedIconPath": "image/mec.png" } ] - } + }, + "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/components/footer/footer.wxml b/components/footer/footer.wxml index 2d21345..924314c 100644 --- a/components/footer/footer.wxml +++ b/components/footer/footer.wxml @@ -3,4 +3,5 @@ {{item.name}} - 确定 \ No newline at end of file + 确定 + \ No newline at end of file diff --git a/components/footer/footer.wxss b/components/footer/footer.wxss index 95a6ba4..080da44 100644 --- a/components/footer/footer.wxss +++ b/components/footer/footer.wxss @@ -25,7 +25,7 @@ .text { font-size: 32rpx; color: #333; - padding: 40rpx 20rpx; + padding: 20rpx 20rpx; margin-right: 10rpx; background-color: #f5f5f5; } diff --git a/pages/bind/binduser.js b/pages/bind/binduser.js index bcd75a2..298fee5 100644 --- a/pages/bind/binduser.js +++ b/pages/bind/binduser.js @@ -26,7 +26,7 @@ Page({ if (res.statusCode === 200) { if (res.data.code == 1) { wx.showToast({}) - getApp().onLaunch() + getApp().mplogin() wx.switchTab({ url: '/pages/main/main', }) diff --git a/pages/examtest/detail.js b/pages/examtest/detail.js new file mode 100644 index 0000000..dc1c0c0 --- /dev/null +++ b/pages/examtest/detail.js @@ -0,0 +1,144 @@ +// pages/examtest/detail.js +var util = require('../../utils/util.js') +Page({ + + /** + * 页面的初始数据 + */ + data: { + }, + detaildata:{ + + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var detailid = options.detailid + this.data.detailid = detailid + wx.showLoading({ + title: '加载中..', + }) + wx.request({ + url: getApp().globalData.serverUrl + 'api/examtestdetail?a=detail&id='+detailid, + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + success: res => { + if (res.statusCode === 200) { + wx.hideLoading() + var data = res.data + data.starttime = util.formatTime2(new Date(data.starttime)) + this.detaildata = data + this.setData({ + starttime:data.starttime, + took:data.took, + tmIndex:0, + tmtotal: data['testdetail'].length, + currentTm:data['testdetail'][0] + } + ) + this.showanswer() + } + } + }); + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + next:function(){ + var that=this + var tmIndex = that.data.tmIndex +1 + that.setData({ + tmIndex:tmIndex, + currentTm:that.detaildata.testdetail[tmIndex] + }) + that.showanswer() + }, + previous: function () { + var that = this + var tmIndex = that.data.tmIndex - 1 + that.setData({ + tmIndex: tmIndex, + currentTm: that.detaildata.testdetail[tmIndex] + }) + that.showanswer() + }, + showanswer: function () { + var that = this + var currentTm = that.data.currentTm + console.log(currentTm) + var answer = currentTm.question__answer + var sorder = Object.keys(answer).sort(); + var answerChecked=[] + for (var x = 0; x < sorder.length; x++) { + if (answer[sorder[x]] != '') { + if(currentTm.userchecked!=undefined){ + var ii = currentTm.userchecked.indexOf(sorder[x]) + }else{ + ii=1 + } + if ( ii!= -1 && currentTm.question__right.indexOf(sorder[x]) != -1){ + answerChecked.push({ 'name': sorder[x] + ':' + answer[sorder[x]], 'right': true, 'checked': true }) + } else if (ii != -1){ + answerChecked.push({ 'name': sorder[x] + ':' + answer[sorder[x]], 'right': false, 'checked': true }) + } else if (currentTm.question__right.indexOf(sorder[x]) != -1){ + answerChecked.push({ 'name': sorder[x] + ':' + answer[sorder[x]], 'right': true, 'checked': false }) + }else{ + answerChecked.push({ 'name': sorder[x] + ':' + answer[sorder[x]], 'right': false, 'checked': false }) + } + + } + + } + that.setData({ 'answerChecked': answerChecked }) + }, +}) \ No newline at end of file diff --git a/pages/examtest/detail.json b/pages/examtest/detail.json new file mode 100644 index 0000000..0b34069 --- /dev/null +++ b/pages/examtest/detail.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "试卷详情" +} \ No newline at end of file diff --git a/pages/examtest/detail.wxml b/pages/examtest/detail.wxml new file mode 100644 index 0000000..a11c950 --- /dev/null +++ b/pages/examtest/detail.wxml @@ -0,0 +1,52 @@ + + + +答题耗时{{took}}分钟 + + + + + {{tmIndex+1}}. + 单选题 + 多选题 + 判断题 + ({{currentTm.score}}分) + + {{currentTm.question__title}} + + + + + + + + + 正确答案是{{currentTm.question__right}},你的答案是{{currentTm.userchecked}} + 回答正确 + 回答有误 + 解析: {{currentTm.question__resoluation}} + 解析: + + + + + + + + + + \ No newline at end of file diff --git a/pages/examtest/detail.wxss b/pages/examtest/detail.wxss new file mode 100644 index 0000000..e51debe --- /dev/null +++ b/pages/examtest/detail.wxss @@ -0,0 +1,18 @@ +.head{ + color:#fff; + background-color: cornflowerblue; +} +.txlabel{ + color:#fff; + background-color: rgb(216, 140, 0); + padding: 2px +} +.weui-btn{ + width:auto; + margin: 5px; +} +.sheet{ + color:#fff; + background-color: red; + float:right +} \ No newline at end of file diff --git a/pages/examtest/index.js b/pages/examtest/index.js new file mode 100644 index 0000000..6e9d245 --- /dev/null +++ b/pages/examtest/index.js @@ -0,0 +1,172 @@ +//var base64 = require("../images/base64"); +var sliderWidth = 96; +Page({ + data: { + page: 1, + serverUrl: getApp().globalData.serverUrl, + allyhlist: [], + tabs: ["待考", "已考"], + activeIndex: 0, + sliderOffset: 0, + sliderLeft: 0 + }, + tabClick: function (e) { + var that = this + that.setData({ + sliderOffset: e.currentTarget.offsetLeft, + activeIndex: e.currentTarget.id + }); + if (that.data.activeIndex == 0) { + that.gettodokslist(1) + that.data.todopage = 1 + } + else if (that.data.activeIndex == 1) { + that.getyklist(1) + that.data.page = 1 + } + }, + getyklist: function (page) { + var that = this; + if (page != 1) { page = that.data.page } + wx.showLoading({ + title: '加载中', + }), + wx.request({ + url: this.data.serverUrl + 'api/examtestdetail?a=listyk&rows=10&page=' + page, + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + success: res => { + if (res.statusCode === 200) { + if (res.data.rows.length == 0) { + if (page == 1) { + this.setData({ + yktotal: 0, + yklist: [] + }) + } + else { + wx.showModal({ + content: "已经到底啦!", + showCancel: false, + confirmText: "确定", + }) + } + } else { + let list + if (page == 1) { + list = res.data.rows + } else { + list = this.data.yklist.concat(res.data.rows) + } + this.setData({ + yktotal: res.data.total, + yklist: list + }) + } + } + wx.hideLoading(); + } + }); + }, + gettodokslist: function (page) { + var that = this; + if (page != 1) { page = that.data.todopage } + wx.showLoading({ + title: '加载中', + }), + wx.request({ + url: this.data.serverUrl + 'api/examtestdetail?a=listdk&rows=10&page=' + page, + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + success: res => { + if (res.statusCode === 200) { + if (res.data.rows.length == 0) { + if (page == 1) { + this.setData({ + todototal: 0, + todokslist: [] + }) + } + else { + wx.showModal({ + content: "已经到底啦!", + showCancel: false, + confirmText: "确定", + }) + } + + + } else { + let list + if (page == 1) { + list = res.data.rows + } else { + list = this.data.todokslist.concat(res.data.rows) + } + this.setData({ + todototal: res.data.total, + todokslist: list + }) + } + } + wx.hideLoading(); + } + }); + }, + onLoad: function () { + // this.setData({ + // icon: base64.icon20 + // }); + var that = this; + wx.getSystemInfo({ + success: function (res) { + that.setData({ + sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2, + sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex + }); + } + }); + }, + onShow: function () { + var that = this; + console.log(that.data.activeIndex) + if (that.data.activeIndex == 0) { + that.gettodokslist(1) + that.data.todopage = 1 + } + else if (that.data.activeIndex == 1) { + that.getyklist(1) + that.data.page = 1 + } + }, + onPullDownRefresh: function () { + var that = this; + if (that.data.activeIndex == 0) { + that.gettodokslist(1) + wx.stopPullDownRefresh(); + that.data.todopage = 1 + } + else if (that.data.activeIndex == 1) { + that.getyklist(1) + wx.stopPullDownRefresh(); + that.data.page = 1 + } + }, + onReachBottom: function () { + //上拉分页,将页码加1,然后调用分页函数 + + var that = this; + if (that.data.activeIndex == 0) { + this.data.todopage = this.data.todopage + 1; + this.gettodokslist(); + } + else if (that.data.activeIndex == 1) { + this.data.page = this.data.page + 1; + this.getyklist(); + } + }, +}); \ No newline at end of file diff --git a/pages/examtest/index.json b/pages/examtest/index.json new file mode 100644 index 0000000..2ac22d3 --- /dev/null +++ b/pages/examtest/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "在线考试", + "enablePullDownRefresh": true +} \ No newline at end of file diff --git a/pages/examtest/index.wxml b/pages/examtest/index.wxml new file mode 100644 index 0000000..e833dac --- /dev/null +++ b/pages/examtest/index.wxml @@ -0,0 +1,53 @@ + + + + + {{item}} + + + + + + + + + + \ No newline at end of file diff --git a/pages/examtest/index.wxss b/pages/examtest/index.wxss new file mode 100644 index 0000000..6d7ae6e --- /dev/null +++ b/pages/examtest/index.wxss @@ -0,0 +1,13 @@ +.weui-btn{ + width:auto; + margin: 5px; +} +.container { + background-color: #fff; + color: #939393; +} +.head{ + color:#fff; + background-color: cornflowerblue; + text-align: center; +} \ No newline at end of file diff --git a/pages/examtest/main.js b/pages/examtest/main.js new file mode 100644 index 0000000..fc0de02 --- /dev/null +++ b/pages/examtest/main.js @@ -0,0 +1,323 @@ +// pages/examtest/main.js +var util = require('../../utils/util.js') +Page({ + + /** + * 页面的初始数据 + */ + data: { + tmIndex: 0, + answerChoices:[], + ydtm:0 + }, + tmdata: { + + }, + calydtm:function(e){ + var tms = this.tmdata.tms + var ydtm = 0 + for (var i = 0, len = tms.length; i < len; ++i) { + if(tms[i].userchecked && tms[i].userchecked.length !=0){ + ydtm +=1 + } + } + this.setData({ + ydtm:ydtm + }) + }, + 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; + } + + this.setData({ + answerChoices: answerChoices, + }); + this.tmdata.tms[this.data.tmIndex]['userchecked'] = e.detail.value + this.calydtm() + }, + checkboxChange: function (e) { + console.log('checkbox发生change事件,携带value值为:', 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; + + for (var j = 0, lenJ = values.length; j < lenJ; ++j) { + if (answerChoices[i].value == values[j]) { + answerChoices[i].checked = true; + break; + } + } + } + + this.setData({ + answerChoices: answerChoices, + }); + this.tmdata.tms[this.data.tmIndex]['userchecked'] = e.detail.value + this.calydtm() + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + if(options.id){ + this.setData({ + testid:options.id + }) + wx.showLoading({}) + wx.request({ + url: getApp().globalData.serverUrl + 'api/examtest?a=detailtm&id=' + options.id, + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + success: res => { + if (res.statusCode === 200) { + wx.hideLoading() + console.log(res.data) + let tms = res.data + this.tmdata = tms + console.log(tms.duration) + let mil = tms.duration * 60 * 1000 + console.log(mil) + this.begin(mil) + this.showTm(0) + this.setData({ + tmtotal: tms.tms.length, + starttime: util.formatTime(new Date()) }) + } + + } + }); + } + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + // wx.showModal({ + // title: '系统提示', + // content: '未完成答卷,是否要提交答卷!', + // confirmText: "提交", + // cancelText: "点错了", + // success: function (res) { + // if (res.confirm) { + // } else { + // this.onShow() + // } + // } + // }) + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + begin: function (mil) { + var temp = formatmil(mil); + this.setData({ + countdown: temp, + }); + + if (mil < 2000) { + wx.showLoading({ + title: '时间到,正在交卷..', + }); + this.handtest() + return + }; + + setTimeout( + () => { + mil -= 1000; + this.begin(mil); + }, 1000 + ); + }, + showTm: function (index) { + var that = this + var currentTm = that.tmdata.tms[index] + console.log(currentTm) + that.setData({ 'currentTm': currentTm }) + var answer = currentTm.question__answer + var i = 0 + var x = ['A','B','C','D','E','F'] + var answerChoices = [] + for(var key in answer){ + if(answer[key]!=''){ + answerChoices.push({'name':x[i],'value':key,'checked':false}) + i = i + 1 + } + } + console.log(answerChoices) + that.setData({ 'answerChoices': answerChoices}) + }, + showChecked: function(index){ + var tm = this.tmdata.tms[index] + let choices = this.data.answerChoices + if(tm.userchecked){ + 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 + } + } + } else { + for (var i = 0, len = choices.length; i < len; i++) { + if (choices[i].value == tm.userchecked) { + choices[i].checked = true + } + } + } + this.setData({ + answerChoices: choices + }) + } + }, + next:function(){ + var that = this + var tmIndex = that.data.tmIndex+1 + that.showTm(tmIndex) + that.setData({ + tmIndex:tmIndex, + }) + that.showChecked(tmIndex) + }, + previous: function () { + var that = this + var tmIndex = that.data.tmIndex - 1 + that.showTm(tmIndex) + that.setData({ + tmIndex: tmIndex, + }) + that.showChecked(tmIndex) + }, + hand:function(){ + var that = this + if (that.data.ydtm < that.tmdata.tms.length){ + wx.showModal({ + title: '警告', + content: '答卷未完成,确定提交?', + confirmText: "确定", + cancelText: "取消", + success: function (res) { + if (res.confirm) { + that.handtest() + } + } + }) + }else{ + wx.showModal({ + content: '确定提交?', + confirmText: "确定", + cancelText: "取消", + success: function (res) { + if (res.confirm) { + that.handtest() + } + } + }) + } + }, + 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), + }) + + } + } + }); + } +}) +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; + } +} +function parseParams(data) { + try { + var tempArr = []; + for (var i in data) { + var key = encodeURIComponent(i); + var value = encodeURIComponent(data[i]); + tempArr.push(key + '=' + value); + } + var urlParamsStr = tempArr.join('&'); + return urlParamsStr; + } catch (err) { + return ''; + } +} \ No newline at end of file diff --git a/pages/examtest/main.json b/pages/examtest/main.json new file mode 100644 index 0000000..9c848e5 --- /dev/null +++ b/pages/examtest/main.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "考试中" +} \ No newline at end of file diff --git a/pages/examtest/main.wxml b/pages/examtest/main.wxml new file mode 100644 index 0000000..809eb2d --- /dev/null +++ b/pages/examtest/main.wxml @@ -0,0 +1,50 @@ + + + +倒计时 {{countdown}} + +答题卡: {{ydtm}}/{{tmtotal}} + + + + + + {{tmIndex+1}}. + 单选题 + 多选题 + 判断题 + ({{currentTm.score}}分) + + {{currentTm.question__title}} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/examtest/main.wxss b/pages/examtest/main.wxss new file mode 100644 index 0000000..e51debe --- /dev/null +++ b/pages/examtest/main.wxss @@ -0,0 +1,18 @@ +.head{ + color:#fff; + background-color: cornflowerblue; +} +.txlabel{ + color:#fff; + background-color: rgb(216, 140, 0); + padding: 2px +} +.weui-btn{ + width:auto; + margin: 5px; +} +.sheet{ + color:#fff; + background-color: red; + float:right +} \ No newline at end of file diff --git a/pages/examtest/note.js b/pages/examtest/note.js new file mode 100644 index 0000000..0030b03 --- /dev/null +++ b/pages/examtest/note.js @@ -0,0 +1,86 @@ +// pages/examtest/note.js +var util = require('../../utils/util.js') +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + wx.request({ + url: getApp().globalData.serverUrl + 'api/examtest?a=detail&id='+options.examtestid, + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + success: res => { + if (res.statusCode === 200) { + let ksdata = res.data + if (ksdata.starttime != '') { ksdata.starttime = util.formatTime2(new Date(ksdata.starttime)) } + if (ksdata.endtime != '') { ksdata.endtime = util.formatTime2(new Date(ksdata.endtime)) } + this.setData(res.data) + } + } + }); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + start: function () { + wx.reLaunch({ + url: 'main?id='+this.data.id, + }) + }, +}) \ No newline at end of file diff --git a/pages/examtest/note.json b/pages/examtest/note.json new file mode 100644 index 0000000..28a2a8e --- /dev/null +++ b/pages/examtest/note.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "考试须知" +} \ No newline at end of file diff --git a/pages/examtest/note.wxml b/pages/examtest/note.wxml new file mode 100644 index 0000000..877792f --- /dev/null +++ b/pages/examtest/note.wxml @@ -0,0 +1,22 @@ + + 考试须知 + + + 1.考试详情 + 名称:{{name}} + 答卷时长:{{duration}}分钟 + 满分{{totalscore}};{{passscore}}以上通过 + {{exampaper__total.dx.num}}道单选题,{{exampaper__total.duox.num}}道多选题,{{exampaper__total.pd.num}}道判断题 + + + 2.答题须知 + 进入答题后请不要后退或返回桌面 + 用户可点击上一题/下一题进行切换答题 + 用户选择好选项后会自动跳转至下一题 + 请合理安排时间答题,可提前交卷,超时会自动提交 + + + + + + \ No newline at end of file diff --git a/pages/examtest/note.wxss b/pages/examtest/note.wxss new file mode 100644 index 0000000..5bbca33 --- /dev/null +++ b/pages/examtest/note.wxss @@ -0,0 +1,4 @@ +.weui-btn{ + width:auto; + margin: 5px; +} \ No newline at end of file diff --git a/pages/examtest/result.js b/pages/examtest/result.js new file mode 100644 index 0000000..95659d9 --- /dev/null +++ b/pages/examtest/result.js @@ -0,0 +1,83 @@ +// pages/examtest/result.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + passcode: options.passcode, + score:options.score, + totalscore:options.totalscore, + rights:options.rights, + tmnum:options.tmnum, + detailid: options.examtestdetailid + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + detail:function(){ + wx.navigateTo({ + url: 'detail?detailid=' + this.data.detailid, + }) + }, + back:function(){ + wx.switchTab({ + url: '/pages/main/main' + }) + } +}) \ No newline at end of file diff --git a/pages/examtest/result.json b/pages/examtest/result.json new file mode 100644 index 0000000..3908474 --- /dev/null +++ b/pages/examtest/result.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "在线考试" +} \ No newline at end of file diff --git a/pages/examtest/result.wxml b/pages/examtest/result.wxml new file mode 100644 index 0000000..75bd39f --- /dev/null +++ b/pages/examtest/result.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + 恭喜你,通过考试! + 得分{{score}},满分{{totalscore}} + 全对{{rights}}题,共{{tmnum}}题 + + + 很遗憾,下次加油! + 得分{{score}},满分{{totalscore}} + 全对{{rights}}题,共{{tmnum}}题 + + + + + + + + + \ No newline at end of file diff --git a/pages/examtest/result.wxss b/pages/examtest/result.wxss new file mode 100644 index 0000000..2285021 --- /dev/null +++ b/pages/examtest/result.wxss @@ -0,0 +1,8 @@ +.weui-btn{ + width:auto; + margin: 5px; +} +.b{ + color:red; + font-weight: bold +} \ No newline at end of file diff --git a/pages/examtest/sheet.js b/pages/examtest/sheet.js new file mode 100644 index 0000000..822418a --- /dev/null +++ b/pages/examtest/sheet.js @@ -0,0 +1,87 @@ +// pages/examtest/sheet.js + +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + back: function (e) { + console.log(e.currentTarget.dataset.index); + var tmIndex = e.currentTarget.dataset.index + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2]; //上一个页面 + prevPage.setData({ + tmIndex:tmIndex + }) + prevPage.showTm(tmIndex) + prevPage.showChecked(tmIndex) + wx.navigateBack({ + }) + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2]; //上一个页面 + var tmlist = prevPage.tmdata.tms //取上页data里的数据也可以修改 + console.log(tmlist) + this.setData({ + tmlist:tmlist + }) + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/examtest/sheet.json b/pages/examtest/sheet.json new file mode 100644 index 0000000..6cfdd8d --- /dev/null +++ b/pages/examtest/sheet.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "答题卡" +} \ No newline at end of file diff --git a/pages/examtest/sheet.wxml b/pages/examtest/sheet.wxml new file mode 100644 index 0000000..05a9db7 --- /dev/null +++ b/pages/examtest/sheet.wxml @@ -0,0 +1,13 @@ + + + + + +{{index+1}} + + +{{index+1}} + + + + diff --git a/pages/examtest/sheet.wxss b/pages/examtest/sheet.wxss new file mode 100644 index 0000000..913bdd4 --- /dev/null +++ b/pages/examtest/sheet.wxss @@ -0,0 +1,21 @@ +/* pages/examtest/sheet.wxss */ +.ok{ + display: flex; + color:#fff; + background-color: green; + border:4rpx solid green; + height:100rpx; + width:100rpx; + margin:20rpx; + justify-content: center; + align-items: center; +} +.no{ + display: flex; + border:4rpx solid red; + height:100rpx; + width:100rpx; + margin:20rpx; + justify-content: center; + align-items: center; +} \ No newline at end of file diff --git a/pages/exercise/index.js b/pages/exercise/index.js new file mode 100644 index 0000000..0d37e7a --- /dev/null +++ b/pages/exercise/index.js @@ -0,0 +1,147 @@ +// pages/exercise/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + catsname:'', + start1:true, + start2:false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var that = this +wx.getStorage({ + key: 'questioncats', + success: function(res) { + let lst = res.data + let nst = [] + let nst1 = [] + if (lst) { + for (var i = 0; i < lst.length; i++) { + nst.push(lst[i]['name']) + nst1.push(lst[i]['id']) + } + that.setData({ + catsname: nst.join(','), + cats: nst1.join(','), + }) + } + }, +}) + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + var that=this + let lst = getApp().globalData.selectList + let nst = [] + let nst1 = [] + if (lst) { + for (var i = 0; i < lst.length; i++) { + nst.push(lst[i]['name']) + nst1.push(lst[i]['id']) + } + that.setData({ + catsname: nst.join(','), + cats: nst1.join(','), + }) + } + wx.getStorage({ + key: 'ydtms', + success: function (res) { + that.setData({ + start1: false, + start2: true + }) + }, + }) + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + choosequestioncat:function(){ + wx.navigateTo({ + url: '/pages/questioncat/index', + }) + }, + start1:function(){ +if(this.data.catsname!=''){ +wx.navigateTo({ + url: 'main', +}) +}else{ + wx.showModal({ + content: '请选择题目分类!', + showCancel: false, + }) +} + }, + start2: function () { + if (this.data.catsname != '') { + wx.removeStorage({ + key: 'ydtms', + success: function(res) { + + }, + complete:function(){ + wx.navigateTo({ + url: 'main', + }) + } + }) + + } else { + wx.showModal({ + content: '请选择题目分类!', + showCancel: false, + }) + } + } +}) \ No newline at end of file diff --git a/pages/exercise/index.json b/pages/exercise/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/exercise/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/exercise/index.wxml b/pages/exercise/index.wxml new file mode 100644 index 0000000..8107526 --- /dev/null +++ b/pages/exercise/index.wxml @@ -0,0 +1,17 @@ + + + 模拟练习 + 选择题库分类进行练习。 + + + + 已选分类 + + {{catsname}} + + + + + + + \ No newline at end of file diff --git a/pages/exercise/index.wxss b/pages/exercise/index.wxss new file mode 100644 index 0000000..5adb1f8 --- /dev/null +++ b/pages/exercise/index.wxss @@ -0,0 +1,8 @@ +.button-sp-area{ + margin: 0 auto; + padding-top: 15px; + width: 60%; +} +.mini-btn{ + margin-right: 5px; +} \ No newline at end of file diff --git a/pages/exercise/main.js b/pages/exercise/main.js new file mode 100644 index 0000000..2b282a5 --- /dev/null +++ b/pages/exercise/main.js @@ -0,0 +1,247 @@ +// pages/examtest/main.js +var util = require('../../utils/util.js') +Page({ + + /** + * 页面的初始数据 + */ + data: { + tmIndex: 0, + answerChoices: [], + answerP:false + }, + tmdata: { + tms:[], + ydtms:[] + }, + 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; + } + + this.setData({ + answerChoices: answerChoices, + }); + this.tmdata.tms[this.data.tmIndex]['userchecked'] = e.detail.value + this.setData({ + currentTm: this.tmdata.tms[this.data.tmIndex] + }) + this.showanswer() + }, + checkboxChange: function (e) { + console.log('checkbox发生change事件,携带value值为:', 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; + + for (var j = 0, lenJ = values.length; j < lenJ; ++j) { + if (answerChoices[i].value == values[j]) { + answerChoices[i].checked = true; + break; + } + } + } + this.tmdata.tms[this.data.tmIndex]['userchecked'] = e.detail.value + this.setData({ + answerChoices: answerChoices, + currentTm: this.tmdata.tms[this.data.tmIndex] + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var that = this + wx.getStorage({ + key: 'questioncats', + success: function (res) { + let lst = res.data + let nst = [] + let nst1 = [] + if (lst) { + for (var i = 0; i < lst.length; i++) { + nst.push(lst[i]['name']) + nst1.push(lst[i]['id']) + } + } + that.setData({ + tmlxs:nst1 + }) + wx.getStorage({ + key: 'ydtms', + success: function(res) { + that.tmdata.ydtms = res.data + that.getTms() + }, + fail:function(){ + that.getTms() + } + }) + + }, + }) + + }, + getTms: function () { + var that = this + wx.showLoading({}) + wx.request({ + url: getApp().globalData.serverUrl + 'api/question?a=exercise', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + method: 'POST', + data: { 'tmlx': that.data.tmlxs,'ydtms':that.tmdata.ydtms }, + success: res => { + if (res.statusCode === 200) { + wx.hideLoading() + 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, + }) + } + + } + }); + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { +wx.setStorage({ + key: 'ydtms', + data: this.tmdata.ydtms, +}) + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + showTm: function (index) { + var that = this + var currentTm = that.tmdata.tms[index] + 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){ + that.getTms() + }else{ + that.showTm(tmIndex) + } + that.showChecked(tmIndex) + }, + previous: function () { + var that = this + var tmIndex = that.data.tmIndex - 1 + that.showTm(tmIndex) + that.setData({ + tmIndex: tmIndex, + answerP: false + }) + that.showChecked(tmIndex) + }, +}) diff --git a/pages/exercise/main.json b/pages/exercise/main.json new file mode 100644 index 0000000..6be8d7d --- /dev/null +++ b/pages/exercise/main.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "模拟练习" +} \ No newline at end of file diff --git a/pages/exercise/main.wxml b/pages/exercise/main.wxml new file mode 100644 index 0000000..ec0b92c --- /dev/null +++ b/pages/exercise/main.wxml @@ -0,0 +1,57 @@ + + + + 题量 {{tmIndex+1}}/{{tmtotal}} + + + + + {{tmIndex+1}}. + 单选题 + 多选题 + 判断题 + + {{currentTm.title}} + + + + + + + + + 正确答案是{{currentTm.right}},你的答案是{{currentTm.userchecked}} + + + 解析: {{currentTm.resoluation}} + + 解析: + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/exercise/main.wxss b/pages/exercise/main.wxss new file mode 100644 index 0000000..e51debe --- /dev/null +++ b/pages/exercise/main.wxss @@ -0,0 +1,18 @@ +.head{ + color:#fff; + background-color: cornflowerblue; +} +.txlabel{ + color:#fff; + background-color: rgb(216, 140, 0); + padding: 2px +} +.weui-btn{ + width:auto; + margin: 5px; +} +.sheet{ + color:#fff; + background-color: red; + float:right +} \ No newline at end of file diff --git a/pages/images/examtest.png b/pages/images/examtest.png new file mode 100644 index 0000000..9ee2219 Binary files /dev/null and b/pages/images/examtest.png differ diff --git a/pages/images/exercise.png b/pages/images/exercise.png new file mode 100644 index 0000000..94ef5d4 Binary files /dev/null and b/pages/images/exercise.png differ diff --git a/pages/images/file.png b/pages/images/file.png new file mode 100644 index 0000000..afe91b2 Binary files /dev/null and b/pages/images/file.png differ diff --git a/pages/images/operation.png b/pages/images/operation.png index 6525376..0cbe2ea 100644 Binary files a/pages/images/operation.png and b/pages/images/operation.png differ diff --git a/pages/images/safecert.png b/pages/images/safecert.png new file mode 100644 index 0000000..b4db00c Binary files /dev/null and b/pages/images/safecert.png differ diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 7b3817c..c887053 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -28,6 +28,17 @@ + + + + + + + 我的安全资格证书 + + + + diff --git a/pages/main/main.js b/pages/main/main.js index 704b2b0..06677b8 100644 --- a/pages/main/main.js +++ b/pages/main/main.js @@ -5,14 +5,18 @@ Page({ * 页面的初始数据 */ data: { - + yhtodonum:0, + zytodonum:0, + noread:0, + dqdnum:0, + dknum:0, + kaoshi:false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - }, /** @@ -29,16 +33,20 @@ Page({ var that = this //获取待阅读通知数目 if(wx.getStorageSync("sessionid")){ + this.getrights() this.getnoread() this.getyhtodonum() this.getzytodonum() this.getpxqdnum() + this.getdknum() //待考 }else{ getApp().callback = () => { + this.getrights() this.getnoread() this.getyhtodonum() this.getzytodonum() this.getpxqdnum() + this.getdknum() }; } @@ -155,5 +163,47 @@ Page({ } } }); - } + }, + getdknum: function () { + var that = this + //获取待考 + wx.request({ + url: getApp().globalData.serverUrl + 'api/examtestdetail?a=dknum', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + //console.log(res.data) + this.setData({ + dknum: res.data.dknum, + }) + } + } + }); + }, +getrights:function(){ + wx.request({ + url: getApp().globalData.serverUrl + 'api/rights?a=have', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + //console.log(res.data.rights.indexOf('25')) + if (res.data.rights.indexOf('25') != -1) {//考试功能 + this.setData({ + kaoshi: true + }) + } + } + console.log(this.data.kaoshi) + } + }); +} + }) \ No newline at end of file diff --git a/pages/main/main.wxml b/pages/main/main.wxml index 6a03d8f..c573b1f 100644 --- a/pages/main/main.wxml +++ b/pages/main/main.wxml @@ -1,51 +1,56 @@ - - 数据采集 - - - - 事故隐患 - {{yhtodonum}} - - - - 行为观察 - - - - 未遂事件 - - - - 合理化建议 - - - - 作业许可 - {{zytodonum}} - - - 学习园地 - - - - 公告 - - - - 通知 - - {{noread}} - - - - 线下培训 - {{dqdnum}} - - - - 即将上线.. - - + + 数据采集 + + + + 事故隐患 + {{yhtodonum}} + + + + 行为观察 + + + + 未遂事件 + + + + 合理化建议 + + + + 作业许可 + {{zytodonum}} + + 学习园地 + + + + 公告 + + + + 通知 + + {{noread}} + + + + 线下培训 + {{dqdnum}} + + + + 在线考试 + {{dknum}} + + + + 模拟练习 + + + \ No newline at end of file diff --git a/pages/notice/detail.js b/pages/notice/detail.js index ecda2d6..cba195e 100644 --- a/pages/notice/detail.js +++ b/pages/notice/detail.js @@ -126,6 +126,7 @@ Page({ if (res.statusCode === 200) { var tzdata = res.data let material = [] + console.log(tzdata) console.log(tzdata.notice.material.length) for (var i = 0, len = tzdata.notice.material.length; i < len; i++) { let x = {} @@ -135,9 +136,12 @@ Page({ } console.log(material) this.setData({ - material: material + material: material, + title:tzdata.notice.title, + readpeople:tzdata.readpeople, + readsnum:tzdata.readsnum }) - this.setData(tzdata) + WxParse.wxParse('article', 'html', tzdata.notice.content, this, 0) } diff --git a/pages/notice/detail.wxml b/pages/notice/detail.wxml index 9e00620..bea177f 100644 --- a/pages/notice/detail.wxml +++ b/pages/notice/detail.wxml @@ -2,7 +2,7 @@ - {{notice.title}} + {{title}} 阅读人数:{{readpeople}} 阅读次数:{{readsnum}} 附件 diff --git a/pages/observe/observe.wxml b/pages/observe/observe.wxml index 005acb1..523f804 100644 --- a/pages/observe/observe.wxml +++ b/pages/observe/observe.wxml @@ -1,20 +1,20 @@ - + 共{{total}}条行为观察 - + - {{item.lookplace}} {{item.actname}} + {{item.lookplace}} {{item.actname}} {{item.looknum}} {{item.looker__name}}填报 {{item.looktime}} - + - + \ No newline at end of file diff --git a/pages/operation/list.js b/pages/operation/list.js new file mode 100644 index 0000000..9c56bd3 --- /dev/null +++ b/pages/operation/list.js @@ -0,0 +1,83 @@ +// pages/operation/list.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + getzylxlist: function () { + wx.request({ + url: getApp().globalData.serverUrl + 'getdickey?dicclass=33', + header: { + 'content-type': 'application/json', // + 'Cookie': wx.getStorageSync("sessionid"), + }, + method: 'GET', + success: res => { + if (res.statusCode === 200) { + let zylxlist = res.data.rows + this.setData({ + zylxlist: zylxlist, + }) + } + } + }) + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.getzylxlist() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/operation/list.json b/pages/operation/list.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/operation/list.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/operation/list.wxml b/pages/operation/list.wxml new file mode 100644 index 0000000..53bb163 --- /dev/null +++ b/pages/operation/list.wxml @@ -0,0 +1,14 @@ + + 选择作业类型 + + + + + {{item.dickeyname}} + + {{item.detail}} + 审批流程:{{item.splcdetail}} + + + + \ No newline at end of file diff --git a/pages/operation/list.wxss b/pages/operation/list.wxss new file mode 100644 index 0000000..a458506 --- /dev/null +++ b/pages/operation/list.wxss @@ -0,0 +1,5 @@ +.head{ + color:#fff; + background-color: cornflowerblue; + text-align: center; +} \ No newline at end of file diff --git a/pages/operation/operation.js b/pages/operation/operation.js index 942abc0..84cc98a 100644 --- a/pages/operation/operation.js +++ b/pages/operation/operation.js @@ -19,7 +19,6 @@ Page({ if (that.data.activeIndex == 0) { that.getmyZylist(1) that.data.mypage = 1 - that.getzylxlist() } else if (that.data.activeIndex == 1) { that.gettodoZylist(1) @@ -135,20 +134,20 @@ Page({ success: res => { if (res.statusCode === 200) { if (res.data.rows.length == 0) { - if(page==1){ + if (page == 1) { this.setData({ todototal: 0, todozylist: [] }) } - else{ + else { wx.showModal({ content: "已经到底啦!", showCancel: false, confirmText: "确定", }) } - + } else { let list @@ -187,7 +186,6 @@ Page({ if (that.data.activeIndex == 0) { that.getmyZylist(1) that.data.mypage = 1 - that.getzylxlist() } else if (that.data.activeIndex == 1) { that.gettodoZylist(1) @@ -233,47 +231,12 @@ Page({ this.getallZylist(); } }, - getzylxlist: function () { - wx.request({ - url: getApp().globalData.serverUrl + 'getdickey?dicclass=33&a=combobox', - header: { - 'content-type': 'application/json', // - 'Cookie': wx.getStorageSync("sessionid"), - }, - method: 'GET', - success: res => { - if (res.statusCode === 200) { - let zylxlist=res.data - let zylxtext = [] - for (var i = 0; i < zylxlist.length; i++) { - zylxtext.push(zylxlist[i]['text']) - } - this.setData({ - zylxlist: zylxlist, - zylxtext: zylxtext - }) - } - } - }) - }, - open: function(){ - var that = this - console.log(that.data.zylxlist) - wx.showActionSheet({ - itemList: that.data.zylxtext, - success: function (res) { - if (!res.cancel) { - console.log(res.tapIndex) - if(false){ - }else{ - wx.navigateTo({ - url: 'operationadd?zylx=' + that.data.zylxlist[res.tapIndex]['value'], - }) - } - - } - } - }); - } + open: function () { + + wx.navigateTo({ + url: 'list', + }) + + }, }); \ No newline at end of file diff --git a/pages/operation/operation.wxml b/pages/operation/operation.wxml index e90058f..5455fa5 100644 --- a/pages/operation/operation.wxml +++ b/pages/operation/operation.wxml @@ -1,91 +1,88 @@ - - - - - - - {{item}} - - - + + + + + {{item}} - - - - + + + + + + + + + + \ No newline at end of file diff --git a/pages/operation/operationadd.js b/pages/operation/operationadd.js index eb45ca3..5479336 100644 --- a/pages/operation/operationadd.js +++ b/pages/operation/operationadd.js @@ -320,7 +320,9 @@ Page({ success: res => { if (res.statusCode === 200) { wx.hideLoading(); - wx.navigateBack() + wx.navigateBack({ + delta: 2 + }) } } }); diff --git a/pages/operation/operationdetail.json b/pages/operation/operationdetail.json index 8835af0..38e5b26 100644 --- a/pages/operation/operationdetail.json +++ b/pages/operation/operationdetail.json @@ -1,3 +1,4 @@ { - "usingComponents": {} + "usingComponents": {}, + "navigationBarTitleText": "作业详情" } \ No newline at end of file diff --git a/pages/public/detail.js b/pages/public/detail.js index 49b8923..949967a 100644 --- a/pages/public/detail.js +++ b/pages/public/detail.js @@ -136,11 +136,12 @@ Page({ x['value'] = ggdata.notice.material[i] material.push(x) } - console.log(material) + //console.log(material) this.setData({ - material: material + material: material, + title: ggdata.notice.title, + reads: ggdata.notice.reads }) - this.setData(ggdata) WxParse.wxParse('article', 'html', ggdata.notice.content, this, 0) } diff --git a/pages/public/detail.wxml b/pages/public/detail.wxml index d2438df..8ec9704 100644 --- a/pages/public/detail.wxml +++ b/pages/public/detail.wxml @@ -2,8 +2,8 @@ - {{notice.title}} - 阅读量:{{notice.reads}} + {{title}} + 阅读量:{{reads}} 附件 diff --git a/pages/questioncat/ArrayUtils.js b/pages/questioncat/ArrayUtils.js new file mode 100644 index 0000000..d094c7d --- /dev/null +++ b/pages/questioncat/ArrayUtils.js @@ -0,0 +1,22 @@ +export default { /** + * 给数组去重 + */ checkRepeat(list) { + let noRepList = [list[0]] + for (let i = 0; i < list.length; i++) { + let repeat = false + for (let j = 0; j < noRepList.length; j++) + { if (noRepList[j].id === list[i].id) { + repeat = true + break } } + if (!repeat) { noRepList.push(list[i]) } } + return noRepList + }, //删除list中id为 delId 的元素 + deleteItemById(list, delId){ + for (let i = 0; i < list.length; i++) { + if (list[i].id == delId) { + list.splice(i, 1) + return list; } + } + return list; + } + } \ No newline at end of file diff --git a/pages/questioncat/index.js b/pages/questioncat/index.js new file mode 100644 index 0000000..fe96fa0 --- /dev/null +++ b/pages/questioncat/index.js @@ -0,0 +1,351 @@ + +//import API from '../../../utils/API.js' +import ArrayUtils from 'ArrayUtils.js' +//import EventBus from '../../../components/NotificationCenter/WxNotificationCenter.js' + + + +Page({ + data: { + currentList: [], //当前展示的列表 + selectList: [], //已选择的元素列表 + originalList: [], //最原始的数据列表 + indexList: [], //存储目录层级的数组,用于准确的返回上一层 + selectList: [], //已选中的人员列表 + }, + + onLoad: function (options) { + wx.setNavigationBarTitle({ + title: '选择分类' + }) + this.init(); + }, + + init() { + //上次选中的列表,用于判断是不是取消选中了 + this.lastTimeSelect = [] + wx.request({ + url: getApp().globalData.serverUrl + 'api/questioncat?a=tree', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + let list = convert(res.data) + this.setData({ + currentList: list, + originalList: list + }) + } + } + }) + }, + + clickItem(res) { + console.log(res) + let index = res.currentTarget.id; + let item = this.data.currentList[index] + + console.log("item", item) + if(item.children.length!=0){ + this.setData({ + currentList: item.children + }) + //将当前的索引存入索引目录中。索引多一个表示目录多一级 + let indexes = this.data.indexList + indexes.push(index) + //是目录不是具体的用户 + this.setData({ + indexList: indexes + }) + //清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect + this.setLastTimeSelectList(); + } + + }, + + + //返回按钮 + goBack() { + let indexList = this.data.indexList + if (indexList.length > 0) { + //返回时删掉最后一个索引 + indexList.pop() + if (indexList.length == 0) { + //indexList长度为0说明回到了最顶层 + this.setData({ + currentList: this.data.originalList, + indexList: indexList + }) + } else { + //循环将当前索引的对应数组赋值给currentList + let list = this.data.originalList + for (let i = 0; i < indexList.length; i++) { + let index = indexList[i] + list = list[index].children + } + this.setData({ + currentList: list, + indexList: indexList + }) + } + //清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect + this.setLastTimeSelectList(); + } + }, + + //清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect + setLastTimeSelectList() { + this.lastTimeSelect = [] + this.data.currentList.forEach(item => { + if (item.checked) { + this.lastTimeSelect.push(item) + } + }) + }, + + //根据部门获取下列列表 + // _getUserByGroup(item) { + // wx.request({ + // url: getApp().globalData.serverUrl + 'api/partuser?a=getall&parentid=' + item.id, + // header: { + // 'content-type': 'application/json', // 默认值 + // 'Cookie': wx.getStorageSync("sessionid"), + // }, + // data: {}, + // success: res => { + // if (res.statusCode === 200) { + // let list = res.data.data + // console.log(res.list) + // this.setData({ + // currentList: list + // }) + // this.addList2DataTree() + // this.setLastTimeSelectList(); + // } + // } + // }) + // getApp().get(API.selectUserByGroup(), params, result => { + // console.log('result', result) + // let list = this.transformData(result.data.data, item.id) + // this.setData({ + // currentList: list + // }) + // this.addList2DataTree() + // //清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect。写在这里防止异步请求时执行顺序问题 + // this.setLastTimeSelectList(); + // }) + // }, + + + + //将请求的数据转化为需要的格式 + // transformData(list, parentId) { + // //先将数据转化为固定的格式 + // let newList = [] + // for (let i = 0; i < list.length; i++) { + // let item = list[i] + // newList.push({ + // id: item.id, + // name: item.realName, + // parentId: parentId, + // checked: false, + // isPeople: true, + // userType: item.userType, + // gender: item.gender, + // children: [] + // }) + // } + // return newList; + // }, + + //将当前列表挂载在原数据树上, 目前支持5层目录,如需更多接着往下写就好 + addList2DataTree() { + let currentList = this.data.currentList; + let originalList = this.data.originalList; + let indexes = this.data.indexList + switch (indexes.length) { + case 1: + originalList[indexes[0]].children = currentList + break; + case 2: + originalList[indexes[0]].children[indexes[1]].children = currentList + break; + case 3: + originalList[indexes[0]].children[indexes[1]].children[indexes[2]].children = currentList + break; + case 4: + originalList[indexes[0]].children[indexes[1]].children[indexes[2]].children[indexes[3]].children = currentList + break; + case 5: + originalList[indexes[0]].children[indexes[1]].children[indexes[2]].children[indexes[3]].children[indexes[4]].children = currentList + break; + case 6: + originalList[indexes[0]].children[indexes[1]].children[indexes[2]].children[indexes[3]].children[indexes[4]].children[indexes[5]].children = currentList + break; + } + + this.setData({ + originalList: originalList + }) + console.log("originalList", originalList) + }, + + //选框变化回调 + checkChange(res) { + console.log(res) + let values = res.detail.value + let selectItems = [] + //将值取出拼接成 id,name 格式 + values.forEach(value => { + let arrs = value.split(",") + selectItems.push({ id: arrs[0], name: arrs[1] }) + }) + console.log("selectItems", selectItems) + console.log("lastTimeSelect", this.lastTimeSelect) + + //将本次选择的与上次选择的比对,本次比上次多说明新增了,本次比上次少说明删除了,找出被删除的那条数据,在footer中也删除 + if (selectItems.length > this.lastTimeSelect.length) { + //将 selectList 与 selectItems 拼接并去重 + let newList = this.data.selectList.concat(selectItems) + newList = ArrayUtils.checkRepeat(newList) + this.setData({ + selectList: newList + }) + } else { + //找出取消勾选的item,从selectList中删除 + //比对出取消勾选的是哪个元素 + let diffItem = {} + this.lastTimeSelect.forEach(item => { + let flag = false; + selectItems.forEach(item2 => { + if (item.id === item2.id) { + flag = true + } + }) + if (!flag) { + diffItem = item + console.log("diff=", item) + } + }) + //找出被删除的元素在 selectList 中的位置 + let list = this.data.selectList + let delIndex = 0; + for (let i = 0; i < list.length; i++) { + if (list[i].id === diffItem.id) { + delIndex = i; + break; + } + } + //从list中删除这个元素 + list.splice(delIndex, 1) + this.setData({ + selectList: list + }) + } + console.log("selectList", this.data.selectList) + //更新 currentList 选中状态并重新挂载在数据树上,以保存选择状态 + this.updateCurrentList(this.data.currentList, this.data.selectList) + }, + + //footer点击删除回调 + footerDelete(res) { + console.log(res) + this.setData({ + selectList: res.detail.selectList + }) + + console.log('selectList', this.data.selectList) + this.updateCurrentList(this.data.currentList, res.detail.selectList) + }, + + //点击 footer 的确定按钮提交数据 + submitData(res) { + let selectList = this.data.selectList + //通过 WxNotificationCenter 发送选择的结果通知 + //EventBus.postNotificationName("SelectPeopleDone", selectList) + //将选择结果存入 app.js 的 globalData + getApp().globalData.selectList = selectList + wx.setStorage({ + key: 'questioncats', + data: selectList, + success: function(res) {}, + fail: function(res) {}, + complete: function(res) {}, + }) + //返回 + wx.navigateBack({ + delta: 1 + }) + console.log("selectdone", selectList) + }, + + //更新 currentList 并将更新后的列表挂载在数据树上 + updateCurrentList(currentList, selectList) { + //let newList = [] + let selectids = [] + for (var i = 0; i < selectList.length; i++) { + selectids.push(selectList[i]['id']) + } + for (var i = 0; i < currentList.length; i++) { + if (selectids.indexOf(currentList[i]['id'].toString()) >= 0) { + currentList[i]['checked'] = true + } else { + currentList[i]['checked'] = false + } + } + console.log(currentList) + this.setData({ + currentList: currentList + }) + this.addList2DataTree() + this.setLastTimeSelectList() + } +}) +function convert(rows) { + function exists(rows, parentId) { + for (var i = 0; i < rows.length; i++) { + if (rows[i].id == parentId) return true; + } + return false; + } + + var nodes = []; + // get the top level nodes + for (var i = 0; i < rows.length; i++) { + var row = rows[i]; + if (!exists(rows, row.parentId)) { + nodes.push({ + id: row.id, + parentId: 0, + name: row.name, + checked:false, + children:[] + }); + } + } + + var toDo = []; + for (var i = 0; i < nodes.length; i++) { + toDo.push(nodes[i]); + } + while (toDo.length) { + var node = toDo.shift(); // the parent node + // get the children nodes + for (var i = 0; i < rows.length; i++) { + var row = rows[i]; + if (row.parentId == node.id) { + var child = { id: row.id, name: row.name,parentId:row.parentId,checked:false,children:[] }; + if (node.children) { + node.children.push(child); + } else { + node.children = [child]; + } + toDo.push(child); + } + } + } + return nodes; +} \ No newline at end of file diff --git a/pages/questioncat/index.json b/pages/questioncat/index.json new file mode 100644 index 0000000..59e4727 --- /dev/null +++ b/pages/questioncat/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "footer": "/components/footer/footer" + } +} \ No newline at end of file diff --git a/pages/questioncat/index.wxml b/pages/questioncat/index.wxml new file mode 100644 index 0000000..fbf3e97 --- /dev/null +++ b/pages/questioncat/index.wxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + {{item.name}} + + + 暂无数据 + + + +