''
liukangdong
2024-05-28 797c27eb2cbe0ee4eb3c3a999b26bd5bd20d456f
h5/pages/answer/answer.vue
@@ -21,28 +21,100 @@
            <view v-for="(item,index) in list"  :key="index" class="list_item">
               <template v-if="item.type == 1">
                  <view class="box_list_answer_name">
                  {{index + 1}}、{{item.title}}<text style="color:#ED4545;">*</text>
              {{ index + 1 }}、{{ item.title
              }}<text style="color: #ed4545">*</text>
               </view>
               <view class="box_list_answer_item" v-for="(line, lIndex) in item.options" :key="lIndex" @click="select(line, index)">
                  <image  src="@/static/video@2x.png" v-if="!item.selAnswer || item.selAnswer !== line.code" />
                  <image src="@/static/video_sel@2x.png" v-if="item.selAnswer && item.selAnswer == line.code && item.answer === item.selAnswer" />
                  <image src="@/static/video_error@2x.png" v-if="item.selAnswer && item.selAnswer == line.code && item.answer !== item.selAnswer" />
                  <text v-if="!item.selAnswer"><text class="mr24">{{line.code}}</text> {{line.value}}</text>
                  <text v-if="item.selAnswer && item.answer === item.selAnswer" style="color: rgba(2, 94, 239, 1)" ><text class="mr24" style="color: rgba(2, 94, 239, 1)">{{line.code}}</text> {{line.value}}</text>
                  <text v-if="item.selAnswer && item.answer !== item.selAnswer" style="color: rgba(237, 69, 69, 1)" ><text class="mr24" style="color: rgba(237, 69, 69, 1)">{{line.code}}</text> {{line.value}}</text>
            <view
              class="box_list_answer_item"
              v-for="(line, lIndex) in item.options"
              :key="lIndex"
              @click="select(line, index)"
            >
              <image
                src="@/static/video@2x.png"
                v-if="!item.selAnswer || item.selAnswer !== line.code"
              />
              <image
                src="@/static/video_sel@2x.png"
                v-if="
                  (item.selAnswer &&
                    item.answer === item.selAnswer &&
                    item.selAnswer == line.code) ||
                  item.selAnswer == line.code
                "
              />
              <image
                src="@/static/video_error@2x.png"
                v-if="
                  item.selAnswer &&
                  item.selAnswer == line.code &&
                  item.answer !== item.selAnswer &&
                  status == '2'
                "
              />
              <text v-if="!item.selAnswer || item.selAnswer !== line.code"
                ><text class="mr24">{{ line.code }}</text>
                {{ line.value }}</text
              >
              <text
                v-if="
                  (item.selAnswer &&
                    item.answer === item.selAnswer &&
                    item.selAnswer == line.code) ||
                  item.selAnswer == line.code
                "
                style="color: rgba(2, 94, 239, 1)"
                ><text class="mr24" style="color: rgba(2, 94, 239, 1)">{{
                  line.code
                }}</text>
                {{ line.value }}</text
              >
              <text
                v-if="
                  item.selAnswer &&
                  item.answer !== item.selAnswer &&
                  status == '2'
                "
                style="color: rgba(237, 69, 69, 1)"
                ><text class="mr24" style="color: rgba(237, 69, 69, 1)">{{
                  line.code
                }}</text>
                {{ line.value }}</text
              >
               </view>
               <view class="box_list_answer_tips" v-if="item.selAnswer && item.answer !== item.selAnswer">
            <view
              class="box_list_answer_tips"
              v-if="item.selAnswer && item.answer !== item.selAnswer && status != '0'"
            >
                  <image src="@/static/ic_wrong@2x.png" />
                  <text>回答错误</text>
               </view>
               <view class="box_list_answer_tips" v-if="item.selAnswer && item.answer === item.selAnswer">
            <view
              class="box_list_answer_tips"
              v-if="item.selAnswer && item.answer === item.selAnswer && status != '0'"
            >
                  <image src="@/static/meeting/icon/ic_choose_sel@2x.png" />
                  <text>回答正确</text>
               </view>
               </template>
            </view>
            <view class="empty"></view>
            <view class="box_list_answer_btn" @click="next()">提交</view>
        <view
          v-if="status == '0'"
          class="box_list_answer_btn"
          @click="onSubmit()"
          >提交</view
        >
        <view v-if="status == '1'" class="box_list_answer_btn" @click="next()"
          >恭喜你答题成功,去申请</view
        >
        <view
          v-if="status == '2'"
          style="background-color: #db534c"
          class="box_list_answer_btn"
          @click="status = '0'"
          >答题失败,再来一次</view
        >
            <!--    多选    -->
