From 8a27f5724e10e82cc5a30bf7051397da2e697e63 Mon Sep 17 00:00:00 2001
From: zhongshujie <2862698242@qq.com>
Date: 星期四, 19 十二月 2024 10:49:11 +0800
Subject: [PATCH] bug优化,答题卡初始化

---
 packageBookService/pages/psychologyAnswer/testdata/index.js       |   15 +++----
 packageBookService/pages/psychologyAnswer/psychologyAnswer.js     |   21 +++++-----
 packageBookService/pages/psychologyAnswer/psychologyAnswer.wxml   |   10 ++++-
 packageBookService/pages/psychologyAnswer/questionList/index.js   |    8 ++-
 .vscode/settings.json                                             |    2 
 packageBookService/pages/psychologyAnswer/questionList/index.wxml |    7 +--
 6 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/.vscode/settings.json b/.vscode/settings.json
index ff37bd1..451d977 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/packageBookService/pages/psychologyAnswer/psychologyAnswer.js b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
index a913ecf..5f5ffde 100644
--- a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
+++ b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
@@ -494,7 +494,7 @@
   // 鍒濆鍖栧嚱鏁�
   async init(isReset) {
     this.setData({
-      loading: false,
+      loading: true,
     });
     const questuionName = this.data.questuionName
     const questuionList = pastData.postData.list
@@ -714,25 +714,24 @@
           this.setData({
             questionDataList: newArr,
             scoreDataList: scoreArr,
+            loading: false,
           })
         } catch (error) {
           this.setData({
             questionDataList: newArr,
-            scoreDataList: scoreArr
+            scoreDataList: scoreArr,
+            loading: false,
           })
           console.log(error);
         }
+        const e = {
+          detail: {
+            index: 0
+          }
+        };
+        this.changeSwiper(e)
       });
   },
