home.uvue 2.0 KB

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