Your Name 3 місяців тому
батько
коміт
ed36dd50fe
4 змінених файлів з 95 додано та 9 видалено
  1. 7 0
      pages/subject/subject.wxml
  2. 30 5
      pages/video/video.js
  3. 13 2
      pages/video/video.wxml
  4. 45 2
      pages/video/video.wxss

+ 7 - 0
pages/subject/subject.wxml

@@ -68,6 +68,13 @@
         </radio-group>
         <checkbox-group  class="option" wx:elif="{{item.qtype == 2}}" bindchange='answer' data-id='{{item.id}}'>
             <view wx:for="{{item.options}}" wx:for-item="opt" wx:key="*this" wx:for-index="i">
+                <!-- <view wx:for="{{item.post_answer}}" wx:for-item="ans" wx:key="*this">
+                  {{ans==opt[0]}}
+                  <checkbox checked="{{ans==opt[0]}}" color="#358BFF" value="{{opt[0]}}">{{opt}}</checkbox>
+                </view> -->
+                <!-- <view wx:if="{{item.post_answer.indexOf(opt[0])!=-1}}" wx:key="*this">
+                  <checkbox checked="true" color="#358BFF" value="{{opt[0]}}">{{opt}}</checkbox>
+                </view> -->
                 <checkbox color="#358BFF" value="{{opt[0]}}">{{opt}}</checkbox>
             </view>
         </checkbox-group>

+ 30 - 5
pages/video/video.js

@@ -10,14 +10,16 @@ Page({
     title:'',
     url:'',
     time:0,
-    duration:0
+    duration:0,
+    recommend:[],
+    currentTime:0,
+    marTime:0
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    console.log(options)
     let time = options.time.split(':')
     this.setData({
       title: options.title,
@@ -25,11 +27,31 @@ Page({
       time: time[0]*60+time[1],
       id:options.id
     })
+    let _this = this;
+    wx.request({
+      url: host + '/api/wx/video/info',
+      method: 'get',
+      header: {
+        openid: app.globalData.openid
+      },
+      data: {
+        video_id: this.data.id,
+        time: this.data.duration
+      },
+      success: function (res) {
+        _this.setData({
+          recommend: res.data.data.recommends
+        })
+      }
+    })
   },
   end: function (event){
     wx.request({
       url: host + '/api/wx/savevtime',
       method: 'post',
+      header: {
+        openid: app.globalData.openid
+      },
       data: {
         video_id: this.data.id,
         time: this.data.duration
@@ -40,11 +62,14 @@ Page({
     })
   },
   timeupdate: function (event){
-    if (!this.data.duration){
+    let currentTime = parseInt(event.detail.currentTime)
+    if (!this.data.duration||true){
         this.setData({
-          duration: event.detail.duration
+          duration: currentTime
         })
-        
+    }
+    if( currentTime/10>=1 && currentTime % 10 == 0){
+      this.end();
     }
   },
   /**

+ 13 - 2
pages/video/video.wxml

@@ -1,2 +1,13 @@
-<video src='{{url}}' title="{{title}}" initial-time='{{time}}' bindtimeupdate='timeupdate'  bindended='end'></video>
-<view>{{title}}</view>
+<video id="video" src='{{url}}' title="{{title}}" initial-time='{{time}}' bindtimeupdate='timeupdate'  bindended='end' controls="false"></video>
+<view class="main_title">{{title}}</view>
+<!-- 相关视频推荐 -->
+<navigator  class="test"  wx:for="{{recommend}}" wx:key="*this" url="../video/video?title={{item.title}}&&url={{item.url}}&&time={{item.finished_time}}&id={{item.id}}">
+    <view class="title">{{item.title}}</view>
+    <text>{{item.credit}}学时/{{item.total_time}}分钟</text>
+    <view class="score" wx:if='{{item.mark_status == 1}}'>
+        <image src="../../images/gou.png" mode="widthFix"></image>  已完成
+    </view> 
+    <view class="score" wx:else>
+       <navigator>立即观看</navigator>
+    </view>
+</navigator>

+ 45 - 2
pages/video/video.wxss

@@ -2,9 +2,52 @@
 video{
   width: 100%;
 }
+.main_title{
+  border-bottom: 1px solid #F9F9F9;
+  height: 75rpx;
+}
 view{
   font-size: 32rpx;
   font-weight: 600;
-  margin-top: 12px;
-  padding: 0 12px;
+  margin-top: 8px;
+  padding: 0 8px;
+}
+.test{
+  padding: 5px;
+  border-bottom: 1px solid #F9F9F9;
+}
+.test text{
+  color: #999;
+  font-size: 24rpx;
+}
+.test navigator{
+  float: right;
+  width:64px;
+  height:21px;
+  background:rgba(53,139,255,1);
+  border-radius:16px;
+  line-height: 21px;
+  text-align: center;
+  color: #fff;
+  font-size: 24rpx;
+  
+  position: relative;
+  top: -2px;
+}
+.score{
+  float: right;
+  color: #28C06B;
+  font-size: 24rpx;
+  margin-top:-10px;
+}
+.score image{
+  width: 32rpx;
+  margin-left: 20rpx;
+  position: relative;
+  top: 2px;
+}
+.score text{
+  color: #358BFF;
+  font-size: 28rpx;
+  margin-right: 10px;
 }