Browse Source

tets_end1

guojy 1 year ago
parent
commit
97db27a14b

+ 1 - 1
config/index.js

@@ -13,7 +13,7 @@ module.exports = {
     proxyTable: {},
     proxyTable: {},
 
 
     // Various Dev Server settings
     // Various Dev Server settings
-    host: 'localhost', // can be overwritten by process.env.HOST
+    host: '0.0.0.0', // can be overwritten by process.env.HOST
     port: 8088, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
     port: 8088, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
     autoOpenBrowser: false,
     autoOpenBrowser: false,
     errorOverlay: true,
     errorOverlay: true,

+ 4 - 6
src/permission.js

@@ -3,7 +3,7 @@ import router from './router'
 import store from './store'
 import store from './store'
 import { getToken, getWxToken } from '@/utils/auth'
 import { getToken, getWxToken } from '@/utils/auth'
 //课程免登录名单
 //课程免登录名单
-const whiteList = ['/courseHome', '/courseDeal', '/courseTeam', '/course/adlist', '/course/limitChange', '/course/courseManage', '/course/courseCreate', '/course/dealerManage']
+const whiteList = ['/courseHome', '/courseError','/courseDeal', '/courseTeam', '/course/adlist', '/course/limitChange', '/course/courseManage', '/course/courseCreate', '/course/dealerManage']
 const whiteList2 = ['/courseDeal/', '/courseDetail/', '/courseAdDetail/', '/course/limitChange/', '/course/transfer/', '/course/video/', '/course/dealOrder/']
 const whiteList2 = ['/courseDeal/', '/courseDetail/', '/courseAdDetail/', '/course/limitChange/', '/course/transfer/', '/course/video/', '/course/dealOrder/']
 function filterWhite(path) {
 function filterWhite(path) {
   return whiteList2.some(item => {
   return whiteList2.some(item => {
@@ -16,7 +16,7 @@ router.beforeEach((to, from, next) => {
       item('interrupt'); //给个标志,中断请求
       item('interrupt'); //给个标志,中断请求
     })
     })
   }
   }
-  if (getToken() && whiteList.indexOf(to.path) === -1 && filterWhite(to.path)) {
+  if (getToken() && whiteList.indexOf(to.path) == -1 && !filterWhite(to.path)) {
     if (to.path == '/login' || to.path == '/') { // 在免登录白名单,直接进入
     if (to.path == '/login' || to.path == '/') { // 在免登录白名单,直接进入
       next({ name: 'home' })
       next({ name: 'home' })
       return false
       return false
@@ -29,8 +29,7 @@ router.beforeEach((to, from, next) => {
     // 初始一些数据
     // 初始一些数据
     init(next);
     init(next);
     // next();
     // next();
-  } else if (whiteList.indexOf(to.path) !== -1 || filterWhite(to.path)) {
-    console.log(2)
+  } else if (whiteList.indexOf(to.path) != -1 || filterWhite(to.path)) {
     if (getWxToken() || to.path == '/courseLogin' || to.path == '/courseHome') {
     if (getWxToken() || to.path == '/courseLogin' || to.path == '/courseHome') {
       if (typeof (window.$routes_map[to.name]) != 'undefined') {
       if (typeof (window.$routes_map[to.name]) != 'undefined') {
         window.document.title = window.$routes_map[to.name].label
         window.document.title = window.$routes_map[to.name].label
@@ -42,13 +41,12 @@ router.beforeEach((to, from, next) => {
       next('/courseHome')
       next('/courseHome')
     }
     }
   } else {
   } else {
-    console.log(3)
     if (!window.$routes_map[to.name].need_login) { // 在免登录白名单,直接进入
     if (!window.$routes_map[to.name].need_login) { // 在免登录白名单,直接进入
       if (typeof (window.$routes_map[to.name]) != 'undefined') {
       if (typeof (window.$routes_map[to.name]) != 'undefined') {
         window.document.title = window.$routes_map[to.name].label
         window.document.title = window.$routes_map[to.name].label
       }
       }
       next()
       next()
-    } else {
+    } else {         
       window.document.title = '用户登录'
       window.document.title = '用户登录'
       next('/login')
       next('/login')
     }
     }

+ 7 - 0
src/router/course.js

@@ -84,5 +84,12 @@
       label: '课程登录',
       label: '课程登录',
       need_login: false,
       need_login: false,
     },
     },
+    {
+      path: '/courseError',
+      name: 'courseError',
+      component: () => import('@/view/course/error'),
+      label: '网络错误',
+      need_login: false,
+    },
 ]
 ]
 export default routes
 export default routes

+ 0 - 1
src/utils/auth.js

@@ -89,7 +89,6 @@ export function returnJSEncrypt1(data,is=true){
   if(is){
   if(is){
       data.st=Date.parse(new Date()).toString();
       data.st=Date.parse(new Date()).toString();
   }
   }
-  console.log(data)
   let s=JSON.stringify(data);
   let s=JSON.stringify(data);
   let arr=[];
   let arr=[];
   if(s.length>100){
   if(s.length>100){

+ 1 - 1
src/utils/axiosKc.js

@@ -68,7 +68,7 @@ request.interceptors.response.use(
           window.localStorage.clear()
           window.localStorage.clear()
         }
         }
         router.replace({
         router.replace({
-          name: 'login'
+          name: 'courseHome'
         })
         })
       });
       });
     } else if (response.data.code === 0) {
     } else if (response.data.code === 0) {

+ 56 - 1
src/view/course/api/index.js

@@ -1,5 +1,6 @@
 import axiosKc from "../../../utils/axiosKc";
 import axiosKc from "../../../utils/axiosKc";
-import { Dialog, Notify } from 'vant'
+import router from '@/router'
+import { Dialog, Notify, Toast } from 'vant'
 import { getWxToken, setWxToken, openError, getWxUserId } from '@/utils/auth'
 import { getWxToken, setWxToken, openError, getWxUserId } from '@/utils/auth'
 
 
 //手机号获取验证码
 //手机号获取验证码
@@ -28,11 +29,25 @@ export function getWxApiToken(wxId) {
         })
         })
     })
     })
 }
 }
