12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- let app = getApp()
- Page({
- data: {
- preList:["A","B","C", "D", "E", "F"],
- from:0,
- size:10,
- item: {},
- next: false,
- loading:false,
- groupId:0,
- list: [],
- },
- onLoad: function(options) {
- let groupId = + options.groupId||0
- this.setData({groupId})
- this.loadData( )
- },
- loadData( cb ){
- let {size,from, groupId, list } = this.data
- this.setData({loading:true})
- app.formPost('Exam.GetErrorAnswerList', {groupId,from,size}).then(res => {
- if (res.code ==200) {
- if( from == 0){
- list = [];
- }
- this.setData({
- from: res.data.from,
- list: list.concat(res.data.list),
- });
- }
- this.setData({loading:false})
- cb&&cb()
- })
- },
- radioChange( e ){
- let index = e.currentTarget.dataset.index;
- let list = this.data.list
- list[index].select = +e.detail.value
- this.setData( {list} );
- if( list[index].select== list[index].result ) this.delAnswer(list[index].answerId )
- },
- 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.delAnswer(list[index].answerId )
- }else{
- for( let i in e.detail.value){
- if(result.indexOf( e.detail.value[i] )==-1 ){
- list[index]._select = true
- }
- }
- }
- this.setData( {list} );
- },
- emptyAnswer(e){
- let list = this.data.list.map( item =>{
- item._select = false;
- item.select = 0
- return item
- })
- this.setData({list})
- },
- onPullDownRefresh() {
- if (!this.loading) {
- this.loadData( this.stopPullDownRefresh )
- }
- },
- onReachBottom() {
- if (!this.loading && this.data.from > -1) {
- this.loadData( )
- }
- },
- stopPullDownRefresh(){
- wx.stopPullDownRefresh()
- },
- delAnswer( answerId ){
- app.formPost('Exam.DelErrorAnswer', {answerId}).then(res => {
- })
- }
- })
|