Эх сурвалжийг харах

我的下级页面完成,新增数据分层dataModel

wyling 3 жил өмнө
parent
commit
5f99eb9ce5

+ 19 - 0
src/api/REST_Client/test.http

@@ -0,0 +1,19 @@
+@host = http://192.168.8.213:8080
+@token = Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImQwMTMzZDZhLTJlMDgtNDM4ZC04MmJkLTFjMzY5MzM3Nzc5YSJ9.1v4xVxuiuvXYOAekH7hfwJTUNoCnJRLJtENRN6lOoD_d-PL7Ax6IrPppr6oOfYAd_FDYvUGTOU9PKuRg9egNLw
+
+GET {{host}}/twzd-admin/student/spread/relation/spreadRelationList
+Authorization: {{token}}
+###
+
+GET https://www.thunderclient.io/welcome HTTP/1.1
+
+###
+
+GET {{host}}/twzd-admin/student/qustion/info/normalList HTTP/1.1
+Authorization: {{token}}
+content-type: application/json
+
+{
+    "name": "sample",
+    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
+}

+ 1 - 0
src/api/index.ts

@@ -4,3 +4,4 @@ export * from "./modules/auth";
 export * from "./modules/pay";
 export * from "./modules/testScores";
 export * from "./modules/collectionAndWrong";
+export * from "./modules/branch";

+ 14 - 0
src/api/modules/branch.ts

@@ -0,0 +1,14 @@
+import { AxiosPromise } from "axios";
+import request from "../request";
+
+class Branch {
+  /**
+   * 查询一二级绑定用户
+   * @returns
+   */
+  spreadRelationList(): AxiosPromise<BranchType.spreadRelationListRes> {
+    return request("/student/spread/relation/spreadRelationList");
+  }
+}
+
+export const branch = new Branch();

+ 1 - 1
src/api/modules/collectionAndWrong.ts

@@ -34,7 +34,7 @@ export class CollectionAndWrong {
       url: this.urlList.getList,
       params,
     });
