y595705120 4 jaren geleden
bovenliggende
commit
3da9481f60

+ 2 - 14
app.js

@@ -10,7 +10,6 @@ App({
     userInfo: {},
   },
   onLaunch: function() {
-
   },
   doLogin: function(cb){
     let _this = this
@@ -84,19 +83,8 @@ App({
             reject('网络出错')
             return false;
           }
-          if( res.data.code == 200){
-            resolve(res.data);
-            return true;
-          }
-
-          if (res.data.code === 401) {
-            wx.reLaunch({
-              url: '/pages/user/bind/index',
-            });
-            return false;
-          } 
-          reject(res.data.msg)
-          return false
+          resolve(res.data);
+          return true;
         },
         fail(res) {
           reject(res.errMsg)

+ 1 - 35
app.json

@@ -7,11 +7,9 @@
     "pages/record/index",
     "pages/exam/read/index",
     "pages/exam/do/index",
-    
-    
     "pages/user/bind/index",
     
-    "pages/exam/edit/index",
+    "pages/exam/error/index",
     
     "pages/my/message/info/index",
     "pages/my/message/list/index",
@@ -24,37 +22,5 @@
     "navigationBarTextStyle": "black",
     "backgroundTextStyle": "dark"
   },
-  "tabBar": {
-    "color": "#6e6d6b",
-    "selectedColor": "#ff9966",
-    "borderStyle": "black",
-    "backgroundColor": "#ffffff",
-    "list": [
-      {
-        "pagePath": "pages/index/index",
-        "text": "首页",
-        "iconPath": "/assets/tabBar/index.png",
-        "selectedIconPath": "/assets/tabBar/index-select.png"
-      },
-      {
-        "pagePath": "pages/exam/index/index",
-        "text": "试卷",
-        "iconPath": "/assets/tabBar/exam.png",
-        "selectedIconPath": "/assets/tabBar/exam-select.png"
-      },
-      {
-        "pagePath": "pages/record/index",
-        "text": "记录",
-        "iconPath": "/assets/tabBar/record.png",
-        "selectedIconPath": "/assets/tabBar/record-select.png"
-      },
-      {
-        "pagePath": "pages/my/index/index",
-        "text": "我的",
-        "iconPath": "/assets/tabBar/my.png",
-        "selectedIconPath": "/assets/tabBar/my-select.png"
-      }
-    ]
-  },
   "sitemapLocation": "sitemap.json"
 }

BIN
assets/logo.png


BIN
assets/logo2.png


+ 44 - 35
pages/exam/do/index.js

@@ -6,6 +6,7 @@ let app = getApp()
 Page({
   data: {
     list: [],
+    redo: false,
     preList:["A","B","C", "D"],
     info:{},
     timer: null,
@@ -19,21 +20,25 @@ Page({
   },
   onLoad: function(options) {
     let groupId = +options.id||3
+    let redo = !!options.redo;
+    this.setData({redo})
+    let method =  redo?'Exam.examreStart':'Exam.examStart';
     let _this = this
-    app.formPost('Exam.examStart', {groupId}).then(res => {
-      let list = res.data.list.map(item=>{
-        delete( item["select"])
-        return item
-      }).sort( (i,j) =>{
-        return i.type > j.type?1:-1;
-      })
-      
+    app.formPost(method, {groupId}).then(res => {
       if (res.code ==200) {
+        let {startTime, info, list} = res.data;
+        let duration = list.length * 60;
+        list = list.map(item=>{
+          delete( item["select"])
+          return item
+        }).sort( (i,j) =>{
+          return i.type > j.type?1:-1;
+        })
         _this.setData({
           list: list,
-          info: res.data.info,
-          startTime: res.data.startTime,
-          remainTime: res.data.info.duration
+          info: info,
+          startTime: startTime,
+          remainTime: duration
         });
         _this.timeReduce()
       }
@@ -61,9 +66,15 @@ Page({
     clearInterval(this.data.timer)
   },
   returnRecord() {
-    wx.reLaunch({
-      url: '/pages/record/index',
-    });
+    if( this.data.redo){
+      wx.reLaunch({
+        url: '/pages/exam/error/index',
+      });
+    }else{
+      wx.reLaunch({
+        url: '/pages/record/index',
+      });
+    }
   },
   timeOut() {
     clearInterval(this.data.timer)
@@ -94,16 +105,17 @@ Page({
     let info = this.data.info;
     let param ={};
     param.groupId = info.groupId;
+    param.paperId = info.paperId;
     param.answers = [];
     param.result  = [];
     param.correct = 0;
-    param.errIds = []
+
     param.counter = this.data.list.length
     param.groupName = info.title;
     param.useTime =  this.data.doTime
     param.duration = info.duration
     param.startTime = this.data.startTime;
-    
+    let errIds = [];
     for( let i=0; i< this.data.list.length; i++){
         let item = this.data.list[i];
         param.answers.push( item.answerId );
@@ -117,7 +129,7 @@ Page({
         if( param.result[i] == item.result){
           param.correct += 1
         }else{
-          param.errIds.push( item.answerId)
+          errIds.push( item.answerId)
         }
         if( !item.select ) isFinish = false
     }
@@ -126,26 +138,23 @@ Page({
       wx.hideLoading()
       return 
     }
-
-    if (this.data.timer) {
-      clearInterval(this.data.timer)
-    }
     param.result = param.result.join(",")
     param.answers = param.answers.join(",")
-    app.formPost('Exam.ExamSubmit', param)
-      .then(res => {
-        if (res.code === 200) {
-          _this.setData({
-            modalShow: true,
-            result:param,
-          });
-        } else {
-          app.message(res.data, 'error')
+    param.errors = errIds.join(",")
+    param.isRedo = this.data.redo?1:0;
+    app.formPost('Exam.ExamSubmit', param).then(res => {
+      if (res.code === 200) {
+        _this.setData({
+          modalShow: true,
+          result:param,
+        });
+        if (this.data.timer) {
+          clearInterval(this.data.timer)
         }
-        wx.hideLoading()
-      }).catch(e => {
-        wx.hideLoading()
-        app.message(e, 'error')
-      })
+      } else {
+        app.message(res.msg, 'error')
+      }
+      wx.hideLoading()
+    })
   }
 })

+ 3 - 1
pages/exam/do/index.json

@@ -12,5 +12,7 @@
     "i-modal": "/component/iView/modal/index",
     "i-message": "/component/iView/message/index",
     "i-spin": "/component/iView/spin/index"
-  }
+  },
+  "navigationBarTitleText": "在线模拟考试"
+
 }

+ 0 - 66
pages/exam/edit/index.js

@@ -1,66 +0,0 @@
-// pages/exam/edit/index.js
-Page({
-
-  /**
-   * Page initial data
-   */
-  data: {
-
-  },
-
-  /**
-   * Lifecycle function--Called when page load
-   */
-  onLoad: function (options) {
-
-  },
-
-  /**
-   * Lifecycle function--Called when page is initially rendered
-   */
-  onReady: function () {
-
-  },
-
-  /**
-   * Lifecycle function--Called when page show
-   */
-  onShow: function () {
-
-  },
-
-  /**
-   * Lifecycle function--Called when page hide
-   */
-  onHide: function () {
-
-  },
-
-  /**
-   * Lifecycle function--Called when page unload
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * Page event handler function--Called when user drop down
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * Called when page reach bottom
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * Called when user click on the top right corner to share
-   */
-  onShareAppMessage: function () {
-
-  }
-})

+ 0 - 3
pages/exam/edit/index.json

@@ -1,3 +0,0 @@
-{
-  "usingComponents": {}
-}

+ 0 - 2
pages/exam/edit/index.wxml

@@ -1,2 +0,0 @@
-<!--pages/exam/edit/index.wxml-->
-<text>pages/exam/edit/index.wxml</text>

+ 0 - 1
pages/exam/edit/index.wxss

@@ -1 +0,0 @@
-/* pages/exam/edit/index.wxss */

+ 46 - 0
pages/exam/error/index.js

@@ -0,0 +1,46 @@
+let app = getApp()
+Page({
+  data: {
+    spinShow: false,
+    loadMoreLoad: false,
+    loadMoreTip: '暂无数据',
+    from:0,
+    size:9,
+    tableData: []
+  },
+  onLoad: function(options) {
+    this.setData({
+      spinShow: true
+    });
+    this.search(true)
+  },
+  onPullDownRefresh() {
+    this.setData({ spinShow: true });
+    if (!this.loading) {
+      this.setData({ from:0,tableData:[]});
+      this.search(true)
+    }
+  },
+  onReachBottom() {
+    console.log( "onReachBottom", this.loading, this.data.from)
+    if (!this.loading && this.data.from > -1) {
+      this.search(false)
+    }
+  },
+  search: function(override) {
+    let _this = this
+    let param = {from: override?0:this.data.from, size:this.data.size}
+    app.formPost('Exam.RedoPaperList', param ).then(res => {
+      _this.setData({spinShow: false});
+      wx.stopPullDownRefresh()
+      if (res.code === 200) {
+        const re = res.data
+        console.log( re )
+        _this.setData({
+          from: re.from,
+          tableData: override ? re.list : this.data.tableData.concat(re.list)
+        });
+      }
+    })
+  }
+})

+ 14 - 0
pages/exam/error/index.json

@@ -0,0 +1,14 @@
+{
+  "usingComponents": {
+    "i-tabs": "/component/iView/tabs/index",
+    "i-tab": "/component/iView/tab/index",
+    "i-cell-group": "/component/iView/cell-group/index",
+    "i-cell": "/component/iView/cell/index",
+    "i-load-more": "/component/iView/load-more/index",
+    "i-button": "/component/iView/button/index",
+    "i-message": "/component/iView/message/index",
+    "i-spin": "/component/iView/spin/index"
+  },
+  "enablePullDownRefresh": true,
+  "navigationBarTitleText": "错题重做"
+}

+ 21 - 0
pages/exam/error/index.wxml

@@ -0,0 +1,21 @@
+<view>
+  <view>
+    <i-cell-group>
+      <i-cell wx:for="{{tableData}}" 
+        data-item="item" 
+        wx:key="paperId" 
+        title="{{item.title}}" 
+        is-link 
+        url="/pages/exam/do/index?id={{item.paperId}}&redo=true" 
+        value="{{item.startTime}}" 
+        label="{{item.title}}  对错:{{item.correct}}/{{item.counter}}"
+      />
+    </i-cell-group>
+  </view>
+
+  <view wx:if="{{from==-1}}"  style="text-align:center;margin-top:40rpx">
+    <view class="padding">没有更多了</view>
+  </view>
+  <view class='cu-tabbar-height'></view>
+
+</view>

+ 1 - 0
pages/exam/error/index.wxss

@@ -0,0 +1 @@
+/* pages/exam/error/index.wxss */

+ 2 - 1
pages/exam/read/index.json

@@ -13,5 +13,6 @@
     "i-message": "/component/iView/message/index",
     "i-spin": "/component/iView/spin/index",
     "i-rate": "/component/iView/rate/index"
-  }
+  },
+  "navigationBarTitleText": "试卷回顾"
 }

+ 0 - 9
pages/exam/read/index.wxml

@@ -70,15 +70,6 @@
                wx:else>错误</text>
             </view>
 
-            <view class="exam-extend-item" style="padding-left:0px">
-              难度:
-              <i-rate value="{{item.star||1}}" i-class="exam-item-rate" />
-            </view>
-
-            <view class="exam-extend-item">
-              <rich-text nodes="解析: {{item.content||'无'}}" />
-            </view>
-
             <view class="exam-extend-item">
               <text wx:if="{{item.type==1}}"> 正确答案: {{preList[item.result]}}</text>
               <text wx:elif="{{item.type==2}}"> 正确答案: {{filter.getMultResult(item.result)}}</text>

+ 73 - 15
pages/index/index.js

@@ -8,35 +8,93 @@ Page({
     groups: [],
     pushPaper: [],
     timeLimitPaper: [],
+    userInfo:{},
     taskList: []
   },
-  onLoad: function() {
-    this.setData({
-      spinShow: true
-    });
-    app.checkLogin( this.indexLoad)
+  onLoad: function(){
+    app.checkLogin( userInfo =>{
+      this.setData({userInfo})
+      this.indexLoad()
+    })
   },
   onPullDownRefresh() {
-    this.setData({
-      spinShow: true
-    });
     if (!this.loading) {
-      this.indexLoad()
+      this.indexLoad( this.stopPullDownRefresh )
     }
   },
-  indexLoad: function() {
+  stopPullDownRefresh(){
+    wx.stopPullDownRefresh()
+  },
+  showPhone(){
+    wx.showToast({
+      title: "手机"+this.data.userInfo.phone,
+      type:'success',
+      duration:2*1000
+    })
+  },
+  indexLoad: function( cb ) {
     let _this = this
     app.formPost('Exam.index', {}).then(res => {
-      _this.setData({
-        spinShow: false
-      });
-      wx.stopPullDownRefresh()
       if (res.code === 200) {
-        console.log( res.data )
         _this.setData({
           groups: res.data.groups
         });
+       cb&&cb() 
+      }
+    })
+  },
+  getPhoneNumber (e) {
+    if( e.detail.errMsg =="getPhoneNumber:ok"){
+      let param = {
+        "iv": e.detail.iv,
+        "encryptedData":e.detail.encryptedData,
+      }
+      app.formPost( "User.bindphone", param).then( (res)=>{
+        if( res.code == 200){
+          this.setData( {userInfo: res.data})
+          app.setUserInfo( res.data )
+          this.indexLoad()
+        }
+      })
+    }else{
+      app.message("绑定失败", 'error')
+    }
+  },
+  gotoHistory: function(){
+    wx.navigateTo({
+      url: '/pages/record/index',
+    })
+  },
+  gotoExam:function( e ){
+    let groupId = e.currentTarget.dataset.id
+    wx.navigateTo({
+      url: `/pages/exam/do/index?id=${groupId}`
+    })
+  },
+  doWxPay( data ){
+    wx.requestPayment({
+      timeStamp: data.timeStamp,//记住,这边的timeStamp一定要是字符串类型的,不然会报错  
+      nonceStr: data.nonceStr,
+      package: data.package, 
+      signType: data.signType,
+      paySign: data.paySign,
+      success: function (event) {
+        console.log(event);
+        wx.showToast({title: '支付成功',icon: 'success', duration: 2000 });
       }
     })
+  },
+  startWxpay(e){
+    let groupId = +e.currentTarget.dataset.id
+    app.formPost('User.PayExam', {groupId}).then(res => {
+      if (res.code === 200) {
+        this.doWxPay( res.data )
+      }
+    })
+  },
+  gotoError: function(){
+    wx.navigateTo({
+      url: '/pages/exam/error/index',
+    })
   }
 })

+ 5 - 2
pages/index/index.json

@@ -6,7 +6,10 @@
     "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-spin": "/component/iView/spin/index",
+    "i-icon": "/component/iView/icon/index",
+    "i-badge": "/component/iView/badge/index"
   },
-  "enablePullDownRefresh": true
+  "enablePullDownRefresh": true,
+  "navigationBarTitleText": "鸿鹄在线练习系统"
 }

+ 48 - 14
pages/index/index.wxml

@@ -17,21 +17,55 @@
     </swiper>
   </view>
 
-  <i-panel title="我的试卷">
-    <i-cell-group>
-      <i-cell wx:for="{{groups}}" 
-        data-item="item" 
-        wx:key="groupId" 
-        
-        title="{{item.groupName}}" 
-        is-link 
-        url="/pages/exam/do/index?id={{item.groupId}}">
-      </i-cell>
-    </i-cell-group>
-  </i-panel>
+  <view class="cate-section">
+    <button class="cate-item" bindtap="gotoVoteList">
+      <i-icon type="collection" size="40" color="#e96900a0" />
+      <text>收藏题库</text>
+    </button>
+
+    <button class="cate-item" bindtap="gotoError">
+      <i-icon type="flag" size="40" color="#e96900a0" />
+      <text>错题重做</text>
+    </button>
+    
+    <button class="cate-item" bindtap="gotoHistory">
+      <i-icon type="createtask" size="40" color="#e96900a0" />
+      <text>考试记录</text>
+    </button>
 
-  <i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
+    <button wx:if="{{userInfo.phone}}" class="cate-item" bindtap="showPhone">
+      <i-icon type="mine" size="40" color="#e96900a0" />
+      <text>登入</text>
+    </button>
 
-  <i-message id="message" />
+    <button wx:else class="cate-item" bindgetphonenumber="getPhoneNumber" open-type="getPhoneNumber">
+      <image src="/assets/tabBar/my-select.png"></image>
+      <text>绑定手机</text>
+    </button>
+  </view>
 
+  <i-panel title="题库">
+    <view class="cate-section" >
+      <view wx:for="{{groups}}"  wx:key="groupId" class="cate-item cate-item-3">
+        <button class="cate-item"
+          wx:if="{{item.isBuy}}"
+          bindtap="gotoExam"
+          data-id="{{item.groupId}}" 
+        >
+            <i-icon  type="browse" size="40" color="#7595f1a0" />
+            <text>{{item.title}}</text>
+        </button>
+      
+        <button class="cate-item"
+          wx:else
+          bindtap="startWxpay"
+          data-id="{{item.groupId}}" >
+          <i-icon type="lock" size="40" color="#e96900a0" />
+          <text>{{item.title}}</text>
+        </button>
+      </view>
+    </view>
+
+    <!-- /pages/exam/do/index?id={{item.groupId}} -->
+  </i-panel>
 </view>

+ 57 - 0
pages/index/index.wxss

@@ -32,4 +32,61 @@
 
 p{
   display: none;
+}
+
+
+.cate-section {
+  display: -webkit-box;
+  display: -webkit-flex;
+  display: -ms-flexbox;
+  display: flex;
+  -webkit-justify-content: space-around;
+      -ms-flex-pack: distribute;
+          justify-content: space-around;
+  -webkit-box-align: center;
+  -webkit-align-items: center;
+      -ms-flex-align: center;
+          align-items: center;
+  -webkit-flex-wrap: wrap;
+      -ms-flex-wrap: wrap;
+          flex-wrap: wrap;
+  padding: 30rpx 22rpx;
+  background: #fff;
+  /* 原图标颜色太深,不想改图了,所以加了透明度 */
+}
+.cate-section .cate-item {
+    display: -webkit-box;
+    display: -webkit-flex;
+    display: -ms-flexbox;
+    display: flex;
+    -webkit-box-orient: vertical;
+    -webkit-box-direction: normal;
+    -webkit-flex-direction: column;
+        -ms-flex-direction: column;
+            flex-direction: column;
+    -webkit-box-align: center;
+    -webkit-align-items: center;
+        -ms-flex-align: center;
+            align-items: center;
+    font-size: 26rpx;
+    background: #fff;
+    color: #5d626b;
+}
+.cate-section image {
+  width: 60rpx;
+  height: 60rpx;
+  margin-bottom: 14rpx;
+  border-radius: 10%;
+  opacity: .7;
+  -webkit-box-shadow: 4rpx 4rpx 20rpx rgba(250, 67, 106, 0.3);
+          box-shadow: 4rpx 4rpx 20rpx rgba(250, 67, 106, 0.3);
+}
+
+button::after {
+  border: none
+}
+.cate-item-3{
+  width:33.33%;
+  height:160rpx;
+  margin-top:40rpx
 }

+ 3 - 0
pages/my/index/index.js

@@ -25,6 +25,9 @@ Page({
     })
   },
   getPhoneNumber (e) {
+    this.bindPhone(e)
+  },
+  bindPhone(e){
     if( e.detail.errMsg =="getPhoneNumber:ok"){
       let param = {
         "iv": e.detail.iv,

+ 1 - 1
pages/my/index/index.wxml

@@ -1,6 +1,6 @@
-<wxs module="filter" src="../../../wxs/exam-fun.wxs"></wxs>
 
 
+<wxs module="filter" src="../../../wxs/exam-fun.wxs"></wxs>
 <view class='userinfo'>
   <view class='userinfo-avatar'>
     <open-data type="userAvatarUrl"></open-data>

+ 2 - 1
pages/record/index.json

@@ -9,5 +9,6 @@
     "i-message": "/component/iView/message/index",
     "i-spin": "/component/iView/spin/index"
   },
-  "enablePullDownRefresh": true
+  "enablePullDownRefresh": true,
+  "navigationBarTitleText": "最新考试记录"
 }

+ 1 - 1
pages/record/index.wxml

@@ -8,7 +8,7 @@
         is-link 
         url="/pages/exam/read/index?id={{item.paperId}}" 
         value="{{item.startTime}}" 
-        label="{{item.title}}  对错:{{item.correct}}/{{item.counter}}"
+        label="对错:{{item.correct}}/{{item.counter}}"
       />
     </i-cell-group>
   </view>