// pages/tu_xing_tui_li/tu_xing_tui_li.js const { throttle } = require('../../utils/util.js') const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isKjxx: true, isAnswer: false, statusBar: app.globalData.statusBar, times: 0, level:1, mentalRotation:0, graphicReasoning:0, spaceImagination:0, executionFunctionality:0, visualSearch:0, workingMemory:0, isWhite:false, allList:[ [ { idx: 3, imgTitle: '../../image/lianxi_title_four.png', header: '正式测试前先练习一下吧:', title: '从左边看这个几何体,看到的形状是?', answerList: [ [ { img: '../../image/lianxi_four_as_a.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/lianxi_four_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/lianxi_four_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/lianxi_four_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/lianxi_four_as_d.png', text: 'A', isAnswer:0, status: '' }, { img: '../../image/lianxi_four_as_c.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/lianxi_four_as_b.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/lianxi_four_as_a.png', text: 'D', isAnswer: 1, status: '' } ], ] }, ], [ { id: 0, imgTitle: '../../image/the_first_pass_three_tittle.png', title: '下面是一个魔方从两面看的效果图,这个魔方六面是不同的颜色,请问蓝色对面是什么颜色?', answerList: [ [ { img: '../../image/the_first_pass_three_as_a.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/the_first_pass_three_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_first_pass_three_as_d.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three_as_a.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_first_pass_three_as_c.png', text: 'D', isAnswer: 0, status: '' } ], ] }, { id: 1, imgTitle: '../../image/the_first_pass_three_tittle1.png', title: '下图中几何体,从正面看是什么图形呢?', answerList: [ [ { img: '../../image/the_first_pass_three1_as_a.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three1_as_c.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_first_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_first_pass_three1_as_c.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_first_pass_three1_as_a.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_first_pass_three1_as_d.png', text: 'D', isAnswer: 1, status: '' } ], ] }, ], [ { id: 0, imgTitle: '../../image/the_second_pass_three_tittle.png', title: '如果把下图的平面叠成一个骰子,下列的骰子中哪个是正确的?', answerList: [ [ { img: '../../image/the_second_pass_three_as_a.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three_as_d.png', text: 'D', isAnswer: 1, status: '' } ], [ { img: '../../image/the_second_pass_three_as_a.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three_as_d.png', text: 'B', isAnswer: 1, status: '' }, { img: '../../image/the_second_pass_three_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three_as_b.png', text: 'D', isAnswer: 0, status: '' } ], ] }, { id:1, imgTitle: '../../image/the_second_pass_three_tittle1.png', title: '观察这堆立方体,从上面看顶部会出现哪个图形?', answerList: [ [ { img: '../../image/the_second_pass_three1_as_a.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three1_as_c.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_second_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_second_pass_three1_as_d.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three1_as_c.png', text: 'B', isAnswer: 1, status: '' }, { img: '../../image/the_second_pass_three1_as_b.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_second_pass_three1_as_a.png', text: 'D', isAnswer: 0, status: '' } ], ] }, ], [ { id: 0, imgTitle: '../../image/the_third_pass_three_tittle.png', title: '若某几何体的三视图如图所示,则这个几何体的直观图可以是下列哪个?', answerList: [ [ { img: '../../image/the_third_pass_three_as_a.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/the_third_pass_three_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_third_pass_three_as_d.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three_as_c.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three_as_b.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three_as_a.png', text: 'D', isAnswer: 1, status: '' } ], ] }, { id: 1, imgTitle: '../../image/the_third_pass_three_tittle1.png', title: '如果把下图的平面叠成一个骰子,下列的骰子中哪个是正确的?', answerList: [ [ { img: '../../image/the_third_pass_three1_as_a.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/the_third_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three1_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_third_pass_three1_as_c.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_third_pass_three1_as_a.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_third_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], ] }, ], [ { id: 0, imgTitle: '../../image/the_fourth_pass_three_tittle.png', title: '如果从不同的方向进行观察,A, B,C, D这几个剖面哪一个是不可能观察到的呢 ?', answerList: [ [ { img: '../../image/the_fourth_pass_three_as_b.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three_as_a.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/the_fourth_pass_three_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_fourth_pass_three_as_b.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three_as_d.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three_as_a.png', text: 'D', isAnswer: 1, status: '' } ] ] }, { id:1, imgTitle: '../../image/the_fourth_pass_three_tittle1.png', title: '如果把下图的平面叠成一个骰子,下列的骰子中哪个是正确的?', answerList: [ [ { img: '../../image/the_fourth_pass_three1_as_a.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/the_fourth_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three1_as_c.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_fourth_pass_three1_as_c.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_fourth_pass_three1_as_a.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_fourth_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], ] }, ], [ { id: 0, imgTitle: '../../image/the_fifth_pass_three_tittle.png', title: '一张桌子上摆放了很多碟子,从正面、上面、左边三那个方向上看,三种视图如下图所示,则这张桌子上共有几个碟子?', answerList: [ [ { img: '14', text: 'A', isAnswer: 0, status: '' }, { img: '12', text: 'B', isAnswer: 1, status: '' }, { img: '16', text: 'C', isAnswer: 0, status: '' }, { img: '10', text: 'D', isAnswer: 0, status: '' } ], [ { img: '10', text: 'A', isAnswer: 0, status: '' }, { img: '16', text: 'B', isAnswer: 0, status: '' }, { img: '14', text: 'C', isAnswer: 0, status: '' }, { img: '12', text: 'D', isAnswer: 1, status: '' } ], ] }, { id: 1, imgTitle: '../../image/the_fifth_pass_three_tittle1.png', title: '下面是一个几何体,从顶上看它的俯视图是选项中哪个形状呢?', answerList: [ [ { img: '../../image/the_fifth_pass_three1_as_a.png', text: 'A', isAnswer: 0, status: '' }, { img: '../../image/the_fifth_pass_three1_as_b.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_fifth_pass_three1_as_c.png', text: 'C', isAnswer: 1, status: '' }, { img: '../../image/the_fifth_pass_three1_as_d.png', text: 'D', isAnswer: 0, status: '' } ], [ { img: '../../image/the_fifth_pass_three1_as_c.png', text: 'A', isAnswer: 1, status: '' }, { img: '../../image/the_fifth_pass_three1_as_d.png', text: 'B', isAnswer: 0, status: '' }, { img: '../../image/the_fifth_pass_three1_as_a.png', text: 'C', isAnswer: 0, status: '' }, { img: '../../image/the_fifth_pass_three1_as_b.png', text: 'D', isAnswer: 0, status: '' } ], ] }, ], ] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData(options) console.log(options) this.setData({ isOne: Math.round(Math.random()), isRandom:Math.round(Math.random()) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * 底部导航跳转 */ redirectCtl: app.redirectCtl, /** * 返回上一级页面 */ blockCtl: function () { this.redirectCtl({ url: 'me', method: {} }, true) this.endSetInter(); }, /** * 开始答题 */ actionAnswer: function () { const { isKjxx } = this.data; this.startSetInter(); this.setData({ isKjxx: false }) }, /** * 选择答案 */ selectItems:throttle(function(e){ const {lindex, mindex,sindex } = e.currentTarget.dataset; const { allList, times, graphicReasoning, ageGroup,isRandom} = this.data; // console.log(lindex, mindex,sindex) var that = this; var temp = {}; for (var i in allList[lindex][mindex].answerList[isRandom]) { temp[`allList[${lindex}][${mindex}].answerList[${isRandom}][${i}].status`] = ''; } temp[`allList[${lindex}][${mindex}].answerList[${isRandom}][${sindex}].status`]='active'; this.setData(temp); if (allList[lindex][mindex].answerList[isRandom][sindex].isAnswer == 1) { that.setData({ isYes: true,isAnswer: true }) if(lindex!=0){ that.integraeRule(1) } that.endSetInter(); that.startSetInter() } else { that.setData({ isYes: false,isAnswer: true }) if(lindex!=0){ that.integraeRule(0) } that.endSetInter(); that.startSetInter() } setTimeout( function () { if(lindex+1==6){ that.endSetInter(); that.tenEndTimes() }else{ that.setData({ level:lindex+1,isAnswer:false,times: 0,isOne: Math.round(Math.random()),isRandom:Math.round(Math.random()),isWhite:true}) that.hiddenShow() } }, 300) },800), /** * 过渡页显示 */ hiddenShow:function(){ const {isWhite} = this.data; var that = this; setTimeout(function () { that.setData({ isWhite:false}) }, 500) }, /** * 积分规则处理 */ integraeRule:function(str){ const { ageGroup, times,spaceImagination}=this.data; var that = this; // console.log(ageGroup, times,spaceImagination) that.saveCase(str) if(str==1){ if (0<ageGroup&&ageGroup <= 5) { if (0 < times && times <= 900) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (900< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } }else if (6<=ageGroup&&ageGroup <= 8){ if (0 < times && times <= 720) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (720< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } } else if (9<=ageGroup&&ageGroup <=12){ if (0 < times && times <= 600) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (600< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } } else if (13<=ageGroup&&ageGroup<= 15){ if (0 < times && times <= 480) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (480< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } } else if (16<=ageGroup&&ageGroup <= 35){ if (0 < times && times <= 300) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (300< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } } else if (36<=ageGroup&&ageGroup <= 49){ if (0 < times && times <= 480) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (480< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } }else if (50<=ageGroup&&ageGroup <= 60){ if (0 < times && times <= 720) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (720< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } } else if (60<ageGroup){ if (0 < times && times <= 900) { that.setData({ spaceImagination: Number(spaceImagination)+20 }); }else if (900< times) { that.setData({ spaceImagination: Number(spaceImagination)+18 }); } } }else{ that.setData({ spaceImagination: Number(spaceImagination)+0 }); } }, /** * 开始计时 */ startSetInter: function () { var that = this; const { graphicReasoning } = that.data; //将计时器赋值给setInter that.data.setInter = setInterval( function () { var numVal = that.data.times + 0.1; that.setData({ times: numVal }); } , 100); }, /** * 结束计时 */ endSetInter: function () { var that = this; clearInterval(that.data.setInter) }, /** * 页面跳转定时器 */ tenEndTimes: function () { var that = this; const { graphicReasoning, level, ageGroup,spaceImagination,executionFunctionality,visualSearch,workingMemory,mentalRotation,gameRespondentId} = that.data; setTimeout( function () { that.redirectCtl({ url: 'shi_jue_suo_sou', method: { graphicReasoning, level:0, ageGroup,spaceImagination,executionFunctionality,visualSearch,workingMemory,mentalRotation,gameRespondentId} }, true) }, 500 ) }, /** * 答题情况保存 */ saveCase:function(str){ const postData = { fn: this.getPersonInfo, param: { ...arguments } } const {level,times,gameRespondentId}=this.data app.post('/api/game/v2/answerInfoSave', {gameRespondentId,moduleCode:4,questionCode:level,usedTime:Math.round(times*1000),answerResult:str+1}, 0, postData).then(res => { }) }, })