Showing
4 changed files
with
61 additions
and
3 deletions
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-18 21:12:23 | 3 | * @Date: 2022-05-18 21:12:23 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-06-01 15:32:49 | 5 | + * @LastEditTime: 2022-06-09 09:21:54 |
| 6 | * @FilePath: /tswj/src/api/C/kg.js | 6 | * @FilePath: /tswj/src/api/C/kg.js |
| 7 | * @Description: 幼儿园相关接口 | 7 | * @Description: 幼儿园相关接口 |
| 8 | */ | 8 | */ |
| ... | @@ -12,6 +12,7 @@ const Api = { | ... | @@ -12,6 +12,7 @@ const Api = { |
| 12 | KG_LIST: '/srv/?a=kg_list', | 12 | KG_LIST: '/srv/?a=kg_list', |
| 13 | KG_DONATE_LIST: '/srv/?a=donate_list', | 13 | KG_DONATE_LIST: '/srv/?a=donate_list', |
| 14 | KG_DONATE_RANK: '/srv/?a=donate_rank', | 14 | KG_DONATE_RANK: '/srv/?a=donate_rank', |
| 15 | + KG_BOOK_LIST: '/srv/?a=kg_book_list', | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| ... | @@ -38,3 +39,10 @@ export const kgDonateListAPI = (params) => fn(fetch.get(Api.KG_DONATE_LIST, para | ... | @@ -38,3 +39,10 @@ export const kgDonateListAPI = (params) => fn(fetch.get(Api.KG_DONATE_LIST, para |
| 38 | * @returns {array} data | 39 | * @returns {array} data |
| 39 | */ | 40 | */ |
| 40 | export const kgDonateRankAPI = (params) => fn(fetch.get(Api.KG_DONATE_RANK, params)); | 41 | export const kgDonateRankAPI = (params) => fn(fetch.get(Api.KG_DONATE_RANK, params)); |
| 42 | + | ||
| 43 | +/** | ||
| 44 | + * @description 幼儿园书籍列表 | ||
| 45 | + * @param {*} kg_id 幼儿园ID | ||
| 46 | + * @returns {*} data | ||
| 47 | + */ | ||
| 48 | +export const kgBookListAPI = (params) => fn(fetch.get(Api.KG_BOOK_LIST, params)); | ... | ... |
| 1 | +/* | ||
| 2 | + * @Author: hookehuyr hookehuyr@gmail.com | ||
| 3 | + * @Date: 2022-05-17 12:13:13 | ||
| 4 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 5 | + * @LastEditTime: 2022-06-09 09:40:35 | ||
| 6 | + * @FilePath: /tswj/src/composables/index.js | ||
| 7 | + * @Description: | ||
| 8 | + */ | ||
| 1 | import { onMounted, onUnmounted } from 'vue' | 9 | import { onMounted, onUnmounted } from 'vue' |
| 2 | 10 | ||
| 3 | import { useVideoList } from '@/composables/useVideoList.js' | 11 | import { useVideoList } from '@/composables/useVideoList.js' |
| 4 | import { useDefaultPerf } from '@/composables/useDefaultPerf.js' | 12 | import { useDefaultPerf } from '@/composables/useDefaultPerf.js' |
| 5 | -import { useBookList } from '@/composables/useBookList.js' | 13 | +import { useBookList, useAsyncBookList } from '@/composables/useBookList.js' |
| 6 | import { useShortcutBar } from '@/composables/useShortcutBar.js' | 14 | import { useShortcutBar } from '@/composables/useShortcutBar.js' |
| 7 | import { useScrollTop } from '@/composables/useScrollTop.js' | 15 | import { useScrollTop } from '@/composables/useScrollTop.js' |
| 8 | 16 | ||
| ... | @@ -10,6 +18,7 @@ export { | ... | @@ -10,6 +18,7 @@ export { |
| 10 | useVideoList, | 18 | useVideoList, |
| 11 | useDefaultPerf, | 19 | useDefaultPerf, |
| 12 | useBookList, | 20 | useBookList, |
| 21 | + useAsyncBookList, | ||
| 13 | useShortcutBar, | 22 | useShortcutBar, |
| 14 | useScrollTop | 23 | useScrollTop |
| 15 | } | 24 | } | ... | ... |
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-07 17:46:54 | 3 | * @Date: 2022-05-07 17:46:54 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-06-01 21:40:57 | 5 | + * @LastEditTime: 2022-06-09 11:26:42 |
| 6 | * @FilePath: /tswj/src/composables/useBookList.js | 6 | * @FilePath: /tswj/src/composables/useBookList.js |
| 7 | * @Description: | 7 | * @Description: |
| 8 | */ | 8 | */ |
| ... | @@ -10,6 +10,7 @@ import { ref } from 'vue' | ... | @@ -10,6 +10,7 @@ import { ref } from 'vue' |
| 10 | import axios from '@/utils/axios'; | 10 | import axios from '@/utils/axios'; |
| 11 | import { Toast } from 'vant'; | 11 | import { Toast } from 'vant'; |
| 12 | import { useRoute } from 'vue-router'; | 12 | import { useRoute } from 'vue-router'; |
| 13 | +import { kgBookListAPI } from '@/api/C/kg' | ||
| 13 | 14 | ||
| 14 | export const useBookList = () => { | 15 | export const useBookList = () => { |
| 15 | const $route = useRoute(); | 16 | const $route = useRoute(); |
| ... | @@ -32,6 +33,9 @@ export const useBookList = () => { | ... | @@ -32,6 +33,9 @@ export const useBookList = () => { |
| 32 | .then(res => { | 33 | .then(res => { |
| 33 | if (res.data.code === 1) { | 34 | if (res.data.code === 1) { |
| 34 | kgInfo.value = res.data.data; | 35 | kgInfo.value = res.data.data; |
| 36 | + kgInfo.value.book_list.forEach(item => { | ||
| 37 | + item.show = true; // 默认显示所有,给搜索功能留的hook | ||
| 38 | + }); | ||
| 35 | // 有空格分割name | 39 | // 有空格分割name |
| 36 | if (kgInfo.value.name.indexOf(' ') > -1) { | 40 | if (kgInfo.value.name.indexOf(' ') > -1) { |
| 37 | kgInfo.value.multi_name = kgInfo.value.name.split(' '); | 41 | kgInfo.value.multi_name = kgInfo.value.name.split(' '); |
| ... | @@ -57,6 +61,9 @@ export const useBookList = () => { | ... | @@ -57,6 +61,9 @@ export const useBookList = () => { |
| 57 | axios.get('/srv/?a=book_list') | 61 | axios.get('/srv/?a=book_list') |
| 58 | .then(res => { | 62 | .then(res => { |
| 59 | if (res.data.code === 1) { | 63 | if (res.data.code === 1) { |
| 64 | + res.data.data.forEach(item => { | ||
| 65 | + item.show = true; // 默认显示所有,给搜索功能留的hook | ||
| 66 | + }); | ||
| 60 | kgInfo.value = { | 67 | kgInfo.value = { |
| 61 | book_list: res.data.data | 68 | book_list: res.data.data |
| 62 | } | 69 | } |
| ... | @@ -84,3 +91,36 @@ export const useBookList = () => { | ... | @@ -84,3 +91,36 @@ export const useBookList = () => { |
| 84 | emptyStatus | 91 | emptyStatus |
| 85 | } | 92 | } |
| 86 | } | 93 | } |
| 94 | + | ||
| 95 | +// !!废弃方法 | ||
| 96 | +// 前端使用方式过于复杂 | ||
| 97 | +export const useAsyncBookList = async () => { | ||
| 98 | + const $route = useRoute(); | ||
| 99 | + const emptyStatus = ref(false); | ||
| 100 | + // tslint:disable-next-line: variable-name | ||
| 101 | + const kg_id = $route.query.kg_id ? $route.query.kg_id : ''; | ||
| 102 | + const kgInfo = ref({ | ||
| 103 | + id: '', | ||
| 104 | + logo: '', | ||
| 105 | + name: '', | ||
| 106 | + multi_name: [], | ||
| 107 | + book_list: [] | ||
| 108 | + }); | ||
| 109 | + const { data } = await kgBookListAPI({ kg_id }); | ||
| 110 | + if (data) kgInfo.value = data; | ||
| 111 | + kgInfo.value.book_list.forEach(item => { | ||
| 112 | + item.show = true; // 默认显示所有,给搜索功能留的hook | ||
| 113 | + }); | ||
| 114 | + // 有空格分割name | ||
| 115 | + if (kgInfo.value.name.indexOf(' ') > -1) { | ||
| 116 | + kgInfo.value.multi_name = kgInfo.value.name.split(' '); | ||
| 117 | + } | ||
| 118 | + if (!kgInfo.value.book_list.length) { | ||
| 119 | + emptyStatus.value = true; | ||
| 120 | + } | ||
| 121 | + return { | ||
| 122 | + kg_id, | ||
| 123 | + kgInfo, | ||
| 124 | + emptyStatus | ||
| 125 | + } | ||
| 126 | +} | ... | ... |
| ... | @@ -72,6 +72,7 @@ killPages(); | ... | @@ -72,6 +72,7 @@ killPages(); |
| 72 | store.changeScrollTop(0); | 72 | store.changeScrollTop(0); |
| 73 | 73 | ||
| 74 | const { kg_id, kgInfo, emptyStatus } = useBookList(); | 74 | const { kg_id, kgInfo, emptyStatus } = useBookList(); |
| 75 | + | ||
| 75 | // 配置快捷访问 | 76 | // 配置快捷访问 |
| 76 | const shortcutItem = ref([]) | 77 | const shortcutItem = ref([]) |
| 77 | const isClient = Cookies.get('userType') === 'client' ? true : false; // 判断C端入口位置,访客/客户 | 78 | const isClient = Cookies.get('userType') === 'client' ? true : false; // 判断C端入口位置,访客/客户 | ... | ... |
-
Please register or login to post a comment