guojy 1 год назад
Родитель
Сommit
57897af099

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 .DS_Store
 node_modules/
 /dist/
+/devtest/
 npm-debug.log*
 yarn-debug.log*
 yarn-error.log*

+ 15 - 2
src/view/course/api/index.js

@@ -74,7 +74,7 @@ export function addDealer(data) {
     })
 }
 
-//获取经销商推广的课程/mkt/client/{userId}/subject/list
+//获取经销商推广的课程
 export function getDealerCourseList() {
     return new Promise((resolve, reject) => {
         axiosKc('get', `/mkt/client/${getWxUserId()}/capital/list`).then((res) => {
@@ -87,7 +87,20 @@ export function getDealerCourseList() {
         })
     })
 }
-//获取经销商推广的课程
+//获取经销商推广的指定课程
+export function getDealerCourseDetail(id) {
+    return new Promise((resolve, reject) => {
+        axiosKc('get', `/mkt/client/${getWxUserId()}/capital/info/${id}`).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Notify({ type: 'danger', message: data.message });
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//获取学员学习的课程
 export function getUserCourseList() {
     return new Promise((resolve, reject) => {
         axiosKc('get', `/mkt/client/${getWxUserId()}/subject/list`).then((res) => {

+ 14 - 21
src/view/course/components/courseList.vue

@@ -123,27 +123,20 @@ export default {
   methods: {
     // 查看课程详情
     toUrl(item) {
-      if (!item.status) {
-        if (
-          !this.isNoAd &&
-          this.$route.path != `/courseAdDetail/${item.subjectId}`
-        ) {
-          sessionStorage.setItem("course_detail", JSON.stringify(item));
-          this.$router.push({
-            path: `/courseAdDetail/${item.subjectId}`
-          });
-        } else if (
-          this.isNoAd &&
-          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}`
-            })
-        }
+      if(this.isNoAd){
+        this.$router.push(`/courseDetail/${item.subjectId}`);
+      }else if(this.showNum == 1 ){
+        this.$router.push({
+          path: `/courseAdDetail/${item.id}-${item.subjectId}`
+        });
+      }else if(this.showNum == 2 ){
+        this.$router.push({
+          path: `/courseDetail/${item.subjectId}`
+        });
+      }else if(this.showNum == 3 ){
+        // this.$router.push({
+        //   path: `/courseAdDetail/${item.subjectId}`
+        // });
       }else if(item.status == 1 && this.listType == 2){
         this.comfirm(item)
       }

+ 28 - 21
src/view/course/user/courseAdDeal.vue

@@ -66,13 +66,13 @@
         </div>
         <div class="copy">
           <p><van-icon name="info-o" /> 链接分享后,1小时内有效</p>
-          <van-button
+          <!-- <van-button
             style="padding: 0 1rem;border-radius: 0.4rem;"
             color="#26A2FF"
             class="copyCode"
             @click="getCourseCode"
-            >复制链接</van-button>
-            <!-- <button ref="copys" :disabled="giveLink == ''"  id="copyLink"  data-clipboard-action="copy" data-clipboard-target="#copy_text" @click="copy">复制</button> -->
+            >复制链接</van-button> -->
+            <button ref="copys"  id="copyLink"  data-clipboard-action="copy" data-clipboard-target="#copy_text" @click="copy">复制链接</button>
         </div>
       </div>
     </van-overlay>
@@ -81,7 +81,7 @@
   </div>
 </template>
 <script>
-import { getCourseRecordList, createCourseCode } from "../api";
+import { getCourseRecordList, createCourseCode ,getDealerCourseDetail} from "../api";
 import Clipboard from "clipboard";
 import axios from "axios";
 import courseList from "../components/courseList.vue";
@@ -91,12 +91,14 @@ export default {
   props: [],
   data() {
     return {
+      subjectId:0,
+      courseId:0,
       showShare: false,
       loading: false,
       finished: false,
       activeTab: 0,
       title: "课程详情",
-      giveLink: "232123123",
+      giveLink: "",
       noDate: false,
       showGive: false,
       options: [
@@ -142,9 +144,7 @@ export default {
     this.init();
   },
   mounted(){
-    
     this.copyBtn = new Clipboard(this.$refs.copys);
-
   },
   methods: {
     //复制
@@ -165,16 +165,25 @@ export default {
         this.showShare = false;
       }
     },
+    //获取课程详情
+    getCourseDetail(){
+      getDealerCourseDetail(this.courseId).then(res=>{
+        this.courseDetail = res
+      })
+    },
     // 获取课程码
     getCourseCode() {
       createCourseCode(this.courseDetail.subjectId).then(res => {
         this.giveLink = `${window.location.href.split("#")[0]}#/courseDetail/${
-          this.$route.params.id
+          this.subjectId
         }?code=${res}`;
-        this.copyLink().then(()=>{
-          this.$toast.success('复制成功')
-        })
-        // this.showGive = true;
+        console.log(this.giveLink)
+        this.showGive = true;
+        // this.getCourseDetail();
+        // this.copyLink().then(()=>{
+        //   this.$toast.success('复制成功')
+        //   this.showGive = false;
+        // })
       });
     },
     // 复制剪切板
@@ -200,12 +209,11 @@ export default {
     },
     // 分享弹出
     comfirmCode() {
-      this.showGive = true;
-      // this.getCourseCode()
+      // this.showGive = true;
+      this.getCourseCode()
     },
     // 触底加载
     getMoreList(done) {
-      console.log("到底了");
       if (!this.noDate) {
         setTimeout(() => {
           this.getRecord(done);
@@ -219,18 +227,16 @@ export default {
       let data = {
         page: this.page.cur,
         pageSize: this.page.size,
-        subjectId: this.courseId
+        subjectId: this.subjectId
       };
       getCourseRecordList(data).then(res => {
         this.recordList = this.recordList.concat(res.list);
         this.page.cur = res.current;
         this.page.total = res.total;
         if (res.pages == res.current || res.pages == 0) {
-          console.log("已无更多");
           if (done) done(true);
           this.noDate = true;
         } else {
-          console.log("更多...");
           if (done) done();
           this.page.cur++; //下拉一次页数+1
           this.noDate = false;
@@ -243,10 +249,11 @@ export default {
     },
     // 初始化
     init() {
-      this.courseId = this.$route.params.id;
-      this.courseDetail = JSON.parse(sessionStorage.getItem("course_detail"));
+      let arr = this.$route.params.id.split('-')
+      this.courseId = arr[0];
+      this.subjectId = arr[1]
+      this.getCourseDetail();
       this.getRecord();
-      // this.wxShare();
     },
     destroyed() {
       sessionStorage.removeItem("course_detail");

+ 15 - 7
src/view/course/user/courseDeal.vue

@@ -54,12 +54,12 @@
               </div>
             </van-tab>
           </van-tabs>
-          <div id="xxhh" style="height: 1.2rem;" v-if="!courseDetail.buy&&canGive"></div>
+          <div id="xxhh" style="height: 1.2rem;" v-if="!courseDetail.buy&&canGive&&canGive2"></div>
         </scroller>
       </div>
       <div
         class="getCourse"
-        v-if="!courseDetail.buy&&canGive"
+        v-if="!courseDetail.buy&&canGive&&canGive2"
         @click="useCode"
       >
         <van-button icon="fire-o" square class="getBtn"
@@ -96,6 +96,7 @@ export default {
         buy: false
       },
       canGive:true,
+      canGive2:true,
       giveCode: false,
       codeDetail: {
         enable: true
@@ -193,6 +194,9 @@ export default {
           !this.giveCode
         ) {
           this.$toast.fail("您已经购买课程,无需再次购买");
+        }else if(!res.enable){
+          this.canGive2 = false;
+          this.$toast.fail("分享码已失效!");
         }
       });
     }
@@ -227,11 +231,15 @@ img {
         font-size: 0.32rem;
         font-weight: 600;
         color: #000;
-        line-height: 1rem;
-        overflow: hidden;
-        text-overflow: ellipsis;
-        white-space: nowrap;
-        word-break: break-all;
+        line-height: .4rem;
+        padding: 0.1rem 0;
+        /* white-space: pre-wrap; */
+        /* overflow: hidden; */
+        /* text-overflow: ellipsis; */
+        /* white-space: nowrap; */
+        /* word-break: break-all; */
+        width: 100%;
+        word-wrap: break-word;
       }
     }
     .tabs {

+ 121 - 53
src/view/course/user/wxAuth.vue

@@ -1,84 +1,152 @@
 <template>
-<div>
-  <div class="center"  style="position: absolute;top: 10%;left: 50%;transform: translateX(-50%);text-align: center;">
-    <van-loading size="24px" style="margin-bottom: .3rem;">请在微信端授权后再使用完整服务...</van-loading>
-    <van-button type="primary"  @click="init">授权获取完整服务</van-button>
+  <div class="page">
+    <template v-if="isWx">
+      <div class="wxTop">
+      <van-image class="logo" :src="logo" type="contain" />
+    </div>
+    <div class="center">
+      <p>申请获取以下权限</p>
+      <span>获取您的公开信息(昵称、头像等)</span>
+      <button class="btn" @click="init"
+        >微信授权</button>
+    </div>
+    </template>
+    <template v-else>
+      <div class="center"  style="width: 80%;position: absolute;top: 10%;left: 50%;transform: translateX(-50%);">
+        <van-loading size="24px" style="margin-bottom: 0.3rem;display: flex;flex-direction: column;justify-content: center;align-items: center;">请在微信端授权后再使用完整服务...</van-loading>
+      </div>
+    </template>
   </div>
-  
-</div>
 </template>
 
 <script>
-import {
-  getWxApiToken,
-  getUSerInfo,
-  getCourseCodeDetail
-} from "../api";
+import { getWxApiToken, getUSerInfo, getCourseCodeDetail } from "../api";
 import { isWxEnv } from "../utils";
-import {mapState,mapGetters} from 'vuex'
+import { mapState, mapGetters } from "vuex";
 export default {
-  name: '',
+  name: "",
   components: {},
-    props: [],
-  data () {
+  props: [],
+  data() {
     return {
-      pid:null,
-      code:null,
-    }
+      isWx:false,
+      pid: null,
+      code: null,
+      logo: require("../../../../static/images/course_logo.png")
+    };
   },
-  created () { 
-    this.init()
+  created() {
+    this.init();
   },
-  computed:{
-    ...mapGetters(['wxid'])
+  computed: {
+    ...mapGetters(["wxid"])
   },
-  methods: { 
+  methods: {
     // 根据wxid获取微信个人数据
     getUerInfo(wxid) {
+      console.log('测试用,正式删除')
       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&&!this.user_info.marketable) {
+          if (
+            this.$route.query &&
+            this.$route.query.pid &&
+            !this.user_info.marketable
+          ) {
             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){
-            let codeArr =  this.$route.query.code.split('-')
-            this.$router.replace(`/course/courseDeail/${codeArr[1]}?code=${codeArr[0]}`);
-            // 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{
+          } else if (this.$route.query && this.$route.query.code) {
+            let codeArr = this.$route.query.code.split("-");
+            this.$router.replace(
+              `/course/courseDeail/${codeArr[1]}?code=${codeArr[0]}`
+            );
+          } else {
             this.$router.replace(`/courseHome`);
           }
         });
       });
     },
     // 微信环境判断
-    wxAuth(type,data){
-      isWxEnv(type,data).then(()=>{
-        this.$router.replace(`/courseHome`);
-      }).catch(()=>{
-        this.getUerInfo(this.wxid)
-      })
+    wxAuth(type, data) {
+      isWxEnv(type, data)
+        .then(() => {
+          this.isWx = true;
+          this.$router.replace(`/courseHome`);
+        })
+        .catch((e) => {
+          if(e == 1){
+            this.isWx = true;
+          }else{
+            this.isWx = false;
+            // 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()
+    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();
       }
+      // this.$dialog
+      //   .confirm({
+      //     title: "提示",
+      //     message: "本程序需要提供您的用户信息"
+      //   })
+      //   .then(() => {
+          
+      //   })
+      //   .catch(() => {});
     }
-   },
-}
+  }
+};
 </script>
-<style scoped lang='scss'>
-
+<style scoped lang="scss">
+*{
+  margin: 0;
+  padding: 0;
+}
+.page {
+  box-sizing: border-box;
+  padding: 0 0.4rem;
+  .wxTop {
+    padding: 1rem 0;
+    border-bottom: 1px solid #ddd;
+    .logo {
+      border-radius: 0.2rem;
+      overflow: hidden;
+      display: block;
+      width: 50%;
+      margin: 0 auto;
+    }
+  }
+  .center {
+    padding-top: .5rem;
+    p{
+      font-size: .28rem;
+      margin-bottom: .3rem
+    }
+    span{
+      font-size: .26rem;
+      color: #888;
+      display: block;
+      margin-bottom: 0.5rem;
+    }
+    .btn{
+      margin: 0 auto;
+      width: 90%;
+      display: block;
+      border-radius: 0.4rem;
+      background-color: #26A2FF;
+      color: #fff;
+      font-size: .32rem;
+      line-height: .8rem;
+      border: 0;
+      outline: none;
+    }
+  }
+}
 </style>

+ 10 - 11
src/view/course/utils/index.js

@@ -4,27 +4,26 @@ 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(type,data) {
-    // return new Promise((resolve, reject) => {
-    //     if (getWxToken()) {
-    //         resolve()
-    //     } else {
-    //         // Toast("当前未授权微信信息");
-    //         reject(1)
-    //     }
-    // })
     return new Promise((resolve, reject) => {
         if (getIsWx()) {
             if (getWxToken()&&localStorage.getItem('wx_user_info')) {
                 // Toast("微信环境已授权");
                 resolve()
             } else {
-                Toast("微信环境未授权");
+                // Toast.fail("微信环境未授权");
+                reject(1)
                 //测试用,正式隐藏
                 doWeixinLogin(type,data);
             }
         } else {
-            Toast("当前不在微信环境中,请在微信中打开浏览");
-            reject(2)
+            // Toast.fail("当前不在微信环境中,请在微信中打开浏览");
+            // reject(2)
+            if (getWxToken()&&localStorage.getItem('wx_user_info')) {
+                resolve()
+            } else {
+                Toast.fail("当前不在微信环境中,请在微信中打开浏览");
+                reject(2)
+            }
         }
     })
 }

+ 3 - 0
src/view/course/video/video.vue

@@ -131,6 +131,9 @@ export default {
     // 获取课程详情
     getDetail(){
       learnerCourseDetail(this.courseId).then(res=>{
+        console.log(res)
+        this.title = res.name
+        document.title = res.name
         res.sections.forEach((item,index)=>{
           item.active = false;
         })

+ 48 - 30
src/view/user/wxInit.vue

@@ -18,8 +18,8 @@
 7.考勤系统审批 (请假,出差,加班,补卡,外出) type=7   考勤审批ID
 8.okr计划 (创建任务指派的,任务审批的) type=8   okr计划ID -->
 <script>
-import { getToken,getWxToken ,getUserToken} from "@/utils/auth";
-import {getUSerInfo} from '@/view/course/api'
+import { getToken, getWxToken, getUserToken } from "@/utils/auth";
+import { getUSerInfo } from "@/view/course/api";
 import router from "../../router";
 export default {
   name: "wxInit",
@@ -39,8 +39,12 @@ export default {
       let request = this.getStr(url);
       let data = { name: "home", query: {} };
       let site_info = this.$getCache("site_info");
-      console.log(request)
-      if (request && request.type && (request.type == 1 || request.type == 2)) {
+      console.log(request);
+      if (
+        request &&
+        request.type &&
+        !(request.type == 9 || request.type == 10 || request.type == 11)
+      ) {
         if (request.type == 1 || request.type == 2) {
           //微信账号有绑定平台账号
           if (request.code) {
@@ -48,12 +52,14 @@ export default {
               code: request.code
             }).then(res => {
               let data = res.data.data;
-              if (data.account_id !== 0) {
-                //微信已经绑定
-                localStorage.setItem("Wx-Token", data.wo_token); // 保存平台账号登录的token
+              if (data.account_id === 0) {
+                //微信未绑定
+                data = { name: "regWx", query: { wo_token: data.wo_token } };
+                this.openUrl(data);
+              } else {
+                localStorage.setItem("a-token-temp", data.token); // 保存平台账号登录的token
+                this.openUrl2(data.account_site, data.invitation_wait_count);
               }
-              data = { name: "regWx", query: { wo_token: data.wo_token } };
-              this.$router.push(data);
             });
           }
           return false;
@@ -110,30 +116,42 @@ export default {
             this.openHome("OKR模块未开通,请联系管理员开通使用。");
           }
         }
-      } else if (request && request.type && (request.type == 9 || request.type == 10 || request.type == 11)) {
+      } else if (
+        request &&
+        request.type &&
+        (request.type == 9 || request.type == 10 || request.type == 11)
+      ) {
         if (request.code) {
           this.$axios("POST", "/api/pro/wo/mp/code", {
-              code: request.code
-            }).then(res => {
-              let data = res.data.data;
-                //微信已经绑定
-              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!=undefined&&!ress.marketable){
-                  this.$router.push(`/courseLogin?pid=${request.pid}`)
-                }else if(request.type == 11&&request.expendCode&&request.subjectId){
-                  this.$router.push({
-                    path:`/courseDetail/${request.subjectId}`,
-                    query:{
-                      code:request.expendCode
-                    }
-                  })
-                }else{
-                  this.$router.push('/courseHome')
-                }
-              })
+            code: request.code
+          }).then(res => {
+            let data = res.data.data;
+            //微信已经绑定
+            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 != undefined &&
+                !ress.marketable
+              ) {
+                this.$router.push(`/courseLogin?pid=${request.pid}`);
+              } else if (
+                request.type == 11 &&
+                request.expendCode &&
+                request.subjectId
+              ) {
+                this.$router.push({
+                  path: `/courseDetail/${request.subjectId}`,
+                  query: {
+                    code: request.expendCode
+                  }
+                });
+              } else {
+                this.$router.push("/courseHome");
+              }
             });
+          });
         }
       }
     },

BIN
static/images/course_logo.png