y595705120 4 rokov pred
rodič
commit
25a1a41ef8

+ 31 - 0
app.js

@@ -10,6 +10,37 @@ App({
     userInfo: {},
   },
   onLaunch: function() {
+    this.autoUpgrade()
+  },
+  autoUpgrade: function(){
+    if (wx.canIUse('getUpdateManager')) {
+      const updateManager = wx.getUpdateManager()
+      updateManager.onCheckForUpdate(function (res) {
+        // 请求完新版本信息的回调
+        if (res.hasUpdate) {
+          console.log('res.hasUpdate====')
+          updateManager.onUpdateReady(function () {
+            wx.showModal({
+              title: '更新提示',
+              content: '新版本已经准备好,是否重启应用?',
+              success: function (res) {
+                console.log('success====', res)
+                if (res.confirm) {
+                  updateManager.applyUpdate()
+                }
+              }
+            })
+          })
+          updateManager.onUpdateFailed(function () {
+            // 新的版本下载失败
+            wx.showModal({
+              title: '已经有新版本了哟~',
+              content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
+            })
+          })
+        }
+      })
+    }
   },
   doLogin: function(cb){
     let _this = this

+ 5 - 4
app.json

@@ -1,20 +1,21 @@
 {
   "pages": [
+    
     "pages/index/index",
     "pages/my/index/index",
     "pages/exam/index/index",
-    
     "pages/record/index",
     "pages/exam/read/index",
     "pages/exam/do/index",
     "pages/user/bind/index",
-    
     "pages/exam/error/index",
-    
     "pages/my/message/info/index",
     "pages/my/message/list/index",
     "pages/my/log/index",
-    "pages/user/register/index"
+    "pages/user/register/index",
+    "pages/exam/buy/index",
+    "pages/course/play/index"
+    
   ],
   "window": {
     "navigationBarBackgroundColor": "#ffffff",

+ 52 - 0
pages/course/play/index.js

@@ -0,0 +1,52 @@
+function getRandomColor() {
+  const rgb = []
+  for (let i = 0; i < 3; ++i) {
+    let color = Math.floor(Math.random() * 256).toString(16)
+    color = color.length == 1 ? '0' + color : color
+    rgb.push(color)
+  }
+  return '#' + rgb.join('')
+}
+
+Page({
+  onReady(res) {
+    this.videoContext = wx.createVideoContext('myVideo')
+  },
+  inputValue: '',
+  data: {
+    src: '',
+    danmuList: [
+      {
+        text: '第 1s 出现的弹幕',
+        color: '#ff0000',
+        time: 1
+      },
+      {
+        text: '第 3s 出现的弹幕',
+        color: '#ff00ff',
+        time: 3
+      }]
+  },
+  bindInputBlur(e) {
+    this.inputValue = e.detail.value
+  },
+  bindButtonTap() {
+    const that = this
+    wx.chooseVideo({
+      sourceType: ['album', 'camera'],
+      maxDuration: 60,
+      camera: ['front', 'back'],
+      success(res) {
+        that.setData({
+          src: res.tempFilePath
+        })
+      }
+    })
+  },
+  bindSendDanmu() {
+    this.videoContext.sendDanmu({
+      text: this.inputValue,
+      color: getRandomColor()
+    })
+  }
+})

+ 3 - 0
pages/course/play/index.json

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

+ 15 - 0
pages/course/play/index.wxml

@@ -0,0 +1,15 @@
+<view class="section tc">
+  <video
+    id="myVideo"
+    src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"
+    danmu-list="{{danmuList}}"
+    enable-danmu
+    danmu-btn
+    controls
+  ></video>
+  <view class="btn-area">
+    <button bindtap="bindButtonTap">获取视频</button>
+    <input bindblur="bindInputBlur" />
+    <button bindtap="bindSendDanmu">发送弹幕</button>
+  </view>
+</view>

+ 1 - 0
pages/course/play/index.wxss

@@ -0,0 +1 @@
+/* pages/course/play/index.wxss */

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

@@ -0,0 +1,66 @@
+// pages/exam/buy/index.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

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

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

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

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

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

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

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

@@ -7,7 +7,7 @@ Page({
   data: {
     list: [],
     redo: false,
-    preList:["A","B","C", "D"],
+    preList:["A","B","C", "D","E","F"],
     info:{},
     timer: null,
     doTime: 0,
@@ -86,12 +86,14 @@ Page({
     let index = e.currentTarget.dataset.index;
     let list = this.data.list
     list[index].select = +e.detail.value
+    console.log("select", index, list[index].select )
     this.setData( {list} );
   },
   checkboxChange( e ){
     let index = e.currentTarget.dataset.index;
     let list = this.data.list
-    list[index].select = e.detail.value.sort()
+    list[index].select = +e.detail.value.sort().join("")
+    console.log("select", index, list[index].select)
     this.setData( {list} );
   },
   formSubmit: function(e) {
@@ -119,14 +121,8 @@ Page({
     for( let i=0; i< this.data.list.length; i++){
         let item = this.data.list[i];
         param.answers.push( item.answerId );
-        if( !item.select ){
-          param.result.push(0);
-        }else if( item.type ==1 || item.type == 3  ){
-          param.result.push( parseInt(item.select) || 0)
-        }else{
-          param.result.push( parseInt(item.select.join("")) ||0 )
-        }
-        if( param.result[i] == item.result){
+        param.result.push( item.select || 0);
+        if( item.select == item.result){
           param.correct += 1
         }else{
           errIds.push( item.answerId)

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

@@ -23,7 +23,7 @@
             <view>
               <rich-text nodes="{{index+1}}.[单]{{item.title}}" />
               <radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}" >
-                <label class="radio" wx:for="{{4}}" wx:for-item="answer" wx:key="anserIndex" >
+                <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}}" >
                       {{preList[index]}}. {{item['answer'+(index+1)]}}
@@ -38,10 +38,10 @@
             <view >
               <text> {{index+1}}. [多]{{item.title}} </text>
               <checkbox-group class="checkbox-answer" style="margin-top:30rpx" bindchange="checkboxChange" data-index="{{index}}">
-                <label class="checkbox" wx:for="{{4}}" wx:for-item="answer" >
+                <label class="checkbox" wx:for="{{preList}}" wx:for-item="answer" wx:if="{{item['answer'+(index+1)]}}">
                   <view class="checkbox-answer">
-                    <checkbox color="#2d8cf0" value="{{index+1}}" checked="{{answer.select}}" >
-                      {{preList[index]}}. {{item['answer'+(index+1)]}}
+                    <checkbox color="#2d8cf0" value="{{index+1}}">
+                      {{answer}}. {{item['answer'+(index+1)]}}
                     </checkbox>
                   </view>
                 </label>

+ 16 - 1
pages/exam/do/index.wxss

@@ -75,4 +75,19 @@
   margin-bottom: 20px;
 }
 
-
+checkbox {
+  margin:10rpx;
+  height: auto;
+  /* font-size:16rpx; */
+}
+/*checkbox 选项框大小  */
+checkbox .wx-checkbox-input {
+  width: 40rpx;
+  height: 40rpx;
+  flex: none;
+}
+.radio .wx-radio-input{
+  width: 40rpx;
+  height: 40rpx;
+  flex: none;
+}

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

@@ -1,7 +1,7 @@
 let app = getApp()
 Page({
   data: {
-    preList:["A","B","C", "D"],
+    preList:["A","B","C", "D", "E", "F"],
     from:0,
     size:10,
     item: {},
@@ -32,7 +32,6 @@ Page({
       app.message("还未作答", 'error')
       return;
     }
-    console.log("checkAnswer", this.data.item)
     let param = {answerId: item.answerId}
     // 判断是否正确
     if( item.type == 2){

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

@@ -14,5 +14,6 @@
     "i-spin": "/component/iView/spin/index",
     "i-rate": "/component/iView/rate/index"
   },
-  "enablePullDownRefresh": false
+  "enablePullDownRefresh": false,
+  "navigationBarTitleText": "收藏题库"
 }

+ 13 - 11
pages/exam/index/index.wxml

@@ -12,10 +12,11 @@
 				<view>
 					<rich-text nodes="[单]{{item.title}}" />
 					<radio-group class="radio-answer" bindchange="radioChange" data-index="{{index}}">
-						<label class="radio" wx:for="{{4}}" wx:for-item="answer" wx:key="anserIndex">
+						<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}}">
-									{{preList[index]}}. {{item['answer'+(index+1)]}}
+									{{answer}}. {{item['answer'+(index+1)]}}
 								</radio>
 							</view>
 						</label>
@@ -26,11 +27,12 @@
 			<i-cell wx:if="{{item.type==2}}">
 				<view>
 					<text> [多]{{item.title}} </text>
-					<checkbox-group class="checkbox-answer" style="margin-top:30rpx" bindchange="checkboxChange" >
-						<label class="checkbox" wx:for="{{4}}" wx:key="index" wx:for-item="answer">
+					<checkbox-group class="checkbox-answer" style="margin-top:30rpx" 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)}}">
-									{{preList[index]}}. {{item['answer'+(index+1)]}}
+									{{answer}}. {{item['answer'+(index+1)]}}
 								</checkbox>
 							</view>
 						</label>
@@ -63,18 +65,18 @@
 				<text class="question-answer-error question-answer-result" wx:else>错误</text>
 			</view>
 
-			<view class="exam-extend-item" style="padding-left:0px">
+			<view class="exam-extend-item" style="padding-left:0px" wx:if="{{item.star}}">
 				难度:
-				<i-rate value="{{item.star||1}}" i-class="exam-item-rate" />
+				<i-rate value="{{item.star}}" i-class="exam-item-rate" />
 			</view>
 
-			<view class="exam-extend-item">
-				<rich-text nodes="解析: {{item.content||'无'}}" />
+			<view class="exam-extend-item" wx:if="{{item.content}}">
+				<rich-text nodes="解析: {{item.content}}" />
 			</view>
 
 			<view class="exam-extend-item">
-				<text wx:if="{{item.type==1}}"> 1正确答案: {{preList[item.result]}}</text>
-				<text wx:elif="{{item.type==2}}"> 2正确答案: {{filter.getMultResult(item.result)}}</text>
+				<text wx:if="{{item.type==1}}"> 正确答案: {{preList[item.result-1]}}</text>
+				<text wx:elif="{{item.type==2}}"> 正确答案: {{filter.getMultResult(item.result)}}</text>
 				<text wx:else> 正确答案: {{item.result==1?'正确':'错误'}}</text>
 			</view>
 		</view>

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

@@ -9,7 +9,7 @@ Page({
     info: {},
     paper: {},
     answer: {},
-    preList:["A","B","C", "D","E"],
+    preList:["A","B","C", "D","E","F"],
     timer: null,
     doTime: 0,
     remainTime: 0,

+ 18 - 8
pages/exam/read/index.wxml

@@ -19,10 +19,11 @@
             <view>
               <rich-text nodes="{{index+1}}.[单]{{item.title}}" />
               <radio-group class="radio-answer" >
-                <label class="radio" wx:for="{{4}}" wx:for-item="answer" wx:key="anserIndex" >
+                <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}}" checked="{{item.select==index}}" disabled>
-                      {{preList[index]}}. {{item['answer'+(index+1)]}}
+                    <radio color="#2d8cf0" value="{{index+1}}" checked="{{item.select==index+1}}" disabled>
+                      {{answer}}. {{item['answer'+(index+1)]}}
                     </radio>
                   </view>
                 </label>
@@ -34,10 +35,10 @@
             <view >
               <text> {{index+1}}. [多]{{item.title}} </text>
               <checkbox-group class="checkbox-answer" style="margin-top:30rpx" >
-                <label class="checkbox" wx:for="{{4}}" wx:for-item="answer" wx:key="index" >
+                <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}}" checked="{{filter.isSelect(index,item.select)}}" disabled>
-                      {{preList[index]}}. {{item['answer'+(index+1)]}}
+                    <checkbox color="#2d8cf0" value="{{index+1}}" checked="{{filter.isSelect(index,item.select)}}" disabled>
+                      {{answer}}. {{item['answer'+(index+1)]}}
                     </checkbox>
                   </view>
                 </label>
@@ -51,7 +52,7 @@
               <radio-group class="radio-answer"  >
                 <label class="radio" wx:for="{{2}}" wx:for-item="answer" wx:key="answerIndex" >
                   <view class="radio-answer">
-                    <radio color="#2d8cf0" value="{{index}}" checked="{{item.select==index}}" disabled>
+                    <radio color="#2d8cf0" value="{{index+1}}" checked="{{item.select==index+1}}" disabled>
                       {{preList[index]}}. {{item['answer'+(index+1)]}}
                     </radio>
                   </view>
@@ -70,8 +71,17 @@
                wx:else>错误</text>
             </view>
 
+            <view class="exam-extend-item" style="padding-left:0px" wx:if="{{item.star}}">
+              难度:
+              <i-rate value="{{item.star}}" i-class="exam-item-rate" />
+            </view>
+
+            <view class="exam-extend-item" wx:if="{{item.content}}">
+              <rich-text nodes="解析: {{item.content}}" />
+            </view>
+
             <view class="exam-extend-item">
-              <text wx:if="{{item.type==1}}"> 正确答案: {{preList[item.result]}}</text>
+              <text wx:if="{{item.type==1}}"> 正确答案: {{preList[item.result-1]}}</text>
               <text wx:elif="{{item.type==2}}"> 正确答案: {{filter.getMultResult(item.result)}}</text>
               <text wx:else> 正确答案: {{item.result==1?'正确':'错误'}}</text>
             </view>

+ 40 - 5
pages/index/index.js

@@ -5,6 +5,10 @@ const app = getApp()
 Page({
   data: {
     spinShow: false,
+    buyModel:false,
+    code_url:'',
+    info:{},
+    system: "",
     groups: [],
     pushPaper: [],
     timeLimitPaper: [],
@@ -16,6 +20,15 @@ Page({
       this.setData({userInfo})
       this.indexLoad()
     })
+    let that = this
+    wx.getSystemInfo({
+      success: function(res) {
+        that.setData({system: res.system})
+      }
+    })
+  },
+  modalConfirm(){
+    this.setData({buyModel:false})
   },
   onPullDownRefresh() {
     if (!this.loading) {
@@ -71,26 +84,48 @@ Page({
       url: `/pages/exam/do/index?id=${groupId}`
     })
   },
+  gotoCollectin(){
+    wx.navigateTo({
+      url: '/pages/exam/index/index',
+    })
+  },
   doWxPay( data ){
+    let that = this
     wx.requestPayment({
-      timeStamp: data.timeStamp,//记住,这边的timeStamp一定要是字符串类型的,不然会报错  
+      timeStamp: data.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 });
+        wx.showModal({
+          title: '支付成功',
+          showCancel: false,
+          content: '本次共支付费用¥'+(data.fee/100)+'元'+ `\n\n试卷更新可能延迟,请耐心等待`,
+          success(res) {
+            that.indexLoad()
+          }
+        })
       }
     })
   },
   startWxpay(e){
     let groupId = +e.currentTarget.dataset.id
-    app.formPost('User.PayExam', {groupId}).then(res => {
+    let system = this.data.system
+    app.formPost('User.PayExam', {groupId, system}).then(res => {
       if (res.code === 200) {
-        this.doWxPay( res.data )
+        if( res.data.payType=="free" ){
+          this.indexLoad()
+        }else if (res.data.payType=="qrcode"){
+          this.setData({info: res.data, buyModel:true})
+        }else{
+          this.doWxPay( res.data )
+        }
       }
     })
+  },
+  onShareAppMessage: function(){
+
   },
   gotoError: function(){
     wx.navigateTo({

+ 11 - 1
pages/index/index.wxml

@@ -18,7 +18,7 @@
   </view>
 
   <view class="cate-section">
-    <button class="cate-item" bindtap="gotoVoteList">
+    <button class="cate-item" bindtap="gotoCollectin">
       <i-icon type="collection" size="40" color="#e96900a0" />
       <text>收藏题库</text>
     </button>
@@ -68,4 +68,14 @@
 
     <!-- /pages/exam/do/index?id={{item.groupId}} -->
   </i-panel>
+
+
+  <modal title="苹果手机购买课程" 
+    confirm-text="确认" 
+    hidden="{{!buyModel}}" 
+    no-cancel="true"
+    bindconfirm="modalConfirm" >
+  <image src="{{info.code_url}}" mode="widthFix" style="width:100%"></image>
+  <text style="color:red"> 本课程费用 {{info.fee/100}}元, 请扫码付款</text>
+</modal>
 </view>