disease.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="category-container">
  3. <!-- 顶部搜索栏 -->
  4. <view class="search-bar">
  5. <view class="search-input">
  6. <text class="iconfont icon-search"></text>
  7. <input
  8. v-model="searchKeyword"
  9. placeholder="搜索疾病"
  10. placeholder-class="search-placeholder"
  11. @confirm="searchDisease"
  12. />
  13. </view>
  14. </view>
  15. <!-- 疾病分类标签 -->
  16. <view class="disease-categories">
  17. <view
  18. class="category-item"
  19. v-for="(category, index) in diseaseCategories"
  20. :key="index"
  21. @click="selectCategory(category)"
  22. >
  23. {{ category.name }}
  24. </view>
  25. </view>
  26. <!-- 疾病列表 -->
  27. <view class="disease-list">
  28. <view
  29. class="disease-item"
  30. v-for="(disease, index) in diseaseList"
  31. :key="index"
  32. @click="viewDiseaseDetail(disease)"
  33. >
  34. <view class="disease-info">
  35. <text class="disease-name">{{ disease.name }}</text>
  36. <text class="disease-desc">{{ disease.desc }}</text>
  37. </view>
  38. <text class="disease-risk" :class="disease.riskClass">{{ disease.risk }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. searchKeyword: '',
  48. selectedCategory: null,
  49. diseaseCategories: [
  50. { id: 1, name: '内科疾病' },
  51. { id: 2, name: '外科疾病' },
  52. { id: 3, name: '儿科疾病' },
  53. { id: 4, name: '妇产科疾病' },
  54. { id: 5, name: '皮肤科疾病' },
  55. { id: 6, name: '五官科疾病' }
  56. ],
  57. diseaseList: [
  58. { id: 1, name: '感冒', desc: '常见呼吸道感染疾病', category: 1, risk: '低危', riskClass: 'low-risk' },
  59. { id: 2, name: '高血压', desc: '常见心血管疾病', category: 1, risk: '中危', riskClass: 'medium-risk' },
  60. { id: 3, name: '糖尿病', desc: '代谢性疾病', category: 1, risk: '中危', riskClass: 'medium-risk' },
  61. { id: 4, name: '胃炎', desc: '胃黏膜炎症', category: 1, risk: '低危', riskClass: 'low-risk' },
  62. { id: 5, name: '冠心病', desc: '冠状动脉粥样硬化性心脏病', category: 1, risk: '高危', riskClass: 'high-risk' },
  63. { id: 6, name: '肺炎', desc: '肺部感染性疾病', category: 1, risk: '中危', riskClass: 'medium-risk' },
  64. { id: 7, name: '胆囊炎', desc: '胆囊炎症', category: 1, risk: '中危', riskClass: 'medium-risk' },
  65. { id: 8, name: '关节炎', desc: '关节炎症', category: 1, risk: '低危', riskClass: 'low-risk' }
  66. ]
  67. }
  68. },
  69. computed: {
  70. filteredDiseases() {
  71. // 根据搜索关键词和选择的分类筛选疾病
  72. return this.diseaseList.filter(disease => {
  73. const matchesSearch = this.searchKeyword ?
  74. disease.name.includes(this.searchKeyword) ||
  75. disease.desc.includes(this.searchKeyword) : true;
  76. const matchesCategory = !this.selectedCategory ||
  77. disease.category === this.selectedCategory.id;
  78. return matchesSearch && matchesCategory;
  79. });
  80. }
  81. },
  82. methods: {
  83. searchDisease() {
  84. // 搜索疾病
  85. console.log('搜索疾病:', this.searchKeyword);
  86. // 实际应用中这里应该调用API进行搜索
  87. },
  88. selectCategory(category) {
  89. // 选择疾病分类
  90. this.selectedCategory = category;
  91. },
  92. viewDiseaseDetail(disease) {
  93. // 查看疾病详情
  94. uni.navigateTo({
  95. url: `/pages/disease/detail?id=${disease.id}`
  96. });
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. .category-container {
  103. max-width: 800px;
  104. margin: 0 auto;
  105. background: #f5f5f5;
  106. min-height: 100vh;
  107. }
  108. .search-bar {
  109. padding: 15px;
  110. background-color: #fff;
  111. }
  112. .search-input {
  113. background-color: #f5f5f5;
  114. border-radius: 25px;
  115. padding: 8px 15px;
  116. display: flex;
  117. align-items: center;
  118. }
  119. .search-input .iconfont {
  120. color: #999;
  121. margin-right: 8px;
  122. }
  123. .search-placeholder {
  124. color: #999;
  125. font-size: 14px;
  126. }
  127. .disease-categories {
  128. display: flex;
  129. flex-wrap: wrap;
  130. padding: 10px 15px;
  131. background-color: #fff;
  132. border-bottom: 1px solid #eee;
  133. }
  134. .category-item {
  135. padding: 8px 15px;
  136. margin: 5px;
  137. background-color: #f5f5f5;
  138. border-radius: 20px;
  139. font-size: 13px;
  140. color: #666;
  141. }
  142. .category-item.active {
  143. background-color: #4CAF50;
  144. color: #fff;
  145. }
  146. .disease-list {
  147. padding: 15px;
  148. background-color: #fff;
  149. }
  150. .disease-item {
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: center;
  154. padding: 15px 0;
  155. border-bottom: 1px solid #eee;
  156. }
  157. .disease-item:last-child {
  158. border-bottom: none;
  159. }
  160. .disease-info {
  161. flex: 1;
  162. }
  163. .disease-name {
  164. font-size: 16px;
  165. font-weight: bold;
  166. color: #333;
  167. margin-bottom: 5px;
  168. }
  169. .disease-desc {
  170. font-size: 13px;
  171. color: #666;
  172. }
  173. .disease-risk {
  174. padding: 4px 8px;
  175. border-radius: 10px;
  176. font-size: 12px;
  177. margin-left: 10px;
  178. }
  179. .low-risk {
  180. background-color: #E8F5E9;
  181. color: #4CAF50;
  182. }
  183. .medium-risk {
  184. background-color: #FFF3E0;
  185. color: #FF9800;
  186. }
  187. .high-risk {
  188. background-color: #FFEBEE;
  189. color: #F44336;
  190. }
  191. </style>