-
-
-
-
-
-
-
-
-
 
   // 璁板綍妯¤�冪瓟棰樻暟鎹�
   saveMockData() {
diff --git a/packageBookService/pages/psychologyAnswer/psychologyAnswer.wxml b/packageBookService/pages/psychologyAnswer/psychologyAnswer.wxml
index c42bd38..9a2cf9c 100644
--- a/packageBookService/pages/psychologyAnswer/psychologyAnswer.wxml
+++ b/packageBookService/pages/psychologyAnswer/psychologyAnswer.wxml
@@ -4,7 +4,11 @@
   wx:if="{{!loading}}"
   style="background-color:{{isNight ? '#222' : ''}}"
 >
-  <view class="page-content" style="background-color:{{isNight ? '#222' : ''}}">
+  <view
+    wx:if="{{!loading}}"
+    class="page-content"
+    style="background-color:{{isNight ? '#222' : ''}}"
+  >
     <question-list
       wx:if="{{!loading}}"
       sliderValue="{{sliderValue}}"
@@ -26,9 +30,10 @@
   <view
     class="page-bottom"
     style="background-color:{{isNight ? '#202020' : ''}}"
-    wx:if="{{answerType !== 'errorQuestion' || (answerType == 'errorQuestion' && !loading)}}"
+    wx:if="{{!loading}}"
   >
     <question-options
+      wx:if="{{!loading}}"
       id="question-options"
       isShowDialog="{{isShowDialog}}"
       isNight="{{isNight}}"
@@ -51,6 +56,7 @@
 </view>
 
 <page-container
+  wx:if="{{loading}}"
   show="{{showDialog}}"
   duration="{{false}}"
   overlay="{{false}}"
diff --git a/packageBookService/pages/psychologyAnswer/questionList/index.js b/packageBookService/pages/psychologyAnswer/questionList/index.js
index e6934a4..a9e9ee6 100644
--- a/packageBookService/pages/psychologyAnswer/questionList/index.js
+++ b/packageBookService/pages/psychologyAnswer/questionList/index.js
@@ -69,9 +69,11 @@
   ready() {
     const query = wx.createSelectorQuery().in(this);
     query.select('#question-title').boundingClientRect((rect) => {
-      this.setData({
-        height: 'calc(100% - 30px - ' + rect.height + 'px)'
-      })
+      if (rect) {
+        this.setData({
+          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 ab7f8ba..d7fc744 100644
--- a/packageBookService/pages/psychologyAnswer/questionList/index.wxml
+++ b/packageBookService/pages/psychologyAnswer/questionList/index.wxml
@@ -72,12 +72,12 @@
             </t-radio>
           </view>
         </t-radio-group>
+        <!-- 鐗规畩棰� -->
         <view wx:if="{{item.questionType == 'linkage'}}">
-          <!-- 鐗规畩棰� -->
           <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 style="font-size: {{sliderValue || 32}}rpx;" class="radio-item {{!submitStatus && item.questionTab == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{item.questionTab == contentItem.value && submitStatus ?  item.isRight ? 'radio-correct' : 'radio-error' :''}}">
                   <!-- 浠呮枃瀛� -->
                   <view class="text-space">
                     {{contentItem.value}}銆亄{contentItem.txt}}
@@ -90,7 +90,7 @@
           <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 style="font-size: {{sliderValue || 32}}rpx;" class="radio-item {{!submitStatus && item.userAnswer == citem.value ? 'radio-active' : isNight ? 'night' :''}}{{item.userAnswer == citem.value && submitStatus ?  item.isRight ? 'radio-correct' : 'radio-error' :''}}">
                   <!-- 浠呮枃瀛� -->
                   <view class="text-space">
                     {{citem.value}}銆亄{citem.txt}}
@@ -110,7 +110,6 @@
                 <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>
diff --git a/packageBookService/pages/psychologyAnswer/testdata/index.js b/packageBookService/pages/psychologyAnswer/testdata/index.js
index 4f498e5..485404a 100644
--- a/packageBookService/pages/psychologyAnswer/testdata/index.js
+++ b/packageBookService/pages/psychologyAnswer/testdata/index.js
@@ -1,6 +1,5 @@
 var localData = {
-  "list": [
-    {
+  "list": [{
       "name": "娴嬫祴浣犵殑鐢熸椿鍝佽川",
       "title": "璇蜂粩缁嗛槄璇讳互涓嬮棶棰橈紝鍑綘鐨勭涓�鎰熻鍥炵瓟銆傝閫夋嫨涓庝綘鐩哥鐨勭瓟妗堬紝鍗充娇浣犳劅鍒颁笉澶‘瀹氾紝涔熻鍥炵瓟姣忎釜闂銆�",
       "fromType": "json",
@@ -46,7 +45,8 @@
           }
         ]
       ],
-      "list": [{
+      "list": [
+        {
           "analysisCon": "鐣�",
           "id": "0C85D525",
           "optionIndex": 0,
@@ -2503,8 +2503,7 @@
         "index": "",
         "desc": "绗�4銆佺5銆佺8銆佺10棰橀�夆�滄槸鈥濆緱1鍒嗭紝閫夆�滃惁鈥濅笉寰楀垎锛涘叾浠栭鐩�夆�滃惁鈥濆緱1鍒嗭紝閫夆�滄槸鈥濅笉寰楀垎銆傛渶鍚庢妸鎵�寰楀垎鏁扮浉鍔犮��"
       }],
-      "scoreData": [
-        {
+      "scoreData": [{
         "name": "寰楀垎",
         "dispatch": "",
         "range": "all",
@@ -2541,8 +2540,7 @@
           }
         ]
       ],
-      "list": [
-        {
+      "list": [{
           "analysisCon": "鐣�",
           "optionIndex": 1,
           "id": "0C85D520",
@@ -2704,7 +2702,8 @@
           }
         ]
       }],
-      "list": [{
+      "list": [
+        {
           "analysisCon": "鐣�",
           "id": "3P1E1B001",
           "optionStyle": "Txt",

--
Gitblit v1.9.1