Selaa lähdekoodia

添加视频分页

zhaogongxue 5 kuukautta sitten
vanhempi
commit
6275ed2555
6 muutettua tiedostoa jossa 128 lisäystä ja 39 poistoa
  1. BIN
      dist.zip
  2. 19 19
      dist/index.html
  3. 9 1
      src/api/login.ts
  4. 33 7
      src/view/Login/index.vue
  5. 27 5
      src/view/handbook/bookinfo.vue
  6. 40 7
      src/view/video/index.vue

BIN
dist.zip


+ 19 - 19
dist/index.html

@@ -1,21 +1,21 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <link
-      rel="icon"
-      type="image/svg+xml"
-      href="./src/assets/image/a8e890b2-ad35-490e-b0cc-1548d7dd1401.png"
-    />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>云厂长</title>
-    <script type="module" crossorigin src="./assets/index-DOk_02cB.js"></script>
-    <link rel="stylesheet" crossorigin href="./assets/index-BkRXtAFK.css">
-  </head>
-  <body>
-    <div id="app"></div>
-  </body>
-</html>
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <link
+      rel="icon"
+      type="image/svg+xml"
+      href="./src/assets/image/a8e890b2-ad35-490e-b0cc-1548d7dd1401.png"
+    />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>云厂长</title>
+    <script type="module" crossorigin src="./assets/index-C7a-BVzJ.js"></script>
+    <link rel="stylesheet" crossorigin href="./assets/index-5TyMKneC.css">
+  </head>
+  <body>
+    <div id="app"></div>

