guojy 1 vuosi sitten
vanhempi
commit
74a9f8dd0e

+ 19 - 17
src/permission.js

@@ -2,28 +2,18 @@ import Vue from 'vue'
 import router from './router'
 import store from './store'
 import { getToken, getWxToken } from '@/utils/auth'
+//课程免登录名单
+const whiteList = ['/courseHome', '/courseDeal/', '/courseTeam/', '/course/courseManage', '/course/courseCreate', '/course/dealerManage']
+function filterWhite(path) {
+  return (path.includes('/courseTeam/') || path.includes('/courseDeal/') || path.includes('/courseDetail/'))
+}
 router.beforeEach((to, from, next) => {
   if (Vue.$httpRequestList.length > 0) { //强行中断时才向下执行
     Vue.$httpRequestList.forEach(item => {
       item('interrupt'); //给个标志,中断请求
     })
   }
-  if (to.path == '/courseHome') {
-    console.log(1)
-    next()
-    // if (getWxToken()) {
-    //   console.log(2)
-    //   next()
-    // } else {
-    //   console.log(3)
-    //   window.document.title = '用户登录'
-    //   next({ path: '/courseLogin', query: to.query })
-    // }
-  } else if (to.path == '/courseLogin') {
-    console.log(4)
-    next()
-  }else if (getToken()) {
-    console.log(5)
+  if (getToken() && whiteList.indexOf(to.path) === -1 && filterWhite(to.path)) {
     if (to.path == '/login' || to.path == '/') { // 在免登录白名单,直接进入
       next({ name: 'home' })
       return false
@@ -36,8 +26,20 @@ router.beforeEach((to, from, next) => {
     // 初始一些数据
     init(next);
     // next();
+  } else if (whiteList.indexOf(to.path) !== -1 || filterWhite(to.path)) {
+    console.log(2)
+    if (getWxToken()) {
+      if (typeof (window.$routes_map[to.name]) != 'undefined') {
+        window.document.title = window.$routes_map[to.name].label
+      } else {
+        window.document.title = '功道云课程'
+      }
+      next()
+    }else{
+      next('courseLogin')
+    }
   } else {
-    console.log(6)
+    console.log(3)
     if (!window.$routes_map[to.name].need_login) { // 在免登录白名单,直接进入
       if (typeof (window.$routes_map[to.name]) != 'undefined') {
         window.document.title = window.$routes_map[to.name].label

+ 10 - 3
src/router/course.js

@@ -12,21 +12,28 @@
       name: 'courseHome',
       component: () => import('@/view/course/home'),
       label: '课程首页',
-      need_login: false,
+      need_login: true,
     },
     {
       path: '/courseTeam/:id',
       name: 'courseHome',
       component: () => import('@/view/course/user/team'),
       label: '我的团队',
-      need_login: false,
+      need_login: true,
     },
     {
       path: '/courseDeal/:id',
       name: 'courseDeal',
       component: () => import('@/view/course/user/deal'),
       label: '课程交易',
-      need_login: false,
+      need_login: true,
+    },
+    {
+      path: '/courseDetail/:id',
+      name: 'courseDetail',
+      component: () => import('@/view/course/user/courseDeal'),
+      label: '课程详情',
+      need_login: true,
     },
 ]
 export default routes

+ 0 - 1
src/utils/auth.js

@@ -378,4 +378,3 @@ export function removeWxToken() {
     return localStorage.removeItem(WxTokenKey)
   }
 }
-

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

@@ -11,7 +11,7 @@
             }}<span>【{{ item.dealNumber }}】套</span>课程
           </p>
         </div>
-        <div class="listLiTop">
+        <div class="listLiTop" @click="toUrl(item.id)">
           <img :src="item.url" />
           <div class="liInfo">
             <div class="courseLiTit">
@@ -63,13 +63,15 @@ export default {
       type: String,
       default: ""
     },
+    //是否有底部剩余数量
     showNum: {
       type: Boolean,
       default: false
     },
+    //是否需要展示课程接收按钮(1不需要2需要)
     listType:{
       type:Number,
-      default:"1"
+      default:1
     }
   },
   data() {
@@ -78,8 +80,22 @@ export default {
   created() {},
   mounted() {},
   methods: {
+    toUrl(id){
+      // console.log(item)
+      this.$router.push(`/courseDetail/${id}`)
+    },
     comfirm(item){
-      this.$emit('dealComfirm',item)
+      console.log(item)
+      if(item.dealStatus == 3){
+        this.$dialog.confirm({
+         title: '提示',
+         message: '确定要接受名额转入吗?',
+        }).then(() => {
+          this.$emit('dealComfirm',item)
+        }).catch(() => {
+         
+        })
+      }
     }
   },
   computed: {}

+ 14 - 11
src/view/course/home.vue

@@ -75,6 +75,7 @@
             :fixedTitle="courseClass.learnCourse.title"
           ></courseList>
         </div>
+        <div style="height: .01rem;"></div>
       </scroller>
     </div>
   </div>
@@ -85,10 +86,7 @@ import Vue from "vue";
 import Clipboard from "clipboard";
 import { getWxToken, setWxToken, openError } from "@/utils/auth";
 import { isWxEnv } from "./utils";
-import { Col, Row } from "vant";
 import courseList from "./components/courseList.vue";
-Vue.use(Col);
-Vue.use(Row);
 export default {
   name: "",
   components: {
@@ -97,7 +95,6 @@ export default {
   props: [],
   data() {
     return {
-      scrollH: "calc(100% - 2rem)",
       isWx: true,
       isAndroid: this.$getCache("isAndroid"),
       user_info: {
@@ -112,31 +109,34 @@ export default {
           title: "我推广的课程",
           courseList: [
             {
+              id:123,
               surplus: 120,
               sale: 341,
               title:
                 "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
               price: 598,
               courseNum: 14,
-              url: "../../../assets/course.jpg"
+              url: "/static/img/course.f1777cf.jpg"
             },
             {
+              id:124,
               surplus: 120,
               sale: 341,
               title:
                 "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
               price: 598,
               courseNum: 14,
-              url: "../../../assets/course.jpg"
+              url: "/static/img/course.f1777cf.jpg"
             },
             {
+              id:125,
               surplus: 120,
               sale: 341,
               title:
                 "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
               price: 598,
               courseNum: 14,
-              url: "../../../assets/course.jpg"
+              url: "/static/img/course.f1777cf.jpg"
             }
           ]
         },
@@ -144,22 +144,24 @@ export default {
           title: "我学习的课程",
           courseList: [
             {
+              id:126,
               surplus: 120,
               sale: 341,
               title:
                 "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
               price: 598,
               courseNum: 14,
-              url: "../../../assets/course.jpg"
+              url: "/static/img/course.f1777cf.jpg"
             },
             {
+              id:127,
               surplus: 120,
               sale: 341,
               title:
                 "大撒大声地大萨达大萨达撒大声地的撒旦撒旦撒打算打算大萨达萨达大萨达",
               price: 598,
               courseNum: 14,
-              url: "../../../assets/course.jpg"
+              url: "/static/img/course.f1777cf.jpg"
             }
           ]
         }
@@ -241,7 +243,7 @@ export default {
   position: relative !important;
   background-color: #eee;
   .userInfo {
-    padding: 0.24rem 0.32rem;
+    padding: 0.24rem 0.32rem .12rem;
     .userImage {
       display: flex;
       align-items: center;
@@ -309,7 +311,8 @@ export default {
     }
   }
   .courScroll {
-    height: calc(100vh - 2rem) !important;
+    height: calc(100vh - 2.4rem) !important;
+    position: relative;
     .cScroll {
       height: 100%;
       position: relative !important;

+ 44 - 0
src/view/course/user/courseDeal.vue

@@ -0,0 +1,44 @@
+<template>
+<div class="page">
+  <van-nav-bar
+      :title="title"
+      left-text="返回"
+      left-arrow
+      @click-left="onClickLeft"
+    ></van-nav-bar>
+    pageDetail
+</div>
+</template>
+
+<script>
+export default {
+  name: '',
+  components: {},
+    props: [],
+  data () {
+    return {
+      title:"课程详情",
+      
+    }
+  },
+  created () { 
+    this.init()
+  },
+  methods: {
+    onClickLeft(){
+      this.$router.go(-1)
+    },
+    init(){
+      this.courseId = this.$route.params.id
+      console.log(courseId)
+    },
+  },
+  computed: {}
+}
+</script>
+<style scoped lang='scss'>
+    .page{
+        padding: 0 .2rem;
+        background-color: #FFF;
+    }
+</style>

+ 30 - 22
src/view/course/user/deal.vue

@@ -38,7 +38,12 @@
       </van-row>
     </div>
     <div class="user_tabs">
-      <van-tabs v-model="active" @click="activeChange" animated title-active-color="#26A2FF">
+      <van-tabs
+        v-model="active"
+        @click="activeChange"
+        animated
+        title-active-color="#26A2FF"
+      >
         <van-tab
           v-for="(item, index) in activeList"
           :key="index"
@@ -74,6 +79,9 @@
         </div>
       </scroller>
     </div>
+    <van-dialog v-model="showDealNum" title="交易课程名额" show-cancel-button>
+      <span>交易</span>
+    </van-dialog>
   </div>
 </template>
 
@@ -91,6 +99,7 @@ export default {
   props: [],
   data() {
     return {
+      showDealNum: false,
       title: "交易",
       activeList: ["待确认的交易", "已交易的记录"],
       active: 0,
@@ -109,7 +118,7 @@ export default {
           courseNum: 14,
           url: "../../../assets/course.jpg",
           direction: "to",
-          dealStatus: 1,
+          dealStatus: 2,
           dealNumber: 60
         },
         {
@@ -119,7 +128,7 @@ export default {
           courseNum: 14,
           url: "../../../assets/course.jpg",
           direction: "from",
-          dealStatus: 1,
+          dealStatus: 3,
           dealNumber: 35
         }
       ],
@@ -128,7 +137,7 @@ export default {
           title: "出吧v发给别的发光飞碟",
           beizhu: "但是反反复复毒贩夫妇",
           direction: "to",
-          dealStatus: 1,
+          dealStatus: 4,
           dealNumber: 60,
           create_time: "2012-10-09"
         },
@@ -136,7 +145,7 @@ export default {
           title: "出吧v发给别的发光飞碟",
           beizhu: "但是反反复复毒贩夫妇",
           direction: "to",
-          dealStatus: 1,
+          dealStatus: 4,
           dealNumber: 60,
           create_time: "2012-10-09"
         },
@@ -144,7 +153,7 @@ export default {
           title: "出吧v发给别的发光飞碟",
           beizhu: "但是反反复复毒贩夫妇",
           direction: "to",
-          dealStatus: 1,
+          dealStatus: 4,
           dealNumber: 60,
           create_time: "2012-10-09"
         },
@@ -152,7 +161,7 @@ export default {
           title: "出吧v发给别的发光飞碟",
           beizhu: "但是反反复复毒贩夫妇",
           direction: "to",
-          dealStatus: 1,
+          dealStatus: 4,
           dealNumber: 60,
           create_time: "2012-10-09"
         },
@@ -160,7 +169,7 @@ export default {
           title: "出吧v发给别的发光飞碟",
           beizhu: "但是反反复复毒贩夫妇",
           direction: "to",
-          dealStatus: 1,
+          dealStatus: 4,
           dealNumber: 60,
           create_time: "2012-10-09"
         }
@@ -168,12 +177,14 @@ export default {
     };
   },
   created() {
-    this.init()
+    this.init();
   },
   methods: {
-    dealCourseNum(){},
-    init(){
-        console.log(this.$route)
+    dealCourseNum() {
+      this.showDealNum = true;
+    },
+    init() {
+      console.log(this.$route);
     },
     dealComfirm(res) {
       console.log(res);
@@ -192,8 +203,8 @@ export default {
           price: 598,
           courseNum: 14,
           url: "../../../assets/course.jpg",
-          direction: "to",
-          dealStatus: 4,
+          direction: "from",
+          dealStatus: 3,
           dealNumber: 60
         },
         {
@@ -202,16 +213,12 @@ export default {
           price: 598,
           courseNum: 14,
           url: "../../../assets/course.jpg",
-          direction: "from",
-          dealStatus: 4,
+          direction: "to",
+          dealStatus: 2,
           dealNumber: 35
         }
       ];
-      setTimeout(() => {
-        if (e == 1) {
-          this.courseList = data;
-        }
-      }, 500);
+      this.courseList = data;
     },
     toUrl(url, id) {
       this.$router.push({
@@ -281,9 +288,10 @@ export default {
     }
   }
   .user_tabs {
-    padding: 0 0.2rem;
+    margin: 0 0.2rem;
     border-radius: 0.1rem;
     position: relative;
+    overflow: hidden;
     &::after {
       content: "";
       width: 1px;