Browse Source

直播权限和分享

xuqiaoying 3 years ago
parent
commit
3a88d02f83

+ 2 - 2
src/axios.js

@@ -4,10 +4,10 @@ import { Message } from 'element-ui'
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
 // export const BASE_URL = 'http://42.192.164.187:19005'    //test
 // export const BASE_URL = 'https://test.xyyxt.net'   //预发布
-// export const BASE_URL = 'http://192.168.1.7:5055'    //dev
+export const BASE_URL = 'http://192.168.1.7:5055'    //dev
 // export const BASE_URL = 'http://120.79.166.78:19012'    //测试-外网
 // export const BASE_URL = 'http://42.192.164.187:19005'    //test
-export const BASE_URL = 'http://192.168.1.222:5055'    //测试
+// export const BASE_URL = 'http://192.168.1.222:5055'    //测试
 export const tenantId = '867735392558919680'
 
 

+ 1 - 0
src/pages/course-detail/index copy.vue

@@ -5141,6 +5141,7 @@ export default {
             sectionId: option.sectionId || option.menuId,
             chapterId: option.chapterId || 0,
             moduleId: option.moduleId || 0,
+            sectionType: 2,
           },
         });
         // this.loadPlayerScriptzb(this.loadPlayerzb);

+ 1 - 0
src/pages/course-detail/index.vue

@@ -5612,6 +5612,7 @@ export default {
             sectionId: option.sectionId || option.menuId,
             chapterId: option.chapterId || 0,
             moduleId: option.moduleId || 0,
+            sectionType: 2,
           },
         });
         // this.loadPlayerScriptzb(this.loadPlayerzb);

+ 1 - 0
src/pages/live-detail/index.vue

@@ -5275,6 +5275,7 @@ export default {
             sectionId: option.sectionId || option.menuId,
             chapterId: option.chapterId || 0,
             moduleId: option.moduleId || 0,
+            sectionType: 2,
           },
         });
         // this.loadPlayerScriptzb(this.loadPlayerzb);

+ 207 - 24
src/pages/living-room/index.vue

@@ -4,15 +4,24 @@
 
     <div class="container">
       <div class="clearfix top-line">
-        <el-button
-          v-if="backNum"
-          class="float-right"
-          type="primary"
-          size="small"
-          round
-          @click="$router.go(backNum)"
-          >返回</el-button
-        >
+        <div class="title">{{ goodsName }}</div>
+        <div class="bottoms">
+          <el-button
+            size="small"
+            round
+            @click="toShare()"
+            >分享</el-button>
+          <el-button
+            v-if="backNum"
+            class="float-right"
+            type="primary"
+            size="small"
+            round
+            @click="returnBack()"
+            >返回</el-button
+          >
+        </div>
+        
       </div>
     </div>
     <!-- pc端 -->
@@ -111,7 +120,6 @@
 
     <el-dialog
       width="400px"
-      class="sign-success"
       :visible.sync="signSuccess"
       :close-on-click-modal="false"
       :close-on-press-escape="false"
@@ -122,6 +130,43 @@
         <div class="title">签到成功!</div>
       </div>
     </el-dialog>
