From b2a6887c94cc7887b03ba1cce578e3fc59a62259 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 27 三月 2024 16:12:28 +0800 Subject: [PATCH] 1 --- packageBookService/pages/bookServices/examination/questionList/index.wxss | 16 ++ pages/home/home.js | 26 ++-- packageBookService/pages/bookServices/examination/questionList/index.wxml | 15 + .vscode/settings.json | 2 static/images/bookService/assort/book-img.png | 0 packageBookService/pages/bookServices/detail/components/suggest/suggest.js | 12 + pages/bookServices/assort/index.js | 7 packageBookService/pages/bookServices/examination/questionList/index.json | 3 packageBookService/pages/bookServices/examination/examination.js | 56 ++++++-- assets/js/userAction.js | 2 pages/bindInfo/index.js | 6 packageBookService/pages/bookServices/list/index.js | 1 packageBookService/pages/bookServices/detail/index.js | 2 pages/bookServices/assort/index.wxss | 1 assets/js/login.js | 186 +++++++++++++++--------------- 15 files changed, 196 insertions(+), 139 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8096c21..22d6d96 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,7 +32,7 @@ }, "editor.tabSize": 2, "[wxml]": { - "editor.defaultFormatter": "wechat.miniprogram.wxml-language-features" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[css]": { "editor.defaultFormatter": "HookyQR.beautify" diff --git a/assets/js/login.js b/assets/js/login.js index 8c5c2c5..c7cb7c9 100644 --- a/assets/js/login.js +++ b/assets/js/login.js @@ -2,102 +2,102 @@ export const loginInfo = (app, callback) => { - wx.login({ - success: (res) => { - wx.getUserInfo({ - success: (infoRes) => { - app.MG.identity.checkWeChatAppAccount({ - code: res.code, - appCode: app.config.appRefCode, - encryptedData: infoRes.encryptedData, - iv: infoRes.iv - }).then(loginRes => { - if (!loginRes) { - const pages = getCurrentPages(); - const currentPage = pages[pages.length - 1]; - let url = `/${currentPage.route}`; - if (Object.keys(currentPage.options).length) { - let option = ""; - for (const key in currentPage.options) { - if (currentPage.options[key]) { - if (option) { - option += "&" - } - option += key + "=" + currentPage.options[key] - } - } - url += "?" + option - } - debugger - console.log(url); - wx.navigateTo({ - url: "/pages/bindInfo/index?page=" + encodeURIComponent(url), - }); - } else { - wx.login({ - success: (res) => { - app.MG.identity.loginByWeChatAppCode({ - code: res.code, - appRefCode: app.config.appRefCode, - platform: "WeChatAppCustom", - encryptedData: infoRes.encryptedData, - iv: infoRes.iv - }).then(res => { - if (res && res.status == "Ok") { - // 鍌ㄥ瓨token - wx.setStorageSync(app.config.tokenKey, res.token); - // 璁板綍鐧诲綍缁熻 - setSessionGuid() - // 鑾峰彇鐢ㄦ埛淇℃伅 - getUserInfo(app, callback, res.token) - } else { - console.log(res); - callback(false) - } - }) - }, - fail: (err) => { - console.log(err); - callback(false) - } - }) - } - }) - }, - fail: (err) => { - console.log(err); - callback(false) - } - }) - }, - fail: (err) => { - console.log(err); - callback(false) - } - }) + wx.login({ + success: (res) => { + wx.getUserInfo({ + success: (infoRes) => { + app.MG.identity.checkWeChatAppAccount({ + code: res.code, + appCode: app.config.appRefCode, + encryptedData: infoRes.encryptedData, + iv: infoRes.iv + }).then(loginRes => { + if (!loginRes) { + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1]; + let url = `/${currentPage.route}`; + if (Object.keys(currentPage.options).length) { + let option = ""; + for (const key in currentPage.options) { + if (currentPage.options[key]) { + if (option) { + option += "&" + } + option += key + "=" + currentPage.options[key] + } + } + url += "?" + option + } + debugger + console.log(url); + wx.navigateTo({ + url: "/pages/bindInfo/index?page=" + encodeURIComponent(url), + }); + } else { + wx.login({ + success: (res) => { + app.MG.identity.loginByWeChatAppCode({ + code: res.code, + appRefCode: app.config.appRefCode, + platform: "WeChatAppCustom", + encryptedData: infoRes.encryptedData, + iv: infoRes.iv + }).then(res => { + if (res && res.status == "Ok") { + // 鍌ㄥ瓨token + wx.setStorageSync(app.config.tokenKey, res.token); + // 鑾峰彇鐢ㄦ埛淇℃伅 + getUserInfo(app, callback, res.token) + // 璁板綍鐧诲綍缁熻 + // setSessionGuid() + } else { + console.log(res); + callback(false) + } + }) + }, + fail: (err) => { + console.log(err); + callback(false) + } + }) + } + }) + }, + fail: (err) => { + console.log(err); + callback(false) + } + }) + }, + fail: (err) => { + console.log(err); + callback(false) + } + }) } // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤 const getUserInfo = (app, callback, token) => { - app.MG.identity.getCurrentAppUser().then(res => { - // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛� - if (res) { - let defaultUser = {}; - let WeChatInfo = res.infoList.find((item) => item.type === "WeChat"); - let phoneNumber = res.secretList.find(i => i.type == 'MobilePhone') + app.MG.identity.getCurrentAppUser().then(res => { + // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛� + if (res) { + let defaultUser = {}; + let WeChatInfo = res.infoList.find((item) => item.type === "WeChat"); + let phoneNumber = res.secretList.find(i => i.type == 'MobilePhone') - if (WeChatInfo) { - defaultUser = { - nickName: WeChatInfo.name, - avatarUrl: WeChatInfo.icon, - weChatId: WeChatInfo.id - } - } - if (phoneNumber) { - defaultUser.phoneNumber = phoneNumber.credential - } - wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); - } - callback(token); - }); + if (WeChatInfo) { + defaultUser = { + nickName: WeChatInfo.name, + avatarUrl: WeChatInfo.icon, + weChatId: WeChatInfo.id + } + } + if (phoneNumber) { + defaultUser.phoneNumber = phoneNumber.credential + } + wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); + } + callback(token); + }); } \ No newline at end of file diff --git a/assets/js/userAction.js b/assets/js/userAction.js index 65472a7..9231bb6 100644 --- a/assets/js/userAction.js +++ b/assets/js/userAction.js @@ -6,7 +6,7 @@ var SnIp = null; try { // eslint-disable-next-line - SnIp = window.returnCitySN; + // SnIp = window.returnCitySN; } catch (error) { SnIp = null; console.log(error); diff --git a/packageBookService/pages/bookServices/detail/components/suggest/suggest.js b/packageBookService/pages/bookServices/detail/components/suggest/suggest.js index bc609d8..c6e2f09 100644 --- a/packageBookService/pages/bookServices/detail/components/suggest/suggest.js +++ b/packageBookService/pages/bookServices/detail/components/suggest/suggest.js @@ -70,7 +70,7 @@ } }) } - + let content = { source: this.data.ratevalue, phone: this.data.inputvalue, @@ -97,23 +97,25 @@ }, // 纭畾 async confirmSuggest() { - const isPhoneNumber = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.data.inputvalue); + const telephoneCheck = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ + const istelePhone = telephoneCheck.test(this.data.inputvalue) + const textvalue = this.data.textvalue.trim() if (!this.data.ratevalue) { return wx.showToast({ icon: "error", title: '璇烽�夋嫨璇勫垎', }) - } else if (!this.data.inputvalue) { + } else if (!this.data.inputvalue.length) { return wx.showToast({ icon: "error", title: '璇峰~鍐欒仈绯绘柟寮�', }) - } else if (!isPhoneNumber) { + } else if (!istelePhone) { return wx.showToast({ icon: "error", title: '璇疯緭鍏ユ纭仈绯绘柟寮�', }) - } else if (!this.data.textvalue) { + } else if (!textvalue.length) { return wx.showToast({ icon: 'error', title: '璇疯緭鍏ュ弽棣堝弽棣堝唴瀹�', diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 6d5226d..dfb39a6 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -1428,7 +1428,7 @@ recordBuyMock() { const num = this.data.mockData.mockList.length const id = tool.uuid(8) - const createDate = new Date().getTime() + const createDate = this.DateFormat(new Date().getTime(), 'yyyy-MM-dd') const mockList = this.data.mockData.mockList mockList.push({ id, createDate, name: `绗�${num + 1}濂楄瘯鍗穈, state: '0' }) this.setData({ diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 7683e2a..9d544ed 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -246,10 +246,11 @@ this.setData({ currentIndex: 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) + let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 + const item = this.data.questionDataList[index] + if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { + let flag = this.isHaveAnswer(item.userAnswer) + if (flag) this.handleQuestion(index) } }, // 鐐瑰嚮绛旈鍗¤烦杞鐩� @@ -269,21 +270,47 @@ const id = e.detail.value.currentTarget.dataset.id const radioChecked = e.detail.value.detail.value const questionList = this.data.questionDataList - questionList.forEach(item => { - if (item.id == id) { + // 鎴戠殑閿欓鍜屾垜鐨勬敹钘忔ā寮忎笅锛屽崟閫夐閫夋嫨浜嗙洿鎺ユ壒鏀� + for (let index = 0; index < questionList.length; index++) { + const item = questionList[index]; + if (item.id == id && !item.isComplete) { item.userAnswer = radioChecked item.isUserAnswer = this.isHaveAnswer(radioChecked) + if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { + debugger + let index = this.data.currentIndex - 1 >= 0 ? this.data.currentIndex - 1 : 0 + this.handleQuestion(index) + } } - }) + } + // questionList.forEach(item => { + // if (item.id == id && !item.isComplete) { + // item.userAnswer = radioChecked + // item.isUserAnswer = this.isHaveAnswer(radioChecked) + // if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { + // this.handleQuestion(this.data.currentIndex) + // } + // } + // }) const cardListUpdata = this.data.cardList - cardListUpdata.forEach(item => { - item.infoList.forEach(citem => { - if (citem.id == id) { + for (let index = 0; index < cardListUpdata.length; index++) { + const item = cardListUpdata[index]; + for (let cindex = 0; cindex < item.infoList.length; cindex++) { + const citem = item.infoList[cindex]; + if (citem.id == id && !citem.isComplete) { citem.userAnswer = radioChecked citem.isUserAnswer = this.isHaveAnswer(radioChecked) } - }) - }) + } + } + // cardListUpdata.forEach(item => { + // item.infoList.forEach(citem => { + // if (citem.id == id && !citem.isComplete) { + // citem.userAnswer = radioChecked + // citem.isUserAnswer = this.isHaveAnswer(radioChecked) + // } + // }) + // }) this.setData({ questionDataList: questionList, cardList: cardListUpdata @@ -375,7 +402,7 @@ const qustionList = this.data.questionDataList for (let index = 0; index < qustionList.length; index++) { const item = qustionList[index]; - if (!item.isComplete) this.handleQuestion(index + 1) + if (!item.isComplete) this.handleQuestion(index) } } if (this.data.answerType == 'option') { @@ -472,7 +499,6 @@ } if (mocklist.length && this.data.uuid) { const oldMockData = mocklist.find((mockItem) => mockItem.id == this.data.uuid) - debugger this.setData({ 'mockData.state': oldMockData.state, 'mockData.score': oldMockData.score, @@ -802,7 +828,7 @@ // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 handleQuestion(num) { const questionList = this.data.questionDataList - const index = num - 1 >= 0 ? num - 1 : 0 + const index = num if (questionList[index].isComplete) { // 棰樼洰宸插畬鎴愶紝璺宠繃 return true diff --git a/packageBookService/pages/bookServices/examination/questionList/index.json b/packageBookService/pages/bookServices/examination/questionList/index.json index 6ffa0d2..c2758c8 100644 --- a/packageBookService/pages/bookServices/examination/questionList/index.json +++ b/packageBookService/pages/bookServices/examination/questionList/index.json @@ -9,6 +9,7 @@ "t-radio-group": "tdesign-miniprogram/radio-group/radio-group", "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", "t-checkbox-group": "tdesign-miniprogram/checkbox-group/checkbox-group", - "t-textarea": "tdesign-miniprogram/textarea/textarea" + "t-textarea": "tdesign-miniprogram/textarea/textarea", + "t-empty": "tdesign-miniprogram/empty/empty" } } \ No newline at end of file diff --git a/packageBookService/pages/bookServices/examination/questionList/index.wxml b/packageBookService/pages/bookServices/examination/questionList/index.wxml index de4ffce..779cf0c 100644 --- a/packageBookService/pages/bookServices/examination/questionList/index.wxml +++ b/packageBookService/pages/bookServices/examination/questionList/index.wxml @@ -67,7 +67,7 @@ data-value="{{item.option}}" data-id="{{item.id}}" data-index="{{inputItem.num}}" - class="title-input" + class="title-input {{isNight ? 'input-night-color' : ''}}" style="border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx;background-color:{{isNight ? '#000' : '#fff'}}; " placeholder-style="{{placeholderstyle}}" wx:if="{{inputItem.data == 'input'}}" @@ -107,7 +107,7 @@ > <view style="font-size: {{sliderValue || 32}}rpx;" - class="radio-item {{(answerType == 'option' || answerType == 'mock' ) && !submitStatus && item.userAnswer == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{ (item.answer == contentItem.value && item.answer == item.userAnswer && submitStatus) ? 'radio-correct' : (item.userAnswer == contentItem.value && item.userAnswer != item.answer && submitStatus) ?'radio-error' :'' }}" + class="radio-item {{(answerType == 'option' || answerType == 'mock' ) && !submitStatus && item.userAnswer == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{item.userAnswer == contentItem.value && submitStatus ? item.isRight ? 'radio-correct' : 'radio-error' :''}}" > <!-- 浠呮枃瀛� --> <text wx:if="{{item.optionStyle == 'Txt'}}" @@ -211,7 +211,7 @@ bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" - class="option-textarea" + class="option-textarea {{isNight ? 'textarea-night-color' :''}}" wx:elif="{{item.questionType == 'shortAnswer'}}" t-class="external-class" placeholder="璇疯緭鍏ユ枃瀛�" @@ -328,8 +328,15 @@ </view> </view> </swiper-item> - <swiper-item wx:if="{{answerType !== 'collectQuestion'}}"> + <swiper-item + wx:if="{{answerType !== 'collectQuestion' && questionList.length}}" + > <text>娌℃湁鏇村浜嗐�傘�傘��</text> </swiper-item> + <swiper-item wx:if="{{!questionList.length}}"> + <view class="noData"> + <t-empty icon="folder-open" description="鏆傛棤鏁版嵁" /> + </view> + </swiper-item> </swiper> </view> diff --git a/packageBookService/pages/bookServices/examination/questionList/index.wxss b/packageBookService/pages/bookServices/examination/questionList/index.wxss index c0fc5bf..9bcc3d8 100644 --- a/packageBookService/pages/bookServices/examination/questionList/index.wxss +++ b/packageBookService/pages/bookServices/examination/questionList/index.wxss @@ -181,4 +181,20 @@ .textarea-center { display: flex; justify-content: center; +} + +.input-night-color { + --td-input-default-text-color: #fff; +} + +.textarea-night-color { + --td-textarea-text-color: rgba(255, 255, 255, 1); +} + +.noData { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; } \ No newline at end of file diff --git a/packageBookService/pages/bookServices/list/index.js b/packageBookService/pages/bookServices/list/index.js index 0f41bda..018f33d 100644 --- a/packageBookService/pages/bookServices/list/index.js +++ b/packageBookService/pages/bookServices/list/index.js @@ -1,4 +1,5 @@ const app = getApp(); +import { loginInfo } from '../../../../assets/js/login'; Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� diff --git a/pages/bindInfo/index.js b/pages/bindInfo/index.js index 897d56c..0386d5d 100644 --- a/pages/bindInfo/index.js +++ b/pages/bindInfo/index.js @@ -56,10 +56,10 @@ if (res && res.status == "Ok") { // 鍌ㄥ瓨token wx.setStorageSync(app.config.tokenKey, res.token); - // 璁板綍鐧诲綍缁熻 - setSessionGuid() // 鑾峰彇鐢ㄦ埛淇℃伅 this.getUserInfo() + // 璁板綍鐧诲綍缁熻 + // setSessionGuid() } else { wx.showToast({ icon: "error", @@ -93,7 +93,7 @@ } wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); } - wx.switchTab({ + wx.navigateTo({ url: this.data.redirectPage ? this.data.redirectPage : '/pages/home/home' }) }); diff --git a/pages/bookServices/assort/index.js b/pages/bookServices/assort/index.js index 3891add..fa4c9de 100644 --- a/pages/bookServices/assort/index.js +++ b/pages/bookServices/assort/index.js @@ -140,7 +140,7 @@ // 鑾峰彇浜岀骇鍒嗙被 for (let index = 0; index < res.datas.length; index++) { const item = res.datas[index]; - item.icon ? item.icon = getPublicImage(item.icon, 58, 72) : item.icon = item.icon + item.icon ? item.icon = getPublicImage(item.icon, 500) : item.icon = item.icon item.children = await this.getSecondList(item); } console.log(res.datas); @@ -166,6 +166,9 @@ field: 'state' } ], + coverSize: { + width: 500 + }, queryType: '\\', searchList: [], size: '30', @@ -177,7 +180,7 @@ for (let index = 0; index < res.datas.length; index++) { const element = res.datas[index]; if (element.icon) - element.icon = getPublicImage(element.icon, 58, 72) + element.icon = getPublicImage(element.icon, 500) } datas = res.datas; diff --git a/pages/bookServices/assort/index.wxss b/pages/bookServices/assort/index.wxss index 1a7f2df..bf4c371 100644 --- a/pages/bookServices/assort/index.wxss +++ b/pages/bookServices/assort/index.wxss @@ -142,6 +142,7 @@ .assort-img { display: flex; + align-items: center; width: 152rpx; height: 186rpx; box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16); diff --git a/pages/home/home.js b/pages/home/home.js index 7b75da0..6b539a6 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -49,19 +49,19 @@ // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }) - } else { - // 濡傛灉鏄涓�娆$櫥褰曪紝浼氳烦杞嚦缁戝畾鐢ㄦ埛淇℃伅椤甸潰锛屽~鍐欏畬鐢ㄦ埛淇℃伅鍚庤繘琛岀櫥褰曞苟鍌ㄥ瓨token鍜岀敤鎴蜂俊鎭紝缁撴潫鍚庤烦杞洖褰撳墠椤甸潰锛堟惡甯﹂〉闈㈠弬鏁帮級 - } + // const token = wx.getStorageSync(app.config.tokenKey) + // if (!token) { + // loginInfo(app, (data) => { + // // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� + // if (data) { + // // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue + // } else { + // // 鍑虹幇閿欒锛岃繑鍥瀎alse + // } + // }) + // } else { + // // 濡傛灉鏄涓�娆$櫥褰曪紝浼氳烦杞嚦缁戝畾鐢ㄦ埛淇℃伅椤甸潰锛屽~鍐欏畬鐢ㄦ埛淇℃伅鍚庤繘琛岀櫥褰曞苟鍌ㄥ瓨token鍜岀敤鎴蜂俊鎭紝缁撴潫鍚庤烦杞洖褰撳墠椤甸潰锛堟惡甯﹂〉闈㈠弬鏁帮級 + // } this.init(); }, diff --git a/static/images/bookService/assort/book-img.png b/static/images/bookService/assort/book-img.png index 6343c4c..2aa98fd 100644 --- a/static/images/bookService/assort/book-img.png +++ b/static/images/bookService/assort/book-img.png Binary files differ -- Gitblit v1.9.1