guojy 1 年間 前
コミット
b4fa95cb83

+ 26 - 4
src/permission.js

@@ -3,7 +3,7 @@ import router from './router'
 import store from './store'
 import { getToken, getWxToken } from '@/utils/auth'
 //课程免登录名单
-const whiteList = ['/courseHome', '/courseError','/courseDeal', '/courseTeam', '/course/adlist', '/course/limitChange', '/course/courseManage', '/course/courseCreate', '/course/dealerManage']
+const whiteList = ['/courseHome', '/courseLogin','/courseError','/courseAuth','/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/']
 function filterWhite(path) {
   return whiteList2.some(item => {
@@ -30,15 +30,37 @@ router.beforeEach((to, from, next) => {
     init(next);
     // next();
   } else if (whiteList.indexOf(to.path) != -1 || filterWhite(to.path)) {
-    if (getWxToken() || to.path == '/courseLogin' || to.path == '/courseHome') {
+    if (getWxToken() || to.path == '/courseAuth') {
+      console.log(1)
       if (typeof (window.$routes_map[to.name]) != 'undefined') {
         window.document.title = window.$routes_map[to.name].label
       } else {
         window.document.title = '功道云课程'
       }
       next()
-    } else {
-      next('/courseHome')
+    } else{
+      if(to.path.includes('/courseDetail/')&&to.query&&to.query.code){
+        console.log(2)
+        next({
+          path:`/courseAuth`,
+          query:{
+            code:to.query.code
+          }
+        })
+      }else if(to.fullPath.includes('/courseLogin')&&to.query&&to.query.pid != undefined){
+        console.log(3)
+        next({
+          path:`/courseAuth`,
+          query:{
+            pid:to.query.pid
+          }
+        })
+      }else{
+        console.log(4)
+        next({
+          path:`/courseAuth`,
+        })
+      }
     }
   } else {
     if (!window.$routes_map[to.name].need_login) { // 在免登录白名单,直接进入

+ 8 - 8
src/router/course.js

@@ -7,6 +7,13 @@
       label: '课程首页',
       need_login: true,
     },
+    {
+      path: '/courseAuth',
+      name: 'courseAuth',
+      component: () => import('@/view/course/user/wxAuth'),
+      label: '微信授权',
+      need_login: true,
+    },
     {
       path: '/courseTeam',
       name: 'courseHome',
@@ -35,13 +42,6 @@
       label: '推广课程详情',
       need_login: true,
     },
-    {
-      path: '/course/adlist',
-      name: 'courseAdlist',
-      component: () => import('@/view/course/user/courseAd'),
-      label: '我的推广',
-      need_login: true,
-    },
     {
       path: '/course/limitChange',
       name: 'limitChange',
@@ -75,7 +75,7 @@
       name: 'courseLogin',
       component: () => import('@/view/course/user/login'),
       label: '课程登录',
-      need_login: false,
+      need_login: true,
     },
     {
       path: '/courseError',

+ 4 - 1
src/store/getters.js

@@ -21,6 +21,9 @@ const getters = {
   selectDate: state => state.user.selectDate,
   monthTime: state => state.user.monthTime,
   selected:  state => state.attendanceApproval.selected,
-  pushCardData:state => state.user.pushCardData
+  pushCardData:state => state.user.pushCardData,
+
+  //test
+  wxid:state => state.user.wxid
 }
 export default getters

+ 1 - 0
src/store/modules/user.js

@@ -5,6 +5,7 @@ import moment from 'moment'
 
 const user = {
   state: {
+    wxid:11770,
     token: '',
     user_info: {},
     account_info: {},

+ 2 - 2
src/utils/axiosKc.js

@@ -18,8 +18,8 @@ if (window.plus) {
 let url = '';
 const request = axios.create({
   // baseURL: process.env.BASE_API, //
-  // baseURL: 'https://oa.g107.com',
-  baseURL:'http://192.168.0.66:8081',
+  baseURL: 'https://oa.g107.com',
+  // baseURL:'http://192.168.0.66:8081',
   timeout: 20000,
   headers: {
     'Content-Type': 'application/x-www-form-urlencoded',

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

@@ -34,7 +34,7 @@
 
 <script>
 export default {
-  name: "",
+  name: "courseTeamMudule",
   components: {},
   props: {
     teamType: {

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

@@ -137,6 +137,12 @@ export default {
           this.$route.path != `/courseDetail/${item.subjectId}`
         ) {
           this.$router.push(`/courseDetail/${item.subjectId}`);
+        }else if(
+          this.showNum == 2 &&
+          this.$route.path != `/courseDetail/${item.subjectId}`){
+            this.$router.push({
+              path:`/courseDetail/${item.subjectId}`
+            })
         }
       }else if(item.status == 1 && this.listType == 2){
         this.comfirm(item)

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

@@ -95,6 +95,7 @@ export default {
     this.getCourseList();
   },
   methods: {
+    //获取可交易的课程
     getCourseList(){
       getDealerCourseList().then(res=>{
         this.courseList = res.list;
@@ -105,6 +106,7 @@ export default {
         this.columnsOptions = list
       })
     },
+    //交易
     postDeal(){
       let data = {
         subjectId:this.form.id,
@@ -120,6 +122,7 @@ export default {
         this.$router.go(-1)
       })
     },
+    //交易提示
     comfirm(){
       this.$dialog.confirm({
          title: '提示',
@@ -132,18 +135,23 @@ export default {
           }
         })
     },
+    //数字输入框加
     onInput(key) {
       this.form.number = Number(`${this.form.number}${key}`)
     },
+    //数字输入框减
     onDelete() {
       this.form.number = Number(this.form.number.toString().slice(0,this.form.number.toString().length - 1))
     },
+    //返回
     onClickLeft() {
       this.$router.go(-1);
     },
+    //显示课程选择
     showPop() {
       this.popupShow = true;
     },
+    //课程选择确认
     onConfirm(e, index) {
       this.form.name = this.courseList[index].subjectName;
       this.form.id = this.courseList[index].subjectId;

+ 4 - 1
src/view/course/deal/limitRecord.vue

@@ -57,9 +57,11 @@ export default {
     this.getList();
   },
   methods: {
+    // 返回
     onClickLeft() {
       this.$router.go(-1);
     },
+    //获取记录列表
     getList(done){
       let data = {
         page:this.page.cur,
@@ -69,7 +71,7 @@ export default {
         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 (res.pages == this.page.cur) {
           if (done) done(true);
           this.noDate = true;
         } else {
@@ -79,6 +81,7 @@ export default {
         }
       })
     },
+    // 触底加载
     getMoreList(done){
       console.log("到底了")
       if (!this.noDate) {

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

@@ -64,12 +64,15 @@ export default {
     this.init()
   },
   methods: {
+    // 初始化
     init(){
       this.transferInfo = this.$route.query
     },
+    // 返回
     onClickLeft() {
       this.$router.go(-1);
     },
+    // 退回、撤回提示
     returnLimit(){
       if(this.transferInfo.toUserId == this.user_info.id){
         this.$dialog.confirm({
@@ -138,6 +141,7 @@ export default {
         })
       })
     },
+    // 接收名额提示
     confirm() {
       this.$dialog.confirm({
         title: "提示",

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

@@ -20,7 +20,7 @@
           ></userImage>
           <div class="info">
             <span
-              >{{ user_info.name
+              >{{ user_info.name?user_info.name:'未知'
               }}<van-icon
                 name="notes-o"
                 color="#E1B98B"
@@ -165,6 +165,7 @@ export default {
     }
   },
   methods: {
+    // 推广/学习标签切换
     selectTbs(i){
       if(this.user_info.marketable){
         if(i == 0&&this.tbsIndex != 0){
@@ -187,67 +188,34 @@ export default {
       // this.$router.push(`/course/adlist`);
       this.$router.push(`/course/limitChange`);
     },
+    // 清楚本地存储/测试用
     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();
-            } else if (!this.user_info.marketable){
-              this.tbsIndex = 1;
-            }
-            getUserCourseList();
+          if (this.user_info.marketable) {
+            getDealerCourseList();
+          } else if (!this.user_info.marketable){
+            this.tbsIndex = 1;
           }
+          getUserCourseList();
         });
       });
     },
     //获取用户数据
     init() {
-      isWxEnv()
-        .then(() => {
-          if (getWxToken() && localStorage.getItem("wx_user_info")) {
-            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) {
-                this.getDealerCourseList();
-              } else if (!this.user_info.marketable){
-                this.tbsIndex = 1;
-              }
-              this.getUserCourseList();
-            }
-          } else {
-            this.getUerInfo(this.wxId);
-          }
-        })
-        .catch(err => {
-          if (getWxToken() && localStorage.getItem("wx_user_info")) {
-            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) {
-                this.getDealerCourseList();
-              } else if (!this.user_info.marketable){
-                this.tbsIndex = 1;
-              }
-              this.getUserCourseList();
-            }
-          } else {
-            this.getUerInfo(this.wxId);
-          }
-        });
+      this.user_info = JSON.parse(localStorage.getItem("wx_user_info"));
+      if (this.user_info.marketable) {
+        this.getDealerCourseList();
+      } else if (!this.user_info.marketable){
+        this.tbsIndex = 1;
+      }
+      this.getUserCourseList();
     },
     //获取经销推广课程列表
     getDealerCourseList(done) {
@@ -289,11 +257,9 @@ export default {
     // 创建二维码
     creatQrCode() {
       if (!this.qrcodeStatus) {
-        console.log(
-          `http://192.168.0.102:8088/#/courseHome?pid=${
+        console.log(`${window.location.href.split("#")[0]}#/courseHome?pid=${
             JSON.parse(localStorage.getItem("wx_user_info")).id
-          }`
-        );
+          }`);
         this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
           text: `${window.location.href.split("#")[0]}#/courseHome?pid=${
             JSON.parse(localStorage.getItem("wx_user_info")).id
@@ -331,11 +297,6 @@ export default {
         path: url
       });
     },
-    // 下拉刷新
-    refresh(done) {
-      this.getDealerCourseList(done);
-      this.getUserCourseList(done);
-    }
   }
 };
 </script>
@@ -477,7 +438,7 @@ img {
     align-items: center;
     height: 100vh;
     .qrContent{
-      width: 65%;
+      width: 70%;
       border-radius: 0.2rem;
       overflow: hidden;
       .tit{

+ 0 - 94
src/view/course/user/courseAd.vue

@@ -1,94 +0,0 @@
-<template>
-  <div>
-    <van-nav-bar
-      :title="title"
-      right-text="名额变动"
-      @click-left="onClickLeft"
-      @click-right="onClickRight"
-    >
-      <template #left>
-        <van-icon name="wap-home-o" size="22" />
-      </template>
-    </van-nav-bar>
-    <div class="listContent">
-      <scroller ref="scroller" :on-infinite="onscrollB" :isInitRefresh="false">
-        <courseList
-          :dataList="courseMap"
-          :showNum="1"
-        ></courseList>
-      </scroller>
-    </div>
-  </div>
-</template>
-
-<script>
-import courseList from "../components/courseList.vue";
-export default {
-  name: "",
-  components: { courseList },
-  props: [],
-  data() {
-    return {
-      title: "我的推广",
-      courseMap: [
-        {
-          id: 123,
-          surplus: 120,
-          sale: 341,
-          title:
-            "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
-          price: 598,
-          courseNum: 14,
-          url: "/static/img/course.f1777cf.jpg"
-        },
-        {
-          id: 124,
-          surplus: 120,
-          sale: 341,
-          title:
-            "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
-          price: 598,
-          courseNum: 14,
-          url: "/static/img/course.f1777cf.jpg"
-        },
-        {
-          id: 125,
-          surplus: 120,
-          sale: 341,
-          title:
-            "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
-          price: 598,
-          courseNum: 14,
-          url: "/static/img/course.f1777cf.jpg"
-        }
-      ]
-    };
-  },
-  created() {},
-  methods: {
-    onscrollB() {
-      console.log("触底了");
-    },
-    onClickLeft() {
-      this.$router.push("/courseHome");
-    },
-    onClickRight() {
-      this.$router.push(`/course/limitChange`);
-    }
-  },
-  computed: {}
-};
-</script>
-<style scoped lang="scss">
-*{
-    margin: 0;
-    padding: 0;
-}
-img{
-    display: block;
-}
-.listContent{
-    height: calc(100vh - .9rem);
-    position: relative;
-}
-</style>

+ 12 - 20
src/view/course/user/courseAdDeal.vue

@@ -123,6 +123,7 @@ export default {
     this.init();
   },
   methods: {
+    // 分享课程方式选择
     onSelect(option) {
       if (option.name == "复制链接") {
         this.showGive = true;
@@ -146,6 +147,7 @@ export default {
         //   });
       }
     },
+    // 获取课程码
     getCourseCode(){
       createCourseCode(this.courseDetail.subjectId).then(res => {
         this.giveLink = `${
@@ -154,6 +156,7 @@ export default {
         this.copyLink(this.giveLink);
       });
     },
+    // 微信分享/未使用
     wxShare() {
       let that = this;
       let url = window.location.href;
@@ -205,25 +208,7 @@ export default {
           console.log(error);
         });
     },
-    //复制剪切板
-    copyLink2(event, text) {
-      let that = this;
-      //这里是复制目标的类名
-      let clipboard = new Clipboard(event, {
-        text: function() {
-          return text;
-        }
-      });
-      clipboard.on("success", function(e) {
-        e.clearSelection(); //清除选中的文字的选择状态
-        that.$toast.success("复制成功~");
-        that.showShare = false;
-      });
-
-      clipboard.on("error", function(e) {
-        console.error(e);
-      });
-    },
+    // 复制剪切板
     copyLink() {
       //创建输入框
       var input = document.createElement("input");
@@ -245,9 +230,11 @@ export default {
         this.showGive = false;
       }
     },
+    // 分享弹出
     comfirmCode() {
       this.showGive = true;
     },
+    // 触底加载
     getMoreList(done) {
       console.log("到底了");
       if (!this.noDate) {
@@ -258,6 +245,7 @@ export default {
         this.$refs.recordScroller.finishInfinite(true);
       }
     },
+    // 获取课程变动记录
     getRecord(done) {
       let data = {
         page: this.page.cur,
@@ -268,19 +256,23 @@ export default {
         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 (res.pages == res.current) {
+          console.log('已无更多')
           if (done) done(true);
           this.noDate = true;
         } else {
+          console.log('更多...')
           if (done) done();
           this.page.cur++; //下拉一次页数+1
           this.noDate = false;
         }
       });
     },
+    // 返回
     onClickLeft() {
       this.$router.go(-1);
     },
+    // 初始化
     init() {
       this.courseId = this.$route.params.id;
       this.courseDetail = JSON.parse(sessionStorage.getItem("course_detail"));

+ 17 - 6
src/view/course/user/courseDeal.vue

@@ -45,11 +45,12 @@
               </div>
             </van-tab>
           </van-tabs>
+          <div id="xxhh" style="height: 1.2rem;" v-if="!courseDetail.buy&&canGive"></div>
         </scroller>
       </div>
       <div
         class="getCourse"
-        v-if="!courseDetail.buy && codeDetail && codeDetail.enable"
+        v-if="!courseDetail.buy&&canGive"
         @click="useCode"
       >
         <van-button icon="fire-o" square class="getBtn"
@@ -84,6 +85,7 @@ export default {
         sections: [],
         buy: false
       },
+      canGive:true,
       giveCode: false,
       codeDetail: {
         enable: true
@@ -94,8 +96,10 @@ export default {
     this.init();
   },
   methods: {
+    // 领取课程提示
     useCode() {
-      this.$dialog
+      if(this.codeDetail.enable){
+        this.$dialog
         .confirm({
           title: "提示",
           message: "确定领取当前课程吗"
@@ -112,16 +116,17 @@ export default {
             this.getDetail();
           });
         });
+      }else{
+        this.$toast.fail("该课程码已失效");
+      }
     },
+    // 领取课程码课程
     getCodeDetail() {
       getCourseCodeDetail(this.$route.query.code).then(res => {
         this.codeDetail = res;
-        if (res && !res.enable) {
-          this.codeDetail.enable = false;
-          this.$toast.fail("该分享码已失效");
-        }
       });
     },
+    // 获取link对应的视频真实地址
     getVideoLink(link){
       let data = {
         subjectId:this.$route.params.id,
@@ -131,6 +136,7 @@ export default {
         window.location.href = res
       })
     },
+    // 章节点击观看视频
     toSectionVidio(item, index) {
       if (this.courseDetail.buy) {
         // this.getVideoLink(item.link)
@@ -146,16 +152,21 @@ export default {
         this.$toast.fail("请先领取课程后再观看");
       }
     },
+    // 返回首页
     onClickLeft() {
       this.$router.push('/courseHome');
     },
+    // 初始化
     init() {
       this.courseId = this.$route.params.id;
       this.getDetail();
       if (this.$route.query && this.$route.query.code) {
         this.getCodeDetail();
+      }else{
+        this.canGive = false;
       }
     },
+    // 获取分享码详情
     getDetail() {
       learnerCourseDetail(this.courseId).then(res => {
         this.courseDetail = res;

+ 9 - 13
src/view/course/user/deal.vue

@@ -63,7 +63,6 @@
           <courseList
             :dataList="courseList"
             :listType="2"
-            @dealComfirm="dealComfirm"
           ></courseList>
         </div>
         <noData :list="courseList" />
@@ -149,11 +148,13 @@ export default {
     this.init();
   },
   methods: {
+    // 初始化
     init() {
       this.user_info = this.$route.query;
       this.getList();
       this.getRecordList();
     },
+    // 初始化数据
     resetList() {
       this.active = 0;
       this.page.cur = 1;
@@ -167,6 +168,7 @@ export default {
       this.getList();
       this.getRecordList();
     },
+    // 触底加载
     getMoreList(done) {
       if (this.active == 0) {
         if (!this.noDate) {
@@ -186,6 +188,7 @@ export default {
         }
       }
     },
+    // 获取待确认的交易列表
     getList(done) {
       let data = {
         page: this.page.cur,
@@ -204,7 +207,7 @@ export default {
         this.courseList = this.courseList.concat(res.list);
         this.page.cur = res.current;
         this.page.total = res.total;
-        if (this.courseList.length >= this.page.total) {
+        if (res.pages == this.page.cur) {
           if (done) done(true);
           this.noDate = true;
         } else {
@@ -214,6 +217,7 @@ export default {
         }
       });
     },
+    // 获取已交易的列表
     getRecordList(done) {
       let data = {
         page: this.page1.cur,
@@ -224,7 +228,7 @@ export default {
         this.page1.cur = res.current;
         this.page1.total = res.total;
         this.recordList = this.recordList.concat(res.list);
-        if (this.recordList.length >= this.page1.total) {
+        if (res.pages == this.page1.cur) {
           console.log("没有更多")
           if (done) done(true);
           this.noDate1 = true;
@@ -235,21 +239,13 @@ export default {
         }
       });
     },
+    // 确认交易
     dealCourseNum() {
       this.$router.push(`/course/dealOrder/${this.$route.params.id}`);
     },
-    dealComfirm(res) {
-    },
+    // 标签切换
     activeChange(e) {
       this.active = e;
-      // this.page.cur = 1;
-      // this.page1.cur = 1;
-    },
-    toUrl(url, id) {
-      this.$router.push({
-        path: url,
-        params: id
-      });
     },
     //导航左侧返回
     onClickLeft() {

+ 7 - 3
src/view/course/user/login.vue

@@ -6,7 +6,7 @@
         <div class="tit">
           <p>请完善用户信息</p>
         </div>
-        <van-form @submit="onSubmit">
+        <van-form>
           <van-cell-group>
             <van-field
               v-model="form.name"
@@ -43,7 +43,7 @@
             </van-field>
           </van-cell-group>
           <div style="margin: 16px;">
-            <van-button block type="info" native-type="submit">提交</van-button>
+            <van-button block type="info" @click="onSubmit">提交</van-button>
           </div>
         </van-form>
       </div>
@@ -80,12 +80,13 @@ export default {
     this.init();
   },
   methods: {
+    // 初始化
     init() {
       if (this.$route.query && this.$route.query.pid) {
         this.pid = this.$route.query.pid;
       }
-      isWxEnv(this.pid)
     },
+    // 手机号校验
     checkMobile(sMobile) {
       if (!/^1\d{10}$/.test(sMobile)) {
         return false;
@@ -93,6 +94,7 @@ export default {
         return true;
       }
     },
+    // 获取验证码
     getYzm() {
       if (!this.checkMobile(this.form.mobile)) {
         this.$toast.fail("请输入正确的手机号");
@@ -110,6 +112,7 @@ export default {
           this.sendMsgLoading = false;
         });
     },
+    // 验证码发送倒计时
     countDownInit() {
       let self = this;
       self.sendMsgText = "已发送(" + self.countdown + ")";
@@ -125,6 +128,7 @@ export default {
         }, 1000);
       }
     },
+    // 注册经销商提交
     onSubmit() {
       if (this.form.name && this.checkMobile(this.form.mobile) && this.form.code) {
         let data = {

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

@@ -49,6 +49,7 @@ export default {
     this.init()
   },
   methods: {
+    // 触底加载
     getMoreList(){
       console.log("到底了")
       if(this.teamList.length<this.page.total && this.canReq){
@@ -62,6 +63,7 @@ export default {
         this.getList()
       }
     },
+    // 初始化
     init(){
         this.getList()
     },
@@ -83,6 +85,7 @@ export default {
         this.page.cur = 1
         this.getList();
     },
+    // 获取团队列表
     getList(){
       let data = {
         page:this.page.cur,
@@ -105,6 +108,7 @@ export default {
           this.canReq = true
       }
     },
+    // 搜索
     search(val){
       this.keyword = val;
       this.getList();

+ 58 - 3
src/view/course/user/wxAuth.vue

@@ -1,24 +1,79 @@
 <template>
 <div>
+  <van-loading style="position: absolute;top: 10%;left: 50%;transform: translateX(-.3rem);"/>
 </div>
 </template>
 
 <script>
+import {
+  getWxApiToken,
+  getUSerInfo,
+  getCourseCodeDetail
+} from "../api";
+import { isWxEnv } from "../utils";
+import {mapState,mapGetters} from 'vuex'
 export default {
   name: '',
   components: {},
     props: [],
   data () {
     return {
+      pid:null,
+      code:null,
     }
   },
   created () { 
-    
+    console.log(this.$route.query)
+    this.init()
+  },
+  computed:{
+    ...mapGetters(['wxid'])
   },
   methods: { 
-    
+    // 根据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.replace(`/courseLogin?pid=${this.$route.query.pid}`);
+          }else if(this.$route.query && this.$route.query.code){
+            getCourseCodeDetail(this.$route.query.code).then(res=>{
+              if(res != null){
+                this.$router.replace(`/course/courseDeail/${res.subjectId}?code=${this.$route.query.code}`);
+              }else{
+                this.$toast.fail("课程码无效")
+                this.$router.replace(`/courseHome`);
+              }
+            })
+          }else{
+            console.log(19)
+            this.$router.replace(`/courseHome`);
+          }
+        });
+      });
+    },
+    // 微信环境判断
+    wxAuth(type,data){
+      isWxEnv(type,data).then(()=>{
+        this.$router.replace(`/courseHome`);
+      }).catch(()=>{
+        console.log(12)
+        this.getUerInfo(this.wxid)
+      })
+    },
+    //初始化判断
+    init(){
+      if(this.$route.query && this.$route.query.pid){
+        this.wxAuth('pid',this.$route.query.pid)
+      }else if(this.$route.query && this.$route.query.code){
+        this.wxAuth('code',this.$route.query.code)
+      }else{
+        this.wxAuth()
+      }
+    }
    },
-  computed: {}
 }
 </script>
 <style scoped lang='scss'>

+ 21 - 17
src/view/course/utils/index.js

@@ -3,7 +3,7 @@ import Clipboard from "clipboard";
 import { getWxToken, setWxToken, openError } from "@/utils/auth";
 import { getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUserData, getEmployeeMap, getCache, setCache, removeCache, returnDeptName, getEmployeeMapItem, returnFh } from '@/utils/auth'
 //判断环境/登录状态
-export function isWxEnv(pid) {
+export function isWxEnv(type,data) {
     // return new Promise((resolve, reject) => {
     //     if (getWxToken()) {
     //         resolve()
@@ -14,13 +14,13 @@ export function isWxEnv(pid) {
     // })
     return new Promise((resolve, reject) => {
         if (getIsWx()) {
-            if (getWxToken()) {
-                Toast("微信环境已授权");
+            if (getWxToken()&&localStorage.getItem('wx_user_info')) {
+                // Toast("微信环境已授权");
                 resolve()
             } else {
                 Toast("微信环境未授权");
-                // doWeixinLogin(pid);
-                reject(3)
+                //测试用,正式隐藏
+                doWeixinLogin(type,data);
             }
         } else {
             Toast("当前不在微信环境中,请在微信中打开浏览");
@@ -29,25 +29,29 @@ export function isWxEnv(pid) {
     })
 }
 //请求微信授权
-export function doWeixinLogin(pid) {
+export function doWeixinLogin(type,data) {
+    let defaultUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=1'
     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'
+    let timinalUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=3&expendCode='
     if (getCache("isAndroid")) {
-        if (pid) {
-            window.open(`${dealerUrl}${pid}`)
-            // window.open(`${process.env.VUE_APP_WXURL}?marketing=1`);
-        } else {
-            window.open(`${timinalUrl}`)
+        if (type == 'pid'&&data) {
+            window.open(`${dealerUrl}${data}`)
+        } else if(type == 'code'&&data){
+            window.open(`${timinalUrl}${data}`)
+        }else{
+            window.open(`${defaultUrl}`)
         }
     } else {
-        // window.location.href = `${process.env.VUE_APP_WXURL}?marketing=1`;
-        if (pid) {
-            window.location.href = `${dealerUrl}${pid}`;
-        } else {
-            window.location.href = `${dealerUrl}`;
+        if (type == 'pid'&&data) {
+            window.location.href = `${dealerUrl}${data}`;
+        } else if(type == 'code'&&data){
+            window.location.href = `${timinalUrl}${data}`;
+        }else{
+            window.location.href = `${defaultUrl}`;
         }
     }
 }
+//复制(event必须为点击元素)
 export function copyLink(event) {
     let that = this;
     //这里是复制目标的类名

+ 5 - 1
src/view/course/video/video.vue

@@ -79,6 +79,7 @@ export default {
     this.init();
   },
   methods: {
+    // 章节切换获取视频地址
     toSectionVidio(item,i) {
       this.courseDetail.sections.forEach((item,index)=>{
         item.active = false;
@@ -94,6 +95,7 @@ export default {
       this.getVideoLink(item.link)
       // this.videoSrc = this.courseDetail.sections[index].link
     },
+    // 获取视频地址
     getVideoLink(link){
       let data = {
         subjectId:this.$route.params.id,
@@ -105,14 +107,17 @@ export default {
         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)=>{
@@ -125,7 +130,6 @@ export default {
       })
     },
   },
-  computed: {}
 };
 </script>
 <style scoped lang="scss">