y595705120 3 years ago
parent
commit
22002a0750

+ 14 - 25
app.js

@@ -49,20 +49,25 @@ App({
     })
   },
   checkLogin: function (cb) {
+    let userInfo = this.globalData.userInfo
+    if( userInfo && userInfo.uid ){
+      cb && cb( userInfo)
+      return;
+    }
     let _this = this
     let openid = wx.getStorageSync('@openid');
     if( !openid ) {
-      cb&&cb({})
       return
     }
     let param = {"openid": openid};
     _this.formPost('Auth.wxLogin', param).then( res =>{
       if (res.code == 200) {
         _this.setUserInfo(res.data);
+        cb && cb(res.data);
       }
-      cb && cb(res.data);
     })
   },
+  // 
   message: function (content, type="info") {
     $Message({
       content: content,
@@ -74,7 +79,6 @@ App({
     let userInfo = this.globalData.userInfo||{}
     let user_id = userInfo.uid||0;
     let token = userInfo.token||'';
-    console.log( userInfo );
     let timestamp = Date.now()
     action = action.toLowerCase()
     let signstr = `weixin_${token}_${action}_${timestamp}_${secret}`
@@ -100,6 +104,10 @@ App({
           if(res.data.code != 200 && res.data.code != 401){
             util.showMsg(res.data.msg )
           }
+          if(  res.data.code == 401  &&  action.indexOf( "auth.") == -1  ){
+            _this.gotoLogin()
+            return
+          }
           resolve(res.data);
           return true;
         },
@@ -151,28 +159,6 @@ App({
       })
     })
   },
-  getUserInfo: function ( cb ) {
-    let userInfo = this.globalData.userInfo
-    if( userInfo && userInfo.token ){
-      cb && cb( userInfo);
-      return
-    }
-    let openid = wx.getStorageSync('@openid');
-    if( !openid ) {
-      cb && cb({});
-      return
-    }
-    let param = {"openid": openid};
-    this.formPost('Auth.wxLogin', param).then( res =>{
-      if (res.code == 200) {
-        this.setUserInfo(res.data);
-      }
-      cb && cb(res.data||{});
-    })
-  },
-  getStudyInfo: function () {
-    return this.globalData.studyInfo;
-  },
   getSystemInfo(  cb ){
     wx.getSystemInfo({
       success: function(res) {
@@ -187,6 +173,9 @@ App({
   },
   setUserInfo: function (userInfo) {
     this.globalData.userInfo = userInfo;
+    if( userInfo.openid ){
+      wx.setStorageSync('@openid', userInfo.openid )
+    }
     wx.setStorageSync('@user', userInfo )
   }
 })

+ 1 - 1
app.json

@@ -61,7 +61,7 @@
   },
   "window": {
     "navigationBarBackgroundColor": "#ffffff",
-    "navigationBarTitleText": "八大员在线练习",
+    "navigationBarTitleText": "鸿锵在线教育",
     "navigationBarTextStyle": "black",
     "backgroundTextStyle": "dark"
   },

+ 6 - 4
pages/exam/do/index.js

@@ -16,6 +16,7 @@ Page({
     remainTime: 0,
     remainTimeStr: '',
     modalShow: false,
+    isFinish: false,
     result: {},
     startTime: "",
     timeOutShow: false
@@ -74,10 +75,11 @@ Page({
     clearInterval(this.data.timer)
   },
   returnRecord() {
-    let id = this.data.id;
-    wx.navigateTo({
-      url: `/pages/exam/read/index?id=${id}`
-    })
+    // let id = this.data.id;
+    this.setData({isFinish: true, modalShow:false})
+    // wx.navigateTo({
+    //   url: `/pages/exam/read/index?id=${id}`
+    // })
   },
   timeOut() {
     clearInterval(this.data.timer)

+ 53 - 5
pages/exam/do/index.wxml

@@ -1,6 +1,8 @@
+<wxs module="enumItem" src="../../../wxs/enumItem.wxs"></wxs>
 <view class="exam-page">
   <view class="view-wrap">
-    <view class="exam-count-down">{{remainTimeStr}}</view>
+    <view class="exam-count-down" wx:if="{{isFinish}}">已经交卷</view>
+    <view class="exam-count-down" wx:else>{{remainTimeStr}}</view>
   </view>
   <view class="view-wrap-hidden">
   </view>
@@ -17,20 +19,36 @@
           wx:key="answerId" 
           i-class="exam-panel-title"> 
         
-          <i-cell-group i-class="exam-cell">
+        <i-cell-group i-class="exam-cell">
           <!-- 单选题 -->
           <i-cell wx:if="{{item.type==2}}"> 
-            <view>
+            <view class="single">
               <rich-text nodes="{{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}}" >
+                    <radio color="#2d8cf0" value="{{index+1}}" checked="{{item.select==index+1}}"  disabled="{{item.select>0?true:false}}" >
                       {{preList[index]}}. {{item['answer'+(index+1)]}}
                     </radio>
                   </view>
                 </label>
               </radio-group>
+
+              <view class="exam-clear mt20" wx:if="{{isFinish || item.select>0}}" >
+                <view class="exam-extend-item" >
+                  答题结果:
+                  <text class="question-answer-right question-answer-result" 
+                    wx:if="{{item.select==item.result}}">正确
+                  </text>
+                  <text class="question-answer-error question-answer-result" 
+                    wx:else>错误</text>
+                </view>
+
+                <view class="exam-extend-item">
+                  正确答案:
+                  <text wx:if="{{item.type==2}}"> {{preList[item.result-1]}}</text>
+                </view>
+              </view>
             </view>
           </i-cell>
           <!-- 多选题 -->
@@ -47,6 +65,22 @@
                 </label>
               </checkbox-group>
             </view>
+
+            <view class="exam-clear mt20" wx:if="{{isFinish}}" >
+                <view class="exam-extend-item" >
+                  答题结果:
+                  <text class="question-answer-right question-answer-result" 
+                    wx:if="{{item.select==item.result}}">正确
+                  </text>
+                  <text class="question-answer-error question-answer-result" 
+                    wx:else>错误</text>
+                </view>
+                <view class="exam-extend-item">
+                  正确答案:
+                  <text> {{filter.getMultResult(item.result)}}</text>
+                </view>
+              </view>
+
           </i-cell>
           <!-- 判断 -->
           <i-cell wx:if="{{item.type==1}}"> 
@@ -55,13 +89,27 @@
               <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}}" >
+                    <radio color="#2d8cf0" value="{{index+1}}" checked="{{item.select==index+1}}" disabled="{{item.select>0?true:false}}" >
                       {{preList[index]}}. {{item['answer'+(index+1)]}}
                     </radio>
                   </view>
                 </label>
               </radio-group>
             </view>
+            <view class="exam-clear mt20" wx:if="{{isFinish || item.select>0}}" >
+                <view class="exam-extend-item" >
+                  答题结果:
+                  <text class="question-answer-right question-answer-result" 
+                    wx:if="{{item.select==item.result}}">正确
+                  </text>
+                  <text class="question-answer-error question-answer-result" 
+                    wx:else>错误</text>
+                </view>
+                <view class="exam-extend-item">
+                  正确答案:
+                  <text> {{item.result==1?'正确':'错误'}}</text>
+                </view>
+              </view>
           </i-cell>
         </i-cell-group>
 

+ 21 - 0
pages/exam/do/index.wxss

@@ -74,3 +74,24 @@
   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;
+}

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

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

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

@@ -11,5 +11,5 @@
     "i-badge": "/component/iView/badge/index"
   },
   "enablePullDownRefresh": true,
-  "navigationBarTitleText": "鸿鹄在线练习系统"
+  "navigationBarTitleText": "鸿锵在线教育-在线练习"
 }

+ 7 - 1
pages/exam/index/index.wxml

@@ -48,10 +48,16 @@
             <text>{{item.title}}</text>
           </button>
 
-          <button class="cate-item" wx:else bindtap="startWxpay" data-id="{{item.groupId}}">
+          <!-- <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> -->
+
+          <button class="cate-item" wx:else open-type="contact" session-from="weapp">
             <i-icon type="lock" size="40" color="#e96900a0" />
             <text>{{item.title}}</text>
           </button>
+
         </view>
       </view>
     </i-panel>

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

@@ -37,7 +37,7 @@
               <checkbox-group class="checkbox-answer" style="margin-top:30rpx" >
                 <label class="checkbox" wx:for="{{preList}}" wx:for-item="answer" wx:key="index"  wx:if="{{item['answer'+(index+1)]}}" >
                   <view class="checkbox-answer">
-                    <checkbox color="#2d8cf0" value="{{index+1}}" checked="{{filter.isSelect(index,item.select)}}" disabled>
+                    <checkbox color="#2d8cf0" value="{{index+1}}" checked="{{filter.isSelect(index+1,item.select)}}" disabled>
                       {{answer}}. {{item['answer'+(index+1)]}}
                     </checkbox>
                   </view>

+ 1 - 1
pages/index/index.json

@@ -11,5 +11,5 @@
     "i-badge": "/component/iView/badge/index"
   },
   "enablePullDownRefresh": true,
-  "navigationBarTitleText": "鸿鹄在线练习系统"
+  "navigationBarTitleText": "鸿锵在线教育"
 }

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

@@ -6,7 +6,7 @@ Page({
     userInfo:{},
   },
   onShow: function(){
-    app.getUserInfo( userInfo =>{
+    app.checkLogin( userInfo =>{
       this.setData({userInfo})
     })
   },
@@ -53,8 +53,7 @@ Page({
     })
   },
   logOut() {
-    wx.setStorageSync('userId', '')
-    wx.setStorageSync('token', '')
+    wx.setStorageSync('@openid', '')
     wx.setStorageSync('@user', '')
     let userInfo = {}
     this.setData({userInfo})

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

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

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

@@ -17,7 +17,7 @@ Page({
   },
   onLoad: function(options) {
     let courseId = +options.courseId||36
-    app.getUserInfo( userInfo =>{
+    app.checkLogin( userInfo =>{
       this.setData({userInfo})
       this.loadData( courseId )
     })

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

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

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

@@ -12,5 +12,5 @@
     "i-badge": "/component/iView/badge/index"
   },
   "enablePullDownRefresh": true,
-  "navigationBarTitleText": "继续教育"
+  "navigationBarTitleText": "鸿锵在线教育-继续教育"
 }

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

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

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

@@ -11,7 +11,7 @@ Page({
     list: []
   },
   onLoad: function( options ){
-    app.getUserInfo( userInfo =>{
+    app.checkLogin( userInfo =>{
       this.setData({userInfo})
       this.loadData( )
     })

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

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

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

@@ -12,5 +12,5 @@
     "i-badge": "/component/iView/badge/index"
   },
   "enablePullDownRefresh": true,
-  "navigationBarTitleText": "岗前培训"
+  "navigationBarTitleText": "鸿锵在线教育-岗前培训"
 }

+ 2 - 2
pages/user/identify/index.js

@@ -10,7 +10,7 @@ Page({
     studyUser :{
       cardId:"",
       cardImg:"",
-      nickname:"吕君喜",
+      nickname:"",
       phone:'',
       openid:'',
       identify:0,
@@ -19,7 +19,7 @@ Page({
     }
   },
   onShow: function () {
-    app.getUserInfo( studyUser =>{
+    app.checkLogin( studyUser =>{
       console.log("userInfo", studyUser)
       this.setData({studyUser})
     })

+ 3 - 3
pages/user/identify/index.wxml

@@ -34,15 +34,15 @@
   </view>
 
   <view class="p20 ">
-    <view class="info-title">用户信息</view>
+    <view class="info-title">绑定用户信息</view>
     <i-panel class="m20 p20" wx:if="{{info.identify}}">
-      <i-input value="{{ studyUser.nickname }}" error title="*身份姓名" class="mt20" disable />
+      <i-input value="{{ studyUser.nickname }}" error title="*真实姓名" class="mt20" disable />
       <i-input value="{{ studyUser.cardId }}" error title="*身份号码" class="mt20" disable />
       <i-input value="{{ studyUser.phone }}" error title="*联系方式" class="mt20" disable />
     </i-panel>
 
     <form wx:else class="p20" bindsubmit="doIdentify">
-      <i-input  value="{{ studyUser.nickname }}" name="nickname"  title="*身份姓名" class="mt20" maxlength="100" />
+      <i-input  value="{{ studyUser.nickname }}" name="nickname"  title="*真实姓名" class="mt20" maxlength="100" />
       <i-input value="{{ studyUser.cardId }}"  name="cardId" title="*身份号码" class="mt20" maxlength="18"  />
       <i-input value="{{ studyUser.phone }}"  name="phone" title="*联系方式" class="mt20" type="number" maxlength="11"/>
 

+ 1 - 1
sitemap.json

@@ -1,5 +1,5 @@
 {
-  "desc": "八大员在线练习",
+  "desc": "鸿锵在线教育",
   "rules": [{
   "action": "allow",
   "page": "*"

+ 0 - 1
wxs/exam-fun.wxs

@@ -46,7 +46,6 @@ var filter = {
     return res.join(",")
   },
   isSelect: function( index, select ){
-    console.log( "select", select )
     if( index == select)  return true;
     select = ""+select
     return select.indexOf( index )>-1;