home.uvue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script lang="ts" setup>
  2. import { computed, onMounted, ref } from 'vue'
  3. import { dict } from '@/.cool/store'
  4. import { router } from '@/.cool'
  5. import { user } from '@/.cool'
  6. import Physics from './components/physics.uvue'
  7. import Chinese from './components/chinese.uvue'
  8. import English from './components/english.uvue'
  9. import Mix from './components/mix.uvue'
  10. import Game from './components/game.uvue'
  11. import Exchange from './components/exchange.uvue'
  12. const menuList = computed(() => {
  13. return [
  14. ...dict.getChildrenList('index_subject_id'),
  15. {
  16. label: '兑换',
  17. code: 'exchange'
  18. },
  19. {
  20. label: '个人中心',
  21. code: 'user'
  22. },
  23. ]
  24. })
  25. const icons = {
  26. physics: "https://oss.xiaoxiongcode.com/static/home/wl.png",
  27. chinese: "https://oss.xiaoxiongcode.com/static/home/语文.png",
  28. english: "https://oss.xiaoxiongcode.com/static/home/英语.png",
  29. mix: "https://oss.xiaoxiongcode.com/static/home/百度百科.png",
  30. game: "https://oss.xiaoxiongcode.com/static/home/娱乐.png",
  31. exchange: "https://oss.xiaoxiongcode.com/static/home/图层 5.png",
  32. user: "https://oss.xiaoxiongcode.com/static/home/个人中心.png",
  33. }
  34. const selected = ref<string>('physics')
  35. function handlePage(val: any) {
  36. selected.value = val.code
  37. if (val.code === 'user') {
  38. router.push({ path: '/pages/user/info' })
  39. }
  40. }
  41. onMounted(() => {
  42. console.log(menuList.value)
  43. })
  44. function handleView(url) {
  45. router.push({ path: url })
  46. }
  47. const userInfo = computed(() => user.info.value?.userInfo)
  48. </script>
  49. <template>
  50. <cl-page>
  51. <img src="https://oss.xiaoxiongcode.com/static/home/11.png" alt="" class="w-full h-full object-cover" />
  52. <view class="menus ">
  53. <view v-for="item in menuList" :key="item.code"
  54. class="flex flex-col items-center p-1 px-4 justify-center gap-1 active:scale-[.9] transition-all duration-300"
  55. @tap="handlePage(item)" :class="{ 'selected': item.code === selected }">
  56. <cl-image :src="icons[item.code]" mode="aspectFill" width="40" height="40"></cl-image>
  57. <text class="text-[12px]">{{ item.label }}</text>
  58. </view>
  59. </view>
  60. <Physics v-if="selected === 'physics'" />
  61. <Chinese v-else-if="selected === 'chinese'" />
  62. <English v-else-if="selected === 'english'" />
  63. <Mix v-else-if="selected === 'mix'" />
  64. <Game v-else-if="selected === 'game'" />
  65. <Exchange v-else-if="selected === 'exchange'" />
  66. </cl-page>
  67. </template>
  68. <style lang="scss" scoped>
  69. .menus {
  70. @apply absolute top-[5vh] left-1/2 bg-white rounded-[20px] p-2 px-3 flex flex-row items-center justify-center gap-2;
  71. transform: translateX(-50%);
  72. }
  73. .selected {
  74. @apply scale-[1.1] bg-[#f0f0f0] rounded-xl;
  75. }
  76. </style>