Browse Source

二期修改

y595705120 2 years ago
parent
commit
ceedefa9d2

+ 6 - 1
app.json

@@ -1,6 +1,9 @@
 {
   "pages": [
     "pages/index/index",
+    "pages/newExam/mockExam/index",
+    
+    "pages/newExam/home/index",
     "pages/my/index/index",
     "pages/exam/index/index",
     "pages/exam/answerIndex/index",
@@ -26,7 +29,9 @@
     "pages/train/limitHome/index",
     "pages/train/limitDo/index",
     "pages/train/limit/index",
-    "pages/train/orderTest/answer"
+    "pages/train/orderTest/answer",
+    "pages/newExam/orderTest/index"
+    
   ],
   "tabBar": {
     "color": "#6e6d6b",

+ 6 - 0
app.wxss

@@ -230,4 +230,10 @@ button::after {
 
 .br20{
   border-radius: 20rpx;
+}
+
+.flex-btn {
+  align-items: center;
+  display: flex;
+  justify-content: center;
 }

+ 5 - 5
pages/exam/index/index.js

@@ -65,13 +65,13 @@ Page({
   },
   gotoExam:function( e ){
     let {groupId, answerId} = e.currentTarget.dataset.item
+    wx.navigateTo({
+      url: `/pages/newExam/home/index?groupId=${groupId}&answerId=${answerId}`
+    })
 
     // wx.navigateTo({
-    //   url: `/pages/exam/do/index?id=${groupId}`
-    // })
-    wx.navigateTo({
-        url: `/pages/exam/group/group?groupId=${groupId}&answerId=${answerId}`
-      })
+    //     url: `/pages/exam/group/group?groupId=${groupId}&answerId=${answerId}`
+    //   })
   },
   gotoCollection(){
     wx.navigateTo({

+ 3 - 0
pages/index/index.js

@@ -39,6 +39,9 @@ Page({
     if (!this.loading && this.data.from > -1) {
       this.search(false)
     }
+  },
+  onShareAppMessage: function() {
+
   },
   search: function(override) {
     let _this = this

+ 39 - 0
pages/newExam/home/index.js

@@ -0,0 +1,39 @@
+let app = getApp()
+Page({
+  data: {
+    groupId: 0,
+    tableData: [],
+    types:{
+      1:'判断题',
+      2:'单选题',
+      3:'多选题',
+      4:'案例题'
+    }
+  },
+  onLoad: function(options) {
+    let groupId = +options.groupId||1;
+    this.setData({ groupId });
+  },
+  onShow: function () {
+    app.checkLogin( userInfo =>{
+      this.setData({userInfo, from:0})
+      this.loadData()
+    })
+  },
+  gotoAnswer(e){
+    let item = e.currentTarget.dataset.item;
+    let groupId = this.data.groupId
+    console.log( item )
+    wx.navigateTo({
+      url: `/pages/newExam/orderTest/index?groupId=${groupId}&type=${item.type}&count=${item.count}`
+    })
+  },
+  loadData: function(){
+    let param= {groupId: this.data.groupId}
+    app.formPost('Exam.InitGroupAnswer', param ).then(res => {
+      if( res.code == 200){
+        this.setData({tableData: res.data})
+      }
+    })
+  }
+})

+ 16 - 0
pages/newExam/home/index.json

@@ -0,0 +1,16 @@
+{
+  "usingComponents": {
+    "i-panel": "/component/iView/panel/index",
+    "i-cell-group": "/component/iView/cell-group/index",
+    "i-cell": "/component/iView/cell/index",
+    "i-collapse": "/component/iView/collapse/index",
+    "i-collapse-item": "/component/iView/collapse-item/index",
+    "i-message": "/component/iView/message/index",
+    "i-spin": "/component/iView/spin/index",
+    "i-icon": "/component/iView/icon/index",
+    "i-button": "/component/iView/button/index",
+    "i-badge": "/component/iView/badge/index"
+  },
+  "enablePullDownRefresh": true,
+  "navigationBarTitleText": "练习题库"
+}

+ 52 - 0
pages/newExam/home/index.wxml

@@ -0,0 +1,52 @@
+
+  <view class="mb20">
+    <swiper indicator-dots="false" autoplay="true" interval="5000" duration="1000">
+      <swiper-item>
+        <image src="/assets/carousel/1.png" class="slide-image" />
+      </swiper-item>
+      <swiper-item>
+        <image src="/assets/carousel/2.png" class="slide-image" />
+      </swiper-item>
+      <swiper-item>
+        <image src="/assets/carousel/3.png" class="slide-image" />
+      </swiper-item>
+    </swiper>
+</view>
+<navigator class="card-wrapper" wx:for="{{tableData}}" wx:key="index" 
+  url="/pages/newExam/orderTest/index?groupId={{groupId}}&type={{item.type}}&count={{item.count}}">
+  <view class="i-class i-card i-card-radus p10"  >
+    <view class="i-class i-card-header">
+      <view class="i-card-header-title fs42">
+        {{types[item.type]}} 
+      </view>
+      <view class="i-card-header-extra fs36">
+        共计【{{item.count}}】题
+      </view>
+    </view>
+  </view>
+</navigator>
+<navigator url="/pages/exam/collection/index?groupId={{groupId}}" class="card-wrapper">
+  <view class="i-class i-card i-card-radus p10">
+    <view class="i-class i-card-header">
+      <view class="i-card-header-title tc fs42">
+        我的错题
+      </view>
+      <view class="i-card-header-extra fs36" >
+        进入
+      </view>
+    </view>
+  </view>
+</navigator>
+
+  <navigator url="/pages/newExam/mockExam/index?id={{groupId}}" class="card-wrapper">
+    <view class="i-class i-card i-card-radus p10" >
+    <view class="i-class i-card-header">
+      <view class="i-card-header-title tc fs42">
+        模拟考试
+      </view>
+      <view class="i-card-header-extra fs36" style="font-size:40rpx" >
+        开始
+      </view>
+    </view>
+  </view>
+  </navigator>

+ 17 - 0
pages/newExam/home/index.wxss

@@ -0,0 +1,17 @@
+@import '/component/iView/card/index.wxss';
+.i-card-radus{
+   border-radius: 10rpx;
+   margin-top: 10rpx;
+   background-color: #fff;
+}
+
+page{
+  background-color: #fafafa;
+}
+
+.card-wrapper{
+  margin-bottom: 24rpx;
+}
+
+.fs42{font-size: 42rpx;}
+.fs36{font-size: 36rpx;}

+ 158 - 0
pages/newExam/mockExam/index.js

@@ -0,0 +1,158 @@
+import {formatSeconds} from '../../../utils/util.js'
+const util = require("../../../utils/util")
+let app = getApp()
+Page({
+  data: {
+    preList:["A","B","C", "D", "E", "F"],
+    userInfo: {},
+    modalShow: false,
+    timeOutShow: false,
+    remainTime: 0,
+    remainTimeStr: '',
+    index:0,
+    score:0,
+    useTime:0,
+    groupId:0,
+    item: {index:0},
+    cacheKey: "",
+    ansewersMap:{ },
+    info: {},
+    list: [],
+  },
+  onLoad: function(options) {
+    let groupId = +options.id||1
+    let cacheKey = "@mockExam_"+groupId;
+    app.checkLogin( userInfo =>{
+      this.setData({userInfo, cacheKey})
+      this.loadData( groupId )
+    })
+  },
+  loadData( groupId ){
+    let info = wx.getStorageSync(this.data.cacheKey)||{};
+    if( info && info.groupId == groupId){ 
+      let  remainTime = info.duration + info.startTime - parseInt(Date.now()/1000)
+      if( remainTime >0){
+        let index = info.index||0;
+        this.setData({info})
+        this.loadQuestion( index )
+        this.timeReduce()
+        return;
+      }
+    }
+    app.formPost('Exam.StartMockExam', {groupId}).then(res => {
+      if (res.code ==200) {
+        this.setData({info:res.data })
+        this.loadQuestion( 0 )
+        this.timeReduce()
+      }
+    })
+  },
+  selectquestion( e ){
+    let index = e.currentTarget.dataset.index
+    this.loadQuestion( index )
+  },
+  checkAnswer( goNext ){
+    let item = this.data.item;
+    let examId = this.data.info.examId;
+    if( !item.select ){
+      return;
+    }
+    let index = item.index||0;
+    let select = item.select||0;
+    if( item.type == 3 && !Number(select)) select = +select.join("");
+    let prevSubMit = this.data.ansewersMap[index];
+    if( prevSubMit == select ) {
+      console.log("submit exit", index, prevSubMit)
+      return;
+    }
+    let param = {id: item.id, examId, select}
+    app.formPost('Exam.SubmitMockAnswer', param).then(res => {
+      goNext && this.nextAnswer( )
+    })
+  },
+  radioChange( e ){
+    let item = this.data.item
+    item.select = +e.detail.value;
+    this.setData({item})
+    this.checkAnswer( true )
+  },
+  loadQuestion( index ) {
+    this.checkAnswer()
+    let item = this.data.info.answers[index];
+    if( !item ) return;
+    item.index = index;
+    if( !item.title ){
+      app.formPost("Exam.loadMockAnswer", {id:item.id} ).then(res => {
+        if( res.code != 200) return;
+        Object.assign( item, res.data)
+        this.saveItem( item ) 
+      })
+    }else{
+      this.saveItem( item ) 
+    }
+  },
+  saveItem( item ){
+    let info = this.data.info;
+    info.index = item.index;
+    info.answers[ item.index] = item;
+    wx.setStorageSync(this.data.cacheKey, info)
+    this.setData({item, info})
+  },
+  checkboxChange( e ){
+    let item = this.data.item
+    item.select = parseInt(e.detail.value.sort().join(''))
+    this.setData({item})
+  },
+  nextAnswer( ){
+    let nextId = (this.data.item.index||0)+1
+    if( nextId >= this.data.info.answers.length){
+      util.showModel("错误提示","已经最后一题" )
+      return
+    }
+    this.loadQuestion( nextId )
+  },
+  returnRecord(){
+    wx.navigateBack({
+      delta: 1,
+    })
+  },
+  dosubmit(e){
+    let examId = this.data.info.examId;
+    app.formPost("Exam.FinishMockExam", {examId}).then(res => {
+      if (res.code == 200) {
+        let { score, useTime } = res.data;
+        this.setData({score, useTime, modalShow:true})
+        wx.setStorageSync(this.data.cacheKey, {})
+        if( this.data.timer) clearInterval(this.data.timer)
+      }
+    });
+  },
+  timeOut() {
+    clearInterval(this.data.timer)
+    this.setData({
+      timeOutShow: true
+    });
+  },
+
+  timeReduce() {
+    let _this = this
+    let  remainTime = this.data.info.duration + this.data.info.startTime - parseInt(Date.now()/1000)
+    console.log("remainTime", remainTime);
+    this.setData({remainTime})
+    let timer = setInterval(function() {
+      let remainTime = _this.data.remainTime
+      if (remainTime <= 0) {
+        _this.timeOut()
+      } else {
+        _this.setData({
+          remainTime: remainTime - 1,
+          remainTimeStr: formatSeconds(remainTime),
+          doTime: _this.data.doTime + 1
+        });
+      }
+    }, 1000)
+    _this.setData({
+      timer: timer
+    });
+  }
+})

+ 16 - 0
pages/newExam/mockExam/index.json

@@ -0,0 +1,16 @@
+{
+  "usingComponents": {
+    "i-panel": "/component/iView/panel/index",
+    "i-cell-group": "/component/iView/cell-group/index",
+    "i-cell": "/component/iView/cell/index",
+    "i-radio-group": "/component/iView/radio-group/index",
+    "i-radio": "/component/iView/radio/index",
+    "i-input": "/component/iView/input/index",
+    "i-action-sheet": "/component/iView/action-sheet/index",
+    "i-modal": "/component/iView/modal/index",
+    "i-col": "/component/iView/col/index",
+    "i-row": "/component/iView/row/index"
+  },
+  "enablePullDownRefresh": false,
+  "navigationBarTitleText": "考试"
+}

+ 88 - 0
pages/newExam/mockExam/index.wxml

@@ -0,0 +1,88 @@
+<wxs module="filter" src="../../../wxs/exam-fun.wxs"></wxs>
+
+<view class="exam-page p10">
+
+	<view class="view-wrap">
+    <view class="exam-count-down">{{remainTimeStr}}</view>
+	</view>
+	<view class="view-wrap-hidden">
+	</view>
+
+	<i-panel i-class="exam-panel-title" >
+		<i-cell-group i-class="exam-cell">
+			<!-- 单选题 -->
+			<i-cell wx:if="{{item.type==2}}">
+				<view>
+					<rich-text nodes="{{item.index+1}}、[单]{{item.title}}" />
+					<radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">
+						<label class="radio" wx:for="{{preList}}" wx:for-item="answer" wx:key="anserIndex"
+							wx:if="{{item['answer'+(index+1)]}}">
+							<view class="radio-answer">
+								<radio color="#2d8cf0" value="{{index+1}}" checked="{{item.select==index+1}}">
+									{{answer}}. {{item['answer'+(index+1)]}}
+								</radio>
+							</view>
+						</label>
+					</radio-group>
+				</view>
+			</i-cell>
+			<!-- 多选题 -->
+			<i-cell wx:if="{{item.type==3}}">
+				<view>
+					<text>{{item.index+1}}、 [多]{{item.title}} </text>
+					<checkbox-group class="checkbox-answer" style="margin-top:10rpx" bindchange="checkboxChange">
+						<label class="checkbox" wx:for="{{preList}}" wx:key="index" wx:for-item="answer"
+							wx:if="{{item['answer'+(index+1)]}}">
+							<view class="checkbox-answer">
+								<checkbox color="#2d8cf0" value="{{index+1}}" checked="{{filter.isSelect( index+1, item.select)}}">
+									{{answer}}. {{item['answer'+(index+1)]}}
+								</checkbox>
+							</view>
+						</label>
+					</checkbox-group>
+				</view>
+			</i-cell>
+			<!-- 判断 -->
+			<i-cell wx:if="{{item.type==1}}">
+				<view>
+					<rich-text nodes="{{item.index+1}}、[判]{{item.title}}" />
+					<radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">
+						<label class="radio" wx:for="{{2}}" wx:for-item="answer">
+							<view class="radio-answer">
+								<radio color="#2d8cf0" value="{{index+1}}" checked="{{item.select==index+1}}">
+									{{preList[index]}}. {{item['answer'+(index+1)]}}
+								</radio>
+							</view>
+						</label>
+					</radio-group>
+				</view>
+			</i-cell>
+		</i-cell-group>
+
+		<view class="tc">
+			<button  type="primary" size="mini" bindtap='nextAnswer'>下一题</button>
+			<button  type="primary" size="mini" bindtap='dosubmit' class="ml20">交卷</button>
+		</view>
+	</i-panel>
+</view>
+
+<view class="bg-white p20">
+	<i-row>
+		<i-col  wx:for="{{info.answers}}"  style="float:left;width:12%;text-align:center" wx:key="item.id">
+			<view class="item-select {{filter.isExamSelect(index, info)}} " 
+				bindtap="selectquestion" data-index="{{index}}" > {{index+1}} </view>
+		</i-col>
+	</i-row>
+</view>
+
+
+<i-modal title="考试结果" visible="{{modalShow}}" bind:ok="returnRecord" bind:cancel="returnRecord">
+	<view>我的战绩:{{score}} </view>
+</i-modal>
+
+<i-action-sheet visible="true" visible="{{timeOutShow}}" mask-closable="{{ false }}">
+	<view slot="header" style="padding: 16px">
+		<view class="exam-timeout-title">考试试卷结束,请提交试卷!</view>
+		<button class="i-btn  i-btn-primary i-btn-square"  bindtap='dosubmit'>提交</button>
+	</view>
+</i-action-sheet>

+ 88 - 0
pages/newExam/mockExam/index.wxss

@@ -0,0 +1,88 @@
+.exam-tab-view {
+  margin-top: 42px;
+}
+
+.view-wrap {
+  position: fixed;
+  width: 100%;
+  background: #fff6f6;
+  text-align: center;
+  height: 35px;
+  z-index: 999;
+}
+
+.exam-count-down {
+  font-size: 40rpx;
+  line-height: 60rpx;
+}
+
+.view-wrap-hidden {
+  height: 35px;
+}
+
+
+.xzs-load-more {
+  margin-top: 60px !important;
+}
+
+.exam-page {
+  background: white;
+}
+
+.question-answer-error {
+  background-color: #fef0f0;
+  border-color: #fde2e2;
+  color: #f56c6c;
+}
+
+.question-answer-right {
+  background-color: #f0f9eb;
+  border-color: #e1f3d8;
+  color: #67c23a;
+}
+
+.exam-clear {
+  clear: both;
+  margin-left: 20rpx;
+}
+.exam-extend-item {
+  padding: 4px;
+}
+
+.item-select{
+  padding: 10rpx !important;
+  margin: 20rpx;
+  font-size:40rpx;
+  margin-top: 10rpx;
+  text-align: center;
+  height: 50rpx;
+}
+
+.un-select{
+  width: 50rpx;
+  height: 50rpx;
+  line-height: 50rpx;
+  border-radius: 100%;
+}
+
+.cur-select{
+  background: lightblue !important;
+  color:red;
+  width: 50rpx;
+  height: 50rpx;
+  font-size: 40rpx;
+  line-height: 50rpx;
+  border-radius: 100%;
+}
+
+.is-select{
+  background: #dadada;
+  width: 50rpx;
+  height: 50rpx;
+  line-height: 50rpx;
+  border-radius: 100%;
+}
+
+.exam-cell{
+  min-height: 500rpx;
+}

+ 130 - 0
pages/newExam/orderTest/index.js

@@ -0,0 +1,130 @@
+let app = getApp()
+const util = require("../../../utils/util")
+Page({
+  data: {
+    preList:["A","B","C", "D", "E", "F"],
+    info:{},
+    total:0,
+    unfinish:0,
+    answerId:0,
+    index:0,
+    type:1,
+    showResult: false,
+    types:{
+      1:'判断题',
+      2:'单选题',
+      3:'多选题',
+      4:'案例题'
+    },
+    groupId:0
+  },
+  onLoad: function(options) {
+    let groupId = +options.groupId||1;
+    let type = +options.type||1;
+    let total = +options.count ||0;
+    this.setData({ groupId, type, total });
+  },
+  onChange(event){
+    const showResult = event.detail.value;
+    let {info} = this.data;
+    if( showResult ) {
+      info.select = info.result;
+    }else{
+      info.select = 0
+    }
+    this.setData({showResult, info})
+  },
+  onShow: function(){
+    app.checkLogin( userInfo =>{
+      this.setData({userInfo, from:0})
+      this.loadAnswer()
+    })
+  },
+  loadAnswer(  ){
+    let {groupId, type, showResult} = this.data
+    app.formPost('Exam.LoadAnswerNew', {groupId, type}).then(res => {
+      if (res.code ==200) {
+        let {unfinish, info, total} = res.data;
+        let index = total- unfinish;
+        if(showResult) info.select = info.result;
+        this.setData({unfinish, total, info, index})
+      }
+    })
+  },
+  checkAnswer( e ){
+    let item = this.data.item;
+    if( !item.select ){
+      app.message("还未作答", 'error')
+      return;
+    }
+    let param = {answerId: item.answerId}
+    // 多选
+    if( item.type == mulSelect ){
+      item.correct = item.select.join("") == item.result;
+    }else{
+      item.correct = item.select == item.result;
+    }
+    param.correct = item.correct?1:0
+    // 打开下一题
+    app.formPost('Exam.EditErrorAnswer', param).then(res => {
+      this.setData({item, next:true})
+    }) 
+  },
+  radioChange( e ){
+    let info = this.data.info
+    info.select = +e.detail.value
+    this.setData( {info} );
+  },
+  checkboxChange( e ){
+    let info = this.data.info
+    info.select = +e.detail.value.sort().join("")
+    let result = ""+info.result
+    if (info.select == result ){
+      info._select = true
+    }else{
+      for( let i in e.detail.value){
+        if(result.indexOf( e.detail.value[i] )==-1 ){
+          info._select = true
+        }
+      }
+    }
+    this.setData( {info} );
+  },
+  restartAnswer(){
+    let {groupId, type, showResult} = this.data
+    app.formPost('Exam.resetAnswerNew', {groupId, type}).then(res => {
+      if (res.code ==200) {
+        let {total, unfinish,info} = res.data
+        let index =  total - unfinish;
+        if(showResult) info.select = info.result;
+        this.setData({info, index, total, unfinish})
+      }
+    })
+  },
+  finishAnswer( e ){
+    let action = e.currentTarget.dataset.action;
+    let {groupId, unfinish, type, showResult, total, index} = this.data
+    let correct = this.data.info.select == this.data.info.result?1:0;
+    if( action == "prev"){
+      if( total <= unfinish ) {
+        util.showMsg("已经在第一题")
+        return
+      }
+      unfinish+=1
+    }else{
+      if( unfinish < 1 ) {
+        util.showMsg("已经最后一题")
+        return;
+      }
+      unfinish-=1
+    }
+    app.formPost('Exam.finishAnswerNew', {groupId, index, type, correct, action}).then(res => {
+      if (res.code ==200) {
+        let info = res.data
+        let index = total-unfinish;
+        if( showResult) info.select = info.result;
+        this.setData({info, unfinish, index})
+      }
+    })
+  }
+})

+ 18 - 0
pages/newExam/orderTest/index.json

@@ -0,0 +1,18 @@
+{
+  "usingComponents": {
+    "i-panel": "/component/iView/panel/index",
+    "i-cell-group": "/component/iView/cell-group/index",
+    "i-cell": "/component/iView/cell/index",
+    "i-radio-group": "/component/iView/radio-group/index",
+    "i-radio": "/component/iView/radio/index",
+    "i-input": "/component/iView/input/index",
+    "i-action-sheet": "/component/iView/action-sheet/index",
+    "i-modal": "/component/iView/modal/index",
+    "i-message": "/component/iView/message/index",
+    "i-switch": "/component/iView/switch/index",
+    "i-spin": "/component/iView/spin/index",
+    "i-rate": "/component/iView/rate/index"
+  },
+  "enablePullDownRefresh": false,
+  "navigationBarTitleText": "顺序答题"
+}

+ 116 - 0
pages/newExam/orderTest/index.wxml

@@ -0,0 +1,116 @@
+<wxs module="filter" src="../../../wxs/exam-fun.wxs"></wxs>
+
+<view class="exam-page p10" wx:if="{{index<total}}">
+  <view class="view-wrap">
+    <view class="exam-count-down">
+      {{types[type]}} ({{index+1}}/{{total}})
+      <text style="margin-left:10rpx;margin-right:10rpx">背景模式</text>
+      <i-switch value="{{showResult}}" bind:change="onChange"></i-switch>
+    </view>
+  </view>
+
+  <i-panel i-class="exam-panel-title">
+    <i-cell-group i-class="exam-cell">
+      <!-- 单选题 -->
+      <i-cell wx:if="{{info.type ==2}}">
+        <view class="single">
+          <rich-text nodes="[单]{{info.title}}" />
+          <radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">
+            <label class="radio" wx:for="{{preList}}" wx:for-item="answer" wx:key="anserIndex"
+              wx:if="{{info['answer'+(index+1)]}}">
+              <view class="radio-answer">
+                <radio color="#2d8cf0" value="{{index+1}}" checked="{{info.select==index+1}}"
+                  disabled="{{info.select>0?true:false}}">
+                  {{preList[index]}}. {{info['answer'+(index+1)]}}
+                </radio>
+              </view>
+            </label>
+          </radio-group>
+
+          <view class="exam-clear mt20" wx:if="{{info.select>0}}">
+            <view class="exam-extend-item">
+              答题结果:
+              <text class="question-answer-right question-answer-result" wx:if="{{info.select==info.result}}">正确
+              </text>
+              <text class="question-answer-error question-answer-result" wx:else>错误</text>
+            </view>
+
+            <view class="exam-extend-item">
+              正确答案:
+              <text wx:if="{{info.type==2}}"> {{preList[info.result-1]}}</text>
+            </view>
+          </view>
+        </view>
+      </i-cell>
+      <!-- 多选题 -->
+      <i-cell wx:if="{{info.type==3}}">
+        <view>
+          <rich-text nodes="[多]{{info.title}}" />
+          <checkbox-group class="checkbox-answer" style="margin-top:30rpx" bindchange="checkboxChange"
+            data-index="{{index}}">
+            <label class="checkbox" wx:for="{{preList}}" wx:for-item="answer" wx:key=""
+              wx:if="{{info['answer'+(index+1)]}}">
+              <view class="checkbox-answer">
+                <checkbox color="#2d8cf0" value="{{index+1}}" disabled="{{!!info._select}}"
+                  checked="{{filter.isSelect(index+1,info.select)}}">
+                  {{answer}}. {{info['answer'+(index+1)]}}
+                </checkbox>
+              </view>
+            </label>
+          </checkbox-group>
+        </view>
+
+        <view class="exam-clear mt20" wx:if="{{isFinish || info._select}}">
+          <view class="exam-extend-item">
+            答题结果:
+            <text class="question-answer-right question-answer-result" wx:if="{{info.select==info.result}}">正确
+            </text>
+            <text class="question-answer-error question-answer-result" wx:else>错误</text>
+          </view>
+          <view class="exam-extend-item">
+            正确答案:
+            <text> {{filter.getMultResult(info.result)}}</text>
+          </view>
+        </view>
+
+      </i-cell>
+      <!-- 判断 -->
+      <i-cell wx:if="{{info.type==1}}">
+        <view>
+          <rich-text nodes="[判]{{info.title}}" />
+          <radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">
+            <label class="radio" wx:for="{{2}}" wx:for-item="answer">
+              <view class="radio-answer">
+                <radio color="#2d8cf0" value="{{index+1}}" checked="{{info.select==index+1}}"
+                  disabled="{{info.select>0?true:false}}">
+                  {{preList[index]}}. {{info['answer'+(index+1)]}}
+                </radio>
+              </view>
+            </label>
+          </radio-group>
+        </view>
+        <view class="exam-clear mt20" wx:if="{{ info.select>0}}">
+          <view class="exam-extend-item">
+            答题结果:
+            <text class="question-answer-right question-answer-result" wx:if="{{info.select==info.result}}">正确
+            </text>
+            <text class="question-answer-error question-answer-result" wx:else>错误</text>
+          </view>
+          <view class="exam-extend-item">
+            正确答案:
+            <text> {{info.result==1?'正确':'错误'}}</text>
+          </view>
+        </view>
+      </i-cell>
+    </i-cell-group>
+  </i-panel>
+
+  <view class="flex-btn">
+    <button class="i-btn  i-btn-primary" style="padding: 0 50rpx" bindtap='finishAnswer' data-action="prev">上一题</button>
+    <button class="i-btn  i-btn-primary" style="padding: 0 50rpx" bindtap='finishAnswer' data-action="next">下一题</button>
+  </view>
+</view>
+
+<view wx:else style="text-align:center;margin-top:40rpx">
+  <button class="i-btn  i-btn-primary i-btn-square" bindtap='restartAnswer'>重新再刷一遍</button>
+</view>

+ 98 - 0
pages/newExam/orderTest/index.wxss

@@ -0,0 +1,98 @@
+/* pages/exam/paper/paper.wxss */
+.exam-page {
+  background: white;
+}
+
+.exam-count-down {
+  font-size: 15px;
+  line-height: 35px;
+}
+
+.view-wrap {
+  position: fixed;
+  width: 100%;
+  background: #fff6f6;
+  text-align: center;
+  height: 35px;
+  z-index: 999;
+}
+
+.view-wrap-hidden {
+  height: 35px;
+}
+
+.exam-name-title {
+  text-align: center;
+  margin-top: 10px;
+  font-size: 17px;
+}
+
+.exam-panel-title {
+  margin-top: 30px;
+}
+
+.exam-radio-item-label {
+  float: left;
+  margin-left: 10px;
+  line-height: 35px;
+}
+
+.exam-item-left {
+  float: left;
+}
+
+.exam-input-contain {
+  margin: 10px 2px !important;
+  border-width: 1px;
+  border-color: #dddee1;
+  border-style: solid;
+  width: 95%;
+  height: 40px;
+}
+
+.exam-input-contain-label {
+  float: left;
+  padding: 0px 15px;
+  line-height: 40px;
+}
+
+.exam-input-contain-content {
+  float: left;
+  height: 40px;
+}
+
+.exam-textarea-contain {
+  margin: 10px 2px !important;
+  border-width: 1px;
+  border-color: #dddee1;
+  border-style: solid;
+  width: 100%;
+}
+
+.exam-timeout-title{
+  font-size: 16px;
+  color: red;
+  margin-top: 10px;
+  margin-bottom: 20px;
+}
+
+.exam-clear {
+  clear: both;
+  margin-left: 20rpx;
+}
+
+.exam-extend-item {
+  padding: 4px;
+}
+
+.question-answer-error {
+  background-color: #fef0f0;
+  border-color: #fde2e2;
+  color: #f56c6c;
+}
+
+.question-answer-right {
+  background-color: #f0f9eb;
+  border-color: #e1f3d8;
+  color: #67c23a;
+}

+ 47 - 0
pages/post/post.js

@@ -1,3 +1,5 @@
+const util = require("../../utils/util");
+
 const app = getApp()
 Page({
 
@@ -13,6 +15,51 @@ Page({
   onShow: function(){
     this.loadData()
   },
+  preview( e ){
+    var imgs = [];
+    let content = this.data.info.content||''
+    content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
+      imgs.push(capture);
+    });
+    console.log("url",content, imgs)
+    if( imgs.length > 0 ){
+      wx.previewImage({
+        current: imgs[0],
+        urls: imgs
+      })
+    }
+  },
+  download( ){
+    let url = this.data.info.sourceUrl;
+    if( !url ){
+      util.showModel("下载失败", "无附件内容")
+      return
+    }
+    wx.downloadFile({
+      url: url,
+      timeout: 0,
+      success: (res) => {
+        var rr=res.tempFilePath;
+        wx.openDocument({
+          filePath:rr,
+          showMenu: true,
+          success(res) {
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+              duration: 2000
+            })
+          }
+        })
+      },
+      fail: (res) => {
+        console.log("res_fail", res)
+      },
+      complete: (res) => {
+        console.log("res_complete", res)
+      },
+    })
+  },
   loadData(){
     let postId = this.data.postId
     app.formPost( "Post.getPostInfo", {postId}).then( res=>{

+ 5 - 1
pages/post/post.wxml

@@ -9,8 +9,12 @@
     {{info.viewCount}}
   </view>
 
+ <view class="tc mt10" wx:if="{{info.sourceUrl}}">
+    <i-button  bindtap="download" class="ml20 bsmall"> 下载附件</i-button>
+  </view>
+
   <view class="wxParse artical-content">
-    <rich-text nodes="{{info.content}}" space="emsp" ></rich-text>
+    <rich-text nodes="{{info.content}}" space="emsp" bindtap="preview"></rich-text>
   </view>
 </view>
 

+ 8 - 8
pages/train/limitHome/index.wxml

@@ -14,12 +14,12 @@
 </view>
 <navigator class="card-wrapper" wx:for="{{tableData}}" wx:key="index" 
   url="/pages/train/orderTest/answer?groupId={{groupId}}&type={{item.type}}&count={{item.count}}">
-  <view class="i-class i-card i-card-radus p10" data-id="{{item.id}}" data-out="{{item.isOut}}"  bindtap="gotoDetail" >
+  <view class="i-class i-card i-card-radus p10" >
     <view class="i-class i-card-header  ">
-      <view class="i-card-header-title" style="font-size:36rpx">
+      <view class="i-card-header-title" style="font-size:42rpx">
         {{types[item.type]}} 
       </view>
-      <view class="i-card-header-extra" style="font-size:28rpx" >
+      <view class="i-card-header-extra" style="font-size:36rpx" >
         共计【{{item.count}}】题
       </view>
     </view>
@@ -29,23 +29,23 @@
 <navigator url="/pages/exam/collection/index?groupId={{groupId}}" class="card-wrapper">
   <view class="i-class i-card i-card-radus" data-id="{{item.id}}" data-out="{{item.isOut}}"  bindtap="gotoDetail" >
     <view class="i-class i-card-header mt10">
-      <view class="i-card-header-title tc" style="font-size:36rpx">
+      <view class="i-card-header-title tc" style="font-size:42rpx">
         我的错题
       </view>
-      <view class="i-card-header-extra" style="font-size:28rpx" >
+      <view class="i-card-header-extra" style="font-size:36rpx" >
         进入
       </view>
     </view>
   </view>
 </navigator>
 
-  <navigator url="/pages/train/limitDo/index?id={{groupId}}" class="card-wrapper">
+  <navigator url="/pages/newExam/mockExam/index?id={{groupId}}" class="card-wrapper">
     <view class="i-class i-card i-card-radus" data-id="{{item.id}}" data-out="{{item.isOut}}"  bindtap="gotoDetail" >
     <view class="i-class i-card-header mt10">
-      <view class="i-card-header-title tc" style="font-size:36rpx">
+      <view class="i-card-header-title tc" style="font-size:42rpx">
         模拟考试
       </view>
-      <view class="i-card-header-extra" style="font-size:28rpx" >
+      <view class="i-card-header-extra" style="font-size:36rpx" >
         开始
       </view>
     </view>

+ 23 - 6
pages/train/orderTest/answer.js

@@ -1,4 +1,5 @@
 let app = getApp()
+const util = require("../../../utils/util")
 Page({
   data: {
     preList:["A","B","C", "D", "E", "F"],
@@ -42,10 +43,10 @@ Page({
     let {groupId, type, showResult} = this.data
     app.formPost('Exam.LoadAnswerLimit', {groupId, type}).then(res => {
       if (res.code ==200) {
-        let {unfinish, info} = res.data
+        let {unfinish, info, total} = res.data
         let answerId = info&&info.answerId||0;
         if( showResult) info.select = info.result;
-        this.setData({unfinish, info, answerId})
+        this.setData({unfinish, total, info, answerId})
       }
     })
   },
@@ -101,14 +102,30 @@ Page({
       }
     })
   },
-  finishAnswer( ){
-    let {groupId, answerId, unfinish, type, showResult} = this.data
+  finishAnswer( e ){
+    let action = e.currentTarget.dataset.action;
+    let {groupId, unfinish, type, showResult, total} = this.data
     let correct = this.data.info.select == this.data.info.result?1:0;
-    app.formPost('Exam.finishAnswerLimit', {groupId, answerId, type, correct}).then(res => {
+    let answerId = total-unfinish;
+    if( action == "prev"){
+      if( total<=unfinish ) {
+        util.showMsg("已经在第一题")
+        return
+      }
+      answerId-=1
+    }else{
+      if( unfinish<1 ) {
+        util.showMsg("已经最后一题")
+        return;
+      }
+      answerId+=1 
+    }
+    console.log("finishAnswer", action, answerId, unfinish, total)
+    app.formPost('Exam.finishAnswerLimit', {groupId, answerId, type, correct, action}).then(res => {
       if (res.code ==200) {
         let info = res.data
         let answerId = info.answerId
-        unfinish = unfinish-1
+        unfinish = (action == "prev")?(unfinish+1):(unfinish-1);
         if( showResult) info.select = info.result;
         this.setData({info, answerId, unfinish})
       }

+ 7 - 6
pages/train/orderTest/answer.wxml

@@ -2,10 +2,10 @@
 
 <view class="exam-page p10" wx:if="{{answerId>0}}">
   <view class="view-wrap">
-    <view class="exam-count-down" >
-     {{types[type]}} ({{unfinish}}/{{total}})
-        <text style="margin-left:10rpx;margin-right:10rpx">背景模式</text> 
-        <i-switch value="{{showResult}}" bind:change="onChange"></i-switch>
+    <view class="exam-count-down">
+      {{types[type]}} ({{unfinish}}/{{total}})
+      <text style="margin-left:10rpx;margin-right:10rpx">背景模式</text>
+      <i-switch value="{{showResult}}" bind:change="onChange"></i-switch>
     </view>
   </view>
 
@@ -105,8 +105,9 @@
     </i-cell-group>
   </i-panel>
 
-<view class="mt50">
-    <button class="i-btn  i-btn-primary i-btn-square" bindtap='finishAnswer'>下一题</button>
+  <view class="flex-btn">
+    <button class="i-btn  i-btn-primary" style="padding: 0 50rpx"  bindtap='finishAnswer' data-action="prev" >上一题</button>
+    <button class="i-btn  i-btn-primary" style="padding: 0 50rpx" bindtap='finishAnswer' data-action="next">下一题</button>
   </view>
 </view>
 

+ 1 - 0
pages/user/register/index.wxss

@@ -15,3 +15,4 @@
   line-height: 45px;
   margin-left: 25px;
 }
+

+ 12 - 0
wxs/exam-fun.wxs

@@ -51,12 +51,24 @@ var filter = {
     return select.indexOf( index )>-1;
   },
   isExamSelect: function( index, info ){
+    if( index == 1){
+      console.log(index, info.index)
+    }
     if( !info.answers ) return '';
     if( index >= info.answers.length ) return '';
     var select = ""
     if( index == info.index ) select += 'cur-select';
     if( info.answers[index].select>0 ) select += ' is-select';
     return select||'un-select'
+  },
+  isExamSelectItem: function( index, item ){
+    if(index==1){
+      console.log(index, JSON.stringify(item))
+    }
+    var select = ""
+    if( index == item.index ) select += 'cur-select';
+    if( item.select>0 ) select += ' is-select';
+    return select||'un-select'
   }
 }
 // 导出对外暴露的属性