+//根据code获取开放平台token
+export function getWxPlatToken(token){
+    return new Promise((resolve, reject) => {
+        axiosKc('post', `/api/wo/mp/code`, {code:token}).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Notify({ type: 'danger', message: data.message });
+                reject(res.data.message)
+            }
+        })
+    })
+}
 //通过wxtoken获取用户wxApiToken
 //通过wxtoken获取用户wxApiToken
 export function getUSerInfo(token) {
 export function getUSerInfo(token) {
     return new Promise((resolve, reject) => {
     return new Promise((resolve, reject) => {
         axiosKc('post', `/mkt/client/login`, {}, '', token).then((res) => {
         axiosKc('post', `/mkt/client/login`, {}, '', token).then((res) => {
             if (res.data.code == 1) {
             if (res.data.code == 1) {
+                Toast(`获取到用户信息${res.data.data.marketable}`)
                 setWxToken(res.data.data.utoken)
                 setWxToken(res.data.data.utoken)
                 localStorage.setItem('wx_user_info', JSON.stringify(res.data.data))
                 localStorage.setItem('wx_user_info', JSON.stringify(res.data.data))
                 resolve(res.data.data)
                 resolve(res.data.data)
@@ -214,4 +229,44 @@ export function createCourseCode(id,data) {
             }
             }
         })
         })
     })
     })
+}
+//获取课程分享码详情
+export function getCourseCodeDetail(salesCode) {
+    return new Promise((resolve, reject) => {
+        axiosKc('get', `/mkt/client/${getWxUserId()}/sales/code/info/${salesCode}`).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Notify({ type: 'danger', message: data.message });
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//领取课程分享码的课程
+export function getCourseCode(data) {
+    return new Promise((resolve, reject) => {
+        axiosKc('post', `/mkt/client/${getWxUserId()}/sales/code/`,data).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Notify({ type: 'danger', message: data.message });
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//获取解析的视频地址
+export function getVideoSrc(data){
+    return new Promise((resolve, reject) => {
+        axiosKc('post', `/mkt/client/${getWxUserId()}/subject/presign`,data).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Notify({ type: 'danger', message: data.message });
+                router.replace('/courseError')
+                reject(res.data.message)
+            }
+        })
+    })
 }
 }

+ 0 - 1
src/view/course/components/CourseTeam.vue

@@ -108,7 +108,6 @@ export default {
     },
     },
     //人员搜索
     //人员搜索
     onSearch() {
     onSearch() {
-      console.log(this.searchValue)
       this.$emit('search',this.searchValue)
       this.$emit('search',this.searchValue)
     },
     },
   }
   }

+ 3 - 6
src/view/course/components/courseList.vue

@@ -141,17 +141,14 @@ export default {
     },
     },
     // 查看课程详情
     // 查看课程详情
     toUrl(item) {
     toUrl(item) {
-      // console.log(item)
       if(!item.status){
       if(!item.status){
         if (!this.isNoAd&&this.$route.path != `/courseAdDetail/${item.subjectId}`) {
         if (!this.isNoAd&&this.$route.path != `/courseAdDetail/${item.subjectId}`) {
+          sessionStorage.setItem('course_detail',JSON.stringify(item))
           this.$router.push({
           this.$router.push({
-            path:`/courseAdDetail/${item.subjectId}`,
-            query:item
+            path:`/courseAdDetail/${item.subjectId}`
           });
           });
         } else if(this.isNoAd&&this.$route.path != `/courseDetail/${item.subjectId}`) {
         } else if(this.isNoAd&&this.$route.path != `/courseDetail/${item.subjectId}`) {
           this.$router.push(`/courseDetail/${item.subjectId}`);
           this.$router.push(`/courseDetail/${item.subjectId}`);
-        }else{
-          console.log(123)
         }
         }
       }
       }
     },
     },
