index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <view class="home-container">
  3. <!-- 顶部搜索栏 -->
  4. <view class="search-bar">
  5. <view class="search-input">
  6. <text class="iconfont icon-search"></text>
  7. <input placeholder="搜索症状、疾病或药品" placeholder-class="search-placeholder" />
  8. </view>
  9. </view>
  10. <!-- 健康分类 -->
  11. <view class="health-categories">
  12. <view class="category-item" @click="navigateToCategory('symptom')">
  13. <view class="category-icon bg-blue">
  14. <text class="iconfont icon-zhengzhuangzicha"></text>
  15. </view>
  16. <text class="category-text">症状自查</text>
  17. </view>
  18. <view class="category-item" @click="navigateToCategory('disease')">
  19. <view class="category-icon bg-green">
  20. <text class="iconfont icon-jibingbaike"></text>
  21. </view>
  22. <text class="category-text">疾病百科</text>
  23. </view>
  24. <view class="category-item" @click="navigateToCategory('medicine')">
  25. <view class="category-icon bg-orange">
  26. <text class="iconfont icon-yaopinchaxun"></text>
  27. </view>
  28. <text class="category-text">药品查询</text>
  29. </view>
  30. </view>
  31. <!-- AI问诊卡片 -->
  32. <view class="ai-consult-card">
  33. <view class="card-content">
  34. <view class="card-left">
  35. <text class="card-title">AI智能问诊</text>
  36. <text class="card-desc">24小时在线,随时解答您的健康问题</text>
  37. <button class="card-button" @click="startConsultation">立即问诊</button>
  38. </view>
  39. <view class="card-right">
  40. <image src="https://picsum.photos/seed/ai-med/200/200" mode="widthFix" class="card-image" />
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 热门健康话题 -->
  45. <view class="health-topics">
  46. <view class="section-header" @click="goToBaidu('topic')">
  47. <text class="section-title">热门健康话题</text>
  48. <text class="section-more">更多</text>
  49. </view>
  50. <!-- 或给每个话题项添加点击事件 -->
  51. <view class="topics-list">
  52. <view class="topic-item" v-for="(topic, index) in hotTopics" :key="index" @click="goToBaidu('topic', topic)">
  53. <image :src="topic.image" mode="widthFix" class="topic-image" />
  54. <text class="topic-title">{{ topic.title }}</text>
  55. <text class="topic-info">{{ topic.info }}</text>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 健康资讯 -->
  60. <view class="health-news">
  61. <view class="section-header" @click="goToBaidu('news')">
  62. <text class="section-title">健康资讯</text>
  63. <text class="section-more">更多</text>
  64. </view>
  65. <view class="news-list">
  66. <view class="news-item" v-for="(news, index) in healthNews" :key="index" @click="goToBaidu('news', news)">
  67. <view class="news-left">
  68. <text class="news-title">{{ news.title }}</text>
  69. <text class="news-desc">{{ news.desc }}</text>
  70. <text class="news-time">{{ news.time }}</text>
  71. </view>
  72. <image :src="news.image" mode="heightFix" class="news-image" />
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. data() {
  81. return {
  82. // 当前选中的标签页
  83. currentTab: 'home',
  84. // 热门健康话题数据
  85. hotTopics: [
  86. {
  87. image: "https://picsum.photos/seed/topic1/300/200",
  88. title: "新冠疫情防护指南",
  89. info: "专家解读最新防护措施"
  90. },
  91. {
  92. image: "https://picsum.photos/seed/topic2/300/200",
  93. title: "高血压日常管理",
  94. info: "科学控制血压的方法"
  95. },
  96. {
  97. image: "https://picsum.photos/seed/topic3/300/200",
  98. title: "儿童常见疾病预防",
  99. info: "家长必知的健康知识"
  100. }
  101. ],
  102. // 健康资讯数据
  103. healthNews: [
  104. {
  105. image: "https://picsum.photos/seed/news1/100/100",
  106. title: "新研究发现:每天步行8000步可降低心血管疾病风险",
  107. desc: "最新医学研究表明,适量运动对心脏健康至关重要...",
  108. time: "2小时前"
  109. },
  110. {
  111. image: "https://picsum.photos/seed/news2/100/100",
  112. title: "季节性过敏高发期,这些预防措施要牢记",
  113. desc: "随着气温升高,花粉过敏人群需注意防护...",
  114. time: "昨天"
  115. },
  116. {
  117. image: "https://picsum.photos/seed/news3/100/100",
  118. title: "世界卫生组织发布最新健康饮食指南",
  119. desc: "平衡膳食对维持身体健康至关重要...",
  120. time: "3天前"
  121. }
  122. ]
  123. }
  124. },
  125. methods: {
  126. // 导航到分类页面
  127. navigateToCategory(type) {
  128. uni.navigateTo({
  129. url: `/pages/category/${type}`
  130. })
  131. },
  132. startConsultation() {
  133. uni.navigateTo({
  134. url: '/pages/chat/index'
  135. })
  136. },
  137. // 跳转到百度页面
  138. // 在 methods 中添加
  139. goToBaidu(type, item) {
  140. // 构建百度搜索URL
  141. let baseUrl = 'https://www.baidu.com/s?wd=';
  142. let keyword = '';
  143. // 根据类型生成搜索关键词
  144. if (type === 'topic') {
  145. keyword = item ? item.title : '热门健康话题';
  146. } else if (type === 'news') {
  147. keyword = item ? item.title : '健康资讯';
  148. }
  149. // 完整URL
  150. const url = encodeURIComponent(baseUrl + keyword);
  151. // 使用 uni.navigateTo 跳转到内置web-view页面
  152. uni.navigateTo({
  153. url: `/pages/web-view/index?url=${url}`
  154. });
  155. },
  156. // 切换标签页
  157. changeTab(tab) {
  158. this.currentTab = tab;
  159. }
  160. }
  161. }
  162. </script>
  163. <style scoped>
  164. @import '@/static/font/iconfont.css';
  165. /* 全局变量 */
  166. :root {
  167. --primary: #4CAF50;
  168. --primary-light: #E8F5E9;
  169. --secondary: #2196F3;
  170. --bg: #f5f5f5;
  171. --tabbar-height: 50px;
  172. --header-height: 80px;
  173. }
  174. /* 首页容器 */
  175. .home-container {
  176. max-width: 800px;
  177. margin: 0 auto;
  178. background: var(--bg);
  179. min-height: 100vh;
  180. padding-bottom: calc(var(--tabbar-height) + 20px);
  181. }
  182. /* 搜索栏 */
  183. .search-bar {
  184. padding: 15px;
  185. background-color: #fff;
  186. }
  187. .search-input {
  188. background-color: #f5f5f5;
  189. border-radius: 25px;
  190. padding: 8px 15px;
  191. display: flex;
  192. align-items: center;
  193. }
  194. .search-input .iconfont {
  195. color: #999;
  196. margin-right: 8px;
  197. }
  198. .search-placeholder {
  199. color: #999;
  200. font-size: 14px;
  201. }
  202. /* 健康分类 */
  203. .health-categories {
  204. display: flex;
  205. justify-content: space-around;
  206. padding: 20px 0;
  207. background-color: #fff;
  208. margin-top: 10px;
  209. }
  210. .category-item {
  211. display: flex;
  212. flex-direction: column;
  213. align-items: center;
  214. }
  215. .category-icon {
  216. width: 50px;
  217. height: 50px;
  218. border-radius: 15px;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. margin-bottom: 8px;
  223. }
  224. .category-icon .iconfont {
  225. color: #fff;
  226. font-size: 24px;
  227. }
  228. .category-text {
  229. font-size: 13px;
  230. color: #666;
  231. }
  232. .bg-blue { background-color: #42A5F5; }
  233. .bg-green { background-color: #66BB6A; }
  234. .bg-orange { background-color: #FFA726; }
  235. .bg-purple { background-color: #AB47BC; }
  236. /* AI问诊卡片 */
  237. .ai-consult-card {
  238. margin: 15px;
  239. background-color: #fff;
  240. border-radius: 15px;
  241. overflow: hidden;
  242. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  243. }
  244. .card-content {
  245. display: flex;
  246. padding: 20px;
  247. }
  248. .card-left {
  249. flex: 1;
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: center;
  253. }
  254. .card-title {
  255. font-size: 18px;
  256. font-weight: bold;
  257. color: #333;
  258. margin-bottom: 8px;
  259. }
  260. .card-desc {
  261. font-size: 14px;
  262. color: #666;
  263. margin-bottom: 15px;
  264. }
  265. .card-button {
  266. width: 120px;
  267. background-color: var(--primary);
  268. color: #fff;
  269. border-radius: 20px;
  270. padding: 8px 15px;
  271. text-align: center;
  272. font-size: 14px;
  273. }
  274. .card-right {
  275. width: 100px;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. }
  280. .card-image {
  281. width: 80px;
  282. height: 80px;
  283. border-radius: 50%;
  284. }
  285. /* 热门健康话题 */
  286. .health-topics {
  287. margin: 15px;
  288. background-color: #fff;
  289. border-radius: 15px;
  290. overflow: hidden;
  291. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  292. }
  293. .section-header {
  294. display: flex;
  295. justify-content: space-between;
  296. align-items: center;
  297. padding: 15px;
  298. border-bottom: 1px solid #eee;
  299. }
  300. .section-title {
  301. font-size: 16px;
  302. font-weight: bold;
  303. color: #333;
  304. }
  305. .section-more {
  306. font-size: 13px;
  307. color: #999;
  308. }
  309. .topics-list {
  310. display: flex;
  311. padding: 15px 0;
  312. overflow-x: auto;
  313. white-space: nowrap;
  314. }
  315. .topic-item {
  316. display: inline-block;
  317. width: 120px;
  318. margin-left: 15px;
  319. }
  320. .topic-image {
  321. width: 120px;
  322. height: 80px;
  323. border-radius: 10px;
  324. margin-bottom: 8px;
  325. }
  326. .topic-title {
  327. font-size: 14px;
  328. font-weight: bold;
  329. color: #333;
  330. display: block;
  331. white-space: normal;
  332. }
  333. .topic-info {
  334. font-size: 12px;
  335. color: #666;
  336. display: block;
  337. white-space: normal;
  338. margin-top: 4px;
  339. }
  340. /* 健康资讯 */
  341. .health-news {
  342. margin: 15px;
  343. background-color: #fff;
  344. border-radius: 15px;
  345. overflow: hidden;
  346. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  347. }
  348. .news-list {
  349. padding: 15px;
  350. }
  351. .news-item {
  352. display: flex;
  353. margin-bottom: 15px;
  354. padding-bottom: 15px;
  355. border-bottom: 1px solid #eee;
  356. }
  357. .news-item:last-child {
  358. border-bottom: none;
  359. margin-bottom: 0;
  360. padding-bottom: 0;
  361. }
  362. .news-left {
  363. flex: 1;
  364. margin-right: 15px;
  365. }
  366. .news-title {
  367. font-size: 15px;
  368. font-weight: bold;
  369. color: #333;
  370. margin-bottom: 5px;
  371. }
  372. .news-desc {
  373. font-size: 13px;
  374. color: #666;
  375. margin-bottom: 8px;
  376. line-height: 1.4;
  377. display: -webkit-box;
  378. -webkit-line-clamp: 2;
  379. -webkit-box-orient: vertical;
  380. overflow: hidden;
  381. }
  382. .news-time {
  383. font-size: 12px;
  384. color: #999;
  385. }
  386. .news-image {
  387. width: 80px;
  388. height: 80px;
  389. border-radius: 10px;
  390. flex-shrink: 0;
  391. }
  392. </style>