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

+ 5 - 1
src/components/UserImage.vue

@@ -1,6 +1,6 @@
 <template>
   <div style="text-align: center;">
-    <el-image v-if="img_url" :src="img_url" :style="{ width: width, height: height }" style="border-radius: 50%;margin: 0 auto;" fit="fill">
+    <el-image v-if="img_url" :src="img_url" :style="{ width: width, height: height ,'border-radius':radius}" style="margin: 0 auto;" fit="fill">
       <div slot="error" class="image-slot"><i class="el-icon-picture"></i></div>
     </el-image>
     <span class="img_round" v-else>
@@ -21,6 +21,10 @@ export default {
       type: String,
       default: '40px'
     },
+    radius:{
+      typoe:String,
+      default:"50%"
+    },
     id: {
       type: Number,
       default: 0

+ 109 - 0
src/course/api/index.js

@@ -0,0 +1,109 @@
+import axiosKc from '@/utils/axiosKc'
+import { getCourseId } from '@/utils/auth'
+import {
+    Message
+} from 'element-ui'
+//wxid获取用户token
+export function getUserToken(wxId) {
+    return new Promise((resolve, reject) => {
+        axiosKc('get', `/mkt/demo/token/wo/${wxId}`).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+// 用户token获取管理员id和token
+export function getAdminTokenId(token) {
+    return new Promise((resolve, reject) => {
+        axiosKc('post', '/mkt/admin/login', {}, '', '', '', token).then(res => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//获取课程列表
+export function getCourseList(data) {
+    return new Promise((resolve, reject) => {
+        axiosKc('get', `/mkt/admin/${getCourseId()}/subject/list`, data).then(res => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//删除课程
+export function deleteCourse(id) {
+    return new Promise((resolve, reject) => {
+        axiosKc('post', `/mkt/admin/${getCourseId()}/subject/delete/${id}`).then(res => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//获取课程详情
+export function getCourseDetail(curId) {
+    return new Promise((resolve, reject) => {
+        axiosKc("get", `/mkt/admin/${getCourseId()}/subject/info/${curId}`).then(res => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//创建课程
+export function createCourse(data) {
+    return new Promise((resolve, reject) => {
+        axiosKc("post",`/mkt/admin/${getCourseId()}/subject/create`,data).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//修改课程
+export function updataCourse(id,data) {
+    return new Promise((resolve, reject) => {
+        axiosKc("post",`/mkt/admin/${getCourseId()}/subject/update/${id}`,data).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}
+//获取经销商/普通看视频用户列表
+export function getDealerList(data) {
+    return new Promise((resolve, reject) => {
+        axiosKc("get",`/mkt/admin/${getCourseId()}/user/list`,data).then((res) => {
+            if (res.data.code == 1) {
+                resolve(res.data.data)
+            } else {
+                Message(res.data.message)
+                reject(res.data.message)
+            }
+        })
+    })
+}

+ 142 - 132
src/course/courseManage/create.vue

@@ -1,4 +1,4 @@
-<!-- 角色创建/修改 -->
+<!-- 课程创建/修改 -->
 
 <template>
   <div class="pjc">
@@ -6,76 +6,56 @@
     <h3>{{ title }}</h3>
     <el-form :model="courseDeail" label-width="110px">
       <el-form-item label="课程名称:">
-        <el-input v-model.trim="courseDeail.name"></el-input>
+        <el-input v-model.trim="courseDeail.name" style="width: 40%"></el-input>
       </el-form-item>
       <el-form-item label="预览图:">
-        <div style="width: 68px;" @click="showSelectImg()">
+        <div style="width: 68px" @click="showSelectImg(1)">
           <userImage
             v-if="courseDeail.thumb"
             width="68px"
             height="68px"
+            radius="5px"
             :img_url="courseDeail.thumb"
             :user_name="courseDeail.name"
+            style="cursor: pointer"
           ></userImage>
           <div v-else class="cursor">
-            <div>
-              +
-            </div>
-            <!-- <div>上传预览图</div> -->
+            <div>+</div>
           </div>
         </div>
       </el-form-item>
       <el-form-item label="价格:">
         <el-input-number
           v-model="courseDeail.price"
-          @change="this.courseDeail.price = !courseDeail.price"
-          :min="1"
+          :min="0"
           :max="10000000"
           label="课程价格"
         ></el-input-number>
       </el-form-item>
       <el-form-item label="是否上架:">
         <el-switch
-          v-model="courseDeail.isShelf"
+          v-model="courseDeail.enable"
           active-color="#13ce66"
           inactive-color="#999"
         >
         </el-switch>
       </el-form-item>
       <el-form-item label="课程介绍:">
-        <el-upload
-          action="#"
-          list-type="picture-card"
-          :auto-upload="false"
-          :file-list="courseDeail.images"
-          :limit="20"
-          multiple
-          :on-change="uploadChange2"
-          :on-error="uploadErr"
-        >
-          <i slot="default" class="el-icon-plus"></i>
-          <div slot="file" slot-scope="{ file }">
-            <img
-              class="el-upload-list__item-thumbnail"
-              :src="file.url"
-              alt=""
-            />
-            <span class="el-upload-list__item-actions">
-              <span
-                class="el-upload-list__item-preview"
-                @click="handlePictureCardPreview(file)"
-              >
-                <i class="el-icon-zoom-in"></i>
-              </span>
-              <span
-                class="el-upload-list__item-delete"
-                @click="handleRemove2(file)"
-              >
-                <i class="el-icon-delete"></i>
-              </span>
-            </span>
+        <div style="display: flex">
+          <div class="img_all">
+            <template v-for="(item, index) in courseImages">
+              <userImage
+                width="68px"
+                radius="5px"
+                height="68px"
+                :img_url="item"
+              ></userImage>
+            </template>
+          </div>
+          <div class="cursor" @click="showSelectImg(2)">
+            <div>+</div>
           </div>
-        </el-upload>
+        </div>
       </el-form-item>
       <el-form-item label="课程章节" size="normal">
         <div class="sectionout">
@@ -85,10 +65,10 @@
             :key="index"
           >
             <div class="sectionName">
-              <el-input v-model.trim="item.name"></el-input>
+              <el-input v-model.trim="item.name" placeholder="请输入章节名..."></el-input>
             </div>
             <div class="sectionUrl">
-              <el-input v-model.trim="item.link"></el-input>
+              <el-input v-model.trim="item.link" placeholder="请输入章节链接..."></el-input>
             </div>
             <div class="del">
               <el-button
@@ -130,13 +110,16 @@
 </template>
 <script>
 import ImageCropper from "@/components/ImageCropper";
+import { validateURL } from "@/utils/validate";
+import {createCourse,updataCourse,getCourseDetail} from '../api'
 export default {
   name: "courseEdit",
   components: { ImageCropper },
   data() {
     return {
+      curId: 0,
       title: "",
-      company_img_show:false,
+      company_img_show: false,
       company_img_loading: false,
       alterCreate: "保存",
       imgIndex: 1,
@@ -144,46 +127,78 @@ export default {
       imgHeight: 300,
       // 个人信息
       courseDeail: {
-        id: 0,
         name: "",
         price: 0,
         thumb: "",
-        images: [],
-        sections: [
-          {
-            name: "精讲1",
-            link: "http:sasdsada.com",
-          },
-          {
-            name: "精讲1",
-            link: "http:sasdsada.com",
-          },
-          {
-            name: "精讲1",
-            link: "http:sasdsada.com",
-          },
-          {
-            name: "精讲1",
-            link: "http:sasdsada.com",
-          },
-        ],
+        enable: false,
+        images: "",
+        sections: [],
       },
       dialogVisible: false,
       dialogImageUrl: "",
     };
   },
-  computed: {},
+  computed: {
+    courseImages() {
+      if (this.courseDeail.images) {
+        return this.courseDeail.images.split(",");
+      } else {
+        return [];
+      }
+    },
+  },
   methods: {
-    //预览图上传成功
+    //章节信息校验
+    validateURL() {
+      let result = false;
+      result = this.courseDeail.sections.every((item) => {
+        return validateURL(item.link) && item.name !== "";
+      });
+      return result;
+    },
+    // 获取课程详情
+    getCourseDetail() {
+      getCourseDetail(this.curId).then((res) => {
+          this.courseDeail = this.uploadToData(res);
+      }).catch(err=>{
+        console.error(err)
+      });
+    },
+    //课程详情数据转换展示
+    uploadToData(data) {
+      data.enable = data.enable == 1 ? true : false;
+      data.price = Number(data.price);
+      data.images = data.images.join(",");
+      return data;
+    },
+    //图片上传成功回调
     company_img_success(resData) {
-      console.log(resData)
-      this.courseDeail.thumb = resData.url;
+      if (this.imgIndex == 1) {
+        this.courseDeail.thumb = resData.url;
+      } else {
+        if (
+          this.courseDeail.images.split(",").length == 1 &&
+          this.courseDeail.images.split(",")[0] == ""
+        ) {
+          this.courseDeail.images = resData.url;
+        } else {
+          this.courseDeail.images = `${this.courseDeail.images},${resData.url}`;
+        }
+      }
       this.company_img_show = false;
     },
-    //图片放大
-    showSelectImg() {
+    //打开上传图片组件
+    showSelectImg(type) {
+      this.imgIndex = type;
       this.company_img_show = true;
     },
+    //展示数据转换成上传数据
+    toUpdata() {
+      let data = JSON.parse(JSON.stringify(this.courseDeail));
+      data.enable = data.enable ? 1 : 0;
+      data.sections = JSON.stringify(data.sections);
+      return data;
+    },
     // 添加课程
     addSection() {
       let section = {
@@ -192,7 +207,7 @@ export default {
       };
       this.courseDeail.sections.push(section);
     },
-    // 删除课程
+    // 删除章节
     sectionDel(index, item) {
       this.$confirm("确定删除当前章节?", "提示", {
         confirmButtonText: "确定",
@@ -209,35 +224,6 @@ export default {
           });
         });
     },
-    suceessChange(res) {
-      console.log(res);
-    },
-    // 上传图片失败
-    uploadErr(err, file, fileList) {
-      console.log(err);
-      console.log(file);
-    },
-    //上传预览图
-    uploadChange(file, fileList) {
-      this.courseDeail.thumb.push(file);
-    },
-    // 上传介绍图组
-    uploadChange2(file, fileList) {
-      this.courseDeail.images.push(file);
-    },
-    // 删除预览图
-    handleRemove(file) {
-      this.deleteImage(file.url);
-    },
-    // 删除介绍图
-    handleRemove2(file) {
-      this.deleteImage(file.url, 1);
-    },
-    // 图片放大查看
-    handlePictureCardPreview(file) {
-      this.dialogImageUrl = file.url;
-      this.dialogVisible = true;
-    },
     // 删除图片
     deleteImage(url, type) {
       this.$confirm("确定删除图片?", "提示", {
@@ -252,7 +238,6 @@ export default {
             });
             this.courseDeail.images = newList;
           } else {
-            console.log(123);
             this.courseDeail.thumb = [];
           }
         })
@@ -263,13 +248,14 @@ export default {
           });
         });
     },
-    //保存修改
+    //保存
     iffirm() {
       if (
         !this.courseDeail.name == "" &&
-        !this.courseDeail.images.length == 0 &&
+        !this.courseDeail.images == "" &&
         !this.courseDeail.thumb == "" &&
-        !this.courseDeail.price !== 0
+        !this.courseDeail.price !== 0 &&
+        this.validateURL()
       ) {
         this.$confirm("确定保存当前页面信息?", "提示", {
           confirmButtonText: "确定",
@@ -289,51 +275,69 @@ export default {
               message: "已取消",
             });
           });
+      } else if (!this.validateURL()) {
+        this.$message({
+          type: "warning",
+          message: "章节列表未填写正确",
+        });
       } else {
         this.$message({
           type: "warning",
-          message: "用户信息未填写完整!",
+          message: "用户信息未填写完整",
         });
       }
     },
     //修改保存
     saveAlter() {
-      this.$message({
-        message: "修改成功!",
-        type: "success",
-        showClose: true,
-        duration: 2000,
-      });
+      let data = this.toUpdata();
+      updataCourse(this.curId,data).then(res=>{
+        this.$message({
+            message: "修改成功!",
+            type: "success",
+            showClose: true,
+            duration: 2000,
+          });
+          this.$router.push("/course/courseManage");
+      }).catch(err=>{
+        console.error(err)
+      })
     },
-    //新建角色保存post
+    //新建课程
     saveCreate() {
-      this.$message({
-        message: "新建课程成功!",
-        type: "success",
-        showClose: true,
-        duration: 2000,
-      });
+      let data = this.toUpdata();
+      createCourse(data).then(res=>{
+        this.$message({
+            message: "新建成功!",
+            type: "success",
+            showClose: true,
+            duration: 2000,
+          });
+          this.$router.push("/course/courseManage");
+      }).catch(err=>{
+        console.error(err)
+      })
     },
     //判断新建/修改
-    judge() {
+    init() {
       if (this.$route.params.id == undefined) {
         this.title = "创建课程";
+        this.courseDeail = {
+          name: "",
+          price: 0,
+          thumb: "",
+          enable: false,
+          images: "",
+          sections: [],
+        };
       } else {
+        this.curId = this.$route.params.id;
         this.title = "编辑课程";
+        this.getCourseDetail();
       }
     },
-    //获取单个角色信息
-    getOneAccount() {
-      // this.$api.role
-      //   .getOne(this.$route.params.id)
-      //   .then((res) => {
-      //     this.toRole(res.data.result);
-      //   })
-      //   .catch((error) => {});
-    },
   },
   created() {
-    this.judge();
+    this.init();
   },
 };
 </script>
@@ -385,8 +389,14 @@ export default {
     }
   }
 }
-.cursor{
-  &>div{
+.img_all {
+  display: flex;
+  & > div {
+    margin-right: 10px;
+  }
+}
+.cursor {
+  & > div {
     height: 68px;
     width: 68px;
     border: 2px dashed #f1f1f1;

+ 17 - 43
src/course/courseManage/home.vue

@@ -34,8 +34,6 @@
         <el-pagination
           background
           layout="prev, pager, next"
-          @prev-click="prevPage()"
-          @next-click="nextPage()"
           @current-change="curPageChange()"
           :current-page.sync="page.cur"
           :page-size="page.size"
@@ -52,42 +50,21 @@
 export default {
   name: "",
   components: {},
-  props: [],
   data() {
     return {
       page:{
-        total:1000,
+        total:0,
         size:10,
         cur:1
       },
-      courseList: [
-        {
-          id: 123455,
-          name: "课程精讲1",
-          price: 598,
-          enable: true,
-        },
-        {
-          id: 123453,
-          name: "课程精讲2",
-          price: 698,
-          enable: true,
-        },
-        {
-          id: 123452,
-          name: "课程精讲3",
-          price: 798,
-          enable: false,
-        },
-        {
-          id: 123451,
-          name: "课程精讲4",
-          price: 898,
-          enable: true,
-        },
-      ],
+      courseList: [],
     };
   },
+  watch:{
+    '$route':function(){
+      this.getCourseList()
+    }
+  },
   created() {
     this.getCourseList()
   },
@@ -103,7 +80,7 @@ export default {
           this.courseList = res.data.data.list
           this.page.total = res.data.data.total
           this.page.size = res.data.data.size
-          this.page.cur = res.data.data.page
+          this.page.cur = res.data.data.current
         }else{
           this.$message({
             message: res.data.message,
@@ -114,24 +91,15 @@ export default {
         }
       })
     },
-    // 上一页
-    prevPage(){
-      console.log(this.page)
-    },
-    // 下一页
-    nextPage(){
-      console.log(this.page)
-    },
     // 当前页切换
     curPageChange(){
-      console.log(this.page)
+      this.getCourseList()
     },
     // 跳转课程修改
     courseEdit(row) {
       this.$router.push({
         path:`/course/courseEdit/${row.id}`,
       })
-      console.log(row);
     },
     // 跳转创建新课程
     courseCreate(){
@@ -147,6 +115,7 @@ export default {
             showClose: true,
             duration: 3000,
           });
+          this.page.cur = 1
           this.getCourseList();
         }else{
           this.$message({
@@ -168,8 +137,6 @@ export default {
         this.deleteCourse(row.id)
       }).catch(() => {
       });
-      
-      console.log(row);
     },
   },
 };
@@ -179,6 +146,13 @@ export default {
   padding: 15px;
   background-color: #fff;
   border-radius: 5px;
+  // width: 900px;
+  // height: auto;
+  // margin: 0 auto;
+  // margin-top: 10px;
+  // background-color: #fff;
+  // border-radius: 5px;
+  // padding: 30px 60px;
   .course_data {
     margin-top: 25px;
     display: block;

+ 2 - 12
src/course/dealerManage/edit.vue

@@ -35,8 +35,6 @@
         <el-pagination
           background
           layout="prev, pager, next"
-          @prev-click="prevPage()"
-          @next-click="nextPage()"
           @current-change="curPageChange()"
           :current-page.sync="page.cur"
           :page-size="page.size"
@@ -155,7 +153,7 @@ export default {
     this.init();
   },
   watch:{
-    $route(){
+    '$route'(){
       this.init()
     }
   },
@@ -213,15 +211,7 @@ export default {
     //初始化
     init() {
       // console.log(this.$route)
-        this.curName = `${this.$route.query.tel}推广的课程`;
-    },
-    // 上一页
-    prevPage() {
-      console.log(this.page);
-    },
-    // 下一页
-    nextPage() {
-      console.log(this.page);
+        this.curName = `${this.$route.query.name}推广的课程`;
     },
     // 页面切换
     curPageChange() {

+ 134 - 98
src/course/dealerManage/home.vue

@@ -1,6 +1,11 @@
 <template>
   <div class="page">
-    <el-page-header @back="$router.go(-1)" :content='curTeamTel' style="margin-bottom: 20px;" v-if="!isOuter"></el-page-header>
+    <el-page-header
+      @back="$router.go(-1)"
+      :content="curTeamTel"
+      style="margin-bottom: 20px"
+      v-if="!isOuter"
+    ></el-page-header>
     <el-header height="40px" style="display: flex; align-items: center">
       <el-button
         type="primary"
@@ -21,25 +26,36 @@
       </div>
     </el-header>
     <el-container class="course_data">
-      <el-table :data="courseList" border stripe highlight-current-row>
+      <el-table :data="dealerInfo" border stripe highlight-current-row>
         <el-table-column prop="name" label="用户名" align="center">
         </el-table-column>
-        <el-table-column label="微信ID" align="center">
-          <template slot-scope="scope"> {{ scope.row.wx_id }} </template>
+        <el-table-column label="微信ID" align="center" min-width="100px">
+          <template slot-scope="scope"> {{ scope.row.unionid }} </template>
         </el-table-column>
         <el-table-column label="手机号" align="center">
-          <template slot-scope="scope"> {{ scope.row.tel }} </template>
+          <template slot-scope="scope"> {{ scope.row.mobile }} </template>
         </el-table-column>
-        <el-table-column label="TA的团队" align="center" style="color: #409eff" class="outTeam" v-if="isOuter">
+        <el-table-column
+          label="TA的团队"
+          align="center"
+          style="color: #409eff"
+          class="outTeam"
+          v-if="isOuter"
+        >
           <template slot-scope="scope">
-            <span @click="toDealerTeam(scope.row)" style="color: #409eff;cursor: pointer;">{{
-              scope.row.teamNum
-            }}</span>
+            <span
+              @click="toDealerTeam(scope.row)"
+              style="color: #409eff; cursor: pointer"
+              >{{ scope.row.statistics.teamAmount }}</span
+            >
           </template>
         </el-table-column>
         <el-table-column fixed="right" label="操作" width="250" align="center">
           <template slot-scope="scope">
-            <el-button type="text" size="mini" @click="infoEdit(scope.row, scope.$index)"
+            <el-button
+              type="text"
+              size="mini"
+              @click="infoEdit(scope.row, scope.$index)"
               >修改信息</el-button
             >
             <el-button
@@ -55,8 +71,6 @@
         <el-pagination
           background
           layout="prev, pager, next"
-          @prev-click="prevPage()"
-          @next-click="nextPage()"
           @current-change="curPageChange()"
           :current-page.sync="page.cur"
           :page-size="page.size"
@@ -67,22 +81,29 @@
       </div>
     </el-container>
     <el-dialog
-      :title="dealerInfo.name"
+      title="用户信息修改"
       :visible.sync="eldiForm"
-      width="30%"
+      width="40%"
       :close-on-click-modal="false"
-      :close-on-press-escape='false'
+      :close-on-press-escape="false"
       center
-      @close="cancleDi">
-      <el-form :model="dealerInfo" ref="form"  label-width="100px" :inline="false" size="normal">
+      @close="cancleDi"
+    >
+      <el-form
+        :model="dealerForm"
+        ref="form"
+        label-width="100px"
+        :inline="false"
+        size="normal"
+      >
         <el-form-item label="用户名">
-          <el-input v-model="dealerInfo.name"></el-input>
+          <el-input v-model="dealerForm.name"></el-input>
         </el-form-item>
         <el-form-item label="绑定微信ID">
-          <el-input v-model="dealerInfo.wx_id"></el-input>
+          <el-input v-model="dealerForm.unionid"></el-input>
         </el-form-item>
         <el-form-item label="手机号">
-          <el-input v-model="dealerInfo.tel"></el-input>
+          <el-input v-model="dealerForm.mobile"></el-input>
         </el-form-item>
       </el-form>
       <span slot="footer">
@@ -90,121 +111,144 @@
         <el-button type="primary" @click="confirmSave">保存</el-button>
       </span>
     </el-dialog>
-    
   </div>
 </template>
 
 <script>
+import { getDealerList } from "../api";
 export default {
   name: "dealerManage",
   components: {},
   props: [],
   data() {
     return {
-      eldiForm:false,
-      dealerInfo:{
+      eldiForm: false,
+      dealerForm: {
         id: 0,
         name: "",
-        wx_id: "",
-        tel: "",
+        unionid: "",
+        mobile: "",
       },
       curTeamTel: "",
       isOuter: false,
       page: {
-        total: 1000,
+        total: 0,
         size: 10,
         cur: 1,
       },
       teamValue: "",
-      courseList: [
+      dealerInfo: [
         {
           id: 123455,
           name: "燕小六",
-          wx_id: "wx1525155255",
-          tel: "15699847711",
-          teamNum: 8,
-        },
-        {
-          id: 123453,
-          name: "王五",
-          wx_id: "wx1525155255",
-          tel: "15699847721",
-          teamNum: 11,
-        },
-        {
-          id: 123452,
-          name: "李四",
-          wx_id: "wx1525155255",
-          tel: "15699847731",
-          teamNum: 21,
-        },
-        {
-          id: 123451,
-          name: "张三",
-          wx_id: "wx1525155255",
-          tel: "15699847751",
-          teamNum: 4,
+          unionid: "wx1525155255",
+          mobile: "15699847711",
+          statistics: {
+            saleAmount: 15000,
+            teamAmount: 11,
+          },
         },
       ],
     };
   },
   watch: {
-    $route:function(to,from){
-      this.init()
-    }
+    // $route: function (to, from) {
+    //   if(to.path == '/course/dealerManage'){
+    //     this.init();
+    //   }
+    // },
   },
   created() {
     this.init();
   },
   methods: {
+    //获取经销商列表
+    getDealerMap(type, pid) {
+      console.log(123)
+      let data = {
+        page: this.page.cur,
+        pageSize: this.page.size,
+        marketable: type,
+      };
+      if (pid != undefined) {
+        data.pid = pid;
+      }
+      console.log(data);
+      getDealerList(data).then((res) => {
+        // console.log(res);
+        this.dealerInfo = res.list;
+        this.page.cur = res.page;
+        this.page.size = res.size;
+        this.page.total = res.total;
+      });
+    },
     // 修改经销商信息
-    confirmSave(){
-      this.$confirm('确定要修改经销商信息吗?', '提示', {
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-        type: 'info',
-      }).then(action => {
-        this.$message({
-          message: '交易成功!',
-          type: 'success',
-          showClose: true,
-          duration: 1500,
+    confirmSave() {
+      this.$confirm("确定要修改经销商信息吗?", "提示", {
+        confirmButtonText: "确认",
+        cancelButtonText: "取消",
+        type: "info",
+      })
+        .then((action) => {
+          this.$message({
+            message: "交易成功!",
+            type: "success",
+            showClose: true,
+            duration: 1500,
+          });
+          this.cancleDi();
+        })
+        .catch(() => {
+          this.cancleDi();
         });
-      this.cancleDi()
-      }).catch(() => {
-        this.cancleDi()
-      });
-      
     },
     // 取消修改并重置表单
-    cancleDi(){
+    cancleDi() {
       let form = {
         id: 0,
         name: "",
-        wx_id: "",
-        tel: "",
-      }
-      this.dealerInfo = form
-      this.eldiForm = false
+        unionid: "",
+        mobile: "",
+      };
+      this.dealerForm = form;
+      this.eldiForm = false;
     },
     // 初始化
     init() {
-      if (this.$route.params.id) {
-        this.isOuter = false;
-        this.curTeamTel = `${this.$route.query.tel}的团队`;
-      } else {
+      console.log(this.$route.params.id)
+      // if (this.$route.params.id) {
+      //   console.log(1111)
+      //   this.isOuter = false;
+      //   this.curTeamTel = `${this.$route.query.tel}的团队`;
+      //   this.getDealerMap(1, this.$route.params.id);
+      // } else {
+      //   console.log(2222)
+      //   this.isOuter = true;
+      //   this.getDealerMap(1);
+      // }
+      console.log(2222)
         this.isOuter = true;
-      }
+        this.getDealerMap(1);
     },
     // 跳转到我的团队
     toDealerTeam(row) {
       console.log(row);
-      this.$router.push({
-        path: `/course/dealerTeam/${row.id}?tel=${row.tel}`,
-        params: {
-          tel: row.tel,
-        },
-      });
+      if (row.statistics.teamAmount != 0) {
+        this.$router.push({
+          path: `/course/dealerTeam/${row.id}?tel=${row.tel}`,
+          params: {
+            tel: row.tel,
+          },
+        });
+      }else{
+        this.$message({
+          message: '您还没有团队',
+          type: 'warning',
+          showClose: true,
+          duration: 3000,
+        });
+        
+      }
     },
     // 搜索
     teamSearch() {
@@ -214,28 +258,20 @@ export default {
     },
     // 创建二维码
     createQr() {},
-    // 上一页
-    prevPage() {
-      console.log(this.page);
-    },
-    // 下一页
-    nextPage() {
-      console.log(this.page);
-    },
     // 切换当前页
     curPageChange() {
       console.log(this.page);
     },
     // 打开弹窗修改个人信息
     infoEdit(row) {
-      this.dealerInfo = row
-      this.eldiForm = true
+      this.dealerForm = JSON.parse(JSON.stringify(row));
+      this.eldiForm = true;
       console.log(row);
     },
     // 跳转查看交易详情
     dealerPay(row) {
       console.log(row);
-      this.$router.push(`/course/dealerEdit/${row.id}?tel=${row.tel}`)
+      this.$router.push(`/course/dealerEdit/${row.id}?name=${row.name}`);
     },
   },
   computed: {},

+ 155 - 119
src/course/index.vue

@@ -1,12 +1,23 @@
 <template>
   <div class="box-all" v-loading="loading">
     <el-header>
-      <div class="flex-box" style="height: 60px;box-shadow: 0 1px 4px rgba(0,21,41,.08);">
-        <div  @click="homeUrl" class="logo-box flex-box flex-center-center">
-          <img v-if="course_account_info.logo_url"  :src="course_account_info.logo_url" class="logo"/>
+      <div
+        class="flex-box"
+        style="height: 60px; box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08)"
+      >
+        <div @click="homeUrl" class="logo-box flex-box flex-center-center">
+          <img
+            v-if="course_account_info.logo_url"
+            :src="course_account_info.logo_url"
+            class="logo"
+          />
           <img v-else src="static/images/logo3.png" class="logo" />
         </div>
-        <div class="flex-1 flex-box-ce" style="padding: 0 20px;" v-if="course_account_info.name">
+        <div
+          class="flex-1 flex-box-ce"
+          style="padding: 0 20px"
+          v-if="course_account_info.name"
+        >
           <div class="left-menu">
             <p>{{ course_account_info.name }}</p>
           </div>
@@ -14,12 +25,26 @@
           <div class="right-menu">
             <!-- 退出账号 -->
             <el-dropdown @command="logOut">
-              <span class="el-dropdown-link" style="cursor: pointer;">
-                <userImage class="user_img"  width="40px" height="40px" fontSize="14" :user_name="course_account_info.name" :img_url="course_account_info.img_url"></userImage>
+              <span class="el-dropdown-link" style="cursor: pointer">
+                <userImage
+                  class="user_img"
+                  width="40px"
+                  height="40px"
+                  fontSize="14"
+                  :user_name="course_account_info.name"
+                  :img_url="course_account_info.img_url"
+                ></userImage>
               </span>
               <el-dropdown-menu slot="dropdown">
-                <el-dropdown-item  v-for="(group, index) in userConcent" :key="index"  :command="group">
-                  <span v-if="group.id == 2" class="red"><i class="el-icon-warning" style="margin-right: 10px;"></i>{{ group.name }}</span>
+                <el-dropdown-item
+                  v-for="(group, index) in userConcent"
+                  :key="index"
+                  :command="group"
+                >
+                  <span v-if="group.id == 2" class="red"
+                    ><i class="el-icon-warning" style="margin-right: 10px"></i
+                    >{{ group.name }}</span
+                  >
                 </el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
@@ -48,176 +73,188 @@
       </div>
       <el-main class="main-content">
         <keep-alive v-if="isRouterAlive">
-          <router-view />
+          <router-view v-if="$route.meta.keepAlive" />
         </keep-alive>
+        <router-view v-if="!$route.meta.keepAlive"></router-view>
       </el-main>
     </el-container>
   </div>
 </template>
 
 <script>
-import axiosKc from '@/utils/axiosKc'
-import { mapGetters, mapState } from 'vuex';
-import { setCourseToken, returnJSEncrypt,_debounce } from '@/utils/auth';
+import { mapGetters, mapState } from "vuex";
 export default {
   name: "courseIndex",
   provide() {
     //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。
     return {
-      reload: this.reload
-    }
+      reload: this.reload,
+    };
   },
   data() {
     return {
       loading: false,
-      isLog:false,
-      menuIndex:1,
-      isRouterAlive:true,
-      menuArr:[
+      isLog: false,
+      menuIndex: 1,
+      isRouterAlive: true,
+      menuArr: [
         {
-          icon:'#icon-shouye',
-          index:1,
-          name:'课程首页',
-          path:'/course',
-          show:true
+          icon: "#icon-shouye",
+          index: 1,
+          name: "课程首页",
+          path: "/course",
+          show: true,
         },
         {
-          icon:'#icon-kecheng',
-          index:2,
-          name:'课程管理',
-          path:'/course/courseManage',
-          show:true
+          icon: "#icon-kecheng",
+          index: 2,
+          name: "课程管理",
+          path: "/course/courseManage",
+          show: true,
         },
         {
-          icon:'#icon-xiaoshoujingxiaoshang',
-          index:3,
-          name:'经销商管理',
-          path:'/course/dealerManage',
-          show:true
+          icon: "#icon-xiaoshoujingxiaoshang",
+          index: 3,
+          name: "经销商管理",
+          path: "/course/dealerManage",
+          show: true,
         },
         {
-          icon:'#icon-tongji1',
-          index:4,
-          name:'统计',
-          path:'/course/statistics',
-          show:true
+          icon: "#icon-tongji1",
+          index: 4,
+          name: "统计",
+          path: "/course/statistics",
+          show: true,
         },
         {
-          icon:'#icon-shezhi-xianxing',
-          index:5,
-          name:'管理员设置',
-          path:'/course/adminSetting',
-          show:true
+          icon: "#icon-shezhi-xianxing",
+          index: 5,
+          name: "管理员设置",
+          path: "/course/adminSetting",
+          show: true,
         },
       ],
-      userConcent: [
-        { id: 2,name: '退出账号'},
-      ],
+      userConcent: [{ id: 2, name: "退出账号" }],
     };
   },
-  watch:{
+  watch: {
     //监视路由变化,有变化就缓存导航状态
     $route(to, from) {
       var str = to.path;
       this.menuArr.some((item, index) => {
-          if (item.path == str) {
-            this.menuIndex =item.index;
-            this.$setCache('course_path',item.index);
-            return true;
-          }
+        if (item.path == str) {
+          this.menuIndex = item.index;
+          this.$setCache("course_path", item.index);
+          return true;
+        }
       });
     },
   },
   created() {
+    this.judegLogin();
     //如果当前页不是首页,则从缓存中取出导航栏状态,没有则为首页1
-    if(this.$route.path!='/course'){
-      this.menuIndex =this.$getCache('course_path')!=1? this.$getCache('course_path'):1;
+    if (this.$route.path != "/course") {
+      this.menuIndex =
+        this.$getCache("course_path") != 1 ? this.$getCache("course_path") : 1;
     }
   },
   methods: {
+    judegLogin() {
+      if (!this.$getCourseId()) {
+        if (!localStorage.getItem("Course-Id")) {
+          this.$message({
+            message: "未登录",
+            type: "warning",
+            showClose: true,
+            duration: 3000,
+          });
+          this.$router.push("/courseLogin");
+        }
+      }
+    },
     //全局刷新不闪烁
     reload() {
       this.isRouterAlive = false;
-      this.$nextTick(function() {
+      this.$nextTick(function () {
         this.isRouterAlive = true;
       });
     },
     //退出账号
     logOut() {
-      this.$store.dispatch('CourseLogOut');
+      this.$store.dispatch("CourseLogOut");
     },
     //回到首页
-    homeUrl(){
-      this.$router.push({ path: '/course' });
+    homeUrl() {
+      this.$router.push({ path: "/course" });
     },
     //跳转相应子页面并缓存当前状态
-    openUrl(item){
-      if(this.menuIndex==item.index||this.isLog){
+    openUrl(item) {
+      if (this.menuIndex == item.index || this.isLog) {
         return false;
       }
-      this.isLog=true;
-      if(item){
-        this.menuIndex=item.index;
-        this.$setCache('course_path',item.index);
+      this.isLog = true;
+      if (item) {
+        this.menuIndex = item.index;
+        this.$setCache("course_path", item.index);
         this.$router.push({ path: item.path });
-      }else{
-        this.$setCache('course_path',1);
-        this.$router.push({ path: '/course' });
+      } else {
+        this.$setCache("course_path", 1);
+        this.$router.push({ path: "/course" });
       }
-      setTimeout(()=>{
-        this.isLog=false
-      },1000);
+      setTimeout(() => {
+        this.isLog = false;
+      }, 1000);
     },
   },
   computed: {
-    ...mapGetters(['course_account_info'])
+    ...mapGetters(["course_account_info"]),
   },
 };
 </script>
 <style scoped="scoped" lang="scss">
-  .el-header-p{
-    font-size: 18px;
-    font-weight: 600;
-    line-height: 60px;
-    color: #000;
-  }
-  .icon-item{
-    margin-right: 30px;
-    cursor: pointer;
-  }
-  .icon-item:hover{
-    color: #409eff;
-  }
- .count_max{
-   border: 1px solid #005bea;
-   border-radius: 5px;
-   padding:4px 10px;
-   color: #005bea;
-   cursor: pointer;
- }
+.el-header-p {
+  font-size: 18px;
+  font-weight: 600;
+  line-height: 60px;
+  color: #000;
+}
+.icon-item {
+  margin-right: 30px;
+  cursor: pointer;
+}
+.icon-item:hover {
+  color: #409eff;
+}
+.count_max {
+  border: 1px solid #005bea;
+  border-radius: 5px;
+  padding: 4px 10px;
+  color: #005bea;
+  cursor: pointer;
+}
 
- .menu-item{
-   width: 90px;
-   color: #ccc;
-   text-align: center;
-   padding: 10px 0;
-   cursor: pointer;
-   position: relative;
-   border-left: 3px solid #191a23;
-   transition: border-color .3s,background-color .3s,color .3s;
- }
- .svgIcon {
-   font-size: 16px;
-   margin: 0 auto;
- }
- .menu-item:hover{
-    background-color: #393b4b;
-  }
- .menu-active{
-   background-color: #393b4b;
-   border-left: 5px solid #005bea;
-   color: #fff;
- }
+.menu-item {
+  width: 90px;
+  color: #ccc;
+  text-align: center;
+  padding: 10px 0;
+  cursor: pointer;
+  position: relative;
+  border-left: 3px solid #191a23;
+  transition: border-color 0.3s, background-color 0.3s, color 0.3s;
+}
+.svgIcon {
+  font-size: 16px;
+  margin: 0 auto;
+}
+.menu-item:hover {
+  background-color: #393b4b;
+}
+.menu-active {
+  background-color: #393b4b;
+  border-left: 5px solid #005bea;
+  color: #fff;
+}
 .announDetails {
   ::v-deep img {
     width: 100%;
@@ -366,8 +403,8 @@ export default {
   color: #409eff;
   background-color: rgba(38, 162, 255, 0.1);
 }
-.left-menu{
-  p{
+.left-menu {
+  p {
     font-size: 18px;
     color: #000;
     line-height: 60px;
@@ -503,11 +540,10 @@ export default {
 }
 .main-left {
   background: #191a23;
-  -webkit-box-shadow: 2px 0 6px rgba(0,21,41,.35);
-  box-shadow: 2px 0 6px rgba(0,21,41,.35);
-  .flex-center-center{
+  -webkit-box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
+  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
+  .flex-center-center {
     // margin-top: 60px;
   }
-
 }
 </style>

+ 32 - 21
src/course/user/login.vue

@@ -51,6 +51,7 @@
 
 <script>
 import { setCourseToken, setCourseId,_debounce } from '@/utils/auth';
+import {getUserToken,getAdminTokenId} from '../api'
 export default {
   data() {
     return {
@@ -62,27 +63,20 @@ export default {
   methods: {
     //临时指定id获取用户token
     getToken(){
-      let url = '/mkt/demo/token/wo/'
-      let wxId = '11770'
-      let that = this
-      this.$axiosKc('get',`${url}${wxId}`).then((res)=>{
-        let data = res.data
-        if(data.code == 1){
-          that.getAccountIdToken(data.data)
-        }else{
-          this.$message(data.message)
-        }
+      getUserToken(11770).then(token=>{
+        console.log(token)
+        this.getAccountIdToken(token)
+      }).catch(err=>{
+        console.log(err)
       })
     },
     //根据用户token获取用户adminUserId和auToken
     getAccountIdToken(token){
-      this.$axiosKc('post','/mkt/admin/login',{},'','','',token).then(res=>{
-        let data = res.data
-        if(data.code == 1){
-          setCourseToken(res.data.data.auToken)
-          setCourseId(res.data.data.adminUserId)
-          localStorage.setItem('Course-Token',res.data.data.auToken)
-          localStorage.setItem('Course-Id',res.data.data.adminUserId)
+      getAdminTokenId(token).then(res=>{
+        setCourseToken(res.auToken)
+          setCourseId(res.adminUserId)
+          localStorage.setItem('Course-Token',res.auToken)
+          localStorage.setItem('Course-Id',res.adminUserId)
           this.$message({
             message: '登陆成功!',
             type: 'success',
@@ -90,12 +84,29 @@ export default {
             duration: 2000,
           });
           this.$router.push('/course')
-        }else{
-          this.$message(data.message)
-        }
       }).catch(err=>{
-
+        console.log(err)
       })
+      // this.$axiosKc('post','/mkt/admin/login',{},'','','',token).then(res=>{
+      //   let data = res.data
+      //   if(data.code == 1){
+      //     setCourseToken(res.data.data.auToken)
+      //     setCourseId(res.data.data.adminUserId)
+      //     localStorage.setItem('Course-Token',res.data.data.auToken)
+      //     localStorage.setItem('Course-Id',res.data.data.adminUserId)
+      //     this.$message({
+      //       message: '登陆成功!',
+      //       type: 'success',
+      //       showClose: true,
+      //       duration: 2000,
+      //     });
+      //     this.$router.push('/course')
+      //   }else{
+      //     this.$message(data.message)
+      //   }
+      // }).catch(err=>{
+
+      // })
     },
     // 微信扫码
     openWx(){

+ 2 - 1
src/main.js

@@ -7,7 +7,7 @@ import moment from 'moment' // 时间库
 import App from './App'
 import router from './router'
 import store from './store'
-import {getDept,openUrl, getToken, getCourseId,getTyps, getTypsName, supremeAuthority, getUserData, getEmployeeMap,getEmployeeMapAll,getEmployeeMapItem,getIsIdentity,getCache,setCache,removeCache,returnDeptName,getIsAdministrator} from '@/utils/auth'
+import {getDept,openUrl, getToken, getCourseId,getTyps,getLocal, getTypsName, supremeAuthority, getUserData, getEmployeeMap,getEmployeeMapAll,getEmployeeMapItem,getIsIdentity,getCache,setCache,removeCache,returnDeptName,getIsAdministrator} from '@/utils/auth'
 import './performanceSet' // 绩效系统相关配置
 import {onFilePreView } from '@/okr/utils/auth';
 import { VueOkrTree } from "vue-okr-tree";
@@ -58,6 +58,7 @@ Vue.prototype.$getEmployeeMap = getEmployeeMap  //人员列表
 Vue.prototype.$getEmployeeMapAll = getEmployeeMapAll  //人员列表(包含已删除的)
 Vue.prototype.$getEmployeeMapItem = getEmployeeMapItem  //查询人员信息(包含已删除的)
 Vue.prototype.$getCache = getCache
+Vue.prototype.$getLocal = getLocal
 Vue.prototype.$setCache = setCache
 Vue.prototype.$removeCache = removeCache
 Vue.prototype.$socketApi = socketApi   //长连接

+ 33 - 11
src/router/course.js

@@ -5,77 +5,99 @@ const routes = [
         name: 'courseHome',
         component: () => import('@/course/home'),
         label: '课程营销首页',
-        meta: {},
+        meta: {
+            keepAlive: true
+        },
     },
     {
         path: 'courseManage',
         name: 'courseManage',
         component: () => import('@/course/courseManage/home'),
         label: '课程管理',
-        meta: {},
+        meta: {
+            keepAlive: true
+        },
     },
     {
         path: 'courseEdit/:id',
         name: 'courseEdit',
         component: () => import('@/course/courseManage/create'),
         label: '编辑课程',
-        meta: {},
+        meta: {
+            keepAlive:false
+        },
     },
     {
         path: 'courseCreate',
         name: 'courseCreate',
         component: () => import('@/course/courseManage/create'),
         label: '创建课程',
-        meta: {},
+        meta: {
+            keepAlive:false
+        },
     },
     {
         path: 'dealerManage',
         name: 'dealerManage',
         component: () => import('@/course/dealerManage/home'),
         label: '经销商管理',
-        meta: {},
+        meta: {
+            keepAlive:true
+        },
     },
     {
         path: 'dealerTeam/:id',
         name: 'dealerTeam',
         component: () => import('@/course/dealerManage/home'),
         label: '经销商团队',
-        meta: {},
+        meta: {
+            keepAlive:true
+        },
     },
     {
         path: 'dealerEdit/:id',
         name: 'dealerEdit',
         component: () => import('@/course/dealerManage/edit'),
         label: '经销商编辑',
-        meta: {},
+        meta: {
+            keepAlive:false
+        },
     },
     {
         path: 'dealerCreate',
         name: 'dealerCreate',
         component: () => import('@/course/dealerManage/edit'),
         label: '经销商创建',
-        meta: {},
+        meta: {
+            keepAlive:false
+        },
     },
     {
         path: 'courseRecord/:id',
         name: 'courseRecord',
         component: () => import('@/course/dealerManage/record'),
         label: '课程交易明细',
-        meta: {},
+        meta: {
+            keepAlive:true
+        },
     },
     {
         path: 'statistics',
         name: 'courseManage',
         component: () => import('@/course/statistics/home'),
         label: '统计',
-        meta: {},
+        meta: {
+            keepAlive:true
+        },
     },
     {
         path: 'adminSetting',
         name: 'adminSetting',
         component: () => import('@/course/setting/home'),
         label: '管理员设置',
-        meta: {},
+        meta: {
+            keepAlive:true
+        },
     }
 ]
 export default routes

+ 0 - 1
src/router/index.js

@@ -419,7 +419,6 @@ const constantRouterMap = [
   },
   {
     path: '/course',
-    name: '课程营销首页',
     component: () => import('@/course/index'),
     children: []
   },

+ 5 - 1
src/utils/auth.js

@@ -114,6 +114,9 @@ export function returnJSEncrypt(data, is = true) {
 export function getCache(key) {
   return JSON.parse(localStorage.getItem(key))
 }
+export function getLocal(key){
+  return localStorage.getItem(key)
+}
 // 设置缓存
 export function setCache(key, data) {
   localStorage.setItem(key, JSON.stringify(data))
@@ -274,7 +277,8 @@ export function setCourseId(id) {
   return Cookies.set(CourseId, id)
 }
 export function getCourseId() {
-  return Cookies.get(CourseId)
+  return localStorage.getItem('Course-Id')
+  // return Cookies.get(CourseId)
 }
 export function getUser() {
   return Cookies.get(USER)

+ 18 - 13
src/utils/axiosKc.js

@@ -6,25 +6,25 @@ import {
 import store from '@/store'
 import Router from '@/router'
 import {
-  getCache,
+  getLocal,
   removeAllToken
 } from '@/utils/auth'
 import qs from 'qs'
 import Vue from 'vue'
 const service = axios.create({
-  baseURL: process.env.BASE_API,
+  // baseURL: process.env.BASE_API,
   // baseURL:'https://oa.g107.com',
-  baseURL:'https://3g954g5149.picp.vip',
+  // baseURL:'https://3g954g5149.picp.vip',
+  baseURL:'http://192.168.0.66:8081',
   
   timeout: 20000,
   headers: {
     'Content-Type': 'application/x-www-form-urlencoded',
     "Cache-Control": 'no-cache',
-    'pl':'b'
   },
-  transformRequest: [function(data) {
-    return qs.stringify(data)
-  }]
+  // transformRequest: [function(data) {
+  //   return qs.stringify(data)
+  // }]
 })
 
 service.interceptors.request.use(
@@ -131,16 +131,16 @@ export default (type, url, data, versions, Content_Type, transform,isToken) => {
       break
   }
   if (Content_Type == '' || Content_Type == undefined) {
-    ContentType = 'application/x-www-form-urlencoded'
+    // ContentType = 'application/x-www-form-urlencoded'
+    ContentType = 'application/json'
   } else {
     ContentType = Content_Type
   }
   if (transform) {
     transformRequest = transform
   }
-  console.log(localStorage.getItem('Course-Token'))
-  if (localStorage.getItem('Course-Token')) {
-    Token = localStorage.getItem('Course-Token');
+  if (getLocal('Course-Token')) {
+    Token = getLocal('Course-Token');
   }
   if(isToken){
     Token=isToken
@@ -160,9 +160,14 @@ export default (type, url, data, versions, Content_Type, transform,isToken) => {
     }
     var json = (type == 'get') ? Object.assign(aa, {
       params: data
-    }, transformRequest) : Object.assign(aa, {
+    }) : Object.assign(aa, {
       data: data
-    }, transformRequest)
+    })
+    // var json = (type == 'get') ? Object.assign(aa, {
+    //   params: data
+    // }, transformRequest) : Object.assign(aa, {
+    //   data: data
+    // }, transformRequest)
     var ajax = service(json).then(res => {
       resolve(res)
     }).catch(error => { // 中断请求和请求出错的处理