Showing
5 changed files
with
69 additions
and
65 deletions
| ... | @@ -3,11 +3,13 @@ import { onMounted, onUnmounted } from 'vue' | ... | @@ -3,11 +3,13 @@ import { onMounted, onUnmounted } from 'vue' |
| 3 | import { useVideoList } from '@/composables/useVideoList.js' | 3 | import { useVideoList } from '@/composables/useVideoList.js' |
| 4 | import { useDefaultPerf } from '@/composables/useDefaultPerf.js' | 4 | import { useDefaultPerf } from '@/composables/useDefaultPerf.js' |
| 5 | import { useBookList } from '@/composables/useBookList.js' | 5 | import { useBookList } from '@/composables/useBookList.js' |
| 6 | +import { useShortcutBar } from '@/composables/useShortcutBar.js' | ||
| 6 | 7 | ||
| 7 | export { | 8 | export { |
| 8 | useVideoList, | 9 | useVideoList, |
| 9 | useDefaultPerf, | 10 | useDefaultPerf, |
| 10 | - useBookList | 11 | + useBookList, |
| 12 | + useShortcutBar | ||
| 11 | } | 13 | } |
| 12 | 14 | ||
| 13 | /** | 15 | /** | ... | ... |
src/composables/useShortcutBar.js
0 → 100644
| 1 | +import { useRoute } from 'vue-router'; | ||
| 2 | +import { ref } from 'vue'; | ||
| 3 | +import { Cookies } from '@/utils/generatePackage' | ||
| 4 | + | ||
| 5 | +export const useShortcutBar = (item) => { | ||
| 6 | + const $route = useRoute(); | ||
| 7 | + const path = $route.path; | ||
| 8 | + const isClient = Cookies.get('userType') === 'client' ? true : false; // 判断C端入口位置,访客/客户 | ||
| 9 | + const case1 = ['home', 'me']; | ||
| 10 | + const case2 = ['home']; | ||
| 11 | + const case3 = ['me']; | ||
| 12 | + const shortcutItem = ref([]); | ||
| 13 | + | ||
| 14 | + // 配置快捷跳转条 | ||
| 15 | + if (item) { | ||
| 16 | + shortcutItem.value = item; | ||
| 17 | + } else { | ||
| 18 | + if (path === '/client/chooseBook') { // 爱心捐书页面 | ||
| 19 | + if (isClient) { | ||
| 20 | + shortcutItem.value = case1 | ||
| 21 | + } else { | ||
| 22 | + shortcutItem.value = case3 | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + if (path === '/client/donateCertificate') { | ||
| 27 | + shortcutItem.value = case2 | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + if (path === '/business/index') { | ||
| 31 | + shortcutItem.value = case3 | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + return { | ||
| 36 | + shortcutItem | ||
| 37 | + } | ||
| 38 | +} |
| ... | @@ -66,7 +66,7 @@ | ... | @@ -66,7 +66,7 @@ |
| 66 | </van-row> | 66 | </van-row> |
| 67 | </div> | 67 | </div> |
| 68 | <template v-for="(item, key) in kgInfo.book" :key="key"> | 68 | <template v-for="(item, key) in kgInfo.book" :key="key"> |
| 69 | - <book-card :item="item" type="B" :user_id="kgInfo.user_id" @on-click="onClick(item)"></book-card> | 69 | + <book-card :item="item" type="B" :user_id="kgInfo.user_id"></book-card> |
| 70 | </template> | 70 | </template> |
| 71 | <van-empty v-if="emptyStatus" | 71 | <van-empty v-if="emptyStatus" |
| 72 | class="custom-image" | 72 | class="custom-image" |
| ... | @@ -75,36 +75,20 @@ | ... | @@ -75,36 +75,20 @@ |
| 75 | /> | 75 | /> |
| 76 | </div> | 76 | </div> |
| 77 | <div style="height: 1rem;"></div> | 77 | <div style="height: 1rem;"></div> |
| 78 | - <shortcut-fixed type="B" :item="['me']"></shortcut-fixed> | 78 | + <shortcut-fixed type="B" :item="shortcutItem"></shortcut-fixed> |
| 79 | </div> | 79 | </div> |
| 80 | </template> | 80 | </template> |
| 81 | 81 | ||
| 82 | <script setup> | 82 | <script setup> |
| 83 | -import icon_avatar from '@images/que-logo@2x.png' | 83 | +import { no_image, icon_avatar, icon_book } from '@/utils/generateIcons' |
| 84 | -import no_image from '@images/que-shuju@2x.png' | 84 | +import { ShortcutFixed, BookCard } from '@/utils/generateModules' |
| 85 | 85 | ||
| 86 | -import icon_book from '@images/shu@2x.png' | 86 | +import { ref } from 'vue' |
| 87 | -import BookCard from '@/components/BookCard/index.vue' | ||
| 88 | -import ShortcutFixed from '@/components/ShortcutFixed/index.vue' | ||
| 89 | - | ||
| 90 | -import { ref, reactive, onMounted } from 'vue' | ||
| 91 | -import { useRoute, useRouter } from 'vue-router' | ||
| 92 | import axios from '@/utils/axios'; | 87 | import axios from '@/utils/axios'; |
| 93 | import { Toast } from 'vant'; | 88 | import { Toast } from 'vant'; |
| 89 | +import { useShortcutBar } from '@/composables'; | ||
| 94 | 90 | ||
| 95 | -const $route = useRoute(); | 91 | +const { shortcutItem } = useShortcutBar(['home']); // 配置快捷跳转条 |
| 96 | -const $router = useRouter(); | ||
| 97 | - | ||
| 98 | -const items = reactive([]) | ||
| 99 | -const onClick = (item) => { | ||
| 100 | - // 调整书籍详情页 | ||
| 101 | - $router.push({ | ||
| 102 | - path: '/client/bookDetail', | ||
| 103 | - query: { | ||
| 104 | - id: item.id | ||
| 105 | - } | ||
| 106 | - }); | ||
| 107 | -} | ||
| 108 | 92 | ||
| 109 | // 因为不能让空图标提前出来的写法 | 93 | // 因为不能让空图标提前出来的写法 |
| 110 | const emptyStatus = ref(false); | 94 | const emptyStatus = ref(false); | ... | ... |
| ... | @@ -4,10 +4,12 @@ | ... | @@ -4,10 +4,12 @@ |
| 4 | <div class="belong-school" v-if="kg_id"> | 4 | <div class="belong-school" v-if="kg_id"> |
| 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 v-if="kgInfo.logo" round width="3rem" height="3rem" lazy-load :src="kgInfo.logo" style="vertical-align: text-bottom;"> | 7 | + <van-image v-if="kgInfo.logo" round width="3rem" height="3rem" lazy-load :src="kgInfo.logo" |
| 8 | + style="vertical-align: text-bottom;"> | ||
| 8 | <template v-slot:error>加载失败</template> | 9 | <template v-slot:error>加载失败</template> |
| 9 | </van-image> | 10 | </van-image> |
| 10 | - <van-image v-else round width="3rem" height="3rem" lazy-load :src="icon_avatar" style="vertical-align: text-bottom;"> | 11 | + <van-image v-else round width="3rem" height="3rem" lazy-load :src="icon_avatar" |
| 12 | + style="vertical-align: text-bottom;"> | ||
| 11 | <template v-slot:error>加载失败</template> | 13 | <template v-slot:error>加载失败</template> |
| 12 | </van-image> | 14 | </van-image> |
| 13 | </van-col> | 15 | </van-col> |
| ... | @@ -23,7 +25,7 @@ | ... | @@ -23,7 +25,7 @@ |
| 23 | <van-row> | 25 | <van-row> |
| 24 | <van-col span="4"></van-col> | 26 | <van-col span="4"></van-col> |
| 25 | <van-col span="16"> | 27 | <van-col span="16"> |
| 26 | - <my-button type="custom" :custom-style="styleObject">幼儿园爱心书籍</my-button> | 28 | + <my-button type="custom" :custom-style="styleObject3">幼儿园爱心书籍</my-button> |
| 27 | </van-col> | 29 | </van-col> |
| 28 | <van-col span="4"></van-col> | 30 | <van-col span="4"></van-col> |
| 29 | </van-row> | 31 | </van-row> |
| ... | @@ -32,13 +34,9 @@ | ... | @@ -32,13 +34,9 @@ |
| 32 | </div> | 34 | </div> |
| 33 | <div class="book-list"> | 35 | <div class="book-list"> |
| 34 | <template v-for="(item, key) in kgInfo.book_list" :key="key"> | 36 | <template v-for="(item, key) in kgInfo.book_list" :key="key"> |
| 35 | - <book-card type="C" :item="item" @on-click="onClick(item)"></book-card> | 37 | + <book-card type="C" :item="item" @on-click="go('/client/bookDetail', { id: item.id })"></book-card> |
| 36 | </template> | 38 | </template> |
| 37 | - <van-empty v-if="emptyStatus" | 39 | + <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无书籍信息" /> |
| 38 | - class="custom-image" | ||
| 39 | - :image="no_image" | ||
| 40 | - description="暂无书籍信息" | ||
| 41 | - /> | ||
| 42 | </div> | 40 | </div> |
| 43 | <div style="height: 1rem;"></div> | 41 | <div style="height: 1rem;"></div> |
| 44 | <shortcut-fixed type="C" :item="shortcutItem"></shortcut-fixed> | 42 | <shortcut-fixed type="C" :item="shortcutItem"></shortcut-fixed> |
| ... | @@ -46,17 +44,14 @@ | ... | @@ -46,17 +44,14 @@ |
| 46 | </template> | 44 | </template> |
| 47 | 45 | ||
| 48 | <script setup> | 46 | <script setup> |
| 49 | -import { ref, reactive, onMounted } from 'vue' | 47 | +import { _, mainStore } from '@/utils/generatePackage' |
| 50 | -import { useRoute } from 'vue-router' | ||
| 51 | - | ||
| 52 | -import { Cookies, _, axios, mainStore, Toast, useTitle } from '@/utils/generatePackage' | ||
| 53 | import { no_image, icon_avatar } from '@/utils/generateIcons' | 48 | import { no_image, icon_avatar } from '@/utils/generateIcons' |
| 54 | import { MyButton, ShortcutFixed, BookCard } from '@/utils/generateModules' | 49 | import { MyButton, ShortcutFixed, BookCard } from '@/utils/generateModules' |
| 55 | - | 50 | +import { styleObject3 } from '@/settings/designSetting.js' |
| 56 | -import { useBookList } from '@/composables'; | 51 | +import { useBookList, useShortcutBar } from '@/composables'; |
| 57 | import { useGo } from '@/hooks/useGo' | 52 | import { useGo } from '@/hooks/useGo' |
| 53 | + | ||
| 58 | const go = useGo() | 54 | const go = useGo() |
| 59 | -const $route = useRoute(); | ||
| 60 | 55 | ||
| 61 | // 删除所有的 keep-alive 缓存 | 56 | // 删除所有的 keep-alive 缓存 |
| 62 | const store = mainStore() | 57 | const store = mainStore() |
| ... | @@ -64,40 +59,24 @@ store.changeKeepPages(); | ... | @@ -64,40 +59,24 @@ store.changeKeepPages(); |
| 64 | // 清空记录位置 | 59 | // 清空记录位置 |
| 65 | store.changeScrollTop(0); | 60 | store.changeScrollTop(0); |
| 66 | 61 | ||
| 67 | -const { kg_id, kgInfo, emptyStatus } = useBookList($route) | 62 | +const { kg_id, kgInfo, emptyStatus } = useBookList(); |
| 68 | - | 63 | +const { shortcutItem } = useShortcutBar(); // 配置快捷跳转条 |
| 69 | -// 配置快捷跳转条 | ||
| 70 | -const shortcutItem = ref([]); | ||
| 71 | -if (Cookies.get('userType') === 'client') { | ||
| 72 | - shortcutItem.value = ['home', 'me'] | ||
| 73 | -} else { | ||
| 74 | - shortcutItem.value = ['me'] | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -// 自定义按钮颜色样式 | ||
| 78 | -const styleObject = reactive({ | ||
| 79 | - backgroundColor: '#F4675A', | ||
| 80 | - color: '#FFFFFF', | ||
| 81 | - borderColor: '#F4675A' | ||
| 82 | -}) | ||
| 83 | - | ||
| 84 | -// 跳转书籍详情页 | ||
| 85 | -const onClick = (item) => { | ||
| 86 | - go('/client/bookDetail', { id: item.id }) | ||
| 87 | -} | ||
| 88 | </script> | 64 | </script> |
| 89 | 65 | ||
| 90 | <style lang="less" scoped> | 66 | <style lang="less" scoped> |
| 91 | @import url('@css/content-bg.less'); | 67 | @import url('@css/content-bg.less'); |
| 68 | + | ||
| 92 | :global(.custom-image .van-empty__image) { | 69 | :global(.custom-image .van-empty__image) { |
| 93 | // margin-top: 15vh; | 70 | // margin-top: 15vh; |
| 94 | width: 10rem; | 71 | width: 10rem; |
| 95 | height: 10rem; | 72 | height: 10rem; |
| 96 | } | 73 | } |
| 74 | + | ||
| 97 | .choose-book-page { | 75 | .choose-book-page { |
| 98 | .belong-school { | 76 | .belong-school { |
| 99 | padding: 1.5rem; | 77 | padding: 1.5rem; |
| 100 | height: 3rem; | 78 | height: 3rem; |
| 79 | + | ||
| 101 | .title { | 80 | .title { |
| 102 | color: #222222; | 81 | color: #222222; |
| 103 | display: inline-block; | 82 | display: inline-block; | ... | ... |
| ... | @@ -9,16 +9,17 @@ | ... | @@ -9,16 +9,17 @@ |
| 9 | import DonateCert from '@/components/DonateCert/index' | 9 | import DonateCert from '@/components/DonateCert/index' |
| 10 | import ShortcutFixed from '@/components/ShortcutFixed/index' | 10 | import ShortcutFixed from '@/components/ShortcutFixed/index' |
| 11 | 11 | ||
| 12 | -import { ref, reactive, onMounted } from 'vue' | 12 | +import { ref } from 'vue' |
| 13 | import { useRoute, useRouter } from 'vue-router' | 13 | import { useRoute, useRouter } from 'vue-router' |
| 14 | import axios from '@/utils/axios'; | 14 | import axios from '@/utils/axios'; |
| 15 | -import $ from 'jquery' | ||
| 16 | import { Toast } from 'vant'; | 15 | import { Toast } from 'vant'; |
| 16 | +import { useShortcutBar } from '@/composables'; | ||
| 17 | + | ||
| 17 | const $route = useRoute(); | 18 | const $route = useRoute(); |
| 18 | -const $router = useRouter(); | ||
| 19 | 19 | ||
| 20 | // 配置快捷跳转条 | 20 | // 配置快捷跳转条 |
| 21 | -const shortcutItem = ref(['home']); | 21 | +// const shortcutItem = ref(['home']); |
| 22 | +const { shortcutItem } = useShortcutBar(['home']); // 配置快捷跳转条 | ||
| 22 | 23 | ||
| 23 | const certItem = ref('') | 24 | const certItem = ref('') |
| 24 | // 捐款成功后,查询生成捐赠证书 | 25 | // 捐款成功后,查询生成捐赠证书 | ... | ... |
-
Please register or login to post a comment