123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564 |
- // pages/zhi_xing_gong_neng/zhi_xing_gong_neng.js
- const { throttle } = require('../../utils/util.js')
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- isZxgn:true,
- isAnswer:false,
- statusBar: app.globalData.statusBar,
- remainTime:0,
- mentalRotation:0,
- graphicReasoning:0,
- spaceImagination:0,
- executionFunctionality:0,
- visualSearch:0,
- workingMemory:0,
- times:0,
- isWay:0,
- level:0,
- isCorrect:false,
- isMistake:false,
- // ageGroup:16,
- smallList: ['一', '二', '三', '四','五'],
- bigList: ['六','七','八','九','十'],
- randomList: ['一','四','六','七','九'],
- zxgnList:[
- {
- score:0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- },
- {
- score: 0
- }
- ],
- exerciseList:[
- {
- idx: 1,
- title: '谁最大?',
- score:0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 0,
- status: ''
- },
- {
- text: 'B',
- num: Math.floor(Math.random() * (5 - 10) + 10),
- isAnswer: 1,
- status: ''
- }
- ]
- }
- ],
- oneList:[
- {
- idx: 0,
- title: '谁最大?',
- score:0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 0,
- status: ''
- },
- {
- text: 'B',
- num: Math.floor(Math.random() * (5 - 10) + 10),
- isAnswer: 1,
- status: ''
- }
- ]
- },
- {
- idx: 1,
- title: '谁最小?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 1,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 0,
- status: ''
- }
- ]
- },
- {
- idx: 2,
- title: '谁最小?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 1,
- status: ''
- },
- {
- text: 'B',
- num:'十',
- isAnswer: 0,
- status: ''
- }
- ]
- },
- {
- idx:3,
- title: '谁最大?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (3 - 7) + 7),
- isAnswer: 0,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (9 - 10) + 10),
- isAnswer: 1,
- status: ''
- }
- ]
- },
- {
- idx: 4,
- title: '谁最小?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 0,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 1,
- status: ''
- }
- ]
- },
- {
- idx:5,
- title: '谁最大?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (6 - 10) + 10),
- isAnswer: 1,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (2 - 5) + 5),
- isAnswer: 0,
- status: ''
- }
- ]
- },
- {
- idx: 6,
- title: '谁最小?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (4 - 8) + 8),
- isAnswer: 0,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (9 - 10) + 10),
- isAnswer: 1,
- status: ''
- }
- ]
- },
- {
- idx: 7,
- title: '谁最大?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 3) + 3),
- isAnswer: 1,
- status: ''
- },
- {
- text: 'B',
- num:'九',
- isAnswer: 0,
- status: ''
- }
- ]
- },
- {
- idx: 8,
- title: '谁最大?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (4 - 6) + 6),
- isAnswer: 1,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (0 - 3) + 3),
- isAnswer: 0,
- status: ''
- }
- ]
- },
- {
- idx: 9,
- title: '谁最小?',
- score: 0,
- answerList: [
- {
- text: 'A',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 0,
- status: ''
- },
- {
- text: 'B',
- num:Math.floor(Math.random() * (0 - 5) + 5),
- isAnswer: 1,
- status: ''
- }
- ]
- },
- ]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData(options)
- // console.log(options)
- this.setData({
- isOne: Math.round(Math.random()),
- small2: Math.floor(Math.random() * (0 - 5) + 5),
- small: Math.floor(Math.random() * (1 - 5) + 5),
- big: Math.floor(Math.random() * (6 - 10) + 10),
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 返回上一级页面
- */
- blockCtl: function () {
- this.redirectCtl({ url: 'me', method: {} }, true)
- this.endSetInter();
- },
- /**
- * 开始答题
- */
- actionAnswer: function () {
- const { isZxgn } = this.data;
- this.setData({ isZxgn: false })
- },
- /**
- * 底部导航跳转
- */
- redirectCtl: app.redirectCtl,
- /**
- * 练习关选择答案
- */
- exerciseSelectItems:throttle(function(e){
- const {lindex, mindex} = e.currentTarget.dataset;
- const { exerciseList, times,level} = this.data;
- var that = this;
- var temp = {};
- for (var i in exerciseList[lindex].answerList) {
- temp[`exerciseList[${lindex}].answerList[${i}].status`] = '';
- }
- if (exerciseList[lindex].answerList[mindex].isAnswer == 1) {
- that.setData({ isYes: true })
- } else {
- that.setData({ isYes: false })
- }
- temp[`exerciseList[${lindex}].answerList[${mindex}].status`] = exerciseList[lindex].answerList[mindex].status == '' ? 'active' : ''
- this.setData(temp);
- this.setData({ isAnswer: true})
- setTimeout(
- function () {
- that.setData({ level:1,isWhite:true,isAnswer:false,times: 0})
- that.hiddenShow()
- }, 500)
- },1000),
-
- /**
- * 选择答案
- */
- selectItems:throttle(function(e){
- const {lindex, mindex} = e.currentTarget.dataset;
- const { oneList, times,level} = this.data;
- // console.log(lindex, mindex)
- var that = this;
- var temp = {};
- for (var i in oneList[lindex].answerList) {
- temp[`oneList[${lindex}].answerList[${i}].status`] = '';
- }
- temp[`oneList[${lindex}].answerList[${mindex}].status`]='active';
- this.setData(temp);
- if (oneList[lindex].answerList[mindex].isAnswer == 1) {
- that.setData({ isYes: true,isAnswer: true })
- that.integraeRule(lindex, 1)
- that.endSetInter();
- } else {
- that.setData({ isYes: false,isAnswer: true })
- that.integraeRule(lindex, 0)
- that.endSetInter();
- }
- setTimeout(
- function () {
- if(lindex+1==10){
- that.endSetInter();
- that.tenEndTimes()
- }else{
- that.setData({ level:1,isWhite:true,isOneImgShow:false,isWay: lindex +1,isAnswer:false,times: 0})
- that.hiddenShow()
- }
- }, 300)
- },800),
- /**
- * 过渡页显示
- */
- hiddenShow:function(){
- const {isWhite} = this.data;
- var that = this;
- setTimeout(function () {
- that.setData({ isWhite:false})
- that.startSetInter()
- }, 500)
- },
- /**
- * 积分规则处理
- */
- integraeRule: function (bindex,tindex) {
- const { zxgnList, times, isWay,ageGroup} = this.data;
- var that = this;
- var temp = {};
- // console.log(ageGroup,bindex)
- that.saveCase(tindex)
- if (tindex==1){
- if (0<ageGroup&&ageGroup <= 8) {
- if(0<times&×<1.4){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(1.4<=times&×<=1.7){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.7){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }else if (9<=ageGroup&&ageGroup <= 12) {
- if(0<times&×<1.2){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(1.2<=times&×<=1.5){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.5){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }else if (13<=ageGroup&&ageGroup <= 15) {
- if(0<times&×<1){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(1<=times&×<=1.2){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.2){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }else if (16<=ageGroup&&ageGroup <= 35) {
- if(0<times&×<0.8){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(0.8<=times&×<=1.1){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.1){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }else if (36<=ageGroup&&ageGroup <= 49) {
- if(0<times&×<1){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(1<=times&×<=1.2){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.2){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }else if (50<=ageGroup&&ageGroup <= 60) {
- if(0<times&×<1.2){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(1.2<=times&×<=1.5){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.5){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }else if (ageGroup>60) {
- if(0<times&×<1.4){
- temp[`zxgnList[${bindex}].score`] = 10;
- }else if(1.4<=times&×<=1.7){
- temp[`zxgnList[${bindex}].score`] = 8;
- }else if(times>1.7){
- temp[`zxgnList[${bindex}].score`] = 5;
- }
- }
-
- }else{
- temp[`zxgnList[${bindex}].score`] = 0;
- }
- // console.log(temp)
- that.setData(temp);
- if (isWay == 10){
- clearTimeout(that.data.timer)
- that.tenEndTimes();
- }
- },
-
- /**
- * 结束计时
- */
- endSetInter: function () {
- var that = this;
- clearTimeout(that.data.setInter)
- },
- /**
- * 开始计时
- */
- startSetInter: function () {
- let time = 100;
- var that = this;
- let { times, isWay } = this.data;
- // console.log(isWay)
- var setTime = this.data.times + 0.1
- that.setData({ times: setTime })
- // console.log(setTime)
- that.data.setInter = setTimeout(this.startSetInter, time);
- if (setTime > 2) {
- if (isWay == 10) {
- that.endSetInter();
- that.tenEndTimes()
- } else {
- that.endSetInter();
- that.setData({ isWay: isWay + 1, times: 0,isWhite:true })
- that.hiddenShow()
- }
- }
- },
-
- /**
- * 页面跳转定时器
- */
- tenEndTimes: function () {
- var that = this;
- const { graphicReasoning, level, ageGroup,spaceImagination,executionFunctionality,visualSearch,workingMemory,mentalRotation,zxgnList,gameRespondentId} = that.data;
- var allScore=0
- for (var i in zxgnList){
- allScore+=zxgnList[i].score
- }
- console.log(zxgnList,allScore)
- setTimeout(
- function () {
- that.redirectCtl({ url: 'result', method: { graphicReasoning, level:1, ageGroup,spaceImagination,executionFunctionality:(Number(executionFunctionality)+allScore),visualSearch,workingMemory,mentalRotation,isRefer:1,gameRespondentId} }, true)
-
- }, 100)
- },
- /**
- * 答题情况保存
- */
- saveCase:function(str){
- const postData = { fn: this.getPersonInfo, param: { ...arguments } }
- const {isWay,times,gameRespondentId}=this.data
- app.post('/api/game/v2/answerInfoSave', {gameRespondentId,moduleCode:6,questionCode:isWay+1,usedTime:Math.round(times*1000),answerResult:str+1}, 0, postData).then(res => {
- })
- },
- })
|