ssfg 5 năm trước cách đây
mục cha
commit
982dfae384

+ 3 - 1
app.js

@@ -1,5 +1,7 @@
 App({
-  globalData: {},
+  globalData: {
+    showAnimation: true
+  },
   onLaunch(options) {
     // Do something initial when launch.
   },

+ 2 - 0
app.json

@@ -2,6 +2,8 @@
   "pages": [
     "pages/index/index",
     "pages/zbDetails/zbDetails",
+   
+   
     "pages/myInteractions/myInteractions",
     "pages/myMission/myMission",
     "pages/exhibitionList/exhibitionList",

+ 8 - 0
pages/Identity/Identity.js

@@ -50,6 +50,10 @@ Page({
     })
   },
   formSubmit: function (e) {
+    wx.showLoading({
+      mask: true,
+      title: '加载中',
+    })
     let _this = this;
     if (_this.data.isRz == 0) {
       const params = e.detail.value
@@ -57,6 +61,7 @@ Page({
       if (!this.WxValidate.checkForm(params)) {
         const error = this.WxValidate.errorList[0]
         this.showModal(error)
+        wx.hideLoading()
         return false
       }
       wx.checkSession({
@@ -78,12 +83,14 @@ Page({
                     sessionKey = res.data.sessionKey;
                     wx.setStorageSync('sessionKey', res.data.sessionKey);
                     _this.tj(sessionKey, params);
+                    wx.hideLoading()
                   }
                 })
               }
             })
           } else {
             _this.tj(sessionKey, params);
+            wx.hideLoading()
           }
         },
         fail() {
@@ -102,6 +109,7 @@ Page({
                   wx.setStorageSync('sessionKey', res.data.sessionKey);
                   var sessionKey = res.data.sessionKey;
                   _this.tj(sessionKey, params);
+                  wx.hideLoading()
                 }
               })
             }

+ 39 - 24
pages/dbDetails/dbDetails.js

@@ -35,7 +35,7 @@ Page({
           title: e.data.course.courseInfo,
           message: e.data.course.courseName,
           playTimes: e.data.course.playTimes
-          
+
         })
       }
     })
@@ -53,7 +53,7 @@ Page({
         console.log(e, "22222222222222")
         _this.setData({
           studyLog: e.data.studyLog,
-          startPlayTime:e.data.studyLog.studyTime
+          startPlayTime: e.data.studyLog.studyTime
         })
       }
     })