@@ -173,7 +170,7 @@ export default {
 .listOuer {
 .listOuer {
   border-radius: 0.1rem;
   border-radius: 0.1rem;
   overflow: hidden;
   overflow: hidden;
-  padding: 0.1rem 0;
+  // padding: 0.1rem 0;
   .listTit {
   .listTit {
     display: flex;
     display: flex;
     align-items: center;
     align-items: center;

+ 0 - 2
src/view/course/deal/dealOrder.vue

@@ -126,7 +126,6 @@ export default {
         })
         })
     },
     },
     onInput(key) {
     onInput(key) {
-      console.log(key)
       this.form.number = Number(`${this.form.number}${key}`)
       this.form.number = Number(`${this.form.number}${key}`)
     },
     },
     onDelete() {
     onDelete() {
@@ -139,7 +138,6 @@ export default {
       this.popupShow = true;
       this.popupShow = true;
     },
     },
     onConfirm(e, index) {
     onConfirm(e, index) {
-      console.log(index);
       this.form.name = this.courseList[index].subjectName;
       this.form.name = this.courseList[index].subjectName;
       this.form.id = this.courseList[index].subjectId;
       this.form.id = this.courseList[index].subjectId;
       this.coursesUsable = this.courseList[index].amount;
       this.coursesUsable = this.courseList[index].amount;

+ 19 - 15
src/view/course/deal/limitRecord.vue

@@ -9,6 +9,8 @@
     <div class="recordContent">
     <div class="recordContent">
       <scroller
       <scroller
         ref="scroller"
         ref="scroller"
+        :list="recordList"
+        noDataText="没有更多..."
         :on-infinite='getMoreList'
         :on-infinite='getMoreList'
       >
       >
         <div class="recordList">
         <div class="recordList">
@@ -26,7 +28,6 @@
             <span>{{ item.createTime }}</span>
             <span>{{ item.createTime }}</span>
           </div>
           </div>
         </div>
         </div>
-        <van-divider  :style="{ color: '#333', borderColor: '#333', padding: '10px 16px' }" v-if='recordList.length == page.total'>没有更多了</van-divider>
       </scroller>
       </scroller>
     </div>
     </div>
   </div>
   </div>
@@ -41,6 +42,7 @@ export default {
   data() {
   data() {
     return {
     return {
       canReq:true,
       canReq:true,
+      noDate:false,
       title: "名额变动明细",
       title: "名额变动明细",
       page:{
       page:{
         cur:1,
         cur:1,
@@ -57,7 +59,7 @@ export default {
     onClickLeft() {
     onClickLeft() {
       this.$router.go(-1);
       this.$router.go(-1);
     },
     },
-    getList(){
+    getList(done){
       let data = {
       let data = {
         page:this.page.cur,
         page:this.page.cur,
         pageSize:this.page.size
         pageSize:this.page.size
@@ -66,23 +68,25 @@ export default {
         this.recordList = this.recordList.concat(res.list)
         this.recordList = this.recordList.concat(res.list)
         this.page.cur = res.current
         this.page.cur = res.current
         this.page.total = res.total
         this.page.total = res.total
-        if(this.recordList.length<this.page.total){
-          this.canReq = true
+        if (this.recordList.length >= this.page.total) {
+          if (done) done(true);
+          this.noDate = true;
+        } else {
+          if (done) done();
+          this.page.cur++; //下拉一次页数+1
+          this.noDate = false;
         }
         }
       })
       })
     },
     },
-    getMoreList(){
+    getMoreList(done){
       console.log("到底了")
       console.log("到底了")
-      if(this.recordList.length<this.page.total && this.canReq){
-        this.canReq = false
-        this.$toast.loading({
-          duration: 1,
-          message: '加载中...',
-          forbidClick: true,
-        })
-        this.page.cur+=1
-        this.getList()
-      }
+      if (!this.noDate) {
+          setTimeout(() => {
+            this.getList(done);
+          }, 300);
+        } else {
+          this.$refs.recordScroller.finishInfinite(true);
+        }
     },
     },
   },
   },
   computed: {}
   computed: {}

+ 0 - 2
src/view/course/deal/transfer.vue

@@ -54,7 +54,6 @@ export default {
     courseInfo() {
     courseInfo() {
       let list = [];
       let list = [];
       list.push(this.transferInfo);
       list.push(this.transferInfo);
-      console.log(list);
       return list;
       return list;
     }
     }
   },
   },
@@ -64,7 +63,6 @@ export default {
   methods: {
   methods: {
     init(){
     init(){
       this.transferInfo = this.$route.query
       this.transferInfo = this.$route.query
-      console.log(this.transferInfo)
     },
     },
     onClickLeft() {
     onClickLeft() {
       this.$router.go(-1);
       this.$router.go(-1);

+ 24 - 0
src/view/course/error.vue

@@ -0,0 +1,24 @@
+<template>
+<div>
+    <van-empty image="network" description="请求失败了呢" />
+</div>
+</template>
+
+<script>
+export default {
+  name: 'error',
+  components: {},
+    props: [],
+  data () {
+    return {
+    }
+  },
+  created () { },
+  mounted () { },
+  methods: { },
+  computed: {}
+}
+</script>
+<style scoped lang='scss'>
+
+</style>

+ 63 - 47
src/view/course/home.vue

@@ -54,8 +54,13 @@
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
+    <van-search v-model="wxId"
+      placeholder="请输入wxid替换当前账号" 
+      show-action
+      @search="changeUSer"
+      />
     <div class="courScroll">
     <div class="courScroll">
-      <scroller ref="scroller" :on-refresh="refresh" :isInitRefresh="false">
+      <scroller ref="scroller" :isInitRefresh="false">
         <div class="myCourseList" v-if="user_info.marketable">
         <div class="myCourseList" v-if="user_info.marketable">
           <courseList
           <courseList
             :dataList="courseClass.proCourse.courseList"
             :dataList="courseClass.proCourse.courseList"
@@ -102,6 +107,7 @@ export default {
   },
   },
   data() {
   data() {
     return {
     return {
+      clipboard:null,
       qrVisible: false,
       qrVisible: false,
       qrcode: null,
       qrcode: null,
       qrcodeStatus: false,
       qrcodeStatus: false,
@@ -130,63 +136,72 @@ export default {
           total:0,
           total:0,
           courseList: []
           courseList: []
         }
         }
-      }
+      },
+      wxId:'11770'
     };
     };
   },
   },
   created() {
   created() {
-    // console.log(this.$route.query);
     this.init();
     this.init();
   },
   },
+  watch:{
+    '$route'(to){
+      if(to.path == '/courseHome'){
+        this.init();
+      }
+    }
+  },
   methods: {
   methods: {
+    changeUSer(){
+      localStorage.clear();
+      this.getUerInfo(this.wxId)
+    },
+    getUerInfo(wxid){
+      getWxApiToken(wxid).then(token => {
+        getUSerInfo(token).then(res => {
+          this.user_info = JSON.parse(
+            localStorage.getItem("wx_user_info")
+          );
+          if(this.$route.query && this.$route.query.pid){
+            localStorage.setItem('pid',this.$route.query.pid)
+            this.$router.push(`/courseLogin?pid=${this.$route.query.pid}`);
+          }else if (this.user_info.marketable) {
+            getDealerCourseList();
+          }
+          getUserCourseList();
+        });
+      });
+    },
     //获取用户数据
     //获取用户数据
     init() {
     init() {
-      if (this.$route.query && this.$route.query.pid) {
-        this.$router.push(`/courseLogin?pid=${this.$route.query.pid}`);
-      } else {
         isWxEnv()
         isWxEnv()
           .then(() => {
           .then(() => {
-            if (getWxToken()) {
+            if (getWxToken()&&localStorage.getItem('wx_user_info')) {
               this.user_info = JSON.parse(localStorage.getItem("wx_user_info"));
               this.user_info = JSON.parse(localStorage.getItem("wx_user_info"));
-              if (this.user_info.marketable) {
+              if(this.$route.query && this.$route.query.pid){
+                localStorage.setItem('pid',this.$route.query.pid)
+                this.$router.push(`/courseLogin?pid=${this.$route.query.pid}`);
+              }else if (this.user_info.marketable) {
                 this.getDealerCourseList();
                 this.getDealerCourseList();
               }
               }
               this.getUserCourseList();
               this.getUserCourseList();
             } else {
             } else {
-              getWxApiToken(7).then(token => {
-                getUSerInfo(token).then(res => {
-                  this.user_info = JSON.parse(
-                    localStorage.getItem("wx_user_info")
-                  );
-                  if (this.user_info.marketable) {
-                    getDealerCourseList();
-                  }
-                  getUserCourseList();
-                });
-              });
+              this.getUerInfo(this.wxId)
             }
             }
           })
           })
           .catch(err => {
           .catch(err => {
-            if (getWxToken()) {
+            if (getWxToken()&&localStorage.getItem('wx_user_info')) {
               this.user_info = JSON.parse(localStorage.getItem("wx_user_info"));
               this.user_info = JSON.parse(localStorage.getItem("wx_user_info"));
-              if (this.user_info.marketable) {
+              if(this.$route.query && this.$route.query.pid){
+                localStorage.setItem('pid',this.$route.query.pid)
+                this.$router.push(`/courseLogin?pid=${this.$route.query.pid}`);
+              }else if (this.user_info.marketable) {
                 this.getDealerCourseList();
                 this.getDealerCourseList();
               }
               }
               this.getUserCourseList();
               this.getUserCourseList();
             } else {
             } else {
-              getWxApiToken(11770).then(token => {
-                getUSerInfo(token).then(res => {
-                  this.user_info = JSON.parse(
-                    localStorage.getItem("wx_user_info")
-                  );
-                  if (this.user_info.marketable) {
-                    this.getDealerCourseList();
-                  }
-                  this.getUserCourseList();
-                });
-              });
+              this.getUerInfo(this.wxId)
             }
             }
           });
           });
-      }
     },
     },
     //获取经销推广课程列表
     //获取经销推广课程列表
     getDealerCourseList(done) {
     getDealerCourseList(done) {
@@ -226,8 +241,11 @@ export default {
     // 创建二维码
     // 创建二维码
     creatQrCode() {
     creatQrCode() {
       if (!this.qrcodeStatus) {
       if (!this.qrcodeStatus) {
+        console.log(`http://192.168.0.102:8088/#/courseHome?pid=${
+            JSON.parse(localStorage.getItem("wx_user_info")).id
+          }`)
         this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
         this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
-          text: `https://3i98944q41.goho.co/#/courseLogin&pid=${
+          text: `${window.location.href.split('#')[0]}#/courseHome?pid=${
             JSON.parse(localStorage.getItem("wx_user_info")).id
             JSON.parse(localStorage.getItem("wx_user_info")).id
           }`, // 需要转换为二维码的内容
           }`, // 需要转换为二维码的内容
           width: 200,
           width: 200,
@@ -243,17 +261,17 @@ export default {
     copyLink(event) {
     copyLink(event) {
       let that = this;
       let that = this;
       //这里是复制目标的类名
       //这里是复制目标的类名
-      let clipboard = new Clipboard(event, {
+      that.clipboard = new Clipboard(event, {
         text: function(trigger) {
         text: function(trigger) {
           return trigger.getAttribute("aria-label");
           return trigger.getAttribute("aria-label");
         }
         }
       });
       });
-      clipboard.on("success", function(e) {
+      that.clipboard.on("success", function(e) {
         e.clearSelection(); //清除选中的文字的选择状态
         e.clearSelection(); //清除选中的文字的选择状态
         that.$toast.success("ID复制成功~");
         that.$toast.success("ID复制成功~");
       });
       });
 
 
-      clipboard.on("error", function(e) {
+      that.clipboard.on("error", function(e) {
         console.error(e);
         console.error(e);
       });
       });
     },
     },
@@ -267,14 +285,6 @@ export default {
     refresh(done) {
     refresh(done) {
       this.getDealerCourseList(done);
       this.getDealerCourseList(done);
       this.getUserCourseList(done);
       this.getUserCourseList(done);
-    },
-    //请求微信授权
-    doWeixinLogin() {
-      if (this.isAndroid) {
-        window.open(`${process.env.VUE_APP_WXURL}?marketing=1`, "_blank");
-      } else {
-        window.location.href = `${process.env.VUE_APP_WXURL}?marketing=1`;
-      }
     }
     }
   }
   }
 };
 };
@@ -289,7 +299,6 @@ img {
   display: block;
   display: block;
 }
 }
 .curPage {
 .curPage {
-  padding: 0.4rem 0 0;
   height: 100%;
   height: 100%;
   position: relative !important;
   position: relative !important;
   background-color: #eee;
   background-color: #eee;
@@ -362,13 +371,16 @@ img {
     }
     }
   }
   }
   .courScroll {
   .courScroll {
-    height: calc(100vh - 2.75rem) !important;
+    height: calc(100vh - 2.35rem) !important;
     position: relative;
     position: relative;
     .cScroll {
     .cScroll {
       height: 100%;
       height: 100%;
       position: relative !important;
       position: relative !important;
     }
     }
     .myCourseList {
     .myCourseList {
+      &:nth-child(2) {
+        padding-bottom: 0.4rem;
+      }
       padding: 0 0.2rem;
       padding: 0 0.2rem;
       margin-top: 0.2rem;
       margin-top: 0.2rem;
     }
     }
@@ -378,6 +390,10 @@ img {
     justify-content: center;
     justify-content: center;
     align-items: center;
     align-items: center;
     height: 100vh;
     height: 100vh;
+    .qrcode-wrap {
+      padding: 0.2rem;
+      background-color: #fff;
+    }
   }
   }
 }
 }
 </style>
 </style>

+ 188 - 89
src/view/course/user/courseAdDeal.vue

@@ -6,11 +6,16 @@
       left-arrow
       left-arrow
       @click-left="onClickLeft"
       @click-left="onClickLeft"
     ></van-nav-bar>
     ></van-nav-bar>
-    <div id="link" style="display: none;" :aria-label="giveLink"></div>
+    <div id="linkCode" style="display: none;" :data-clipboard-text="giveLink">
+      {{ giveLink }}
+    </div>
     <div class="courseContent">
     <div class="courseContent">
-      <scroller 
-        ref="scroller"
-        :on-infinite='getMoreList'>
+      <scroller
+        ref="recordScroller"
+        :on-infinite="getMoreList"
+        :list="recordList"
+        noDataText="没有更多..."
+      >
         <courseList :dataList="courseInfo" :showNum="2"></courseList>
         <courseList :dataList="courseInfo" :showNum="2"></courseList>
         <div class="record">
         <div class="record">
           <p>名额变动明细</p>
           <p>名额变动明细</p>
@@ -22,14 +27,15 @@
             >
             >
               <div class="flex-name-num">
               <div class="flex-name-num">
                 <p>{{ item.subjectName }}</p>
                 <p>{{ item.subjectName }}</p>
-                <span>{{Number(item.amount)>0?`+${item.amount}`:item.amount}}</span>
+                <span>{{
+                  Number(item.amount) > 0 ? `+${item.amount}` : item.amount
+                }}</span>
               </div>
               </div>
               <p>{{ item.content }}</p>
               <p>{{ item.content }}</p>
               <span>{{ item.createTime }}</span>
               <span>{{ item.createTime }}</span>
             </div>
             </div>
           </div>
           </div>
         </div>
         </div>
-        <van-divider  :style="{ color: '#333', borderColor: '#333', padding: '10px 16px' }" v-if='recordList.length == page.total'>没有更多了</van-divider>
       </scroller>
       </scroller>
     </div>
     </div>
     <div class="courseShare" @click="comfirmCode">
     <div class="courseShare" @click="comfirmCode">
@@ -40,13 +46,15 @@
       title="立即赠送给好友"
       title="立即赠送给好友"
       :options="options"
       :options="options"
       @select="onSelect"
       @select="onSelect"
+      :aria-label="giveLink"
+      class="linkCodeShare"
     />
     />
   </div>
   </div>
 </template>
 </template>
-
 <script>
 <script>
-import {getCourseRecordList,createCourseCode} from '../api'
+import { getCourseRecordList, createCourseCode } from "../api";
 import Clipboard from "clipboard";
 import Clipboard from "clipboard";
+import axios from "axios";
 import courseList from "../components/courseList.vue";
 import courseList from "../components/courseList.vue";
 export default {
 export default {
   name: "",
   name: "",
@@ -54,46 +62,49 @@ export default {
   props: [],
   props: [],
   data() {
   data() {
     return {
     return {
-      showShare:false,
-      canReq:true,
+      showShare: false,
+      canReq: true,
       loading: false,
       loading: false,
       finished: false,
       finished: false,
       activeTab: 0,
       activeTab: 0,
       title: "课程详情",
       title: "课程详情",
-      giveLink:"",
-      options:[
+      giveLink: "",
+      noDate: false,
+      options: [
         // { name: '微信', icon: 'wechat' },
         // { name: '微信', icon: 'wechat' },
-        { name: '复制链接', icon: 'link' },
+        { name: "复制链接", icon: "link" }
         // { name: '二维码', icon: 'qrcode' },
         // { name: '二维码', icon: 'qrcode' },
       ],
       ],
-      page:{
-        cur:1,
-        total:0,
-        size:10
+      page: {
+        cur: 1,
+        total: 0,
+        size: 10
       },
       },
       courseDetail: {
       courseDetail: {
-        id: 0,//资产id
-        userId:0,//用户id
-        subjectId:0,//课程id
-        subjectName:"",
-        subjectThumb:"",//缩略图
-        subjectPrice:0,//课程价格
-        sectionsNum:0,//章节数
-        subjectEnable:1,//是否上架
-        amount:0,//剩余名额
-        statistics:{
-          saleAmount:0,//已卖出
-          transferOutAmount:0,//已转入
-          transferInAmount:0,//已转出
-        },
+        id: 0, //资产id
+        userId: 0, //用户id
+        subjectId: 0, //课程id
+        subjectName: "",
+        subjectThumb: "", //缩略图
+        subjectPrice: 0, //课程价格
+        sectionsNum: 0, //章节数
+        subjectEnable: 1, //是否上架
+        amount: 0, //剩余名额
+        statistics: {
+          saleAmount: 0, //已卖出
+          transferOutAmount: 0, //已转入
+          transferInAmount: 0 //已转出
+        }
       },
       },
-      recordList:[]
+      recordList: []
     };
     };
   },
   },
   computed: {
   computed: {
     courseInfo() {
     courseInfo() {
       let list = [];
       let list = [];
-      list.push(this.courseDetail);
+      if (this.courseDetail && this.courseDetail.userId != 0) {
+        list.push(this.courseDetail);
+      }
       return list;
       return list;
     }
     }
   },
   },
@@ -101,26 +112,89 @@ export default {
     this.init();
     this.init();
   },
   },
   methods: {
   methods: {
-    onSelect(option){
-      console.log(option)
-          if(option.name == '复制链接'){
-            this.$dialog.confirm({
-            title: '提示',
-            message: '确定要生成课程分享码?',
-            }).then(() => {
-              createCourseCode(this.courseDetail.subjectId).then(res=>{
-                this.giveLink = res
-                this.copyLink('#link')
-              })
-            }).catch(err=>{
-              this.showShare = false 
-            })
-            
-          }
+    onSelect(option) {
+      if (option.name == "复制链接") {
+        this.$dialog
+          .confirm({
+            title: "提示",
+            message: "确定要生成课程分享码?"
+          })
+          .then(() => {
+            createCourseCode(this.courseDetail.subjectId).then(res => {
+              this.giveLink = `${
+                window.location.href.split("#")[0]
+              }#/courseDetail/${this.$route.params.id}?code=${res}`;
+              this.copyLink(this.giveLink);
+              // this.copyTextToClipboard(this.giveLink);
+            });
+          })
+          .catch(err => {
+            this.showShare = false;
+          });
+      }
+    },
+    async copyTextToClipboard(text) {
+      try {
+        await navigator.clipboard.writeText(text);
+        this.$toast.success("复制成功~");
+        this.showShare = false;
+      } catch (err) {
+        console.error("Failed to copy: ", err);
+      }
+    },
+    wxShare() {
+      let that = this;
+      let url = window.location.href;
+      let newurl = url.split("#")[0];
+      axios(
+        "https://i.g107.com/564/Ajax/getJsSdk",
+        {
+          url: newurl
+        },
+        {
+          headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+          transformRequest: [
+            function(data) {
+              // 对 data 进行任意转换处理
+              return qs.stringify(data);
+            }
+          ]
+        }
+      )
+        .then(function(response) {
+          console.log(response);
+          var config = response.data;
+          var adress = "ceshi";
+          wx.config({
+            debug: false,
+            appId: config.appId,
+            timestamp: config.timestamp,
+            nonceStr: config.nonceStr,
+            signature: config.signature,
+            jsApiList: ["updateAppMessageShareData"]
+          });
+          wx.ready(function() {
+            wx.updateAppMessageShareData({
+              title: `${that.courseDetail.subjectName}`, // 分享标题
+              desc: `分享简介`, // 分享描述
+              link: `${window.location.href.split("#")[0]}#/courseAdDetail/${
+                this.$route.params.id
+              }/code=${res}`, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+              imgUrl: `${that.courseDetail.subjectThumb}`, // 分享图标
+              success: function() {
+                // 设置成功
+              }
+            });
+          });
+        })
+        .catch(function(error) {
+          console.log(error);
+        });
     },
     },
     //复制剪切板
     //复制剪切板
-    copyLink(event) {
-      console.log(23333)
+    copyLink2(event, text) {
       let that = this;
       let that = this;
       //这里是复制目标的类名
       //这里是复制目标的类名
       let clipboard = new Clipboard(event, {
       let clipboard = new Clipboard(event, {
@@ -128,7 +202,6 @@ export default {
           return trigger.getAttribute("aria-label");
           return trigger.getAttribute("aria-label");
         }
         }
       });
       });
-      console.log(clipboard)
       clipboard.on("success", function(e) {
       clipboard.on("success", function(e) {
         e.clearSelection(); //清除选中的文字的选择状态
         e.clearSelection(); //清除选中的文字的选择状态
         that.$toast.success("复制成功~");
         that.$toast.success("复制成功~");
@@ -136,48 +209,74 @@ export default {
       });
       });
 
 
       clipboard.on("error", function(e) {
       clipboard.on("error", function(e) {
-        console.log(5544332)
         console.error(e);
         console.error(e);
       });
       });
     },
     },
-    comfirmCode(){
-      this.showShare = true 
+    copyLink() {
+      //创建输入框
+      var input = document.createElement("input");
+      //对输入框进行赋值
+      input.value = this.giveLink;
+
+      //添加到body中。
+      document.body.appendChild(input);
+      input.select();
+      var copyResult = document.execCommand("copy");
+      if (copyResult) {
+        this.$toast.success("复制成功~");
+        that.showShare = false;
+        //移除
+        document.body.removeChild(input);
+      } else {
+        navigator.clipboard.writeText(str);
+        this.$toast.success("复制成功~");
+        that.showShare = false;
+      }
+    },
+    comfirmCode() {
+      this.showShare = true;
     },
     },
-    getMoreList(){
-      console.log("到底了")
-      if(this.recordList.length<this.page.total && this.canReq){
-        this.canReq = false
-        this.$toast.loading({
-          duration: 1,
-          message: '加载中...',
-          forbidClick: true,
-        })
-        this.page.cur+=1
-        this.getRecord()
+    getMoreList(done) {
+      console.log("到底了");
+      if (!this.noDate1) {
+        setTimeout(() => {
+          this.getRecord(done);
+        }, 300);
+      } else {
+        this.$refs.recordScroller.finishInfinite(true);
       }
       }
     },
     },
-    getRecord(){
+    getRecord(done) {
       let data = {
       let data = {
-        page:this.page.cur,
-        pageSize:this.page.size,
-        subjectId:this.courseId
-      }
-      getCourseRecordList(data).then(res=>{
-        this.recordList = this.recordList.concat(res.list)
-        this.page.cur = res.current
-        this.page.total = res.total
-        if(this.recordList.length<this.page.total){
-          this.canReq = true
+        page: this.page.cur,
+        pageSize: this.page.size,
+        subjectId: this.courseId
+      };
+      getCourseRecordList(data).then(res => {
+        this.recordList = this.recordList.concat(res.list);
+        this.page.cur = res.current;
+        this.page.total = res.total;
+        if (this.recordList.length >= this.page.total) {
+          if (done) done(true);
+          this.noDate = true;
+        } else {
+          if (done) done();
+          this.page.cur++; //下拉一次页数+1
+          this.noDate = false;
         }
         }
-      })
+      });
     },
     },
     onClickLeft() {
     onClickLeft() {
       this.$router.go(-1);
       this.$router.go(-1);
     },
     },
     init() {
     init() {
       this.courseId = this.$route.params.id;
       this.courseId = this.$route.params.id;
-      this.courseDetail = this.$route.query
+      this.courseDetail = JSON.parse(sessionStorage.getItem("course_detail"));
       this.getRecord();
       this.getRecord();
+      // this.wxShare();
+    },
+    destroyed() {
+      sessionStorage.removeItem("course_detail");
     }
     }
   }
   }
 };
 };
@@ -202,7 +301,7 @@ img {
       border-bottom: 1px solid #999;
       border-bottom: 1px solid #999;
       & > p {
       & > p {
         font-size: 0.28rem;
         font-size: 0.28rem;
-        line-height: .8rem;
+        line-height: 0.8rem;
         color: #000;
         color: #000;
         font-weight: 550;
         font-weight: 550;
         padding: 0 0.2rem;
         padding: 0 0.2rem;
@@ -245,20 +344,20 @@ img {
       }
       }
     }
     }
   }
   }
-  .courseShare{
-    width: calc(100% - .6rem);
-    height: .8rem;
+  .courseShare {
+    width: calc(100% - 0.6rem);
+    height: 0.8rem;
     position: absolute;
     position: absolute;
-    left: .3rem;
-    bottom: .1rem;
+    left: 0.3rem;
+    bottom: 0.1rem;
     border: 1px solid #999;
     border: 1px solid #999;
-    background-color: #FFF;
+    background-color: #fff;
     display: flex;
     display: flex;
     align-items: center;
     align-items: center;
     justify-content: center;
     justify-content: center;
-    border-radius: .1rem;
-    span{
-      font-size: .26rem;
+    border-radius: 0.1rem;
+    span {
+      font-size: 0.26rem;
       color: #333;
       color: #333;
     }
     }
   }
   }

+ 89 - 28
src/view/course/user/courseDeal.vue

@@ -26,7 +26,7 @@
                     class="logLi"
                     class="logLi"
                     v-for="(item, index) in courseDetail.sections"
                     v-for="(item, index) in courseDetail.sections"
                     :key="index"
                     :key="index"
-                    @click="toSectionVidio(item)"
+                    @click="toSectionVidio(item, index)"
                   >
                   >
                     <p>{{ index + 1 }}、{{ item.name }}</p>
                     <p>{{ index + 1 }}、{{ item.name }}</p>
                   </div>
                   </div>
@@ -47,33 +47,46 @@
           </van-tabs>
           </van-tabs>
         </scroller>
         </scroller>
       </div>
       </div>
-      <div class="getCourse">
-        <van-button icon="fire-o" square class="getBtn">点击领取课程名额</van-button>
+      <div
+        class="getCourse"
+        v-if="!courseDetail.buy && codeDetail && codeDetail.enable"
+        @click="useCode"
+      >
+        <van-button icon="fire-o" square class="getBtn"
+          >点击领取课程名额</van-button
+        >
       </div>
       </div>
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
-import JSEncrypt from 'jsencrypt';  
-import {learnerCourseDetail} from '../api'
+import {
+  learnerCourseDetail,
+  getCourseCodeDetail,
+  getCourseCode,
+  getVideoSrc
+} from "../api";
 export default {
 export default {
   name: "",
   name: "",
   components: {},
   components: {},
   props: [],
   props: [],
   data() {
   data() {
     return {
     return {
-      encrypt:null,
       loading: false,
       loading: false,
       finished: false,
       finished: false,
       activeTab: 0,
       activeTab: 0,
-      privateKey:"hdisadnihcuxhzcjxhidhsadahdoihasdnxjhuchasjdhandkjnasidhsadsadasklmcxasnsjdoasdjaosijkxoajsidjsaodkasj",
       title: "课程详情",
       title: "课程详情",
       courseDetail: {
       courseDetail: {
         thumb: "",
         thumb: "",
         name: "",
         name: "",
         images: [],
         images: [],
-        sections: []
+        sections: [],
+        buy: false
+      },
+      giveCode: false,
+      codeDetail: {
+        enable: true
       }
       }
     };
     };
   },
   },
@@ -81,33 +94,81 @@ export default {
     this.init();
     this.init();
   },
   },
   methods: {
   methods: {
-    encryLink(text){
-      return this.encrypt.encrypt(text)
+    useCode() {
+      this.$dialog
+        .confirm({
+          title: "提示",
+          message: "确定领取当前课程吗"
+        })
+        .then(() => {
+          let data = {
+            salesCode: this.codeDetail.salesCode,
+            userId: this.codeDetail.userId,
+            subjectId: this.codeDetail.subjectId
+          };
+          getCourseCode(data).then(res => {
+            this.$toast.success("领取成功!");
+            this.giveCode = true;
+            this.getDetail();
+          });
+        });
+    },
+    getCodeDetail() {
+      getCourseCodeDetail(this.$route.query.code).then(res => {
+        this.codeDetail = res;
+        if (res && !res.enable) {
+          this.codeDetail.enable = false;
+          this.$toast.fail("该分享码已失效");
+        }
+      });
     },
     },
-    toSectionVidio(item,index) {
-      if(this.courseDetail.buy){
+    getVideoLink(link){
+      let data = {
+        subjectId:this.$route.params.id,
+        link:link
+      }
+      getVideoSrc(data).then(res=>{
+        window.location.href = res
+      })
+    },
+    toSectionVidio(item, index) {
+      if (this.courseDetail.buy) {
+        // this.getVideoLink(item.link)
+        let data = {
+          index: index,
+          link: item.link
+        };
+        sessionStorage.setItem('vd_info',JSON.stringify(data))
         this.$router.push({
         this.$router.push({
-          path:`/course/video/${item.link}`
-        })
-      }else{
-        this.$toast.fail("请先领取课程后再观看")
+          path: `/course/video/${this.$route.params.id}`
+        });
+      } else {
+        this.$toast.fail("请先领取课程后再观看");
       }
       }
-      console.log(item);
     },
     },
     onClickLeft() {
     onClickLeft() {
-      this.$router.go(-1);
+      this.$router.push('/courseHome');
     },
     },
     init() {
     init() {
       this.courseId = this.$route.params.id;
       this.courseId = this.$route.params.id;
-      this.encrypt = new JSEncrypt();
-      this.encrypt.setPublicKey(this.publicKey);  
-      this.getDetail()
-    },
-    getDetail(){
-      learnerCourseDetail(this.courseId).then(res=>{
-        this.courseDetail = res
-      })
+      this.getDetail();
+      if (this.$route.query && this.$route.query.code) {
+        this.getCodeDetail();
+      }
     },
     },
+    getDetail() {
+      learnerCourseDetail(this.courseId).then(res => {
+        this.courseDetail = res;
+        if (
+          this.courseDetail.buy &&
+          this.$route.query &&
+          this.$route.query.code &&
+          !this.giveCode
+        ) {
+          this.$toast.fail("您已经购买课程,无需再次购买");
+        }
+      });
+    }
   },
   },
   computed: {}
   computed: {}
 };
 };
@@ -195,10 +256,10 @@ img {
     width: calc(100% - 0.2rem);
     width: calc(100% - 0.2rem);
     .getBtn {
     .getBtn {
       width: 100%;
       width: 100%;
-      background-color: #26A2FF;
+      background-color: #26a2ff;
       color: #fff;
       color: #fff;
       // animation: getFire 3s infinite linear;
       // animation: getFire 3s infinite linear;
-      border-radius: .1rem;
+      border-radius: 0.1rem;
     }
     }
   }
   }
 }
 }

+ 35 - 37
src/view/course/user/deal.vue

@@ -53,7 +53,7 @@
     </div>
     </div>
     <div class="dealScroll">
     <div class="dealScroll">
       <scroller
       <scroller
-      ref='courseScroller'
+        ref="courseScroller"
         :on-infinite="getMoreList"
         :on-infinite="getMoreList"
         :list="courseList"
         :list="courseList"
         noDataText="没有更多..."
         noDataText="没有更多..."
@@ -69,7 +69,7 @@
         <noData :list="courseList" />
         <noData :list="courseList" />
       </scroller>
       </scroller>
       <scroller
       <scroller
-        ref='recordScroller'
+        ref="recordScroller"
         :on-infinite="getMoreList"
         :on-infinite="getMoreList"
         noDataText="没有更多..."
         noDataText="没有更多..."
         :list="recordList"
         :list="recordList"
@@ -92,6 +92,7 @@
             <span>{{ item.createTime }}</span>
             <span>{{ item.createTime }}</span>
           </div>
           </div>
         </div>
         </div>
+        <van-divider v-if="recordList.length != 0 && recordList.length == page1.total">没有更多了...</van-divider>
         <noData :list="recordList" />
         <noData :list="recordList" />
       </scroller>
       </scroller>
     </div>
     </div>
@@ -114,8 +115,8 @@ export default {
       title: "交易",
       title: "交易",
       activeList: ["待确认的交易", "已交易的记录"],
       activeList: ["待确认的交易", "已交易的记录"],
       active: 0,
       active: 0,
-      noDate:false,
-      noDate1:false,
+      noDate: false,
+      noDate1: false,
       page: {
       page: {
         cur: 1,
         cur: 1,
         size: 10,
         size: 10,
@@ -137,10 +138,10 @@ export default {
       recordList: []
       recordList: []
     };
     };
   },
   },
-  watch:{
-    '$route'(to){
-      if(to.path.includes('/courseDeal/')){
-        this.resetList()
+  watch: {
+    $route(to) {
+      if (to.path.includes("/courseDeal/")) {
+        this.resetList();
       }
       }
     }
     }
   },
   },
@@ -153,36 +154,33 @@ export default {
       this.getList();
       this.getList();
       this.getRecordList();
       this.getRecordList();
     },
     },
-    resetList(){
-      console.log('reset')
+    resetList() {
       this.active = 0;
       this.active = 0;
       this.page.cur = 1;
       this.page.cur = 1;
       this.page.total = 0;
       this.page.total = 0;
       this.page1.cur = 1;
       this.page1.cur = 1;
       this.page1.total = 0;
       this.page1.total = 0;
-      this.noDate=false,
-      this.noDate1=false,
-      this.courseList=[];
-      this.recordList=[];
-      this.$refs.courseScroller.scrollTo(0,0,false);
-      this.$refs.recordScroller.scrollTo(0,0,false);
+      this.noDate = false;
+      this.noDate1 = false;
+      this.courseList = [];
+      this.recordList = [];
       this.getList();
       this.getList();
       this.getRecordList();
       this.getRecordList();
     },
     },
     getMoreList(done) {
     getMoreList(done) {
-      if(this.active == 0){
+      if (this.active == 0) {
         if (!this.noDate) {
         if (!this.noDate) {
-          setTimeout(() => {          
+          setTimeout(() => {
             this.getList(done);
             this.getList(done);
-          }, 300)
+          }, 300);
         } else {
         } else {
           this.$refs.courseScroller.finishInfinite(true);
           this.$refs.courseScroller.finishInfinite(true);
         }
         }
-      }else{
+      } else {
         if (!this.noDate1) {
         if (!this.noDate1) {
-          setTimeout(() => {          
+          setTimeout(() => {
             this.getRecordList(done);
             this.getRecordList(done);
-          }, 300)
+          }, 300);
         } else {
         } else {
           this.$refs.recordScroller.finishInfinite(true);
           this.$refs.recordScroller.finishInfinite(true);
         }
         }
@@ -207,12 +205,12 @@ export default {
         this.page.cur = res.current;
         this.page.cur = res.current;
         this.page.total = res.total;
         this.page.total = res.total;
         if (this.courseList.length >= this.page.total) {
         if (this.courseList.length >= this.page.total) {
-          if(done) done(true);      
-          this.noDate = true
-        }else{
-          if(done) done();
-          this.page.cur++;//下拉一次页数+1
-          this.noDate = false
+          if (done) done(true);
+          this.noDate = true;
+        } else {
+          if (done) done();
+          this.page.cur++; //下拉一次页数+1
+          this.noDate = false;
         }
         }
       });
       });
     },
     },
@@ -223,16 +221,17 @@ export default {
         status: -1
         status: -1
       };
       };
       getDealerRecord(this.$route.params.id, data).then(res => {
       getDealerRecord(this.$route.params.id, data).then(res => {
-        this.page.cur = res.current;
-        this.page.total = res.total;
+        this.page1.cur = res.current;
+        this.page1.total = res.total;
         this.recordList = this.recordList.concat(res.list);
         this.recordList = this.recordList.concat(res.list);
         if (this.recordList.length >= this.page1.total) {
         if (this.recordList.length >= this.page1.total) {
-          if(done) done(true);      
-          this.noDate1 = true
-        }else{
-          if(done) done();
-          this.page1.cur++;//下拉一次页数+1
-          this.noDate1 = false
+          console.log("没有更多")
+          if (done) done(true);
+          this.noDate1 = true;
+        } else {
+          if (done) done();
+          this.page1.cur++; //下拉一次页数+1
+          this.noDate1 = false;
         }
         }
       });
       });
     },
     },
