1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- let app = getApp()
- Page({
- data: {
- list: [],
- paperId:0,
- title:'',
- preList:["A","B","C", "D","E","F"],
- info:{},
- id:0,
- userInfo:{},
- result: {}
- },
- onLoad: function(options) {
- let paperId = +options.paperId||1
- let title = options.title||'试卷'
- this.setData({paperId, title})
- },
- onShow: function () {
- app.checkLogin( userInfo =>{
- this.setData({userInfo, from:0})
- this.indexLoad()
- })
- },
- indexLoad(){
- let paperId = this.data.paperId;
- app.formPost("exam.GetWxGroupPaperInfo", {paperId}).then(res => {
- if (res.code ==200) {
- let list = res.data.map( item =>{
- if( item.select > 0) item._select = true;
- return item
- })
- this.setData({list });
- }
- })
- },
- radioChange( e ){
- let index = e.currentTarget.dataset.index;
- let list = this.data.list
- list[index].select = +e.detail.value
- this.submitAnswer(list[index], list[index].select== list[index].result?1:0 )
- this.setData( {list} );
- },
- emptyAnswer(e){
- let list = this.data.list.map( item =>{
- item._select = false;
- item.select = 0
- return item
- })
- this.setData({list})
- },
- checkboxChange( e ){
- let index = e.currentTarget.dataset.index;
- let list = this.data.list
- list[index].select = +e.detail.value.sort().join("")
- let result = ""+list[index].result
- if (list[index].select == result ){
- list[index]._select = true
- this.submitAnswer(list[index], 1 )
- }else{
- for( let i in e.detail.value){
- if(result.indexOf( e.detail.value[i] )==-1 ){
- list[index]._select = true
- this.submitAnswer(list[index], 0 )
- }
- }
- }
- this.setData( {list} );
- },
- submitAnswer( answer, correct ){
- let {paperId} = this.data
- let {answerId, groupId, select} = answer
- let param = {paperId, groupId, answerId, correct, select}
- app.formPost('Exam.SubmitWxGroupPaperAnswer', param).then(res => {
- console.log( res )
- })
- }
- })
|