Showing
3 changed files
with
57 additions
and
24 deletions
src/api/B/kg.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Author: hookehuyr hookehuyr@gmail.com | ||
| 3 | + * @Date: 2022-06-09 02:25:31 | ||
| 4 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 5 | + * @LastEditTime: 2022-06-09 02:26:54 | ||
| 6 | + * @FilePath: /tswj/src/api/B/kg.js | ||
| 7 | + * @Description: 幼儿园主页接口 | ||
| 8 | + */ | ||
| 9 | +import { fn, fetch } from '@/api/fn'; | ||
| 10 | + | ||
| 11 | +const Api = { | ||
| 12 | + KG_INFO: '/srv/?a=kg_info', | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * @description 幼儿园详情 | ||
| 17 | + * @returns {*} data | ||
| 18 | + */ | ||
| 19 | +export const kgInfoAPI = (params) => fn(fetch.get(Api.KG_INFO, params)); |
| ... | @@ -2,12 +2,12 @@ | ... | @@ -2,12 +2,12 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-31 12:06:19 | 3 | * @Date: 2022-05-31 12:06:19 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-06-03 00:05:56 | 5 | + * @LastEditTime: 2022-06-09 02:02:04 |
| 6 | * @FilePath: /tswj/src/main.js | 6 | * @FilePath: /tswj/src/main.js |
| 7 | * @Description: | 7 | * @Description: |
| 8 | */ | 8 | */ |
| 9 | import { createApp } from 'vue'; | 9 | import { createApp } from 'vue'; |
| 10 | -import { Button, Image as VanImage, Col, Row, Icon, Form, Field, CellGroup, ConfigProvider, Toast, Uploader, Empty, Tab, Tabs, Overlay, NumberKeyboard, Lazyload, List, PullRefresh, Popup, Picker, Sticky, Stepper, Tag, Swipe, SwipeItem, Dialog, ActionSheet, Loading, Checkbox } from 'vant'; | 10 | +import { Button, Image as VanImage, Col, Row, Icon, Form, Field, CellGroup, ConfigProvider, Toast, Uploader, Empty, Tab, Tabs, Overlay, NumberKeyboard, Lazyload, List, PullRefresh, Popup, Picker, Sticky, Stepper, Tag, Swipe, SwipeItem, Dialog, ActionSheet, Loading, Checkbox, Search } from 'vant'; |
| 11 | import router from './router'; | 11 | import router from './router'; |
| 12 | import App from './App.vue'; | 12 | import App from './App.vue'; |
| 13 | // import axios from './utils/axios'; | 13 | // import axios from './utils/axios'; |
| ... | @@ -20,7 +20,7 @@ const app = createApp(App); | ... | @@ -20,7 +20,7 @@ const app = createApp(App); |
| 20 | 20 | ||
| 21 | app.config.globalProperties.$http = axios; // 关键语句 | 21 | app.config.globalProperties.$http = axios; // 关键语句 |
| 22 | 22 | ||
| 23 | -app.use(pinia).use(router).use(Button).use(VanImage).use(Col).use(Row).use(Icon).use(Form).use(Field).use(CellGroup).use(Toast).use(Uploader).use(Empty).use(Tab).use(Tabs).use(Overlay).use(NumberKeyboard).use(Lazyload).use(List).use(PullRefresh).use(Popup).use(Picker).use(Sticky).use(Stepper).use(Tag).use(Swipe).use(SwipeItem).use(Dialog).use(ActionSheet).use(Loading).use(Checkbox); | 23 | +app.use(pinia).use(router).use(Button).use(VanImage).use(Col).use(Row).use(Icon).use(Form).use(Field).use(CellGroup).use(Toast).use(Uploader).use(Empty).use(Tab).use(Tabs).use(Overlay).use(NumberKeyboard).use(Lazyload).use(List).use(PullRefresh).use(Popup).use(Picker).use(Sticky).use(Stepper).use(Tag).use(Swipe).use(SwipeItem).use(Dialog).use(ActionSheet).use(Loading).use(Checkbox).use(Search); |
| 24 | 24 | ||
| 25 | app.use(ConfigProvider); | 25 | app.use(ConfigProvider); |
| 26 | 26 | ... | ... |
| ... | @@ -4,7 +4,8 @@ | ... | @@ -4,7 +4,8 @@ |
| 4 | <div class="belong-school"> | 4 | <div class="belong-school"> |
| 5 | <van-row align="center" justify="center" style="position: relative; top: 50%; transform: translateY(-50%);"> | 5 | <van-row align="center" justify="center" style="position: relative; top: 50%; transform: translateY(-50%);"> |
| 6 | <van-col span="2"> | 6 | <van-col span="2"> |
| 7 | - <van-image round width="3rem" height="3rem" lazy-load :src="kgInfo.logo ? kgInfo.logo : icon_logo" style="vertical-align: text-bottom;" /> | 7 | + <van-image round width="3rem" height="3rem" lazy-load :src="kgInfo.logo ? kgInfo.logo : icon_logo" |
| 8 | + style="vertical-align: text-bottom;" /> | ||
| 8 | </van-col> | 9 | </van-col> |
| 9 | <van-col span="22"> | 10 | <van-col span="22"> |
| 10 | <p class="title">{{ kgInfo.name }}</p> | 11 | <p class="title">{{ kgInfo.name }}</p> |
| ... | @@ -61,8 +62,12 @@ | ... | @@ -61,8 +62,12 @@ |
| 61 | </van-col> | 62 | </van-col> |
| 62 | </van-row> | 63 | </van-row> |
| 63 | </div> | 64 | </div> |
| 65 | + <!-- NOTICE: 新增搜索功能,需要时放出 --> | ||
| 66 | + <!-- <van-sticky> | ||
| 67 | + <van-search v-model="search_value" placeholder="请输入书籍名称" @search="onSearch" /> | ||
| 68 | + </van-sticky> --> | ||
| 64 | <template v-for="(item, key) in kgInfo.book" :key="key"> | 69 | <template v-for="(item, key) in kgInfo.book" :key="key"> |
| 65 | - <book-card :item="item" :type="USER_ROLE.BUSINESS" :user_id="kgInfo.user_id" /> | 70 | + <book-card v-if="item.show" :item="item" :type="USER_ROLE.BUSINESS" :user_id="kgInfo.user_id" /> |
| 66 | </template> | 71 | </template> |
| 67 | <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无书籍" /> | 72 | <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无书籍" /> |
| 68 | </div> | 73 | </div> |
| ... | @@ -75,34 +80,43 @@ | ... | @@ -75,34 +80,43 @@ |
| 75 | import { no_image, icon_logo, icon_book } from '@/utils/generateIcons' | 80 | import { no_image, icon_logo, icon_book } from '@/utils/generateIcons' |
| 76 | import { ShortcutFixed, BookCard } from '@/utils/generateModules' | 81 | import { ShortcutFixed, BookCard } from '@/utils/generateModules' |
| 77 | import { USER_ROLE } from '@/constant' | 82 | import { USER_ROLE } from '@/constant' |
| 78 | - | 83 | +import { kgInfoAPI } from '@/api/B/kg' |
| 79 | -import { ref } from 'vue' | 84 | +import { onMounted, ref, watch } from 'vue' |
| 80 | -import axios from '@/utils/axios'; | ||
| 81 | -import { Toast } from 'vant'; | ||
| 82 | 85 | ||
| 83 | // 因为不能让空图标提前出来的写法 | 86 | // 因为不能让空图标提前出来的写法 |
| 84 | const emptyStatus = ref(false); | 87 | const emptyStatus = ref(false); |
| 85 | 88 | ||
| 86 | const kgInfo = ref({}); | 89 | const kgInfo = ref({}); |
| 87 | -axios.get('/srv/?a=kg_info') | 90 | +onMounted(async () => { |
| 88 | -.then(res => { | 91 | + const { data } = await kgInfoAPI() |
| 89 | - if (res.data.code === 1) { | 92 | + kgInfo.value = data |
| 90 | - kgInfo.value = res.data.data; | 93 | + kgInfo.value.book.forEach(item => { |
| 91 | - if (!res.data.data.book.length) { | 94 | + item.show = true; |
| 95 | + }); | ||
| 96 | + if (!data.book.length) { | ||
| 92 | emptyStatus.value = true; | 97 | emptyStatus.value = true; |
| 93 | } | 98 | } |
| 94 | - } else { | 99 | +}) |
| 95 | - console.warn(res); | 100 | + |
| 96 | - if (!res.data.show) return false; | 101 | +/********************* 搜索功能栏 **********************/ |
| 97 | - Toast({ | 102 | +const search_value = ref('') |
| 98 | - icon: 'close', | 103 | +const onSearch = () => { // 前端过滤搜索结果 |
| 99 | - message: res.data.msg | 104 | + kgInfo.value.book.forEach(item => { |
| 105 | + if (item.name.indexOf(search_value.value) === -1) { | ||
| 106 | + item.show = false; | ||
| 107 | + } | ||
| 108 | + }); | ||
| 109 | +} | ||
| 110 | +watch( | ||
| 111 | + search_value, | ||
| 112 | + (v) => { | ||
| 113 | + if (!v) { | ||
| 114 | + kgInfo.value.book.forEach(item => { | ||
| 115 | + item.show = true; | ||
| 100 | }); | 116 | }); |
| 101 | } | 117 | } |
| 102 | -}) | 118 | + } |
| 103 | -.catch(err => { | 119 | +) |
| 104 | - console.error(err); | ||
| 105 | -}); | ||
| 106 | </script> | 120 | </script> |
| 107 | 121 | ||
| 108 | <style lang="less" scoped> | 122 | <style lang="less" scoped> | ... | ... |
-
Please register or login to post a comment