From dc19fdf86993b2ddeb6b92e2561cb01176ded889 Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期三, 16 七月 2025 23:12:58 +0800 Subject: [PATCH] 量表优化(通过查询嵌套的关系进行判断) --- packageBookService/pages/psychologyAnswer/testdata/index.js | 23 ++++--- app.json | 3 + pages/home/home.js | 14 ++++ packageBookService/pages/psychologyAnswer/psychologyAnswer.js | 85 +++++++++++++++++----------- assets/js/middleGround/api/store.js | 1 packageBookService/pages/bookServices/linkPage/index.js | 4 6 files changed, 82 insertions(+), 48 deletions(-) diff --git a/app.json b/app.json index fb99c71..eb047bf 100644 --- a/app.json +++ b/app.json @@ -138,6 +138,9 @@ "permission": { "scope.userLocation": { "desc": "浣犵殑浣嶇疆淇℃伅灏嗙敤浜庡皬绋嬪簭浣嶇疆鎺ュ彛鐨勬晥鏋滃睍绀�" + }, + "clipboard": { + "desc": "鐢ㄤ簬澶嶅埗鍐呭鍒板壀璐存澘" } } } \ No newline at end of file diff --git a/assets/js/middleGround/api/store.js b/assets/js/middleGround/api/store.js index 472b10a..064d3fb 100644 --- a/assets/js/middleGround/api/store.js +++ b/assets/js/middleGround/api/store.js @@ -303,7 +303,6 @@ if (resp.length > 0) { const data = resp[0] if (data.datas.length) { - data.datas[0].subDatas = data.datas[0].cmsDatas const datas = handleDetailQueryRequestData({ productId, diff --git a/packageBookService/pages/bookServices/linkPage/index.js b/packageBookService/pages/bookServices/linkPage/index.js index 279af9f..dec1070 100644 --- a/packageBookService/pages/bookServices/linkPage/index.js +++ b/packageBookService/pages/bookServices/linkPage/index.js @@ -83,13 +83,13 @@ copyPath() { wx.setClipboardData({ data: this.data.path, - success: () => { + success: (res) => { wx.showToast({ icon: 'success', title: '澶嶅埗鎴愬姛', }) }, - fail: () => { + fail: (res) => { wx.showToast({ icon: 'error', title: '璇烽噸璇�', diff --git a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js index 8911ba3..10fe090 100644 --- a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js +++ b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js @@ -56,46 +56,65 @@ } } const indexof = listIndex - const questionId = questionList[indexof].id; + const idPath = questionList[indexof].idPath; const bookId = questionList[indexof].bookId; const bookName = "澶у鐢熷績鐞嗗仴搴凤紙绗�3鐗堬級锛堣瀺濯掍綋鐗堬級" const formPath = "questionBank" + // 杩涜澶勭悊 const query = { - "cmsItemId": Number(questionId) + path: "*", + queryType: "*", + productId: bookId, + cmsPath: "161796", + cmsType: "*" }; - app.MG.file.checkCmsItem(query) - .then((res) => { - const isBuys = res; - this.setData({ - isBuy: isBuys - }); - if (!isBuys) { - wx.showModal({ - icon: 'error', - title: '娓╅Θ鎻愮ず', - content: '璇疯喘涔伴搴擄紝鍗冲皢杩斿洖璐拱椤�', - confirmText: '纭畾', - showCancel: false, // 鍏抽棴鍙栨秷鎸夐挳 - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + bookName + '&tabValue=' + formPath, - }) - } - } - }); - return; // 鐩存帴杩斿洖锛岄伩鍏嶆墽琛屽悗缁唬鐮� + app.MG.store.getProductDetail(query).then(async (res) => { + const linkPathList = res.datas.cmsDatas[0].datas + const isBuyList = res.datas.purchasedSaleMethodIdList + let isBuy = false + const idParhList = idPath.split("/").reverse() + for (let index = 0; index < idParhList.length; index++) { + const item = idParhList[index]; + const thisItem = linkPathList.find(citem => item == citem.id); + if (thisItem.saleMethod.length > 0) { + if (isBuyList.includes(thisItem.saleMethod[0].Id)) { + isBuy = true + break + } else { + isBuy = false + break + } } - // 鍏朵粬閫昏緫 - this.initialize() - }) - .catch((err) => { - console.error('妫�鏌ラ搴撳け璐�:', err); - wx.showToast({ - icon: 'error', - title: '鍔犺浇澶辫触锛岃閲嶈瘯' - }); + } + this.setData({ + isBuy: isBuy }); + if (!isBuy) { + wx.showModal({ + icon: 'error', + title: '娓╅Θ鎻愮ず', + content: '璇疯喘涔伴搴擄紝鍗冲皢杩斿洖璐拱椤�', + confirmText: '纭畾', + showCancel: false, // 鍏抽棴鍙栨秷鎸夐挳 + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + bookName + '&tabValue=' + formPath, + }) + } + } + }); + return; // 鐩存帴杩斿洖锛岄伩鍏嶆墽琛屽悗缁唬鐮� + } + // 鍏朵粬閫昏緫 + this.initialize() + }).catch((err) => { + console.error('妫�鏌ラ搴撳け璐�:', err); + wx.showToast({ + icon: 'error', + title: '鍔犺浇澶辫触锛岃閲嶈瘯' + }); + }); } }, diff --git a/packageBookService/pages/psychologyAnswer/testdata/index.js b/packageBookService/pages/psychologyAnswer/testdata/index.js index 82fac74..73994a0 100644 --- a/packageBookService/pages/psychologyAnswer/testdata/index.js +++ b/packageBookService/pages/psychologyAnswer/testdata/index.js @@ -1,7 +1,7 @@ var localData = { "list": [{ "name": "娴嬫祴浣犵殑鐢熸椿鍝佽川", - "id": 162287, + "idPath": "161796/162214/162217/162287", "bookId": 7129, "title": "璇蜂粩缁嗛槄璇讳互涓嬮棶棰橈紝鍑綘鐨勭涓�鎰熻鍥炵瓟銆傝閫夋嫨涓庝綘鐩哥鐨勭瓟妗堬紝鍗充娇浣犳劅鍒颁笉澶‘瀹氾紝涔熻鍥炵瓟姣忎釜闂銆�(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -1297,7 +1297,7 @@ }, { "name": "韬綋鐥囩姸闂嵎", - "id": 162288, + "idPath": "161796/162214/162217/162288", "bookId": 7129, "title": "涓嬮潰鏄笌蹇冪悊鍥犵礌鐩稿叧鐨勮韩浣撶棁鐘跺垪琛紝璇锋牴鎹嚜宸变笂涓�鍛ㄧ殑鎯呭喌锛屽湪鐩稿簲鐨勪綅缃笂鐢诲湀锛岀湅鐪嬪伐浣滈噺涓庤韩浣撶棁鐘朵箣闂存槸鍚﹀瓨鍦ㄨ仈绯汇��(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -3325,7 +3325,7 @@ }, { "name": "涓�鑸嚜鎴戞晥鑳芥劅閲忚〃", - "id": 162289, + "idPath": "161796/162214/162217/162289", "bookId": 7129, "title": "<p>浠ヤ笅10涓彞瀛愰兘鏄叧浜庝綘骞虫椂瀵硅嚜宸辩殑涓�鑸湅娉曪紝璇蜂綘鏍规嵁鑷繁鐨勫疄闄呮儏鍐碉紝閫夋嫨鍚堥�傜殑閫夐」銆傗��1鈥濊〃绀哄畬鍏ㄤ笉姝g‘銆傗��2鈥濊〃绀烘湁鐐规纭紝鈥�3鈥濊〃绀哄鏁版纭紝鈥�4鈥濊〃绀哄畬鍏ㄦ纭�傜瓟妗堟病鏈夊閿欎箣鍒嗭紝瀵规瘡涓�涓彞瀛愭棤椤诲鑰冭檻銆�(绛旀浠呰嚜宸卞彲瑙�)</p>", "fromType": "json", @@ -3653,7 +3653,7 @@ }, { "name": "瀛︿範鍔ㄥ姏鑷垜璇婃柇娴嬭瘯", - "id": 162290, + "idPath": "161796/162214/162217/162290", "bookId": 7129, "title": "杩欎釜閲忚〃涓昏涓轰簡甯姪浣犱簡瑙h嚜宸卞湪瀛︿範鍔ㄦ満銆佸涔犲叴瓒c�佸涔犵洰鏍囦笂鏄惁瀛樺湪鍥版壈锛屽叡20涓鐩�傝浣犳牴鎹嚜宸辩殑鎯呭喌锛屽疄浜嬫眰鏄湴瀵规瘡涓鐩仛鈥滄槸鈥濇垨鈥滃惁鈥濈殑鍥炵瓟銆�(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -4231,7 +4231,7 @@ }, { "name": "浜洪檯鍏崇郴缁煎悎璇婃柇琛�", - "id": 162291, + "idPath": "161796/162214/162217/162291", "bookId": 7129, "title": "鏈噺琛ㄥ叡28涓棶棰橈紝姣忎釜闂鍋氣�滄槸鈥濇垨鈥滃惁鈥濆洖绛斻�傝浣犺鐪熷畬鎴愶紝鐒跺悗鍙傜収璁″垎鍙婂垎鏋愭柟娉曪紝瀵规祴璇曠粨鏋滃仛鍑鸿В閲娿��(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -5001,7 +5001,7 @@ }, { "name": "濠氬Щ绋冲畾鎬ф祴璇�", - "id": 162292, + "idPath": "161796/162214/162217/162292", "bookId": 7129, "title": "<p>浣犻�夋嫨濂界粓韬即渚d簡鍚楋紵浣犳槸鎬庢牱鐪嬪緟濠氬Щ鐨勫憿锛熶笅闈㈢殑濠氬Щ绋冲畾鎬ф祴璇曞彲浠ュ府浣犳洿濂藉湴棰勬祴鏈潵濠氬Щ鐨勭ǔ瀹氭�с��</p><p>璇蜂粩缁嗛槄璇绘瘡閬撻锛岄�夋嫨绗﹀悎浣犵殑绛旀銆�(绛旀浠呰嚜宸卞彲瑙�)</p>", "fromType": "json", @@ -5337,7 +5337,7 @@ }, { "name": "浣犵殑鎭嬬埍蹇冪悊鏄惁鎴愮啛锛�", - "id": 162293, + "idPath": "161796/162214/162217/162293", "bookId": 7129, "title": "璇疯鐪熼槄璇讳互涓嬪悇椤癸紝鏍规嵁鑷繁鐨勭湡瀹炴儏鍐典綔绛斻��(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -6195,7 +6195,7 @@ }, { "name": "鍘嬪姏蹇冪悊娴嬭瘯", - "id": 162294, + "idPath": "161796/162214/162217/162294", "bookId": 7129, "title": "璇峰洖鎯充竴涓嬭嚜宸卞湪杩囧幓涓�涓湀鍐呮槸鍚﹀嚭鐜拌繃涓嬭堪鎯呭喌銆�(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -6711,7 +6711,7 @@ }, { "name": "鎶戦儊鑷瘎閲忚〃锛圫DS锛�", - "id": 162295, + "idPath": "161796/162214/162217/162295", "bookId": 7129, "title": "涓嬮潰鏈�20鏉℃枃瀛楋紝璇蜂粩缁嗛槄璇绘瘡涓�鏉★紝鎶婃剰鎬濆紕鏄庣櫧鍚庢牴鎹偍鏈�杩戜竴鏄熸湡鐨勬儏鍐甸�夋嫨閫傚綋鐨勯�夐」銆傗�淎鈥濊〃绀烘病鏈夋垨寰堝皯鏃堕棿鏈夛紝鈥淏鈥濊〃绀哄皬閮ㄥ垎鏃堕棿鏈夛紝鈥淐鈥濊〃绀虹浉褰撳鏃堕棿鏈夛紝鈥淒鈥濊〃绀虹粷澶ч儴鍒嗘椂闂撮兘鏈夈��(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -7367,7 +7367,7 @@ }, { "name": "浜嗚В浣犵殑鑱屼笟鍖栫▼搴�", - "id": 162296, + "idPath": "161796/162214/162217/162296", "bookId": 7129, "title": "鑱屼笟鍖栨寚涓�绉嶅伐浣滅姸鎬佺殑鏍囧噯鍖栥�佽鑼冨寲鍜屽埗搴﹀寲锛屽嵆鍦ㄥ悎閫傜殑鏃堕棿銆佸湴鐐圭敤鍚堥�傜殑鏂瑰紡瀹屾垚宸ヤ綔銆傝亴涓氬寲浣撶幇浜嗕竴涓汉鑳藉噯纭湴鎵紨濂借嚜宸辩殑鑱屼笟瑙掕壊锛屽敖鑱屽敖璐e湴瀹屾垚鑷繁鐨勫伐浣溿�備綔涓轰竴鍚嶅嵆灏嗚蛋杩涜亴鍦虹殑澶у鐢燂紝浣犵殑鑱屼笟鍖栫▼搴︽湁澶氶珮鍛紵璇峰畬鎴愪笅鍒楁祴璇曘��(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -8088,6 +8088,7 @@ { "name": "鑱屼笟鑳藉姏娴嬭瘯", "id": 162297, + "idPath": "161796/162214/162217/162297", "bookId": 7129, "title": "鏍规嵁浣犵殑瀹為檯鎯呭喌锛屽涓嬮潰姣忕娲诲姩鍋氬嚭璇勫畾銆�(绛旀浠呰嚜宸卞彲瑙�)", "fromType": "json", @@ -10357,7 +10358,7 @@ }, { "name": "濞佸粔鏂垱閫犲姏鍊惧悜閲忚〃", - "id": 162298, + "idPath": "161796/162214/162217/162298", "bookId": 7129, "title": "<p>杩欐槸涓�浠藉府鍔╀綘浜嗚В鑷繁鍒涢�犲姏鐨勮〃鍗曘�傛瘡涓�棰橀兘瑕佸仛锛屼笉瑕佽姳澶鏃堕棿鍘绘�濊�冿紱鎵�鏈夐鐩兘娌℃湁姝g‘绛旀锛屽嚟浣犺瀹屾瘡涓�鍙ョ殑绗竴鍗拌薄浣滅瓟锛涜櫧鐒舵病鏈夋椂闂撮檺鍒讹紝浣嗗敖鍙兘浠ヨ緝蹇殑閫熷害瀹屾垚锛岃秺蹇秺濂斤紱鍑嚜宸辩殑鐪熷疄鎰熷彈浣滅瓟銆�(绛旀浠呰嚜宸卞彲瑙�)</p>", "fromType": "json", diff --git a/pages/home/home.js b/pages/home/home.js index bdc8161..2db5511 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -140,7 +140,6 @@ list.push({ value: item.icon, link: item.jsek_link, - }) } this.setData({ @@ -472,6 +471,19 @@ const item = e.currentTarget.dataset.book // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲� let urlData = '' + if (!item.jsek_link) { + wx.showModal({ + title: '鎻愮ず', + content: '鏆傛棤鍐呭', + showCancel: false, + success: (res) => { + if (res.confirm) { + console.log(res, '3232') + } + } + }) + return false; + } const flags = item.jsek_link.indexOf("?") if (flags > -1) { urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) -- Gitblit v1.9.1