home.uvue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. const visible = ref(false)
  50. </script>
  51. <template>
  52. <cl-page :backTop="false">
  53. <img src="https://oss.xiaoxiongcode.com/static/home/11.jpg" alt="" class="w-full h-full object-cover" />
  54. <view class="menus ">
  55. <view v-for="item in menuList" :key="item.code"
  56. class="flex flex-col items-center p-1 px-4 justify-center gap-1 active:scale-[.9] transition-all duration-300"
  57. @tap="handlePage(item)" :class="{ 'selected': item.code === selected }">
  58. <cl-image :src="icons[item.code]" mode="aspectFill" width="40" height="40"></cl-image>
  59. <text class="text-[12px]">{{ item.label }}</text>
  60. </view>
  61. </view>
  62. <view class="flex flex-col items-center justify-center fixed bottom-[3vh] right-[3vh] " >
  63. <view class="bg-[#09ba07] p-2 rounded-full border-[2px] border-[#FFF] border-solid " @tap="visible = true">
  64. <image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" class="w-5 h-5"></image>
  65. </view>
  66. <text class="text-[14px] text-white font-bold text-stroke">添加老师</text>
  67. </view>
  68. <cl-popup v-model="visible" :size="400" :show-header="false" direction="center">
  69. <view class="flex flex-col items-center justify-center gap-4 py-7 bg-slate-50">
  70. <cl-text class="text-center " color="#09ba07" :size="30"> ——专属服务内容—— </cl-text>
  71. <image src="https://oss.xiaoxiongcode.com/static/home/qr.png" show-menu-by-longpress class="w-32 h-32" />
  72. <view class="text-center "> <cl-text class="text-center" color="#999" :size="14"> 长按识别二维码 </cl-text>
  73. <cl-text class="text-center" color="#999" :size="14"> 添加微信,享专业老师服务 </cl-text> </view>
  74. </view>
  75. </cl-popup>
  76. <Physics v-if="selected === 'physics'" />
  77. <Chinese v-else-if="selected === 'chinese'" />
  78. <English v-else-if="selected === 'english'" />
  79. <Mix v-else-if="selected === 'mix'" />
  80. <Game v-else-if="selected === 'game'" />
  81. <Exchange v-else-if="selected === 'exchange'" />
  82. </cl-page>
  83. </template>
  84. <style lang="scss" scoped>
  85. .menus {
  86. @apply absolute top-[3vh] left-1/2 bg-white rounded-[20px] p-2 px-3 flex flex-row items-center justify-center gap-2;
  87. transform: translateX(-50%);
  88. }
  89. .selected {
  90. @apply scale-[1.1] bg-[#f0f0f0] rounded-xl;
  91. }
  92. .text-stroke {
  93. text-shadow:
  94. -1px -1px 0 #000,
  95. 1px -1px 0 #000,
  96. -1px 1px 0 #000,
  97. 1px 1px 0 #000;
  98. }
  99. </style>