-    return <CollectionAndWrongType.ListRes[]>res.data.rows;
+    return <CollectionAndWrongType.ListRes>res.data;
   };
 
   /**

+ 14 - 0
src/api/types/branch.d.ts

@@ -0,0 +1,14 @@
+declare namespace BranchType {
+  interface userInfo {
+    headImage: string;
+    nickName: string;
+    createTime: string;
+  }
+  interface dataInfo {
+    title: string;
+    userList: userInfo[];
+  }
+  interface spreadRelationListRes extends Common.Res {
+    data: dataInfo[];
+  }
+}

+ 6 - 1
src/api/types/collectionAndWrong.d.ts

@@ -20,11 +20,16 @@ declare namespace CollectionAndWrongType {
     km?: Km;
   }
 
-  interface ListRes extends Question {
+  interface QuestionRes extends Question {
     id: number;
     userId: number;
   }
 
+  interface ListRes extends Common.Res {
+    rows: QuestionRes[];
+    total: number;
+  }
+
   type AddCullectionsParams = Question[];
 
   interface AddCullectionsRes extends Common.Res {

+ 10 - 0
src/dataModel/myBranchList.ts

@@ -0,0 +1,10 @@
+import { branch } from "@/api";
+
+export class MyBranchList {
+  private api = branch.spreadRelationList;
+
+  async getData() {
+    const res = await this.api();
+    return res.data.data;
+  }
+}

+ 52 - 31
src/views/collection/index.vue

@@ -10,33 +10,40 @@
   <div>
     <van-checkbox-group v-model="checked" ref="checkboxGroup">
       <van-cell-group>
-        <van-swipe-cell
-          v-for="(item, index) in list"
-          :key="index"
-          :disabled="isChoose"
+        <van-list
+          v-model="loading"
+          :finished="finished"
+          finished-text="没有更多了"
+          @load="onLoad"
         >
-          <van-cell clickable :title="`${item.id}. ${item.issue}`" @click="">
-            <template #icon v-if="isChoose">
-              <van-checkbox :name="item.id" class="checkbox" />
+          <van-swipe-cell
+            v-for="(item, index) in list"
+            :key="index"
+            :disabled="isChoose"
+          >
+            <van-cell clickable :title="`${item.id}. ${item.issue}`" @click="">
+              <template #icon v-if="isChoose">
+                <van-checkbox :name="item.id" class="checkbox" />
+              </template>
+            </van-cell>
+            <template #right>
+              <van-button
+                square
+                style="height: 100%"
+                type="danger"
+                text="删除"
+                @click="deleteClick(item.id)"
+              />
+              <van-button
+                square
+                style="height: 100%"
+                type="primary"
+                text="收藏"
+                v-if="isType == 0"
+              />
             </template>
-          </van-cell>
-          <template #right>
-            <van-button
-              square
-              style="height: 100%"
-              type="danger"
-              text="删除"
-              @click="deleteClick(item.id)"
-            />
-            <van-button
-              square
-              style="height: 100%"
-              type="primary"
-              text="收藏"
-              v-if="isType == 0"
-            />
-          </template>
-        </van-swipe-cell>
+          </van-swipe-cell>
+        </van-list>
       </van-cell-group>
     </van-checkbox-group>
   </div>
@@ -78,7 +85,7 @@
 </template>
 
 <script lang="ts">
-import { onBeforeMount } from "vue";
+import { onBeforeMount, computed } from "vue";
 import { getQuestionInfoByIds, CollectionAndWrong } from "@/api";
 
 /**
@@ -87,7 +94,8 @@ import { getQuestionInfoByIds, CollectionAndWrong } from "@/api";
 const useQuestionList = (type: CollectionAndWrongType.type) => {
   const QuestionApi = new CollectionAndWrong(type);
   const questionList = ref<Test.QuestionInfo[]>([]);
-  const collectionList = ref<CollectionAndWrongType.ListRes[]>([]);
+  const collectionList = ref<CollectionAndWrongType.QuestionRes[]>([]);
+  const total = ref(0);
   const pageNum = ref(0);
   const pageSize = ref(10);
   /**
@@ -112,25 +120,31 @@ const useQuestionList = (type: CollectionAndWrongType.type) => {
       pageNum: pageNum.value,
       pageSize: pageSize.value,
     });
-    collectionList.value = collectionListRes;
-    const ids = collectionListRes.map((item) => item.questionId);
+    collectionList.value = collectionListRes.rows;
+    total.value = collectionListRes.total;
+    const ids = collectionListRes.rows.map((item) => item.questionId);
     const questions = await getQuestionInfoByIds({
       ids,
     });
     questionList.value = questions.rows;
   };
+
+  const finished = computed(() => {
+    return questionList.value.length === total.value;
+  });
   onBeforeMount(() => {
     setData();
   });
   return {
     questionList,
     deletes,
+    finished,
   };
 };
 </script>
 
 <script setup lang="ts">
-import { nextTick, ref, watch, computed } from "vue";
+import { nextTick, ref, watch } from "vue";
 import { useRouter } from "vue-router";
 const router = useRouter();
 const onClickLeft = () => {
@@ -152,6 +166,11 @@ const list = computed(() => {
   return currentView.value.questionList.value;
 });
 
+//是否全部加载完成
+const finished = computed(() => {
+  return currentView.value.finished.value;
+});
+
 const isChoose = ref(false); //开启批量选中
 const isSelectAll = ref(false); //是否全选
 const checked = ref([]); //选中内容
@@ -186,11 +205,13 @@ const unSelectAll = () => {
 const deleteClick = (id: number) => {
   currentView.value.deletes([id]);
 };
-//单个收藏
 //批量删除
 const deletesClick = () => {
   currentView.value.deletes(checked.value);
 };
+
+//单个收藏
+
 //批量收藏
 </script>
 

+ 4 - 4
src/views/home/children/user/index.vue

@@ -9,11 +9,11 @@
       </template>
     </van-cell>
     <van-cell-group class="group">
-      <van-cell title="我要提现" value="" is-link center @click="goCashOut">
+      <!-- <van-cell title="我要提现" value="" is-link center @click="goCashOut">
         <template #icon>
           <m-icon type="hyyxq" class="cell-icon" />
         </template>
-      </van-cell>
+      </van-cell> -->
       <van-cell title="我的下级" value="" is-link center @click="goMyBranch">
         <template #icon>
           <m-icon type="hyyxq" class="cell-icon" />
@@ -27,7 +27,7 @@
         @click="goBuyVip"
       >
         <template #icon>
-          <m-icon type="hyyxq" class="cell-icon" />
+          <m-icon type="huiyuan" class="cell-icon" />
         </template>
       </van-cell>
     </van-cell-group>
@@ -39,7 +39,7 @@
         @click="loopPrepareOrder"
       >
         <template #icon>
-          <m-icon type="fkbz" class="cell-icon" />
+          <m-icon type="bbgx" class="cell-icon" />
         </template>
       </van-cell>
       <van-cell

+ 28 - 65
src/views/myBranch/index.vue

@@ -6,106 +6,69 @@
       <m-user-name />
     </div>
   </div>
-  <van-tabs
-    v-model="active"
-    style="margin: -82px 10px; border-radius: 15px; overflow: hidden"
-  >
-    <van-tab title="一级">
+  <van-tabs style="margin: -82px 10px; border-radius: 15px; overflow: hidden">
+    <van-tab
+      :title="item.title"
+      v-for="(item, index) in branchList"
+      :key="index"
+    >
       <van-search
         class="search"
         shape="round"
         placeholder="请输入下级代理昵称"
+        v-model="searchValue"
       />
       <div class="test-scores content-box">
         <table class="table">
           <tr>
             <th>头像</th>
             <th>昵称</th>
-            <th>代理等级</th>
             <th>绑定时间</th>
           </tr>
-          <tr v-for="(item, index) in testScoresList" :key="index">
+          <tr
+            v-for="(userInfo, index) in item.userList.filter((userInfo) =>
+              userInfo.nickName.includes(searchValue)
+            )"
+            :key="index"
+          >
             <td>
               <van-image
                 round
                 width="50px"
                 height="50px"
-                src="https://img01.yzcdn.cn/vant/cat.jpeg"
+                :src="userInfo.headImage"
               />
             </td>
-            <td>{{ "item.type" }}</td>
-            <td>{{ "一级" }}</td>
-            <td>{{ "12312350%" }}</td>
+            <td>{{ userInfo.nickName }}</td>
+            <td>{{ userInfo.createTime }}</td>
           </tr>
         </table>
       </div></van-tab
     >
-    <van-tab title="二级">xxx</van-tab>
   </van-tabs>
 </template>
 
 <script lang="ts">
-import { getTestScoresList, getTestScoresInfo } from "@/api";
+import { MyBranchList } from "@/dataModel/myBranchList";
 import { ref, onBeforeMount } from "vue";
-import { RouterBus } from "@/hooks";
-/**
- * 考试成绩数据结构
- */
-interface TestScores {
-  createTime: string; //考试时间
-  kskm: string; //科目
-  score: number; //分数
-  type: string; //车型
-}
-/**
- * 模拟考成绩列表
- */
-const useTestScoresList = () => {
-  const testScoresList = ref<TestScores[]>([]);
-  onBeforeMount(async () => {
-    let res = await getTestScoresList();
-    testScoresList.value = res.rows;
-  });
-  return {
-    testScoresList,
+
+const useMyBranchList = () => {
+  const branchList = ref<BranchType.dataInfo[]>([]);
+  const myBranchListModel = new MyBranchList();
+  const setData = async () => {
+    const data = await myBranchListModel.getData();
+    branchList.value = data;
   };
-};
-/**
- * 成绩信息数据结构
- */
-interface TestScoresInfo {
-  avgScore: number; //平均成绩
-  forecastScore: number; //预测成绩
-  maxScore: number; //最大成绩
-}
-/**
- * 最大成绩,平均成绩,预测成绩
- */
-const useTestScoresInfo = () => {
-  const testScoresInfo = ref<TestScoresInfo>({
-    avgScore: 0,
-    forecastScore: 0,
-    maxScore: 0,
-  });
-  onBeforeMount(async () => {
-    let res = await getTestScoresInfo();
-    testScoresInfo.value = res.data;
-  });
+  setData();
   return {
-    testScoresInfo,
+    branchList,
   };
 };
 </script>
 
 <script lang="ts" setup>
-const { testScoresList } = useTestScoresList();
-const { testScoresInfo } = useTestScoresInfo();
-const { goMockTest } = new RouterBus();
-const show = ref(false);
-const fn = () => {
-  console.log(123);
-  show.value = true;
-};
+const { branchList } = useMyBranchList();
+const searchValue = ref("");
 </script>
 
 <style scoped lang="scss">