+  </body>
+</html>
 <style lang="scss">* {
   margin: 0;
   padding: 0;
@@ -31,4 +31,4 @@ html {
   width: 100%;
   overflow-x: hidden;
 }
-</style>
+</style>

+ 9 - 1
src/api/login.ts

@@ -3,7 +3,15 @@ import request from "../utils/request";
 //登录
 export const login = (data: any) => {
   return request({
-    url: "/login",
+    url: "/login/code",
+    method: "post",
+    data,
+  });
+};
+//注册
+export const code_register = (data: any) => {
+  return request({
+    url: "/code_register",
     method: "post",
     data,
   });

+ 33 - 7
src/view/Login/index.vue

@@ -91,7 +91,7 @@
           </div>
           <!-- 开始体验 -->
           <div v-if="isLogin" class="tiyan" @click="toindex">立即登录</div>
-          <div v-else class="tiyan">开始体验</div>
+          <div v-else class="tiyan" @click="register">开始体验</div>
         </div>
         <div class="bottom_line"></div>
         <div class="bottom_login">
@@ -137,7 +137,7 @@ const __topic__ = async () => {
   try {
     const { data } = await loginApi.login({
       mobile: phone.value,
-      password: 123456,
+      code:code.value,
     });
     if (route.query.index) {
       router.go(-1);
@@ -147,10 +147,6 @@ const __topic__ = async () => {
       });
     }
     localStorage.setItem("access_token", JSON.stringify(data.token));
-    router.push({
-      name: "home",
-    });
-    localStorage.setItem("access_token", JSON.stringify(data.token));
     localStorage.setItem("userInfo", JSON.stringify(data));
     localStorage.setItem("USER_STORE", JSON.stringify(data));
   } catch (error) {}
@@ -160,7 +156,7 @@ const getQrCode = () => {
   loginApi
     .getCode({
       mobile: phone.value,
-      type: "register",
+      type: isLogin ? "login" : "register",
     })
     .then((res) => {
       console.log(res);
@@ -185,6 +181,36 @@ const toindex = () => {
     __topic__();
   }
 };
+//注册
+const register = () => {
+  if (checked1.value == "") {
+    ElMessage({
+      message: "请勾选协议",
+      type: "warning",
+    });
+  } else {
+    __register__();
+  }
+};
+//注册接口
+const __register__ = async () => {
+  try {
+    const { data } = await loginApi.code_register({
+      mobile: phone.value,
+      code:code.value,
+    });
+    if (route.query.index) {
+      router.go(-1);
+    } else {
+      router.push({
+        name: "home",
+      });
+    }
+    localStorage.setItem("access_token", JSON.stringify(data.token));
+    localStorage.setItem("userInfo", JSON.stringify(data));
+    localStorage.setItem("USER_STORE", JSON.stringify(data));
+  } catch (error) {}
+};
 </script>
 <style lang="less" scoped>
 .image {

+ 27 - 5
src/view/handbook/bookinfo.vue

@@ -96,9 +96,9 @@
     <div class="right">
       <div style="display: flex; align-items: center; column-gap: 6px">
         <span class="topsm">{{ changefont }}</span>
-        <el-icon><ArrowRight /></el-icon>
+        <el-icon v-if="categoryname"><ArrowRight /></el-icon>
         <span class="topsm">{{ categoryname }}</span>
-        <el-icon><ArrowRight /></el-icon>
+        <el-icon v-if="docu"><ArrowRight /></el-icon>
         <span class="topsm">{{ docu }}</span>
       </div>
       <div class="bigtitle">{{ docu }}</div>
@@ -128,7 +128,10 @@ const topchange = (name, index, id) => {
   changefont.value = name;
   changeindex.value = index;
   type_id.value = id;
+  docu.value = ''
+  categoryname.value = ''
   book.documentlist = [];
+  book.content.con = "";
   category();
 };
 
@@ -156,9 +159,28 @@ const category = async () => {
       type_id: type_id.value,
     });
     book.category = data;
-    categoryname.value = data[0].name;
-    category_id.value = data[0].id;
-    document();
+    if (data[0].children) {
+      if (data[0].children[0].children) {
+        console.log(111);
+        categoryname.value = data[0].children[0].children[0].name;
+        category_id.value = data[0].children[0].children[0].id;
+        console.log(category_id.value );
+        
+        document(category_id.value);
+      } else {
+        console.log(222);
+        categoryname.value = data[0].children[0].name;
+        category_id.value = data[0].children[0].id;
+        console.log(category_id.value );
+        document(category_id.value);
+      }
+    } else {
+      console.log(333);
+      categoryname.value = data[0].name;
+      category_id.value = data[0].id;
+      document(category_id.value);
+    }
+    
   } catch (error) {}
 };
 onMounted(category);

+ 40 - 7
src/view/video/index.vue

@@ -1,6 +1,13 @@
 <template>
   <Banne :banneImageList="imgList.banneImageList" />
-  <div class="videobox">
+  <div
+    class="videobox"
+    style="
+      display: flex;
+      justify-content: space-between;
+      flex-direction: column;
+    "
+  >
     <div class="box">
       <div
         @click="toinfo(item.id)"
@@ -19,6 +26,15 @@
         </div>
       </div>
     </div>
+    <div class="bottompage">
+      <el-pagination
+        background
+        layout="prev, pager, next"
+        :total="total"
+        @current-change="handleCurrentChange"
+        :page-size="8"
+      />
+    </div>
   </div>
   <!-- <div class="foot"></div> -->
   <bottom></bottom>
@@ -32,15 +48,27 @@ import * as videoAPi from "../../api/kecheng";
 import * as configApi from "../../api/config";
 const router = useRouter();
 
+//课程总数
+const total = ref(0)
+const page = ref(1)
 //课程列表
 const list = async () => {
   try {
-    const { data } = await videoAPi.list({});
+    const { data } = await videoAPi.list({
+      page:page.value,
+      limit:8
+    });
     imgList.list = data.data;
+    total.value = data.total
   } catch (error) {}
 };
 onMounted(list);
 
+const handleCurrentChange = (val) => {
+  page.value = val;
+  list()
+};
+
 const imgList = reactive({
   //banne图需要的数据
   banneImageList: [
@@ -61,12 +89,12 @@ const imgList = reactive({
 const getBanneList = async () => {
   try {
     const { data } = await configApi.getBanneList({
-      code:'video'
-  });
-  imgList.banneImageList = data;
+      code: "video",
+    });
+    imgList.banneImageList = data;
   } catch (error) {}
 };
-onMounted(getBanneList)
+onMounted(getBanneList);
 const toinfo = (id) => {
   router.push({
     name: "course",
@@ -78,11 +106,16 @@ const toinfo = (id) => {
 };
 </script>
 <style lang="less" scoped>
+.bottompage {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
 .foot {
   height: 480px;
 }
 .videobox {
-  height: 640px;
+  min-height: 640px;
   padding: 60px 0 70px;
   box-sizing: border-box;
   background: rgba(245, 245, 247, 1);