index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <CustomNav title="首页" leftType="scan" @scan="handleScan" />
  3. <view class="content">
  4. <!-- 轮播图 -->
  5. <swiper class="banner-swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :circular="true">
  6. <swiper-item v-for="(img, idx) in bannerImages" :key="idx">
  7. <image :src="img" class="banner-img" mode="aspectFill" />
  8. </swiper-item>
  9. </swiper>
  10. <!-- 卡片列表 -->
  11. <view class="card-list">
  12. <view class="card" v-for="(card, idx) in cards" :key="idx">
  13. <view class="card-title">{{ card.title }}</view>
  14. <view class="card-desc">{{ card.desc }}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <TabBar />
  19. </template>
  20. <script setup lang="ts">
  21. import { ref } from 'vue'
  22. import CustomNav from '@/components/custom-nav.vue'
  23. import TabBar from '@/components/tab-bar.vue'
  24. const title = ref('Hello')
  25. const bannerImages = [
  26. '/static/carousel/BHFIIABBCDJII-5kCEkD6zh9.png',
  27. '/static/carousel/BHFIIABBDGHEA-wtWLrLS75o.png',
  28. '/static/carousel/BHFIIABBHJBAH-yDeckRiiQP.png'
  29. ]
  30. const cards = [
  31. { title: '健康档案', desc: '管理您的健康信息' },
  32. { title: '慢病管理', desc: '查看慢病相关数据' },
  33. { title: '健康咨询', desc: '在线咨询医生' },
  34. { title: '用药提醒', desc: '设置用药提醒' }
  35. ]
  36. function handleScan(res: any) {
  37. console.log('[index] scan result', res)
  38. const resultText = res?.result || ''
  39. if (resultText) {
  40. // 简单演示:弹出内容,实际可根据业务解析并跳转
  41. uni.showToast({ title: String(resultText), icon: 'none', duration: 2000 })
  42. } else {
  43. uni.showToast({ title: '未识别到有效内容', icon: 'none' })
  44. }
  45. }
  46. </script>
  47. <style>
  48. .content {
  49. display: flex;
  50. flex-direction: column;
  51. align-items: center;
  52. justify-content: flex-start;
  53. padding-top: calc(var(--status-bar-height) + 44px);
  54. height: calc(100vh - var(--status-bar-height) - 44px);
  55. background: #f7f8fa;
  56. }
  57. .banner-swiper {
  58. width: 670rpx;
  59. max-width: 100vw;
  60. height: 400rpx;
  61. margin: 20rpx auto 30rpx auto;
  62. border-radius: 16rpx;
  63. overflow: hidden;
  64. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  65. background: #fff;
  66. }
  67. .banner-img {
  68. width: 100%;
  69. height: 100%;
  70. display: block;
  71. }
  72. .card-list {
  73. width: 90%;
  74. display: flex;
  75. flex-direction: column;
  76. gap: 32rpx;
  77. padding: 0 40rpx;
  78. margin: 0 auto;
  79. }
  80. .card {
  81. /* 不设置width,宽度由父容器控制 */
  82. background: #fff;
  83. border-radius: 16rpx;
  84. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  85. padding: 40rpx 32rpx;
  86. box-sizing: border-box;
  87. display: flex;
  88. flex-direction: column;
  89. }
  90. .card-title {
  91. font-size: 36rpx;
  92. font-weight: bold;
  93. color: #333;
  94. margin-bottom: 16rpx;
  95. }
  96. .card-desc {
  97. font-size: 28rpx;
  98. color: #888;
  99. }
  100. /* .logo {
  101. height: 200rpx;
  102. width: 200rpx;
  103. margin-top: 200rpx;
  104. margin-left: auto;
  105. margin-right: auto;
  106. margin-bottom: 50rpx;
  107. } */
  108. .text-area {
  109. display: flex;
  110. justify-content: center;
  111. }
  112. .title {
  113. font-size: 36rpx;
  114. color: #8f8f94;
  115. }
  116. </style>