y595705120 3 years ago
parent
commit
7ec6a82727

+ 6 - 3
app.js

@@ -1,7 +1,8 @@
 const { $Message} = require('/component/iView/base/index');
 const md5 = require('./utils/md5.js');
 const secret = "117c0743819088468e590246464cc75e"
-const {baseUrl} = require("./utils/util.js")
+const {baseUrl} = require("./utils/util.js");
+const util = require('./utils/util.js');
 
 App({
   globalData: {
@@ -96,6 +97,9 @@ App({
             reject('网络出错')
             return false;
           }
+          if(res.data.code != 200 && res.data.code != 401){
+            util.showMsg(res.data.msg )
+          }
           resolve(res.data);
           return true;
         },
@@ -154,7 +158,6 @@ App({
       return
     }
     let openid = wx.getStorageSync('@openid');
-    // let openid="oG3Fi5ait37qL-3edzAkzysH5apU"
     if( !openid ) {
       cb && cb({});
       return
@@ -184,6 +187,6 @@ App({
   },
   setUserInfo: function (userInfo) {
     this.globalData.userInfo = userInfo;
-    wx.setStorageSync('@openid', userInfo.openid)
+    wx.setStorageSync('@user', userInfo )
   }
 })

+ 3 - 1
app.json

@@ -1,6 +1,8 @@
 {
   "pages": [
     "pages/index/index",
+    "pages/exam/do/index",
+    
     "pages/study/exam/index",
     "pages/user/identify/index",    
     "pages/study/course/index",
@@ -14,7 +16,7 @@
     "pages/my/message/info/index",
     "pages/my/message/list/index",
     "pages/exam/read/index",
-    "pages/exam/do/index",
+    
     "pages/exam/error/index",
     "pages/exam/record/index",
     "pages/train/index/index"

+ 3 - 2
pages/exam/collection/index.js

@@ -1,4 +1,5 @@
 let app = getApp()
+let mulSelect = 3
 Page({
   data: {
     preList:["A","B","C", "D", "E", "F"],
@@ -33,8 +34,8 @@ Page({
       return;
     }
     let param = {answerId: item.answerId}
-    // 判断是否正确
-    if( item.type == 2){
+    // 多选
+    if( item.type == mulSelect ){
       item.correct = item.select.join("") == item.result;
     }else{
       item.correct = item.select == item.result;

+ 3 - 3
pages/exam/collection/index.wxml

@@ -8,7 +8,7 @@
 	<i-panel   i-class="exam-panel-title">   
 		<i-cell-group i-class="exam-cell" >
 			<!-- 单选题 -->
-			<i-cell wx:if="{{item.type==1}}">
+			<i-cell wx:if="{{item.type==2}}">
 				<view>
 					<rich-text nodes="[单]{{item.title}}" />
 					<radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">
@@ -24,7 +24,7 @@
 				</view>
 			</i-cell>
 			<!-- 多选题 -->
-			<i-cell wx:if="{{item.type==2}}">
+			<i-cell wx:if="{{item.type==3}}">
 				<view>
 					<text> [多]{{item.title}} </text>
 					<checkbox-group class="checkbox-answer" style="margin-top:30rpx" bindchange="checkboxChange"  >
@@ -40,7 +40,7 @@
 				</view>
 			</i-cell>
 			<!-- 判断 -->
-			<i-cell wx:if="{{item.type==3}}">
+			<i-cell wx:if="{{item.type==1}}">
 				<view>
 					<rich-text nodes="[判]{{item.title}}" />
 					<radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">

+ 16 - 16
pages/exam/do/index.js

@@ -3,12 +3,14 @@ import {
 } from '../../../utils/util.js'
 
 let app = getApp()
+let mulSelect = 3
 Page({
   data: {
     list: [],
     redo: false,
     preList:["A","B","C", "D","E","F"],
     info:{},
+    id:0,
     timer: null,
     doTime: 0,
     remainTime: 0,
@@ -24,16 +26,18 @@ Page({
     this.setData({redo})
     let method =  redo?'Exam.examreStart':'Exam.examStart';
     let _this = this
+    let oindex = [2,3,1]
     app.formPost(method, {groupId}).then(res => {
       if (res.code ==200) {
         let {startTime, info, list} = res.data;
-        let duration = list.length * 60;
+        let duration = info.duration
         list = list.map(item=>{
           delete( item["select"])
           return item
         }).sort( (i,j) =>{
-          return i.type > j.type?1:-1;
+          return oindex.indexOf(i.type) >  oindex.indexOf(j.type)?1:-1;
         })
+        console.log( list.map( item=>{ return item.type}) )
         wx.setNavigationBarTitle({
           title: info.title+'-模拟考试'
         })
@@ -70,15 +74,10 @@ Page({
     clearInterval(this.data.timer)
   },
   returnRecord() {
-    if( this.data.redo){
-      wx.reLaunch({
-        url: '/pages/exam/error/index',
-      });
-    }else{
-      wx.reLaunch({
-        url: '/pages/exam/record/index',
-      });
-    }
+    let id = this.data.id;
+    wx.navigateTo({
+      url: `/pages/exam/read/index?id=${id}`
+    })
   },
   timeOut() {
     clearInterval(this.data.timer)
@@ -133,11 +132,11 @@ Page({
         }
         if( !item.select ) isFinish = false
     }
-    if( !isFinish && !force){
-      app.message("还未完成", 'error')
-      wx.hideLoading()
-      return 
-    }
+    // if( !isFinish && !force){
+    //   app.message("还未完成", 'error')
+    //   wx.hideLoading()
+    //   return 
+    // }
     param.result = param.result.join(",")
     param.answers = param.answers.join(",")
     param.errors = errIds.join(",")
@@ -145,6 +144,7 @@ Page({
     app.formPost('Exam.ExamSubmit', param).then(res => {
       if (res.code === 200) {
         _this.setData({
+          id: res.data.id,
           modalShow: true,
           result:param,
         });

+ 4 - 3
pages/exam/do/index.wxml

@@ -19,7 +19,7 @@
         
           <i-cell-group i-class="exam-cell">
           <!-- 单选题 -->
-          <i-cell wx:if="{{item.type==1}}"> 
+          <i-cell wx:if="{{item.type==2}}"> 
             <view>
               <rich-text nodes="{{index+1}}.[单]{{item.title}}" />
               <radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}" >
@@ -34,7 +34,7 @@
             </view>
           </i-cell>
           <!-- 多选题 -->
-          <i-cell wx:if="{{item.type==2}}"> 
+          <i-cell wx:if="{{item.type==3}}"> 
             <view >
               <text> {{index+1}}. [多]{{item.title}} </text>
               <checkbox-group class="checkbox-answer" style="margin-top:30rpx" bindchange="checkboxChange" data-index="{{index}}">
@@ -49,7 +49,7 @@
             </view>
           </i-cell>
           <!-- 判断 -->
-          <i-cell wx:if="{{item.type==3}}"> 
+          <i-cell wx:if="{{item.type==1}}"> 
             <view>
               <rich-text nodes="{{index+1}}.[判]{{item.title}}" />
               <radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}" >
@@ -64,6 +64,7 @@
             </view>
           </i-cell>
         </i-cell-group>
+
       </i-panel>
 
       <view>

+ 2 - 0
pages/exam/index/index.js

@@ -28,7 +28,9 @@ Page({
   },
   onShow: function(){
     app.getUserInfo( userInfo =>{
+    
       this.setData({userInfo})
+      console.log( "userInfo", userInfo)
       // 已经实名认证
       if( userInfo.identify ){
         this.indexLoad()

+ 0 - 5
pages/exam/index/index.wxml

@@ -34,11 +34,6 @@
         <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>

+ 3 - 0
pages/exam/read/index.js

@@ -34,6 +34,9 @@ Page({
   },
   onUnload() {
     clearInterval(this.data.timer)
+    wx.reLaunch({
+      url: "/pages/exam/index/index"
+    })
   },
   returnRecord() {
     wx.reLaunch({

+ 5 - 5
pages/exam/read/index.wxml

@@ -15,7 +15,7 @@
     <i-panel  wx:for="{{answers}}"  wx:for-item="item"   wx:key="answerId"  i-class="exam-panel-title">   
       <i-cell-group i-class="exam-cell">
           <!-- 单选题 -->
-          <i-cell wx:if="{{item.type==1}}"> 
+          <i-cell wx:if="{{item.type==2}}"> 
             <view>
               <rich-text nodes="{{index+1}}.[单]{{item.title}}" />
               <radio-group class="radio-answer" >
@@ -31,7 +31,7 @@
             </view>
           </i-cell>
           <!-- 多选题 -->
-          <i-cell wx:if="{{item.type==2}}"> 
+          <i-cell wx:if="{{item.type==3}}"> 
             <view >
               <text> {{index+1}}. [多]{{item.title}} </text>
               <checkbox-group class="checkbox-answer" style="margin-top:30rpx" >
@@ -46,7 +46,7 @@
             </view>
           </i-cell>
           <!-- 判断 -->
-          <i-cell wx:if="{{item.type==3}}"> 
+          <i-cell wx:if="{{item.type==1}}"> 
             <view>
               <rich-text nodes="{{index+1}}.[判]{{item.title}}" />
               <radio-group class="radio-answer"  >
@@ -81,8 +81,8 @@
             </view>
 
             <view class="exam-extend-item">
-              <text wx:if="{{item.type==1}}"> 正确答案: {{preList[item.result-1]}}</text>
-              <text wx:elif="{{item.type==2}}"> 正确答案: {{filter.getMultResult(item.result)}}</text>
+              <text wx:if="{{item.type==2}}"> 正确答案: {{preList[item.result-1]}}</text>
+              <text wx:elif="{{item.type==3}}"> 正确答案: {{filter.getMultResult(item.result)}}</text>
               <text wx:else> 正确答案: {{item.result==1?'正确':'错误'}}</text>
             </view>
           </view>

+ 2 - 6
pages/my/index/index.js

@@ -1,12 +1,11 @@
 const util = require("../../../utils/util")
-
 const app = getApp()
 Page({
   data: {
     spinShow: false,
     userInfo:{},
   },
-  onShow: function () {
+  onShow: function(){
     app.getUserInfo( userInfo =>{
       this.setData({userInfo})
     })
@@ -56,13 +55,10 @@ Page({
   logOut() {
     wx.setStorageSync('userId', '')
     wx.setStorageSync('token', '')
-    wx.setStorageSync('@openid', '')
+    wx.setStorageSync('@user', '')
     let userInfo = {}
     this.setData({userInfo})
     app.setUserInfo( userInfo )
-    wx.navigateTo({
-      url: '/pages/index/index',
-    })
   },
   gotoIdentify(){
     wx.navigateTo({

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

@@ -4,9 +4,9 @@
 
 
 <view class='headImg'>
-  <button  wx:if="{{!userInfo.token}}"  type="primary"  bindtap="wxLogin" class="tc">
-    快捷登入
-  </button>
+  <button  wx:if="{{!userInfo.token}}"  type="primary"  bindtap="gotoIdentify" class="tc">
+    绑定账号
+  </button> 
 
   <view class="headImg-avatar" wx:else>
     <image src="{{userInfo.headImg}}" mode="aspectFill"></image>

+ 4 - 1
pages/study/course/index.js

@@ -22,8 +22,11 @@ Page({
       this.setData({system})
     })
     // 
+    
+  },
+  onShow: function(){
     app.getUserInfo( userInfo =>{
-      this.setData({userInfo})
+      this.setData({userInfo, from:0})
       this.loadData( courseId )
     })
   },

+ 2 - 2
pages/study/index/index.js

@@ -30,7 +30,7 @@ Page({
   },
   onShow: function () {
     app.getUserInfo( userInfo =>{
-      this.setData({userInfo})
+      this.setData({userInfo, from:0})
       this.indexLoad()
     })
   },
@@ -46,7 +46,7 @@ Page({
     let param ={ 
       from: this.data.from,
       size: this.data.size,
-      type:'施工现场专业人员',
+      type:'继续教育',
     }
     app.formPost('Study.GetWxCourseList', param).then(res => {
       if (res.code === 200) {

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

@@ -60,7 +60,7 @@
             【{{item.nd}}】 {{item.name}}
           </text>
           <view class="info">
-            <text class="price">
+            <text class="price" wx:if="{{item.canBuy}}">
               价格:{{"¥"+item.fee/100}}
             </text>
             <text class="xs">

+ 1 - 1
pages/study/market/index.js

@@ -36,7 +36,7 @@ Page({
   },
   onShow: function () {
     app.getUserInfo( userInfo =>{
-      this.setData({userInfo})
+      this.setData({userInfo, from:0})
       this.indexLoad()
     })
   },

+ 6 - 1
pages/study/market/index.wxml

@@ -33,12 +33,17 @@
             【{{item.nd}}】 {{item.name}}
           </text>
           <view class="info">
-            <text class="price">
+            <text class="price" wx:if="{{item.canBuy}}">
               价格:{{"¥"+item.fee/100}}
             </text>
+
             <text class="xs">
               学时:{{item.totalXs/10}}
             </text>
+
+            <button class="contact" open-type="contact" session-from="weapp" wx:if="{{!item.canBuy}}">
+              联系我们
+            </button>
           </view>
         </view>
       </block>

+ 8 - 0
pages/study/market/index.wxss

@@ -95,6 +95,14 @@
   float: left;
 }
 
+.guess-section .info .contact {
+  font-size: 26rpx;
+  float: right;
+  padding:0;
+  background: #fff;
+  margin-top:20rpx;
+}
+
 .guess-section .info .xs {
   font-size: 26rpx;
   margin-left: 20rpx;

+ 1 - 1
pages/train/index/index.js

@@ -31,7 +31,7 @@ Page({
   },
   onShow: function () {
     app.getUserInfo( userInfo =>{
-      this.setData({userInfo})
+      this.setData({userInfo, from:0})
       this.indexLoad()
     })
   },

+ 6 - 2
pages/train/index/index.wxml

@@ -60,12 +60,16 @@
             【{{item.nd}}】 {{item.name}}
           </text>
           <view class="info">
-            <text class="price">
+            <text class="price" wx:if="{{item.canBuy}}">
               价格:{{"¥"+item.fee/100}}
             </text>
+            <text class="price" wx:else>
+              获得:{{item.getXs/10}} 时
+            </text>
             <text class="xs">
-              学时:{{item.totalXs/10}}
+              学时:{{item.totalXs/10}}
             </text>
+
           </view>
         </view>
       </block>

+ 8 - 0
pages/train/index/index.wxss

@@ -95,6 +95,14 @@
   float: left;
 }
 
+.guess-section .info .contact {
+  font-size: 26rpx;
+  float: right;
+  padding:0;
+  background: #fff;
+  margin-top:20rpx;
+}
+
 .guess-section .info .xs {
   font-size: 26rpx;
   margin-left: 20rpx;

+ 3 - 5
pages/user/identify/index.js

@@ -8,10 +8,10 @@ Page({
     type:'card',
     phone:'',
     studyUser :{
-      cardId:"352202198709031536",
+      cardId:"",
       cardImg:"",
       nickname:"吕君喜",
-      phone:'18850724428',
+      phone:'',
       openid:'',
       identify:0,
       session_key:'',
@@ -20,9 +20,7 @@ Page({
   },
   onShow: function () {
     app.getUserInfo( studyUser =>{
-      if( !studyUser.token ){
-        studyUser = wx.getStorageSync('@identify')||{}
-      }
+      console.log("userInfo", studyUser)
       this.setData({studyUser})
     })
   },