home.uvue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. if (val.code === 'user') {
  37. router.push({ path: '/pages/user/info' })
  38. return
  39. }
  40. selected.value = val.code
  41. }
  42. onMounted(() => {
  43. console.log(menuList.value)
  44. })
  45. function handleView(url) {
  46. router.push({ path: url })
  47. }
  48. const userInfo = computed(() => user.info.value?.userInfo)
  49. </script>
  50. <template>
  51. <cl-page>
  52. <img src="https://oss.xiaoxiongcode.com/static/home/11.png" alt="" class="w-full h-full object-cover" />
  53. <view class="menus ">
  54. <view v-for="item in menuList" :key="item.code"
  55. class="flex flex-col items-center p-1 px-4 justify-center gap-1 active:scale-[.9] transition-all duration-300"
  56. @tap="handlePage(item)" :class="{ 'selected': item.code === selected }">
  57. <cl-image :src="icons[item.code]" mode="aspectFill" width="40" height="40"></cl-image>
  58. <text class="text-[12px]">{{ item.label }}</text>
  59. </view>
  60. </view>
  61. <Physics v-if="selected === 'physics'" />
  62. <Chinese v-else-if="selected === 'chinese'" />
  63. <English v-else-if="selected === 'english'" />
  64. <Mix v-else-if="selected === 'mix'" />
  65. <Game v-else-if="selected === 'game'" />
  66. <Exchange v-else-if="selected === 'exchange'" />
  67. </cl-page>
  68. </template>
  69. <style lang="scss" scoped>
  70. .menus {
  71. @apply absolute top-[3vh] left-1/2 bg-white rounded-[20px] p-2 px-3 flex flex-row items-center justify-center gap-2;
  72. transform: translateX(-50%);
  73. }
  74. .selected {
  75. @apply scale-[1.1] bg-[#f0f0f0] rounded-xl;
  76. }
  77. </style>