From ce062b3ff6d8e3db929820d004972df893882d4e Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期三, 18 十二月 2024 09:47:49 +0800 Subject: [PATCH] bug优化 --- packageBookService/pages/psychologyAnswer/testdata/index.js | 9 + packageBookService/pages/psychologyAnswer/psychologyAnswer.js | 21 +-- packageBookService/pages/psychologyAnswer/questionList/index.js | 2 packageBookService/pages/psychologyAnswer/questionOptions/index.wxml | 5 packageBookService/pages/psychologyAnswer/questionList/index.wxml | 278 ++++++--------------------------------------- 5 files changed, 56 insertions(+), 259 deletions(-) diff --git a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js index ad07a50..a913ecf 100644 --- a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js +++ b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js @@ -282,21 +282,12 @@ }, // 鍒囨崲棰樼洰 changeSwiper(e) { - let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0; - const item = this.data.questionDataList[index]; - const lastItem = this.data.questionDataList[index + 1]; + let index = e.detail.index; + const lastItem = this.data.questionDataList[index]; this.setData({ currentIndex: e.detail.index, showId: lastItem.id }); - if ( - (this.data.answerType == "collectQuestion" || - this.data.answerType == "errorQuestion") && - !item.isComplete - ) { - let flag = this.isHaveAnswer(item.userAnswer); - if (flag) this.handleQuestion(index); - } }, // 鎴戠殑閿欓锛屾敹钘忔煡鐪嬭В鏋愭寜閽� viewParsing() { @@ -471,10 +462,6 @@ // 鍏堥亶鍘嗘墍鏈夐鐩紝灏嗘湭鎵规敼鐨勯鐩壒鏀� const qustionList = this.data.questionDataList; if (qustionList.length) this.handleQuestion(); - this.setData({ - isShowDialog: true, - submitStatus: true, - }) // 璁板綍鐢ㄦ埛绛旈鏁版嵁 let saveData = []; for (let index = 0; index < this.data.questionDataList.length; index++) { @@ -499,6 +486,10 @@ loading: false, showDialog: false, }); + this.setData({ + isShowDialog: true, + submitStatus: true, + }); }, // 鍒濆鍖栧嚱鏁� async init(isReset) { diff --git a/packageBookService/pages/psychologyAnswer/questionList/index.js b/packageBookService/pages/psychologyAnswer/questionList/index.js index 95e115a..e6934a4 100644 --- a/packageBookService/pages/psychologyAnswer/questionList/index.js +++ b/packageBookService/pages/psychologyAnswer/questionList/index.js @@ -73,8 +73,6 @@ height: 'calc(100% - 30px - ' + rect.height + 'px)' }) }).exec(); - - }, diff --git a/packageBookService/pages/psychologyAnswer/questionList/index.wxml b/packageBookService/pages/psychologyAnswer/questionList/index.wxml index ef84962..ab7f8ba 100644 --- a/packageBookService/pages/psychologyAnswer/questionList/index.wxml +++ b/packageBookService/pages/psychologyAnswer/questionList/index.wxml @@ -1,67 +1,31 @@ <!--pages/bookServices/examination/questionList/index.wxml--> -<view - class="question-list" - style="background-color:{{isNight ? '#222' : '#fff'}}" -> +<view class="question-list" style="background-color:{{isNight ? '#222' : '#fff'}}"> <!-- 绛旈鎻愮ずtitle --> <view id="question-title" class="question-title" wx:if="{{questionTitle}}"> - <rich-text - class="substance" - nodes="{{questionTitle}}" - space="emsp" - ></rich-text> + <rich-text class="substance" nodes="{{questionTitle}}" space="emsp"></rich-text> </view> <!-- 棰樼洰鍒楄〃 --> - <swiper - id="swiper" - class="swiper" - bindanimationfinish="changeSwiper" - current="{{currentIndex}}" - style="{{'height:'+height}}" - > - <swiper-item - wx:for="{{questionList}}" - wx:for-index="index" - wx:key="id" - style="overflow-y: auto" - > + <swiper id="swiper" class="swiper" bindanimationfinish="changeSwiper" current="{{currentIndex}}" style="{{'height:'+height}}"> + <swiper-item wx:for="{{questionList}}" wx:for-index="index" wx:key="id" style="overflow-y: auto"> <!-- 棰樺共 --> - <view - class="question-stem title-score" - style="color: {{isNight ? '#fff' : '#000'}}; font-size: {{sliderValue || 32}}rpx;" - > + <view class="question-stem title-score" style="color: {{isNight ? '#fff' : '#000'}}; font-size: {{sliderValue || 32}}rpx;"> <!-- 棰樺彿 --> <text>{{index+1}}.</text> <!-- 鍚姏棰� --> <view wx:if="{{item.questionType == 'singleChoice' && item.src}}"> <rich-text nodes="{{item.stem.stemTxt }}" /> - <view - style="margin-top: {{item.stem.stemTxt ? '10rpx' : ''}};" - class="audio-play-box" - bind:tap="audioPlay" - data-src="{{item.src}}" - > - <image - src="{{isPlay ? '/static/images/resourceDetailsMyAudio/zanting@2x.png' : '/static/images/resourceDetailsMyAudio/play@2x.png'}}" - mode="aspectFit" - ></image> + <view style="margin-top: {{item.stem.stemTxt ? '10rpx' : ''}};" class="audio-play-box" bind:tap="audioPlay" data-src="{{item.src}}"> + <image src="{{isPlay ? '/static/images/resourceDetailsMyAudio/zanting@2x.png' : '/static/images/resourceDetailsMyAudio/play@2x.png'}}" mode="aspectFit"></image> </view> </view> <!-- 浠呮枃瀛� --> - <view - class="title-content text-space" - wx:elif="{{item.stemStyle == 'Txt' && item.questionType != 'completion'}}" - >{{item.stem.stemTxt}}</view - > + <view class="title-content text-space" wx:elif="{{item.stemStyle == 'Txt' && item.questionType != 'completion'}}">{{item.stem.stemTxt}}</view> <!-- 浠呭浘鐗� --> <view wx:elif="{{item.stemStyle == 'Image'}}" class="title-content"> <image src="{{item.stem.stemImage}}" mode="aspectFit" /> </view> <!-- 鍥剧墖鍔犳枃瀛� --> - <view - wx:elif="{{item.stemStyle == 'TxtAndImage'}}" - class="title-content text-space" - > + <view wx:elif="{{item.stemStyle == 'TxtAndImage'}}" class="title-content text-space"> <view>{{item.stem.stemTxt}}</view> <image src="{{item.stem.stemImage}}" mode="aspectFit" /> </view> @@ -71,61 +35,19 @@ </view> <!-- 濉┖棰� --> <view wx:if="{{item.questionType == 'completion'}}"> - <view - class="completion-box" - wx:for="{{item.stem}}" - wx:for-item="inputItem" - wx:for-index="inputIndex" - wx:key="inputIndex" - > - <t-input - disabled="{{item.isComplete}}" - borderless - bind:change="onChangeInput" - data-value="{{item.option}}" - data-id="{{item.id}}" - data-index="{{inputItem.num}}" - 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'}}" - placeholder="璇疯緭鍏ユ枃瀛�" - value="{{item.userAnswer[inputItem.num]}}" - ></t-input> + <view class="completion-box" wx:for="{{item.stem}}" wx:for-item="inputItem" wx:for-index="inputIndex" wx:key="inputIndex"> + <t-input disabled="{{submitStatus}}" borderless bind:change="onChangeInput" data-value="{{item.option}}" data-id="{{item.id}}" data-index="{{inputItem.num}}" 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'}}" placeholder="璇疯緭鍏ユ枃瀛�" value="{{item.userAnswer[inputItem.num]}}"></t-input> <text wx:else class="text-space">{{inputItem}}</text> </view> </view> </view> <!-- 绛旈鍖哄煙 --> - <view - class="question-answer {{item.questionType == 'shortAnswer' ? 'textarea-center' : ''}}" - > + <view class="question-answer {{item.questionType == 'shortAnswer' ? 'textarea-center' : ''}}"> <!-- 鍗曢�夐 --> - <t-radio-group - wx:if="{{item.questionType == 'singleChoice' || item.questionType == 'judge'}}" - defaultValue="{{item.userAnswer}}" - disabled="{{item.isComplete}}" - bind:change="onChangeRadio" - class="radio-group" - data-id="{{item.id}}" - > - <view - wx:for="{{questionOptions && questionOptions.length ? questionOptions[item.optionIndex] : item.option}}" - wx:for-item="contentItem" - wx:for-index="contentIndex" - wx:key="contentIndex" - > - <t-radio - value="{{contentItem.value}}" - icon="none" - placement="right" - borderless - style="background-color: {{isNight ? '#222' : '#fff'}}" - > - <view - style="font-size: {{sliderValue || 32}}rpx;" - class="radio-item {{!submitStatus && item.userAnswer == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{item.userAnswer == contentItem.value && submitStatus ? item.isRight ? 'radio-correct' : 'radio-error' :''}}" - > + <t-radio-group wx:if="{{item.questionType == 'singleChoice' || item.questionType == 'judge'}}" defaultValue="{{item.userAnswer}}" disabled="{{submitStatus}}" bind:change="onChangeRadio" class="radio-group" data-id="{{item.id}}"> + <view wx:for="{{questionOptions && questionOptions.length ? questionOptions[item.optionIndex] : item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex"> + <t-radio value="{{contentItem.value}}" icon="none" placement="right" borderless style="background-color: {{isNight ? '#222' : '#fff'}}"> + <view style="font-size: {{sliderValue || 32}}rpx;" class="radio-item {{!submitStatus && item.userAnswer == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{item.userAnswer == contentItem.value && submitStatus ? item.isRight ? 'radio-correct' : 'radio-error' :''}}"> <!-- 浠呮枃瀛� --> <view wx:if="{{item.optionStyle == 'Txt'}}" class="text-space"> {{contentItem.value}}銆亄{contentItem.txt}} @@ -136,25 +58,15 @@ <image src="{{contentItem.img}}" mode="aspectFit" /> </view> <!-- 鏂囧瓧鍔犲浘鐗� --> - <view - wx:if="{{item.optionStyle == 'TxtAndImage'}}" - class="fl-center" - class="TxtAndImage-box" - > + <view wx:if="{{item.optionStyle == 'TxtAndImage'}}" class="fl-center" class="TxtAndImage-box"> <text class="text-space">{{contentItem.value}}銆�</text> <view class="radio-textimg">{{contentItem.txt}}</view> <image src="{{contentItem.img}}" mode="aspectFit" /> </view> <!-- 瀵屾枃鏈� --> - <view - wx:if="{{item.optionStyle == 'RichText'}}" - class="judge-rich-box" - > + <view wx:if="{{item.optionStyle == 'RichText'}}" class="judge-rich-box"> <text>{{contentItem.value}}銆�</text> - <rich-text - nodes="{{ contentItem.txt}}" - style="display: flex; align-items: center; width: 100%" - ></rich-text> + <rich-text nodes="{{ contentItem.txt}}" style="display: flex; align-items: center; width: 100%"></rich-text> </view> </view> </t-radio> @@ -162,32 +74,10 @@ </t-radio-group> <view wx:if="{{item.questionType == 'linkage'}}"> <!-- 鐗规畩棰� --> - <t-radio-group - defaultValue="{{item.questionTab}}" - disabled="{{item.isComplete}}" - bind:change="handeleOption" - class="radio-group" - data-value="{{item.questionTab}}" - data-id="{{item.id}}" - > - <view - wx:if="{{item.optionData}}" - wx:for="{{item.option}}" - wx:for-item="contentItem" - wx:for-index="contentIndex" - wx:key="contentIndex" - > - <t-radio - value="{{contentItem.value}}" - icon="none" - placement="right" - borderless - style="background-color: {{isNight ? '#222' : '#fff'}}" - > - <view - style="font-size: {{sliderValue || 32}}rpx;" - class="radio-item {{!submitStatus && item.questionTab == contentItem.value ? 'radio-active' : isNight ? 'night' :''}}" - > + <t-radio-group defaultValue="{{item.questionTab}}" disabled="{{submitStatus}}" bind:change="handeleOption" class="radio-group" data-value="{{item.questionTab}}" data-id="{{item.id}}"> + <view wx:if="{{item.optionData}}" wx:for="{{item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex"> + <t-radio value="{{contentItem.value}}" icon="none" placement="right" borderless style="background-color: {{isNight ? '#222' : '#fff'}}"> + <view style="font-size: {{sliderValue || 32}}rpx;" class="radio-item {{!submitStatus && item.questionTab == contentItem.value ? 'radio-active' : isNight ? 'night' :''}}"> <!-- 浠呮枃瀛� --> <view class="text-space"> {{contentItem.value}}銆亄{contentItem.txt}} @@ -197,31 +87,10 @@ </view> </t-radio-group> <view class="title-content text-space">{{item.stem.stem}}</view> - <t-radio-group - defaultValue="{{item.userAnswer}}" - disabled="{{item.isComplete}}" - bind:change="onChangeRadio" - class="radio-group" - data-value="{{item.userAnswer}}" - data-id="{{item.id}}" - > - <view - wx:for="{{item.optionData[item.questionTab]}}" - wx:for-item="citem" - wx:for-index="cindex" - wx:key="cindex" - > - <t-radio - value="{{citem.value}}" - icon="none" - placement="right" - borderless - style="background-color: {{isNight ? '#222' : '#fff'}}" - > - <view - style="font-size: {{sliderValue || 32}}rpx;" - class="radio-item {{!submitStatus && item.userAnswer == citem.value ? 'radio-active' : isNight ? 'night' :''}}" - > + <t-radio-group defaultValue="{{item.userAnswer}}" disabled="{{submitStatus}}" bind:change="onChangeRadio" class="radio-group" data-value="{{item.userAnswer}}" data-id="{{item.id}}"> + <view wx:for="{{item.optionData[item.questionTab]}}" wx:for-item="citem" wx:for-index="cindex" wx:key="cindex"> + <t-radio value="{{citem.value}}" icon="none" placement="right" borderless style="background-color: {{isNight ? '#222' : '#fff'}}"> + <view style="font-size: {{sliderValue || 32}}rpx;" class="radio-item {{!submitStatus && item.userAnswer == citem.value ? 'radio-active' : isNight ? 'night' :''}}"> <!-- 浠呮枃瀛� --> <view class="text-space"> {{citem.value}}銆亄{citem.txt}} @@ -233,101 +102,36 @@ </view> <!-- 澶氶�夐 --> - <t-checkbox-group - class="checkbox-group" - wx:elif="{{item.questionType == 'multipleChoice'}}" - t-class="box" - borderless - bind:change="onChangeRadio" - data-value="{{item.option}}" - data-id="{{item.id}}" - defaultValue="{{item.userAnswer}}" - > - <view - wx:for="{{item.option}}" - wx:for-item="contentItem" - wx:for-index="contentIndex" - wx:key="contentIndex" - > - <t-checkbox - disabled="{{item.isComplete}}" - icon="rectangle" - block="{{false}}" - class="t-checkbox" - value="{{contentItem.value}}" - style="background-color:{{isNight ? '#222' :'#F9F9F9'}}; " - > + <t-checkbox-group class="checkbox-group" wx:elif="{{item.questionType == 'multipleChoice'}}" t-class="box" borderless bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" defaultValue="{{item.userAnswer}}"> + <view wx:for="{{item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex"> + <t-checkbox disabled="{{submitStatus}}" icon="rectangle" block="{{false}}" class="t-checkbox" value="{{contentItem.value}}" style="background-color:{{isNight ? '#222' :'#F9F9F9'}}; "> <!-- 浠呮枃瀛� --> - <view - class="fl-center mh text-space" - wx:if="{{item.optionStyle == 'Txt'}}" - style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;" - > + <view class="fl-center mh text-space" wx:if="{{item.optionStyle == 'Txt'}}" style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;"> <text>{{contentItem.value}}銆�</text> <text class="check-text-box">{{contentItem.txt}}</text> </view> <!-- 浠呭浘鐗� --> - <view - wx:if="{{item.optionStyle == 'Image'}}" - class="fl-center mh" - > - <text - style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;" - >{{contentItem.value}}銆�</text - > + <view wx:if="{{item.optionStyle == 'Image'}}" class="fl-center mh"> + <text style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;">{{contentItem.value}}銆�</text> <image src="{{contentItem.img}}" mode="aspectFit" /> </view> <!-- 鏂囧瓧鍔犲浘鐗� --> - <view - wx:if="{{item.optionStyle == 'TxtAndImage'}}" - class="fl-center mh text-space" - > - <text - style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;" - >{{contentItem.value}}銆�</text - > - <text - style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;" - >{{contentItem.txt}}</text - > - <image - src="{{contentItem.img}}" - wx:if="{{contentItem.img}}" - mode="aspectFit" - /> + <view wx:if="{{item.optionStyle == 'TxtAndImage'}}" class="fl-center mh text-space"> + <text style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;">{{contentItem.value}}銆�</text> + <text style="color:{{ isNight ? '#fff' : '#000'}};font-size:{{sliderValue || 32}}rpx;">{{contentItem.txt}}</text> + <image src="{{contentItem.img}}" wx:if="{{contentItem.img}}" mode="aspectFit" /> </view> <!-- 瀵屾枃鏈� --> - <view - wx:if="{{item.optionStyle == 'RichText'}}" - class="check-rich-box mh" - > + <view wx:if="{{item.optionStyle == 'RichText'}}" class="check-rich-box mh"> <text>{{contentItem.value}}銆�</text> - <rich-text - nodes="{{contentItem.txt}}" - class="multipleChoice" - ></rich-text> + <rich-text nodes="{{contentItem.txt}}" class="multipleChoice"></rich-text> </view> </t-checkbox> </view> </t-checkbox-group> <!-- 绠�绛� 缈昏瘧 --> - <t-textarea - disabled="{{item.isComplete}}" - value="{{item.userAnswer}}" - bind:change="onChangeRadio" - data-value="{{item.option}}" - data-id="{{item.id}}" - class="option-textarea {{isNight ? 'textarea-night-color' :''}}" - wx:elif="{{item.questionType == 'shortAnswer'}}" - t-class="external-class" - placeholder="璇疯緭鍏ユ枃瀛�" - bordered - maxlength="500" - disableDefaultPadding="{{true}}" - indicator - style="background-color:{{isNight ? '#000' : '#fff'}}; " - /> + <t-textarea disabled="{{submitStatus}}" value="{{item.userAnswer}}" bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" class="option-textarea {{isNight ? 'textarea-night-color' :''}}" wx:elif="{{item.questionType == 'shortAnswer'}}" t-class="external-class" placeholder="璇疯緭鍏ユ枃瀛�" bordered maxlength="500" disableDefaultPadding="{{true}}" indicator style="background-color:{{isNight ? '#000' : '#fff'}}; " /> </view> </swiper-item> <swiper-item wx:if="{{noData}}"> @@ -337,4 +141,4 @@ </view> </swiper-item> </swiper> -</view> +</view> \ No newline at end of file diff --git a/packageBookService/pages/psychologyAnswer/questionOptions/index.wxml b/packageBookService/pages/psychologyAnswer/questionOptions/index.wxml index 2881232..5098630 100644 --- a/packageBookService/pages/psychologyAnswer/questionOptions/index.wxml +++ b/packageBookService/pages/psychologyAnswer/questionOptions/index.wxml @@ -74,7 +74,7 @@ wx:for-index="cindex" wx:key="cindex" style="border: {{showId == citem.id ? '1px solid #ff6c00' : ''}}" - class="question-box {{ citem.isUserAnswer ? 'answered' : 'un-answered' }}" + class="question-box {{ citem.userAnswer ? 'answered' : 'un-answered' }}" > {{cindex+1}} </view> @@ -170,7 +170,8 @@ <scroll-view scroll-y style="height: 30vh; overflow-y: auto"> <view class="report-li"> <view class="report-li-left" style="white-space: nowrap" - >棰樼洰鎬绘暟锛�</view> + >棰樼洰鎬绘暟锛�</view + > <view class="report-li-right">{{questionDataList.length}}閬�</view> </view> <view diff --git a/packageBookService/pages/psychologyAnswer/testdata/index.js b/packageBookService/pages/psychologyAnswer/testdata/index.js index 91603c3..4f498e5 100644 --- a/packageBookService/pages/psychologyAnswer/testdata/index.js +++ b/packageBookService/pages/psychologyAnswer/testdata/index.js @@ -1,5 +1,6 @@ var localData = { - "list": [{ + "list": [ + { "name": "娴嬫祴浣犵殑鐢熸椿鍝佽川", "title": "璇蜂粩缁嗛槄璇讳互涓嬮棶棰橈紝鍑綘鐨勭涓�鎰熻鍥炵瓟銆傝閫夋嫨涓庝綘鐩哥鐨勭瓟妗堬紝鍗充娇浣犳劅鍒颁笉澶‘瀹氾紝涔熻鍥炵瓟姣忎釜闂銆�", "fromType": "json", @@ -2502,7 +2503,8 @@ "index": "", "desc": "绗�4銆佺5銆佺8銆佺10棰橀�夆�滄槸鈥濆緱1鍒嗭紝閫夆�滃惁鈥濅笉寰楀垎锛涘叾浠栭鐩�夆�滃惁鈥濆緱1鍒嗭紝閫夆�滄槸鈥濅笉寰楀垎銆傛渶鍚庢妸鎵�寰楀垎鏁扮浉鍔犮��" }], - "scoreData": [{ + "scoreData": [ + { "name": "寰楀垎", "dispatch": "", "range": "all", @@ -2539,7 +2541,8 @@ } ] ], - "list": [{ + "list": [ + { "analysisCon": "鐣�", "optionIndex": 1, "id": "0C85D520", -- Gitblit v1.9.1