guojy 1 年之前
父節點
當前提交
4d72558cea

+ 12 - 19
src/view/course/home.vue

@@ -8,10 +8,10 @@
       noDataText="没有更多..."
       :on-refresh='resetList'
       :on-infinite="getMoreList">
-        <div class="tit" style="margin-top: .3rem;">
+        <div class="tit" style="margin-top: .3rem;" v-if="freeCourseList.length>0">
           <span>今日更新</span>
         </div>
-        <div class="freeContent">
+        <div class="freeContent" v-if="freeCourseList.length>0">
           <div class="freeLi" v-for="(item,index) in freeCourseList" :key="index" @click="toUrl(item)">
             <div class="liIcon">
               <van-icon name="play-circle-o" />
@@ -40,8 +40,9 @@ import { getUserAllCourseList ,getFreeCourseList} from "./api";
 import courseList from "./components/courseList.vue";
 import {setDocumentTitle} from '../../components/vueHashCalendar/utils/util'
 import {setWxConfig} from './utils'
+import wx from 'weixin-js-sdk'
 export default {
-  name: "",
+  name: "courseHome",
   components: {
     courseList
   },
@@ -50,6 +51,7 @@ export default {
       active:0,
       canReq: true,
       noDate: false,
+      logo:require('../../../static/images/logo.png'),
       page: {
         cur: 1,
         size: 10,
@@ -63,22 +65,13 @@ export default {
     setDocumentTitle('首页')
     this.init();
     if(this.$isWx){
-      setWxConfig().then(() => {
-        wx.ready(() => {
-          console.log("微信配置成功");
-          wx.updateAppMessageShareData({
-            title: "公道云课程", // 分享标题
-            desc: "点击查看课程", // 分享描述
-            link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
-            imgUrl: logo, // 分享图标
-            success: function () {
-              // 设置成功
-              console.log("分享成功");
-              // this.$toast.success('')
-            },
-          });
-        });
-      });
+      let info = {
+        title:'公道云课程',// 分享标题
+        desc:'公道云',// 分享描述
+        link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+        imgUrl: this.logo, // 分享图标
+      }
+      setWxConfig(info);
     }
   },
   methods: {

+ 1 - 1
src/view/course/user.vue

@@ -162,7 +162,7 @@
     getUserCourseList
   } from "./api";
   export default {
-    name: "courseHome",
+    name: "courseUser",
     components: {
       courseList
     },

+ 1 - 18
src/view/course/user/courseAdDeal.vue

@@ -84,11 +84,10 @@
 import { getCourseRecordList, createCourseCode ,getDealerCourseDetail} from "../api";
 import {setWxConfig} from '../utils'
 import Clipboard from "clipboard";
-import axios from "axios";
 import courseList from "../components/courseList.vue";
 import wx from "weixin-js-sdk";
 export default {
-  name: "",
+  name: "courseAdDetail",
   components: { courseList },
   props: [],
   data() {
@@ -150,22 +149,6 @@ export default {
     this.copyBtn = new Clipboard(this.$refs.copys);
   },
   methods: {
-    setShare(){
-      wx.ready(function () {
-        console.log("微信配置成功")
-      })
-      wx.error(function (res) {
-        console.log("微信配置失败",res)
-      })
-      // if(this.$isWx){
-      //   wx.ready(function () {
-      //     console.log("微信配置成功")
-      //   })
-      //   wx.error(function (res) {
-      //     console.log("微信配置失败",res)
-      //   })
-      // }
-    },
     //分享链接
     shareLink(){
       if(this.$isWx){

+ 14 - 23
src/view/course/user/courseDeal.vue

@@ -82,6 +82,7 @@
 
 <script>
 import { setWxConfig } from "../utils";
+import wx from 'weixin-js-sdk'
 import {
   learnerCourseDetail,
   getCourseCodeDetail,
@@ -89,15 +90,12 @@ import {
   getVideoSrc
 } from "../api";
 export default {
-  name: "",
+  name: "courseDetail",
   components: {},
   props: [],
   data() {
     return {
       showBack:false,
-      goLeft: "返回",
-      loading: false,
-      finished: false,
       activeTab: 0,
       title: "课程详情",
       courseDetail: {
@@ -117,28 +115,22 @@ export default {
   },
   created() {
     this.init();
-    if (this.$isWx) {
-      setWxConfig().then(() => {
-        wx.ready(() => {
-          console.log("微信配置成功");
-          wx.updateAppMessageShareData({
-            title: this.courseDetail.name, // 分享标题
-            desc: "点击查看课程", // 分享描述
-            link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
-            imgUrl: this.courseDetail.thumb, // 分享图标
-            success: function() {
-              // 设置成功
-              console.log("分享成功");
-              // this.$toast.success('')
-            }
-          });
-        });
-      });
+  },
+  mounted(){
+    if(this.$isWx){
+      let info = {
+        title:this.courseDetail.name,// 分享标题
+        desc:'点击查看课程',// 分享描述
+        link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+        imgUrl: this.courseDetail.thumb, // 分享图标
+      }
+      setWxConfig(info);
     }
   },
   methods: {
     scrollChange(e){
-      if(e>60){
+      //需要滚动的界面实际长度大于整个页面长度
+      if(e>40&&document.getElementsByClassName('page')[0].offsetHeight<document.getElementsByClassName('_v-content')[0].offsetHeight){
         this.showBack = true;
       }else{
         this.showBack = false;
@@ -218,7 +210,6 @@ export default {
     init() {
       this.courseId = this.$route.params.id;
       if (this.$route.query && this.$route.query.code) {
-        this.goLeft = "首页";
         this.getDetail();
       } else {
         this.getDetail();

+ 1 - 1
src/view/course/user/team.vue

@@ -30,7 +30,7 @@ import { getDealerTeam, getDealerPerson } from "../api";
 import Team from "../components/CourseTeam";
 import {setDocumentTitle} from '../../../components/vueHashCalendar/utils/util'
 export default {
-  name: "",
+  name: "courseTeam",
   components: { Team },
   data() {
     return {

+ 1 - 1
src/view/course/user/wxAuth.vue

@@ -24,7 +24,7 @@ import { getWxApiToken, getUSerInfo, getCourseCodeDetail } from "../api";
 import { isWxEnv } from "../utils";
 import { mapState, mapGetters } from "vuex";
 export default {
-  name: "",
+  name: "wxAuth",
   components: {},
   props: [],
   data() {

+ 23 - 13
src/view/course/utils/index.js

@@ -101,22 +101,32 @@ export function copyLink(event) {
         console.error(e);
     });
 }
-export function setWxConfig() {
+export function setWxConfig(shareInfo) {
+    console.log(shareInfo)
     let data = {
         url:window.location.href
     }
-    return new Promise((resovle,reject)=>{
-        getWxConfigInfo(data).then(config => {
-            wx.config({
-                appId: config.appId,
-                timestamp: config.timestamp,
-                nonceStr: config.nonceStr,
-                signature: config.signature,
-                jsApiList: ['updateAppMessageShareData']
-            })
-            resovle()
-        }).catch(err=>{
-            console.log(err)
+    getWxConfigInfo(data).then(config => {
+        wx.config({
+            appId: config.appId,
+            timestamp: config.timestamp,
+            nonceStr: config.nonceStr,
+            signature: config.signature,
+            jsApiList: ['updateAppMessageShareData']
         })
+        wx.ready(() => {
+            wx.updateAppMessageShareData({
+                title: shareInfo.title, // 分享标题
+                desc: shareInfo.desc, // 分享描述
+                link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+                imgUrl: shareInfo.logo, // 分享图标
+                success: function () {
+                // 设置成功
+                console.log("分享成功");
+                },
+            });
+        });
+    }).catch(err=>{
+        console.log(err)
     })
 }

+ 86 - 69
src/view/course/video/courseVideo.vue

@@ -8,9 +8,16 @@
     ></van-nav-bar>
     <div class="courseContent">
       <div class="previewImg">
-        <video ref="vueMiniPlayer" :src="videoSrc" controls autoplay v-if="showVideo" controlsList="nodownload"></video>
+        <video
+          ref="vueMiniPlayer"
+          :src="videoSrc"
+          controls
+          autoplay
+          v-if="showVideo"
+          controlsList="nodownload"
+        ></video>
       </div>
-      <div class="title">
+      <div class="videoTitle">
         <!-- <span>{{ courseDetail.price }}</span> -->
         <p>{{ curTitle }}</p>
         <!-- <i style="margin-right: .1rem;">已更新{{ courseDetail.sections.length }}节课</i>
@@ -29,8 +36,8 @@
                     class="logLi"
                     v-for="(item, index) in courseDetail.sections"
                     :key="index"
-                    @click="toSectionVidio(item,index)"
-                    :class="{active:item.active}"
+                    @click="toSectionVidio(item, index)"
+                    :class="{ active: item.active }"
                   >
                     <p>{{ index + 1 }}、{{ item.name }}</p>
                   </div>
@@ -56,19 +63,19 @@
 </template>
 
 <script>
-import {learnerCourseDetail,getVideoSrc} from '../api'
+import { learnerCourseDetail, getVideoSrc } from "../api";
 export default {
   name: "video",
   data() {
     return {
-      showBack:false,
-      showVideo:true,
+      showBack: false,
+      showVideo: true,
       loading: false,
       finished: false,
       activeTab: 0,
       title: "课程详情",
-      curTitle:'',
-      videoSrc:"",
+      curTitle: "",
+      videoSrc: "",
       courseDetail: {
         thumb: "",
         name: "",
@@ -77,15 +84,15 @@ export default {
       }
     };
   },
-  watch:{
-    videoSrc(){
+  watch: {
+    videoSrc() {
       this.showVideo = false;
-      this.$nextTick(()=>{
+      this.$nextTick(() => {
         this.showVideo = true;
-        this.$nextTick(()=>{
-          this.$refs.vueMiniPlayer.play();//播放
-        })
-      })
+        this.$nextTick(() => {
+          this.$refs.vueMiniPlayer.play(); //播放
+        });
+      });
     }
   },
   created() {
@@ -93,10 +100,13 @@ export default {
   },
   methods: {
     //滚动监控
-    scrollChange(e){
-      if(e>60){
+    scrollChange(e) {
+      //需要滚动的界面实际长度大于整个页面长度
+      let allH = document.getElementsByClassName("_v-content")[0].offsetHeight + document.getElementsByClassName("van-nav-bar")[0].offsetHeight+document.getElementsByClassName("previewImg")[0].offsetHeight+document.getElementsByClassName("videoTitle")[0].offsetHeight
+      let canShow = allH > document.getElementsByClassName("page")[0].offsetHeight
+      if ( e > 40 && canShow ) {
         this.showBack = true;
-      }else{
+      } else {
         this.showBack = false;
       }
     },
@@ -105,32 +115,34 @@ export default {
       this.$refs.scroller.scrollTo(0, 0, 500);
     },
     // 章节切换获取视频地址
-    toSectionVidio(item,i) {
-      this.courseDetail.sections.forEach((item,index)=>{
+    toSectionVidio(item, i) {
+      this.courseDetail.sections.forEach((item, index) => {
         item.active = false;
-        if(index == i){
+        if (index == i) {
           item.active = true;
         }
-      })
+      });
       let data = {
-          index: i,
-          link: item.link
+        index: i,
+        link: item.link
       };
-      sessionStorage.setItem('vd_info',JSON.stringify(data))
-      this.getVideoLink(item.link)
+      sessionStorage.setItem("vd_info", JSON.stringify(data));
+      this.getVideoLink(item.link);
       // this.videoSrc = this.courseDetail.sections[index].link
     },
     // 获取视频地址
-    getVideoLink(link){
+    getVideoLink(link) {
       let data = {
-        subjectId:this.$route.params.id,
-        link:link
-      }
-      getVideoSrc(data).then(res=>{
-        this.videoSrc = res
-      }).catch(err=>{
-        this.$router.push('/courseError')
-      })
+        subjectId: this.$route.params.id,
+        link: link
+      };
+      getVideoSrc(data)
+        .then(res => {
+          this.videoSrc = res;
+        })
+        .catch(err => {
+          this.$router.push("/courseError");
+        });
     },
     // 返回
     onClickLeft() {
@@ -139,29 +151,34 @@ export default {
     // 初始化
     init() {
       this.courseId = this.$route.params.id;
-      this.getVideoLink(JSON.parse(sessionStorage.getItem('vd_info')).link)
-      this.getDetail()
+      this.getVideoLink(JSON.parse(sessionStorage.getItem("vd_info")).link);
+      this.getDetail();
     },
     // 获取课程详情
-    getDetail(){
-      learnerCourseDetail(this.courseId).then(res=>{
-        this.title = res.name
-        document.title = res.name
-        res.sections.forEach((item,index)=>{
+    getDetail() {
+      learnerCourseDetail(this.courseId).then(res => {
+        this.title = res.name;
+        document.title = res.name;
+        res.sections.forEach((item, index) => {
           item.active = false;
-        })
-        if(JSON.parse(sessionStorage.getItem('vd_info'))){
-          res.sections[JSON.parse(sessionStorage.getItem('vd_info')).index].active = true;
-          this.curTitle = res.sections[JSON.parse(sessionStorage.getItem('vd_info')).index].name
+        });
+        if (JSON.parse(sessionStorage.getItem("vd_info"))) {
+          res.sections[
+            JSON.parse(sessionStorage.getItem("vd_info")).index
+          ].active = true;
+          this.curTitle =
+            res.sections[
+              JSON.parse(sessionStorage.getItem("vd_info")).index
+            ].name;
         }
         this.courseDetail = res;
-      })
-    },
-  },
+      });
+    }
+  }
 };
 </script>
 <style scoped lang="scss">
-@import url('../utils/navBar.scss');
+@import url("../utils/navBar.scss");
 * {
   margin: 0;
   padding: 0;
@@ -183,21 +200,21 @@ img {
         height: 4rem;
       }
     }
-    .title {
-      padding: .2rem;
-      background-color: #FFF;
-      margin-bottom: .2rem;
-      span{
-        font-size: .35rem;
+    .videoTitle {
+      padding: 0.2rem;
+      background-color: #fff;
+      margin-bottom: 0.2rem;
+      span {
+        font-size: 0.35rem;
         font-weight: 600;
         color: red;
-        line-height: .8rem;
+        line-height: 0.8rem;
       }
       p {
         font-size: 0.32rem;
         font-weight: 600;
         color: #000;
-        line-height: .4rem;
+        line-height: 0.4rem;
         // margin-bottom: .2rem;
         /* white-space: pre-wrap; */
         /* overflow: hidden; */
@@ -207,15 +224,15 @@ img {
         width: 100%;
         word-wrap: break-word;
       }
-      i{
-        font-size: .22rem;
+      i {
+        font-size: 0.22rem;
         color: #888;
-        line-height: .3rem;
+        line-height: 0.3rem;
         font-style: normal;
       }
     }
     .tabs {
-      height: calc(100vh - 6.25rem);
+      height: calc(100vh - 6rem);
       position: relative;
       .toTop {
         width: 1rem;
@@ -241,7 +258,7 @@ img {
         }
       }
       .catelog {
-        background: #FFF;
+        background: #fff;
         padding: 0.2rem;
         margin-top: 1px;
         border-top: 1px solid #efefef;
@@ -253,7 +270,7 @@ img {
             font-size: 0.24rem;
             color: #666;
             line-height: 3;
-            margin-left: .1rem;
+            margin-left: 0.1rem;
           }
         }
         .logConetent {
@@ -262,14 +279,14 @@ img {
             border-radius: 0.1rem;
             padding: 0 0.2rem;
             margin-bottom: 0.15rem;
-            &.active{
+            &.active {
               box-shadow: 0.02rem 0.08rem #ddd;
-              p{
-                color:#26a2ff;
+              p {
+                color: #26a2ff;
               }
             }
             p {
-              padding: .2rem 0;
+              padding: 0.2rem 0;
               font-size: 0.3rem;
               color: #000;
               line-height: 1.3;