@@ -240,7 +239,6 @@ export default {
       this.$router.push(`/course/dealOrder/${this.$route.params.id}`);
       this.$router.push(`/course/dealOrder/${this.$route.params.id}`);
     },
     },
     dealComfirm(res) {
     dealComfirm(res) {
-      console.log(res);
     },
     },
     activeChange(e) {
     activeChange(e) {
       this.active = e;
       this.active = e;

+ 8 - 5
src/view/course/user/login.vue

@@ -53,8 +53,9 @@
 
 
 <script>
 <script>
 import { returnJSEncrypt1 } from "@/utils/auth";
 import { returnJSEncrypt1 } from "@/utils/auth";
-import { getMobileYzm } from "../api";
+import { getMobileYzm,getUSerInfo } from "../api";
 import { addDealer } from "../api";
 import { addDealer } from "../api";
+import { isWxEnv } from "../utils";
 export default {
 export default {
   name: "courseLogin",
   name: "courseLogin",
   components: {},
   components: {},
@@ -83,6 +84,7 @@ export default {
       if (this.$route.query && this.$route.query.pid) {
       if (this.$route.query && this.$route.query.pid) {
         this.pid = this.$route.query.pid;
         this.pid = this.$route.query.pid;
       }
       }
+      isWxEnv(this.pid)
     },
     },
     checkMobile(sMobile) {
     checkMobile(sMobile) {
       if (!/^1\d{10}$/.test(sMobile)) {
       if (!/^1\d{10}$/.test(sMobile)) {
@@ -93,7 +95,7 @@ export default {
     },
     },
     getYzm() {
     getYzm() {
       if (!this.checkMobile(this.form.mobile)) {
       if (!this.checkMobile(this.form.mobile)) {
-        this.$toast("请输入正确的手机号");
+        this.$toast.fail("请输入正确的手机号");
         return false;
         return false;
       }
       }
       let data = { mobile: this.form.mobile.toString(), type: 1 };
       let data = { mobile: this.form.mobile.toString(), type: 1 };
@@ -102,7 +104,7 @@ export default {
         .then(res => {
         .then(res => {
           this.sended = true;
           this.sended = true;
           this.countDownInit();
           this.countDownInit();
-          this.$toast("已经发送,请注意查收!");
+          this.$toast.success("已经发送,请注意查收!");
         })
         })
         .finally(() => {
         .finally(() => {
           this.sendMsgLoading = false;
           this.sendMsgLoading = false;
@@ -130,13 +132,14 @@ export default {
           mobile: this.form.mobile,
           mobile: this.form.mobile,
           code: this.form.code
           code: this.form.code
         };
         };
-        if (this.pid != null) {
+        if (this.pid != null&&this.pid!=0) {
           data.pid = this.pid;
           data.pid = this.pid;
         }
         }
         addDealer(data).then(res => {
         addDealer(data).then(res => {
           this.$toast.success("注册经销商成功");
           this.$toast.success("注册经销商成功");
+          localStorage.removeItem('wx_user_info')
           setTimeout(() => {
           setTimeout(() => {
-            this.$router.push("/courseHome");
+            this.$router.replace("/courseHome");
           }, 1000);
           }, 1000);
         });
         });
       } else {
       } else {

+ 0 - 2
src/view/course/user/team.vue

@@ -90,13 +90,11 @@ export default {
         keyword:this.keyword
         keyword:this.keyword
       }
       }
       if(this.type){
       if(this.type){
-        console.log(1)
         getDealerTeam(data).then(res=>{
         getDealerTeam(data).then(res=>{
           this.teamList = res.list
           this.teamList = res.list
           this.page.total = res.total
           this.page.total = res.total
         })
         })
       }else{
       }else{
-        console.log(2)
         getDealerPerson(data).then(res=>{
         getDealerPerson(data).then(res=>{
           this.teamList = res.list
           this.teamList = res.list
           this.page.total = res.total
           this.page.total = res.total

+ 20 - 6
src/view/course/utils/index.js

@@ -3,7 +3,7 @@ import Clipboard from "clipboard";
 import { getWxToken, setWxToken, openError } from "@/utils/auth";
 import { getWxToken, setWxToken, openError } from "@/utils/auth";
 import { getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUserData, getEmployeeMap, getCache, setCache, removeCache, returnDeptName, getEmployeeMapItem, returnFh } from '@/utils/auth'
 import { getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUserData, getEmployeeMap, getCache, setCache, removeCache, returnDeptName, getEmployeeMapItem, returnFh } from '@/utils/auth'
 //判断环境/登录状态
 //判断环境/登录状态
-export function isWxEnv() {
+export function isWxEnv(pid) {
     // return new Promise((resolve, reject) => {
     // return new Promise((resolve, reject) => {
     //     if (getWxToken()) {
     //     if (getWxToken()) {
     //         resolve()
     //         resolve()
@@ -15,10 +15,12 @@ export function isWxEnv() {
     return new Promise((resolve, reject) => {
     return new Promise((resolve, reject) => {
         if (getIsWx()) {
         if (getIsWx()) {
             if (getWxToken()) {
             if (getWxToken()) {
+                Toast("微信环境已授权");
                 resolve()
                 resolve()
             } else {
             } else {
-                doWeixinLogin();
-                reject(1)
+                Toast("微信环境未授权");
+                // doWeixinLogin(pid);
+                reject(3)
             }
             }
         } else {
         } else {
             Toast("当前不在微信环境中,请在微信中打开浏览");
             Toast("当前不在微信环境中,请在微信中打开浏览");
@@ -27,11 +29,23 @@ export function isWxEnv() {
     })
     })
 }
 }
 //请求微信授权
 //请求微信授权
-function doWeixinLogin() {
+export function doWeixinLogin(pid) {
+    let dealerUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=2&pid='
+    let timinalUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=3&expendCode=ssoie'
     if (getCache("isAndroid")) {
     if (getCache("isAndroid")) {
-        window.open(`${process.env.VUE_APP_WXURL}?marketing=1`, "_blank");
+        if (pid) {
+            window.open(`${dealerUrl}${pid}`)
+            // window.open(`${process.env.VUE_APP_WXURL}?marketing=1`);
+        } else {
+            window.open(`${timinalUrl}`)
+        }
     } else {
     } else {
-        window.location.href = `${process.env.VUE_APP_WXURL}?marketing=1`;
+        // window.location.href = `${process.env.VUE_APP_WXURL}?marketing=1`;
+        if (pid) {
+            window.location.href = `${dealerUrl}${pid}`;
+        } else {
+            window.location.href = `${dealerUrl}`;
+        }
     }
     }
 }
 }
 export function copyLink(event) {
 export function copyLink(event) {

+ 221 - 26
src/view/course/video/video.vue

@@ -1,40 +1,235 @@
 <template>
 <template>
-<div>
-    video
-</div>
+  <div class="page">
+    <van-nav-bar
+      :title="title"
+      left-text="返回"
+      left-arrow
+      @click-left="onClickLeft"
+    ></van-nav-bar>
+    <div class="courseContent">
+      <div class="previewImg">
+        <video controls autoplay name="media">
+          <source :src="videoSrc" type="video/mp4">
+        </video>
+      </div>
+      <div class="title">
+        <p>{{ courseDetail.name }}</p>
+      </div>
+      <div class="tabs">
+        <scroller ref="scroller">
+          <van-tabs v-model="activeTab" swipeable>
+            <van-tab title="课程目录">
+              <div class="catelog">
+                <div class="sup">
+                  <span>共{{ courseDetail.sections.length }}节课</span>
+                </div>
+                <div class="logConetent">
+                  <div
+                    class="logLi"
+                    v-for="(item, index) in courseDetail.sections"
+                    :key="index"
+                    @click="toSectionVidio(item,index)"
+                    :class="{active:item.active}"
+                  >
+                    <p>{{ index + 1 }}、{{ item.name }}</p>
+                  </div>
+                </div>
+              </div>
+            </van-tab>
+            <van-tab title="课程介绍">
+              <div class="images">
+                <div
+                  class="descImage"
+                  v-for="(item, index) in courseDetail.images"
+                  :key="index"
+                >
+                  <img :src="item" />
+                </div>
+              </div>
+            </van-tab>
+          </van-tabs>
+        </scroller>
+      </div>
+    </div>
+  </div>
 </template>
 </template>
 
 
 <script>
 <script>
-import JSEncrypt from 'jsencrypt';  
+import {learnerCourseDetail,getVideoSrc} from '../api'
 export default {
 export default {
-  name: '',
+  name: "",
   components: {},
   components: {},
-    props: [],
-  data () {
+  props: [],
+  data() {
     return {
     return {
-      decrypt:null,
-      link:"",
-      privateKey:"hdisadnihcuxhzcjxhidhsadahdoihasdnxjhuchasjdhandkjnasidhsadsadasklmcxasnsjdoasdjaosijkxoajsidjsaodkasj"
-    }
+      loading: false,
+      finished: false,
+      activeTab: 0,
+      title: "课程详情",
+      videoSrc:"",
+      courseDetail: {
+        thumb: "",
+        name: "",
+        images: [],
+        sections: []
+      }
+    };
   },
   },
-  created () {
+  created() {
     this.init();
     this.init();
-   },
-  methods: { 
-    init(){
-      this.decrypt = new JSEncrypt(); 
-      this.decrypt.setPrivateKey(this.privateKey); // 设置私钥  
-      this.link = this.decryptMessage(this.$route.params.id)
-      this.link = this.$route.params.id;
-      console.log(this.init)
+  },
+  methods: {
+    toSectionVidio(item,i) {
+      this.courseDetail.sections.forEach((item,index)=>{
+        item.active = false;
+        if(index == i){
+          item.active = true;
+        }
+      })
+      let data = {
+          index: i,
+          link: item.link
+      };
+      sessionStorage.setItem('vd_info',JSON.stringify(data))
+      this.getVideoLink(item.link)
+      // this.videoSrc = this.courseDetail.sections[index].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')
+      })
+    },
+    onClickLeft() {
+      this.$router.go(-1);
+    },
+    init() {
+      this.courseId = this.$route.params.id;
+      this.getVideoLink(JSON.parse(sessionStorage.getItem('vd_info')).link)
+      this.getDetail()
+    },
+    getDetail(){
+      learnerCourseDetail(this.courseId).then(res=>{
+        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.courseDetail = res;
+      })
     },
     },
-    decryptMessage(text) {  
-      return this.decrypt.decrypt(text); // 解密消息  
-    }, 
   },
   },
   computed: {}
   computed: {}
-}
+};
 </script>
 </script>
-<style scoped lang='scss'>
-
+<style scoped lang="scss">
+* {
+  margin: 0;
+  padding: 0;
+}
+img {
+  display: block;
+}
+.page {
+  background-color: #fff;
+  box-sizing: border-box;
+  .courseContent {
+    padding: 0 0.2rem;
+    margin-top: 0.3rem;
+    .previewImg {
+      border-radius: 0.1rem;
+      overflow: hidden;
+      video {
+        width: 100%;
+        height: 4rem;
+      }
+    }
+    .title {
+      p {
+        font-size: 0.32rem;
+        font-weight: 600;
+        color: #000;
+        line-height: 1rem;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        word-break: break-all;
+      }
+    }
+    .tabs {
+      height: calc(100vh - 6.25rem);
+      position: relative;
+      .images {
+        margin-top: 0.1rem;
+        img {
+          width: 100%;
+        }
+      }
+      .catelog {
+        margin-top: 1px;
+        border-top: 1px solid #ccc;
+        .sup {
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+          span {
+            font-size: 0.24rem;
+            color: #666;
+            line-height: 3;
+          }
+        }
+        .logConetent {
+          .logLi {
+            border: 1px solid #ccc;
+            border-radius: 0.1rem;
+            padding: 0 0.2rem;
+            margin-bottom: 0.15rem;
+            p {
+              font-size: 0.3rem;
+              color: #000;
+              line-height: 3;
+              overflow: hidden;
+              text-overflow: ellipsis;
+              white-space: nowrap;
+              word-break: break-all;
+            }
+            &.active{
+              box-shadow: 1px 4px #ddd;
+              p{
+                color: #26A2FF;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  .getCourse {
+    position: absolute;
+    bottom: 0.1rem;
+    left: 0.1rem;
+    width: calc(100% - 0.2rem);
+    .getBtn {
+      width: 100%;
+      background-color: #26A2FF;
+      color: #fff;
+      // animation: getFire 3s infinite linear;
+      border-radius: .1rem;
+    }
+  }
+}
+@keyframes getFire {
+  0% {
+    transform: scale(0.95);
+  }
+  100% {
+    transform: scale(1.05);
+  }
+}
 </style>
 </style>

+ 28 - 16
src/view/user/wxInit.vue

@@ -18,7 +18,8 @@
 7.考勤系统审批 (请假,出差,加班,补卡,外出) type=7   考勤审批ID
 7.考勤系统审批 (请假,出差,加班,补卡,外出) type=7   考勤审批ID
 8.okr计划 (创建任务指派的,任务审批的) type=8   okr计划ID -->
 8.okr计划 (创建任务指派的,任务审批的) type=8   okr计划ID -->
 <script>
 <script>
-import { getToken } from "@/utils/auth";
+import { getToken,getWxToken ,getUserToken} from "@/utils/auth";
+import {getUSerInfo} from '@/view/course/api'
 import router from "../../router";
 import router from "../../router";
 export default {
 export default {
   name: "wxInit",
   name: "wxInit",
@@ -109,22 +110,33 @@ export default {
             this.openHome("OKR模块未开通,请联系管理员开通使用。");
             this.openHome("OKR模块未开通,请联系管理员开通使用。");
           }
           }
         }
         }
-      } else if (request && request.type && request.type == 9) {
+      } else if (request && request.type && (request.type == 9 || request.type == 10 || request.type == 11)) {
         if (request.code) {
         if (request.code) {
-          this.$axiosKc("POST", "https://oa.g107.com/api/pro/wo/mp/code", {
-            code: request.code
-          }).then(res => {
-            let data = res.data.data;
-            if (data.account_id === 0) {
-              //微信未绑定
-              data = { name: "regWx", query: { wo_token: data.wo_token } };
-              this.openUrl(data);
-            } else {
-              localStorage.setItem("wx_user_info", JSON.stringify(data));
-              localStorage.setItem("Wx-Token", data.wo_token); // 保存微信课程账号登录的token
-              this.$router.push('/courseHome')
-            }
-          });
+          this.$axios("POST", "/api/pro/wo/mp/code", {
+              code: request.code
+            }).then(res => {
+              let data = res.data.data;
+              if (data.account_id !== 0) {
+                //微信已经绑定
+                localStorage.setItem("Wx-Token", data.wo_token); // 保存平台账号登录的token
+                getUSerInfo(data.wo_token).then(ress=>{
+                  localStorage.setItem("wx_user_info", JSON.stringify(ress));
+                  if(request.type == 10&&request.pid){
+                    this.$router.push(`/courseLogin?pid=${request.pid}`)
+                  }else if(request.type == 11&&request.expendCode){
+                    let arr = request.expendCode.toString().split('-');
+                    this.$router.push({
+                      path:`/course/courseDetail/${arr[1]}`,
+                      query:{
+                        code:arr[0]
+                      }
+                    })
+                  }else{
+                    this.$router.push('/courseHome')
+                  }
+                })
+              }
+            });
         }
         }
       }
       }
     },
     },