home.uvue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. import MathModal from './components/math.uvue'
  13. const menuList = computed(() => {
  14. return [
  15. ...dict.getChildrenList('index_subject_id'),
  16. {
  17. label: '少儿编程',
  18. code: 'coding'
  19. },
  20. {
  21. label: '兑换',
  22. code: 'exchange'
  23. },
  24. {
  25. label: '个人中心',
  26. code: 'user'
  27. },
  28. ]
  29. })
  30. const icons = {
  31. physics: "https://oss.xiaoxiongcode.com/static/home/wl.png",
  32. chinese: "https://oss.xiaoxiongcode.com/static/home/语文.png",
  33. english: "https://oss.xiaoxiongcode.com/static/home/英语.png",
  34. mix: "https://oss.xiaoxiongcode.com/static/home/百度百科.png",
  35. game: "https://oss.xiaoxiongcode.com/static/home/娱乐.png",
  36. exchange: "https://oss.xiaoxiongcode.com/static/home/图层 5.png",
  37. user: "https://oss.xiaoxiongcode.com/static/home/个人中心.png",
  38. math: "https://oss.xiaoxiongcode.com/static/home/math.png",
  39. coding: "https://oss.xiaoxiongcode.com/static/home/coding.png",
  40. }
  41. const selected = ref<string>('physics')
  42. function handlePage(val: any) {
  43. if (val.code === 'user') {
  44. router.push({ path: '/pages/user/info' })
  45. return
  46. }
  47. if (val.code === 'coding') {
  48. visible2.value = true
  49. return
  50. }
  51. selected.value = val.code
  52. }
  53. onMounted(() => {
  54. console.log(menuList.value)
  55. })
  56. function handleView(url) {
  57. router.push({ path: url })
  58. }
  59. const userInfo = computed(() => user.info.value?.userInfo)
  60. const visible = ref(false)
  61. const visible2 = ref(false)
  62. function copyUrl() {
  63. uni.setClipboardData({
  64. data: 'www.xiaoxiongcode.com',
  65. success: (res) => {
  66. uni.showToast({
  67. title: '复制成功',
  68. icon: 'success'
  69. });
  70. }
  71. });
  72. }
  73. </script>
  74. <template>
  75. <cl-page :backTop="false">
  76. <image src="https://oss.xiaoxiongcode.com/static/home/111.png" mode="aspectFill" alt=""
  77. class="w-full h-full object-cover absolute top-0 left-0" />
  78. <view class="menus w-[90vw]">
  79. <image src="https://oss.xiaoxiongcode.com/static/home/643.png"
  80. class="w-[90vw] h-[24vh] absolute top-0 left-0 z-[1]"></image>
  81. <view class="w-[87vw] relative z-[2] p-1 px-3 flex flex-row items-center justify-between gap-1 mx-auto ">
  82. <view v-for="item in menuList" :key="item.code"
  83. class="flex flex-col items-center p-1 px-4 justify-center gap-1 transition-all duration-300"
  84. @tap="handlePage(item)" :class="{ 'selected': item.code === selected }">
  85. <image :src="icons[item.code]" mode="aspectFill" class="w-[4vw] h-[4vw]"></image>
  86. <text class="text-[1.5vw] text-[#1E1E1E]">{{ item.label }}</text>
  87. </view>
  88. </view>
  89. </view>
  90. <cl-float-view :left="20" :bottom="100">
  91. <view
  92. class="flex flex-col items-center p-1 px-4 justify-center gap-1 w-[40px] h-[40px] transition-all duration-300"
  93. @tap="visible = true">
  94. <view class="bg-[#09ba07] p-[1vw] rounded-full w-[40px] h-[40px] flex items-center justify-center"
  95. @tap="visible = true">
  96. <cl-icon name="customer-service-line" :size="20" color="#FFF"></cl-icon>
  97. </view>
  98. </view>
  99. </cl-float-view>
  100. <!-- <view class="flex flex-col items-center justify-center fixed bottom-[3vh] right-[3vh] ">
  101. <view class="bg-[#09ba07] p-2 rounded-full border-[2px] border-[#FFF] border-solid " @tap="visible = true">
  102. <image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" class="w-5 h-5"></image>
  103. </view>
  104. <text class="text-[14px] text-white font-bold text-stroke">添加老师</text>
  105. </view> -->
  106. <cl-popup v-model="visible" :size="400" :show-header="false" direction="center">
  107. <view class="flex flex-col items-center justify-center gap-4 py-7 bg-slate-50">
  108. <cl-text class="text-center " color="#09ba07" :size="30"> ——专属服务内容—— </cl-text>
  109. <image src="https://oss.xiaoxiongcode.com/static/home/qr.png" show-menu-by-longpress
  110. class="w-32 h-32" />
  111. <view class="text-center "> <cl-text class="text-center" color="#999" :size="14"> 长按识别二维码 </cl-text>
  112. <cl-text class="text-center" color="#999" :size="14"> 添加微信,享专业老师服务 </cl-text>
  113. </view>
  114. </view>
  115. </cl-popup>
  116. <cl-popup v-model="visible2" :size="400" :show-header="false" direction="center">
  117. <view class="flex flex-col items-center justify-center gap-4 py-7 bg-slate-50">
  118. <cl-text class="text-center " color="#09ba07" :size="30"> ——会员福利—— </cl-text>
  119. <image src="https://oss.xiaoxiongcode.com/static/home/coding.png" class="w-32 h-32" />
  120. <view class="text-center " v-if="userInfo?.memberLevel !== 'default'">
  121. <cl-text class="text-center" color="#999" :size="14">账号:小程序登录手机账号 </cl-text>
  122. <cl-text class="text-center" color="#999" :size="14"> 密码:初始密码为123456 </cl-text>
  123. <cl-text class="text-center" color="#999" :size="14">少儿编程网址: www.xiaoxiongcode.com </cl-text>
  124. <cl-button type="primary" size="small" @tap="copyUrl"> 复制网址 </cl-button>
  125. </view>
  126. <view class="text-center " v-else>
  127. <cl-text class="text-center" color="#999" :size="14"> 您不是会员,无法使用会员福利 </cl-text>
  128. </view>
  129. </view>
  130. </cl-popup>
  131. <Physics v-if="selected === 'physics'" />
  132. <Chinese v-else-if="selected === 'chinese'" />
  133. <English v-else-if="selected === 'english'" />
  134. <Mix v-else-if="selected === 'mix'" />
  135. <Game v-else-if="selected === 'game'" />
  136. <Exchange v-else-if="selected === 'exchange'" />
  137. <MathModal v-else-if="selected === 'math'" />
  138. </cl-page>
  139. </template>
  140. <style lang="scss" scoped>
  141. .menus {
  142. @apply mt-[3vh] mx-auto rounded-[20px];
  143. }
  144. .selected {
  145. @apply scale-[1.1] bg-[#efefef99] rounded-xl;
  146. font-weight: bold;
  147. }
  148. .text-stroke {
  149. text-shadow:
  150. -1px -1px 0 #000,
  151. 1px -1px 0 #000,
  152. -1px 1px 0 #000,
  153. 1px 1px 0 #000;
  154. }
  155. </style>