- //wxss
- <view class='quest_container' wx:for="{{quest}}" wx:key="id" wx:for-index="outterIndex">
-         <!-- {{item.type==1?'(单选)':'(多选)'}} -->
-         <text class="quest_containerName">{{item.question}}</text>
-         <view wx:for="{{item.answers}}" wx:key="content" bindtap="answerSelected" data-outidx='{{outterIndex}}' data-idx="{{index}}" class="item {{item.selected?'active':''}}">
-             <text>{{item.index}}.</text>
-             <text>{{item.content}}</text>
-         </view>
-         <view class="quest_containerImage" wx:if="{{item.image}}">
-             <image src="{{item.image}}" mode="" />
-         </view>
-     </view>
-     <view class="submit_btn" bindtap="submit">提交</view>
- //js
- const app = getApp()
- const {
-   $Toast
- } = require('../../dist/base/index');
- Page({
-   /**
-    * 页面的初始数据
-    */
-   data: {
-     Custom: {},
-     quest: [{
-       id: 1,
-       type: 1, //类型,1.单选,2.多选
-       question: "1.发现有人倒地无反应,你的反应是?",
-       answers: [{
-         index: 'A',
-         content: '不知道,没学过急救知识'
-       }, {
-         index: 'B',
-         content: '拨打120后等待医护人员到场'
-       },
-       {
-         index: 'C',
-         content: '拨打120后评估病情进行及时急救措施'
-       }],
-       correctAnswer: 'C',
-       scope: 10,
-     }, {
-       id: 2,
-       type: 1,
-       question: "2.如何判断一个倒地患者是否发生心跳骤停?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '拍打肩膀、掐肩膀并大声询问无反应,确定有无意识、判断有无呼吸'
-       }, {
-         index: 'C',
-         content: '掐人中,如果没有反应就是心脏骤停'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     }, {
-       id: 3,
-       type: 1,
-       question: "3.如图所示,您认为胸外按压的部位为?",
-       image: '/image/dati/xinzhangtu.png',
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '两乳头连线中点(B)'
-       }, {
-         index: 'C',
-         content: '剑突上1/3(A)'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     }, {
-       id: 4,
-       type: 1,
-       question: "4.胸外按压的频率是每分钟多少次?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '100-120次'
-       }, {
-         index: 'C',
-         content: '100以下'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     }, {
-       id: 5,
-       type: 1,
-       question: "5.成人心肺复苏时,胸外按压的深度为?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '5~6cm'
-       }, {
-         index: 'C',
-         content: '<5cm'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     }, {
-       id: 6,
-       type: 1,
-       question: "6.心脏骤停的病人实施胸外按压与人工呼吸的比例为?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '30次按压然后2次吹气'
-       }, {
-         index: 'C',
-         content: '15次按压然后1次吹气'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     }, {
-       id: 7,
-       type: 1,
-       question: "7.你会使用自动除颤仪AED?",
-       image: '/image/dati/ti2.png',
-       answers: [{
-         index: 'A',
-         content: '没有见过,不知道怎么做'
-       }, {
-         index: 'B',
-         content: '已经学会使用'
-       }, {
-         index: 'C',
-         content: '有见过,不会使用'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     }, {
-       id: 8,
-       type: 1,
-       question: "8.遇到面色苍白、大汗淋漓的胸痛病人,应该?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '知道,立即卧床安静 、不随意搬动、迅速拨打“120”、含服硝酸甘油或者速效救心丸'
-       }, {
-         index: 'C',
-         content: '让他自己走路活动一下,看能否缓解'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     },
-     {
-       id: 9,
-       type: 1,
-       question: "9.对于出现昏迷不醒的伤者,应该?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '知道,立即卧床安静 、不随意搬动、迅速拨打“120”、含服硝酸甘油或者速效救心丸'
-       }, {
-         index: 'C',
-         content: '让他自己走路活动一下,看能否缓解'
-       }],
-       correctAnswer: 'B',
-       scope: 10,
-     },
-     {
-       id: 10,
-       type: 1,
-       question: "10.是否知道脑血管意外病人的FAST识别原则?",
-       answers: [{
-         index: 'A',
-         content: '不知道'
-       }, {
-         index: 'B',
-         content: '立即心肺复苏'
-       }, {
-         index: 'C',
-         content: '知道,Face/面瘫、Arm/偏瘫、Speech/言语不清、Time/尽快到医院'
-       }],
-       correctAnswer: 'C',
-       scope: 10,
-     }
-     ]
-   },
-   // 点击问题答案触发事件
-   answerSelected(e) {
-     console.log("我的选择", e)
-     let outidx = e.currentTarget.dataset.outidx;
-     let idx = e.currentTarget.dataset.idx;
-     let question = this.data.quest[outidx];
-     if (question.type == 1) {
-       //单选
-       for (let item of question.answers) {
-         item.selected = false;
-       }
-       question.answers[idx].selected = true;
-       console.log('数据:::', question)
-       this.setData({
-         quest: this.data.quest
-       });
-     } else if (question.type == 2) {
-       //多选
-       question.answers[idx].selected = !question.answers[idx].selected;
-       this.setData({
-         quest: this.data.quest
-       });
-     }
-   },
-   submit() {
-     let {
-       quest
-     } = this.data;
-     let totalScope = 0; //记录分数
-     //用来保存选中的答案
-     let answerSelected = [];
-     for (let questItem of quest) {
-       if (questItem.type == 1) { //处理单选题
-         let isSelected = false;
-         for (let answerItem of questItem.answers) {
-           if (answerItem.selected) {
-             //答案被选中
-             isSelected = true;
-             console.log('选中的答案', answerItem)
-             answerSelected.push(answerItem.index);
-           }
-         }
-         if (!isSelected) {
-           //如果一个都没选
-           answerSelected.push('');
-           console.log('测试', isSelected)
-           this.handleWarning('请检查题目是否做完')
-         }
-       } else { //处理多选题
-         let multiAnswer = [];
-         for (let answerItem of questItem.answers) {
-           if (answerItem.selected) {
-             //答案被选中
-             multiAnswer.push(answerItem.index);
-           }
-         }
-         answerSelected.push(multiAnswer.join(''));
-       }
-       totalScope += questItem.correctAnswer == answerSelected[answerSelected.length - 1] ? questItem.scope : 0;
-     }
-     console.log(answerSelected);
-     console.log(totalScope);
-   },
-   // 弹窗
-   handleWarning(text) {
-     $Toast({
-       content: text,
-       type: 'warning'
-     });
-   },
-   /**
-    * 生命周期函数--监听页面加载
-    */
-   onLoad: function (options) {
-     this.setData({
-       Custom: app.globalData.Custom
-     })
-   },
-   /**
-    * 生命周期函数--监听页面初次渲染完成
-    */
-   onReady: function () {
-   },
-   /**
-    * 生命周期函数--监听页面显示
-    */
-   onShow: function () {
-   },
-   /**
-    * 生命周期函数--监听页面隐藏
-    */
-   onHide: function () {
-   },
-   /**
-    * 生命周期函数--监听页面卸载
-    */
-   onUnload: function () {
-   },
-   /**
-    * 页面相关事件处理函数--监听用户下拉动作
-    */
-   onPullDownRefresh: function () {
-   },
-   /**
-    * 页面上拉触底事件的处理函数
-    */
-   onReachBottom: function () {
-   },
-   /**
-    * 用户点击右上角分享
-    */
-   onShareAppMessage: function () {
-   }
- })
//less
.headeDemo {
    position: fixed;
    top: 0px;
    background: #fff;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
} 
.questions{
    width: 100%;
}
.quest_container {
    padding: 20rpx;
  }
  .quest_containerName{
    font-size: 32rpx;
    font-weight: bold;
  }
  .item {
    margin-top: 32rpx;
  }
  .active {
    color: red;
  }
  .submit_btn {
    background: #00a050;
    color: white;
    margin: 50rpx;
    padding: 25rpx;
    border-radius: 10rpx;
    text-align: center;
  }
  .quest_containerImage{
      width: 100%;
      display: flex;
      justify-content: center;
      margin-top: 20rpx;
    image{
        width: 560rpx;
    }
  }