From c4e651ac030ef5fe8870f6974fcc4658d42986c6 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 21 三月 2024 14:35:01 +0800 Subject: [PATCH] 图书列表,详情页、答题器样式修改,代码合并上传测试服 --- packageBookService/pages/bookServices/examination/examination.js | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 11 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index d948903..3bec06c 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -48,6 +48,15 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + // wx.enableAlertBeforeUnload({ + // message: "鏈彁浜わ紝鏄惁閫�鍑虹瓟棰橈紵", + // success: function (res) { + // console.log('纭畾', res); + // }, + // fail: function (err) { + // console.log("澶辫触锛�", err); + // }, + // }); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -75,7 +84,6 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ onReady() { - }, /** @@ -101,13 +109,12 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ onHide() { - }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ - onUnload() { + onUnload(e) { if (this.data.countdownInterval !== null) { clearInterval(this.data.countdownInterval) } @@ -132,8 +139,29 @@ */ onShareAppMessage() { }, + + // 鐩戝惉watch + watch(context, variableName, callback) { + let value = context.data[variableName]; // 鑾峰彇琚洃鍚睘鎬х殑褰撳墠鍊� + + // 浣跨敤 Object.defineProperty 鏂规硶鍦ㄦ暟鎹璞′笂瀹氫箟灞炴�х殑 getter 鍜� setter + Object.defineProperty(context.data, variableName, { + configurable: true, // 鍙厤缃� + enumerable: true, // 鍙灇涓� + get: function () { + return value; // 杩斿洖灞炴�х殑褰撳墠鍊� + }, + set: function (newVal) { + const oldVal = value; // 璁板綍灞炴�х殑鏃у�� + value = newVal; // 鏇存柊灞炴�х殑鍊� + callback.call(context, newVal, oldVal); // 璋冪敤鍥炶皟鍑芥暟锛屼紶閫掓柊鍊煎拰鏃у�� + } + }); + }, + // 杩斿洖 goBack() { + console.log(this.data.submitStatus); wx.navigateBack(); }, //璁剧疆鑳屾櫙鑹� @@ -201,10 +229,11 @@ this.setData({ currentIndex: e.detail.index }) - let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 - let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer) - if (flag) this.handleQuestion(e.detail.index) - + if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { + let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 + let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer) + if (flag) this.handleQuestion(e.detail.index) + } }, // 鐐瑰嚮绛旈鍗¤烦杞鐩� goQuestion(e) { @@ -282,17 +311,21 @@ } else { return false } - } else { + } else if (typeof data == 'object') { const answer = data.find((item) => item.length > 0) if (answer) { return true } else { return false } + } else { + return false } }, // 鎻愪氦閫昏緫 submitPaper() { + // 鍏抽棴閫�鍑洪〉闈㈢洃鍚� + wx.disableAlertBeforeUnload() this.setData({ submitStatus: true }) @@ -493,6 +526,7 @@ let value = JSON.parse(res[0].value) // 鏈夌瓟棰樿褰曪紝寰楀垎璧嬪�� if (value) { + wx.disableAlertBeforeUnload() this.setData({ submitStatus: true }) @@ -506,6 +540,7 @@ this.setData({ currentIndex: value.currentIndex }) + console.log(this.data.submitStatus); // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰 await this.getQuestionList(value.dataList) } else { @@ -712,7 +747,7 @@ loading: false, }) }, - // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘忥級 + // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 handleQuestion(num) { const questionList = this.data.questionDataList const index = num - 1 >= 0 ? num - 1 : 0 @@ -1332,7 +1367,6 @@ }, // 鑾峰彇缁勫嵎棰樼洰鍒楄〃 async getMockDataList(questionList, oldList) { - console.log(questionList, oldList); const questionDataList = this.data.questionDataList questionList.forEach(async (pathitem, pathindex) => { let itemIds = [] @@ -1451,7 +1485,6 @@ }) let questionList = [] const cardUpdatedList = this.data.cardList - // if (flag == this.data.idPathList.length) { cardUpdatedList.forEach(aitem => { aitem.infoList.forEach((bitem, bindex) => { questionList.push(bitem) @@ -1462,6 +1495,7 @@ questionDataList: questionList, cardList: cardUpdatedList }) + console.log('缁勫嵎棰樼洰鍒楄〃', this.data.questionDataList); }) }) }) -- Gitblit v1.9.1