+
+    <!-- 您还没有开通直播课程,无法观看 -->
+    <el-dialog
+      title="提示"
+      :visible.sync="showAuth"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      :show-close="false"
+      width="400px"
+      >
+      <div class="popCentent">
+        <div class="tips">您还没有开通直播课程,无法观看</div>
+        <div class="btns" @click="toAuth()">立即开通</div>
+      </div>
+    </el-dialog>
+
+    <!-- 分享弹窗 -->
+    <el-dialog
+      title="提示"
+      :visible.sync="shareShow"
+      width="600px"
+      >
+      <div v-loading="shareLoading" class="popShare">
+        <el-form ref="form" :model="formShare" label-width="130px">
+          <el-form-item label="观看链接(pc端):">
+            <div>
+              <span>{{ formShare.links }}</span>
+              <span class="ccopy" @click="copy()">复制</span>
+            </div>
+          </el-form-item>
+          <el-form-item label="观看二维码:">
+            <img class="ercode_pic" :src="formShare.ercode" alt="" />
+            <span class="ccopy" @click="download()">下载</span>
+          </el-form-item>
+        </el-form>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -179,7 +224,17 @@ export default {
       backNum: -1, //返回页面数
       buyCourse: 1, // 是否购买课程:1是 0否
       identification: '', // 标识
-
+      goodsName: '', // 名称
+      checkStatus: 0, // 0没有权限,1有权限
+      goodsStatus: 0, // 0未上架,1上架
+      showAuth: false, 
+      shareShow: false,
+      sectionType: '',
+      formShare: {
+        links: '',
+        ercode: '',
+      },
+      shareLoading: false
     };
   },
   computed: {
@@ -197,7 +252,7 @@ export default {
     });
   },
   created() {
-    console.log('是否登录了', this.$tools.isLogin())
+    console.log('是否登录了', this.$route.query)
     if (!this.$tools.isLogin()) {
       this.setCurrentRouter(this.$route);
       this.$router.push({
@@ -222,8 +277,11 @@ export default {
     this.chapterId = this.$route.query.chapterId;
     this.moduleId = this.$route.query.moduleId;
     this.channelId = this.$route.params.channelId;
+    this.goodsName = this.$route.query.goodsName
+    this.sectionType = this.$route.query.sectionType
     this.identification = new Date().valueOf() + ""
     this.buyCourse = 0
+    // this.getParam()
     this.playVideo();
     this.studyRecordGetLastLive();
   },
@@ -234,9 +292,45 @@ export default {
   },
   methods: {
     ...mapMutations(["setCurrentRouter", "getCartCount"]),
+    returnBack() {
+      console.log('backNum', this.backNum)
+      if (this.backNum == 0) {
+        this.$router.push({
+          path: '/home'
+        })
+      } else {
+        this.$router.go(this.backNum)
+      }
+    },
+    toShare() {
+      this.shareLoading = true
+      this.shareShow = true
+      this.$axios({
+        url: '/course/watch/per',
+        method: 'get',
+        params: {
+          courseId: this.courseId, //课程ID	
+          goodsId: this.goodsId, // 商品id
+          moduleId: this.moduleId || null,
+          chapterId: this.chapterId || null,
+          sectionId: this.sectionId, // 节id
+          sectionType: this.sectionType, //节类型 1录播 2直播 3回放
+        },
+      }).then((res) => {
+        this.shareLoading = false
+        if (res.code == 200) {
+          this.formShare.links = res.data.enCodePC
+          this.formShare.ercode = res.data.enCode
+        }
+      }).catch((err) => {
+        this.shareLoading = false
+        this.$message.warning(err.msg)
+      })
+    },
     // 获取直播间跳转参数的接口
     getParam() {
       const { cid, gid, sid} = this.$route.query
+      console.log('cid, gid, sid',  cid, gid, sid)
       this.$axios({
         url: '/course/check/watch/per',
         method: 'get',
@@ -246,28 +340,51 @@ export default {
           sectionId: sid, // 节id
         },
       }).then((res) => {
-        if (res.data.code == 200) {
-          let item = res.data.data
-          console.log('item', item)
-          const {sectionId, goodsId, courseId, orderGoodsId, gradeId, chapterId, moduleId, buyCourse} = item
-          this.sectionId = sectionId
+        if (res.code == 200) {
+          let item = res.data
+          const {sectionId, goodsId, courseId, orderGoodsId, gradeId, chapterId, moduleId, buyCourse, sectionType} = item
           this.goodsId = goodsId
+          this.sectionId = sectionId
           this.courseId = courseId
           this.orderGoodsId = orderGoodsId
           this.gradeId = +gradeId || 0
           this.chapterId = chapterId
           this.moduleId = moduleId
           this.buyCourse = buyCourse
-          // console.log('url:', this.url)
-          this.identification = new Date().valueOf() + ""
-          this.playVideo();
-          this.studyRecordGetLastLive();
-        } else {
-          this.$u.toast(res.data.msg)
+          this.goodsStatus = item.goodsStatus
+          this.goodsName = item.goodsName
+          this.sectionType = sectionType
+          if (item.checkStatus == 1) { // 有权限
+            this.identification = new Date().valueOf() + ""
+            this.playVideo();
+            this.studyRecordGetLastLive();
+          } else {
+            this.showAuth = true
+          }
         }
+      }).catch((err) => {
+        console.log('500:', err)
+        this.$message({
+          message: err.msg,
+          type: "warning",
+        })
+        this.$router.push({
+          path: '/home'
+        })
       })
 
     },
+    toAuth() {
+      if (this.goodsStatus == 1) { //已上架
+        this.$router.push({
+          path: "/course-detail/" + this.goodsId,
+        })
+      } else {
+        this.$router.push({
+          path: '/home'
+        })
+      }
+    },
     // 新增用户视频学习日志
     studyLog() {
       this.$axios({
@@ -597,6 +714,31 @@ export default {
       this.plv.liveSdk.player.resize(); // ppt容器宽高修改,调用resize刷新ppt尺寸
       this.plv.liveSdk.player.resizeBarrage(); // 刷新弹幕显示区域尺寸
     },
+    download() {
+      var url = this.formShare.ercode
+      var a = document.createElement("a");
+      var event = new MouseEvent("click");
+      a.download = "二维码";
+      a.href = url;
+      a.dispatchEvent(event);
+    },
+
+    copy() {
+      var copyInput = document.createElement("input");
+      //val是要复制的内容
+      copyInput.setAttribute("value", this.formShare.links);
+      document.body.appendChild(copyInput);
+      copyInput.select();
+      try {
+        var copyed = document.execCommand("copy");
+        if (copyed) {
+          document.body.removeChild(copyInput);
+          this.$message.success("复制成功");
+        }
+      } catch (err) {
+        this.$message.error("复制失败,请检查浏览器兼容");
+      }
+    },
   },
 };
 </script>
@@ -607,8 +749,16 @@ export default {
   background: #eee;
   .top-line {
     margin: 10px 0;
-    .float-right {
+    overflow: hidden;
+    padding: 0px 45px;
+    .title {
+      font-size: 18px;
+      float: left;
+    }
+    .bottoms {
       float: right;
+    }
+    .float-right {
       width: 100px;
     }
   }
@@ -730,5 +880,38 @@ export default {
       }
     }
   }
+
+  .popCentent {
+      display: flex;
+      flex-direction: column;
+      align-items: center;
+    .btns {
+      width: 300px;
+      height: 40px;
+      line-height: 40px;
+      text-align: center;
+      background-color: #3577E8;
+      color: #fff;
+      font-size: 16px;
+      border-radius: 20px;
+      margin-top: 20px;
+      cursor: pointer;
+    }
+  }
+  .popShare {
+    .ccopy {
+      color: #1890ff;
+      font-size: 14px;
+      margin-left: 10px;
+      cursor: pointer;
+    }
+    .ercode_pic {
+      width: 150px;
+      height: 150px;
+      // &.bg {
+      //   background: url();
+      // }
+    }
+  }
 }
 </style>

+ 3 - 0
src/pages/mock-report/index.vue

@@ -284,6 +284,9 @@ export default {
     goLive() {
       this.$router.push({
         path: "/living-room/" + this.subscribeInfo.liveUrl,
+        query: {
+          sectionType: 2,
+        },
       });
     },
     openRemind() {

+ 2 - 0
src/pages/person-center/my-live/index.vue

@@ -102,6 +102,8 @@ export default {
           sectionId: this.livingSectionList[0].sectionId,
           chapterId: this.livingSectionList[0].chapterId || 0,
           moduleId: this.livingSectionList[0].moduleId || 0,
+          goodsName: this.livingSectionList[0].name,
+          sectionType: this.livingSectionList[0].sectionType,
         },
       });
     },

+ 6 - 0
src/pages/person-center/my-mock/index.vue

@@ -663,6 +663,9 @@ export default {
         //直播中
         this.$router.push({
           path: "/living-room/" + item.liveUrl,
+          query: {
+            sectionType: 2,
+          }
         });
       } else if (item.liveStatus == 1) {
         //未开播
@@ -758,6 +761,9 @@ export default {
     goLive(item) {
       this.$router.push({
         path: "/living-room/" + item.liveUrl,
+        query: {
+          sectionType: 2,
+        }
       });
     },
     goTest(item) {