<!--             <template v-else-if="list[i].type === 2">
               <view class="box_list_answer_item" v-for="(item, index) in list[i].options" :key="index"
@@ -75,7 +147,9 @@
            list: [],
            bg: require("@/static/banner_dati.jpg"),
            title: '',
            content: ''
      content: '',
      status: '0'
         }
      },
      
@@ -121,7 +195,7 @@
                        item.status = '0'
                        item.selAnswer = null
                     })
                     console.log('options', res.data);
            console.log('options', res.data)
                     this.list = res.data
                  }
                  // res.param.problemsDOList.forEach(item => {
@@ -167,47 +241,42 @@
            }
         },
         // 下一题
    onSubmit() {
      const { list } = this
      // 验证所有题目都有选项
      let count = 0
      list.forEach(item => {
        if (!item.selAnswer) {
          count++
        }
      })
      if (count > 0) {
        return uni.showToast({
          title: '请先完成所有答题在提交',
          icon: 'none'
        })
      }
      // 判断对错
      let flag = 0
      list.forEach(item => {
        if (item.selAnswer !== item.answer) {
          flag++
        }
      })
      if (flag > 0) {
        this.status = '2'
        return uni.showToast({
          title: '答题失败,再来一次',
          icon: 'none'
        })
      } else {
        this.status = '1'
      }
    },
         next() {
            uni.navigateTo({
               url: `/pages/userinfo/userinfo?userAnswerId=${1}`
        url: `/pages/userinfo/userinfo`
            })
            return
            if (this.list[this.i].type === 0 || this.list[this.i].type === 1) {
               if (!String(this.problemIndex)) return
               if (this.list[this.i].answer === this.list[this.i].options[this.problemIndex].code) {
                  this.success = false
                  this.problemIndex = null
                  this.i += 1
               } else {
                  this.success = true
               }
            } else {
               if (!this.multiple) return
               if (this.list[this.i].answer === this.multiple) {
                  this.success = false
                  this.multiple = null
                  this.i += 1
               } else {
                  this.success = true
               }
            }
            if (this.i + 1 > this.list.length) {
               let arr = []
               this.list.forEach(item => {
                  arr.push({ id: item.id, answer: item.answer })
               })
               this.$u.api.finishAnswer({
                  content: JSON.stringify(arr),
                  openId: this.$store.state.openId,
                  useType: 1
               }).then(res => {
                  if (res.code === 200) {
                     uni.navigateTo({
                        url: `/pages/userinfo/userinfo?userAnswerId=${res.data}`
                     })
                  }
               })
            }
         }
      }
   }
@@ -217,7 +286,7 @@
   .box {
      width: 100%;
      height: 100vh;
      background: #025EEF;
  background: #025eef;
      .box_bgimage {
         width: 100%;
         padding: 0 40rpx;
@@ -232,13 +301,13 @@
         .box_bgimage_a {
            font-size: 54rpx;
            font-weight: bold;
            color: #FFFFFF;
      color: #ffffff;
            text-shadow: 0rpx 4rpx 8rpx rgba(0, 0, 0, 0.19);
         }
         .box_bgimage_b {
            font-size: 26rpx;
            font-weight: 400;
            color: #FFFFFF;
      color: #ffffff;
            text-shadow: 0rpx 2rpx 4rpx rgba(0, 0, 0, 0.24);
            margin-top: 18rpx;
         }
@@ -252,7 +321,7 @@
            width: 100%;
            height: 100%;
            overflow-y: auto;
            background: #FFFFFF;
      background: #ffffff;
            border-radius: 16rpx;
            padding: 30rpx;
            box-sizing: border-box;
@@ -267,7 +336,7 @@
               width: 100%;
               padding: 22rpx 30rpx;
               box-sizing: border-box;
               background: #F7F7F7;
        background: #f7f7f7;
               border-radius: 8rpx;
               display: flex;
               align-items: center;
@@ -279,7 +348,7 @@
               text {
                  font-size: 28rpx;
                  font-weight: 400;
                  color: #E42D2D;
          color: #e42d2d;
                  margin-left: 16rpx;
               }
            }
@@ -304,7 +373,7 @@
            }
         }
         .des {
            background: #CCCCCC !important;
      background: #cccccc !important;
            border: none !important;
         }
         .empty{
@@ -319,12 +388,12 @@
            height: 88rpx;
            line-height: 88rpx;
            text-align: center;
            background: #025EEF;
      background: #025eef;
            box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(2, 94, 239, 0.3);
            border-radius: 44rpx;
            font-size: 30rpx;
            font-weight: 500;
            color: #FFFFFF;
      color: #ffffff;
         }
      }
   }