@@ -87,31 +87,46 @@ Page({
   },
   onUnload() {
     var _this = this;
-    console.log(_this.data.studyLog)
-    wx.request({
-      method: "post",
-      url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
-      data: {
-        studyLog: _this.data.studyLog
-      },
-      success: (e) => {
-        console.log(e, "我修改进度成功了")
-      }
-    })
+    if (_this.data.studyTime < _this.data.studyLog.studyTime) {
+      console.log(_this.data.studyLog)
+      wx.request({
+        method: "post",
+        url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
+        data: {
+          studyLog: _this.data.studyLog
+        },
+        success: (e) => {
+          console.log(e, "我修改进度成功了")
+        }
+      })
+    }
   },
   onHide() {
     var _this = this;
-    console.log(_this.data.studyLog)
-    wx.request({
-      method: "post",
-      url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
-      data: {
-        studyLog: _this.data.studyLog
-      },
-      success: (e) => {
-        console.log(e, "我修改进度成功了")
-      }
-    })
+    if (_this.data.studyTime < _this.data.studyLog.studyTime) {
+      console.log(_this.data.studyLog)
+      wx.request({
+        method: "post",
+        url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
+        data: {
+          studyLog: _this.data.studyLog
+        },
+        success: (e) => {
+          console.log(e, "我修改进度成功了")
+        }
+      })
+    }
+    // console.log(_this.data.studyLog)
+    // wx.request({
+    //   method: "post",
+    //   url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
+    //   data: {
+    //     studyLog: _this.data.studyLog
+    //   },
+    //   success: (e) => {
+    //     console.log(e, "我修改进度成功了")
+    //   }
+    // })
   },
   onLoad: function (options) {
     var _this = this;

+ 2 - 1
pages/demandCourses/demandCourses.js

@@ -20,7 +20,8 @@ Page({
         sessionKey: sessionKey
       },
       success: function (res) {
-        if (res.code == 0) {
+        console.log(res,"lb")
+        if (res.data.code == 0) {
           console.log(res)
           _this.setData({
             lbArr: res.data.list

+ 11 - 6
pages/index/index.js

@@ -1,4 +1,4 @@
-// const app = getApp()
+const app1 = getApp();
 const app = require('../../utils/util.js');
 Page({
   data: {
@@ -178,11 +178,16 @@ Page({
   onReady: function () {},
   onLoad() {
     let _this = this;
-    setTimeout(function () {
-      _this.setData({
-        kjShow: false
-      })
-    }, 4000)
+    if (app1.globalData.showAnimation == true) {
+      setTimeout(function () {
+        _this.setData({
+          kjShow: false,
+        })
+      }, 4000)
+    }
+  },
+  onUnload: function () {
+    app1.globalData.showAnimation = false;
   },
   onShow: function () {
     var _this = this;

+ 18 - 17
pages/myClass/myClass.js

@@ -142,12 +142,19 @@ Page({
   },
   // 跳转直播点播页面
   goStudy(e) {
-    // console.log(e.currentTarget.dataset.item.id)
     let id = e.currentTarget.dataset.item.id
     if (e.currentTarget.dataset.item.isLive == 1) {
-      wx.navigateTo({
-        url: '../zbDetails/zbDetails?id=' + id
-      })
+      if (e.currentTarget.dataset.item.isActive == 1) {
+        wx.navigateTo({
+          url: '../zbDetails/zbDetails?id=' + id
+        })
+      } else {
+        wx.showModal({
+          showCancel: false,
+          content: "直播还未开始哦",
+          success(res) {}
+        })
+      }
     } else {
       wx.navigateTo({
         url: '../dbDetails/dbDetails?id=' + id
@@ -164,7 +171,7 @@ Page({
         sessionKey: sessionKey
       },
       success: function (res) {
-        console.log(res, "我是返回的班级列表")
+        console.log(res, "我是返回是否班级")
         if (res.data.code == 0) {
           if (res.data.data !== null || res.data.data !== "") {
             _this.setData({
@@ -172,15 +179,12 @@ Page({
             })
           } else {
             wx.showModal({
-              content: "您还未加入班级,快去认证吧!",
+              content: "您当前还没有开放的班级!",
+              showCancel: false,
               success(res) {
                 if (res.confirm) {
-                  wx.navigateTo({
-                    url: '../Identity/Identity'
-                  })
-                } else {
                   wx.switchTab({
-                    url: '../myClass/myClass'
+                    url: '../index/index'
                   })
                 }
               }
@@ -189,15 +193,12 @@ Page({
           }
         } else {
           wx.showModal({
-            content: "您还未加入班级,快去认证吧!",
+            content: "您当前还没有开放的班级!",
+            showCancel: false,
             success(res) {
               if (res.confirm) {
-                wx.navigateTo({
-                  url: '../Identity/Identity'
-                })
-              } else {
                 wx.switchTab({
-                  url: '../myClass/myClass'
+                  url: '../index/index'
                 })
               }
             }

+ 21 - 20
pages/myMission/myMission.js

@@ -10,7 +10,7 @@ Page({
     kcArr: [],
     ewmurl: '',
     sfmArr: [],
-    className:'',
+    className: '',
     istask1: false,
     istask2: false,
     istask3: false,
@@ -74,12 +74,19 @@ Page({
   },
   // 跳转直播点播页面
   goStudy(e) {
-    // console.log(e.currentTarget.dataset.item.id)
     let id = e.currentTarget.dataset.item.id
     if (e.currentTarget.dataset.item.isLive == 1) {
-      wx.navigateTo({
-        url: '../zbDetails/zbDetails?id=' + id
-      })
+      if (e.currentTarget.dataset.item.isActive == 1) {
+        wx.navigateTo({
+          url: '../zbDetails/zbDetails?id=' + id
+        })
+      } else {
+        wx.showModal({
+          showCancel: false,
+          content: "直播还未开始哦",
+          success(res) {}
+        })
+      }
     } else {
       wx.navigateTo({
         url: '../dbDetails/dbDetails?id=' + id
@@ -95,7 +102,7 @@ Page({
         sessionKey: sessionKey
       },
       success: function (res) {
-        if (res.data.code == 0) {
+        if (res.data.code == 0 && res.data.list.length !== 0) {
           _this.setData({
             kcArr: res.data.list,
             istask3: res.data.allDone
@@ -165,7 +172,7 @@ Page({
       }
     })
   },
-    // 查询我是否有班&&班级名字
+  // 查询我是否有班&&班级名字
   isClass(sessionKey) {
     var _this = this;
     wx.request({
@@ -175,7 +182,7 @@ Page({
         sessionKey: sessionKey
       },
       success: function (res) {
-        console.log(res, "我是返回的班级列表")
+        console.log(res, "我是返回是否班级")
         if (res.data.code == 0) {
           if (res.data.data !== null || res.data.data !== "") {
             _this.setData({
@@ -183,15 +190,12 @@ Page({
             })
           } else {
             wx.showModal({
-              content: "您还未加入班级,快去认证吧!",
+              content: "您当前还没有开放的班级!",
+              showCancel: false,
               success(res) {
                 if (res.confirm) {
-                  wx.navigateTo({
-                    url: '../Identity/Identity'
-                  })
-                } else {
                   wx.switchTab({
-                    url: '../myClass/myClass'
+                    url: '../index/index'
                   })
                 }
               }
@@ -200,15 +204,12 @@ Page({
           }
         } else {
           wx.showModal({
-            content: "您还未加入班级,快去认证吧!",
+            content: "您当前还没有开放的班级!",
+            showCancel: false,
             success(res) {
               if (res.confirm) {
-                wx.navigateTo({
-                  url: '../Identity/Identity'
-                })
-              } else {
                 wx.switchTab({
-                  url: '../myClass/myClass'
+                  url: '../index/index'
                 })
               }
             }

+ 1 - 1
pages/onlineClass/onlineClass.js

@@ -36,7 +36,7 @@ Page({
         sessionKey: sessionKey
       },
       success: function (res) {
-        if (res.code == 0) {
+        if (res.data.code == 0) {
           _this.setData({
             zbArr: res.data.list
           })

+ 29 - 2
pages/zbDetails/zbDetails.js

@@ -11,7 +11,30 @@ Page({
     socketOpen: false,
     chatContent: [],
     inputValue: '',
-    bottom: ""
+    bottom: "",
+    pushUrl: '',
+    videoContext: '',
+    isPush: true
+  },
+  startBf: function () {
+    //pullUrl: `rtmp://hnb.spaceships.cn/education/live56?auth_key=1593654178-0-0-30f7fa190656ddb994151d23cf30d3b7`
+    this.setData({
+      pushUrl: `rtmp://live.spaceships.cn/education/live56?auth_key=1593654164-0-0-cd12fbad7bd0cf3d94f56645875a180a`,
+      isPush:false
+    })
+    this.data.videoContext.start();
+  },
+  stopBf: function () {
+    // console.log("start 111");
+    //pullUrl: `rtmp://hnb.spaceships.cn/education/live56?auth_key=1593654178-0-0-30f7fa190656ddb994151d23cf30d3b7`
+    this.setData({
+      pushUrl: ``,
+      isPush:true
+    })
+    this.data.videoContext.stop()
+  },
+  statechange: function (e) {
+    console.log(e)
   },
   // videoErrorCallback: function (e) {
   //   console.log('视频错误信息:')
@@ -35,6 +58,9 @@ Page({
     let _this = this;
     let input_val = _this.data.inputValue;
     _this.sendSocketMessage(input_val)
+    _this.setData({
+      inputValue: ""
+    })
   },
   getZbArr(sessionKey) {
     var _this = this;
@@ -177,7 +203,8 @@ Page({
   onLoad: function (options) {
     var _this = this;
     _this.setData({
-      id: options.id
+      id: options.id,
+      videoContext: wx.createLivePusherContext("video-livePusher")
     })
     wx.checkSession({
       success: () => {

+ 7 - 9
pages/zbDetails/zbDetails.wxml

@@ -2,17 +2,10 @@
 	<live-player src="{{url}}" mode="live" autoplay bindstatechange="statechange" binderror="error" style="width:100%" />
 	<view class="text_box">
 		<view class="title">{{title}}</view>
-		<!-- <view class="bfnum">{{playTimes}}次播放</view> -->
-		<!-- <view class="zj">主讲:授课教师</view> -->
 		<view class="zw">{{message}}
 		</view>
 	</view>
-	<!-- <view class="chatbox">
-		<view wx:for="{{chatContent}}" wx:for-index="idx" wx:for-item="item" wx:key="idx" class="chat_text">
-			{{item}}
-		</view>
-	</view> -->
-	<view class="chatbox">
+	<view class="chatbox" wx:if="{{isPush}}">
 		<scroll-view scroll-y="true" style="height: 400rpx;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{bottom}}" scroll-top="{{scrollTop}}">
 			<view style="padding:30rpx">
 				<view wx:for="{{chatContent}}" wx:for-index="idx" wx:for-item="item" wx:key="idx" class="chat_text">
@@ -25,7 +18,12 @@
 	<view class="puthands_box">
 		<image src='/images/puthands.png' mode='aspectFill' class="handimg"></image>
 		<view style="font-size:30rpx;color:#eb3f33;float:left;line-height:60rpx;margin-right:20rpx" bindtap="hands">举手</view>
-		<input class="weui-input" bindinput="bindKeyInput" placeholder="请输入你的问题" style="height:60rpx" />
+		<input class="weui-input" bindinput="bindKeyInput" placeholder="请输入你的问题" style="height:60rpx" value="{{inputValue}}"/>
 		<view class="send" bindtap="submit">发送</view>
 	</view>
+	<view class="push_box" wx:if="{{!isPush}}">
+		<button bindtap="startBf">开始播放</button>
+		<button bindtap="stopBf">停止播放</button>
+		<live-pusher id="video-livePusher" mirror="false" mode="RTC" autopush url="{{pushUrl}}" bindstatechange="statechange" style="width: 750rpx; height: 225px;"></live-pusher>
+	</view>
 </view>

+ 2 - 2
utils/util.js

@@ -1,11 +1,11 @@
 const globalData = {
   publicUrl: 'https://sqdx.windd.cn',
-  publicUrl2: 'https://sqdx.windd.cn',
+  // publicUrl2: 'https://sqdx.windd.cn',
   publicUrl3: 'https://sqdx.windd.cn',
   publicSocketUrl: 'wss://sqdx.windd.cn',
   // publicSocketUrl: 'ws://10.16.10.139:8090',
   // publicUrl: 'http://10.16.10.139:8090', //luyu
-  // publicUrl2: 'http://10.16.4.19:8090', //huyubo
+  publicUrl2: 'http://10.16.4.19:8090', //huyubo
   // publicUrl3: 'http://10.16.4.22:8090', //zxq
 };
 module.exports = {