ConfirmStep.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="confirm-step">
  3. <view class="step-title-row">
  4. <text class="step-title">确认信息</text>
  5. <text class="step-sub">核对无误后保存并生成健康方案</text>
  6. </view>
  7. <!-- 基础体征 -->
  8. <view class="form-card">
  9. <view class="card-head">
  10. <text class="card-title">基础体征</text>
  11. </view>
  12. <view class="preview-row" v-if="healthStatus.heightCm">
  13. <text class="preview-label">身高</text>
  14. <text class="preview-value">{{ healthStatus.heightCm }} cm</text>
  15. </view>
  16. <view class="preview-row" v-if="healthStatus.weightKg">
  17. <text class="preview-label">体重</text>
  18. <text class="preview-value">{{ healthStatus.weightKg }} kg</text>
  19. </view>
  20. <view class="preview-row" v-if="healthStatus.bloodPressure">
  21. <text class="preview-label">血压</text>
  22. <text class="preview-value">{{ healthStatus.bloodPressure }}</text>
  23. </view>
  24. <view class="preview-row" v-if="healthStatus.bloodGlucose">
  25. <text class="preview-label">空腹血糖</text>
  26. <text class="preview-value">{{ healthStatus.bloodGlucose }} mmol/L</text>
  27. </view>
  28. <view class="preview-row" v-if="healthStatus.lipidCholesterol">
  29. <text class="preview-label">总胆固醇</text>
  30. <text class="preview-value">{{ healthStatus.lipidCholesterol }} mmol/L</text>
  31. </view>
  32. </view>
  33. <!-- 疾病史 -->
  34. <view class="form-card" v-if="healthStatus.selectedDiseases && healthStatus.selectedDiseases.length > 0">
  35. <view class="card-head">
  36. <text class="card-title">疾病史</text>
  37. </view>
  38. <view class="tag-wrap">
  39. <view v-for="(d, i) in healthStatus.selectedDiseases" :key="getKey(d.name, i)" class="tag-item">
  40. <text>{{ d.name }}</text>
  41. <text v-if="d.diagnosedAt" class="tag-date">{{ d.diagnosedAt }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 用药 -->
  46. <view class="form-card" v-if="hasMeds">
  47. <view class="card-head">
  48. <text class="card-title">在服药物/治疗</text>
  49. </view>
  50. <view v-for="(med, i) in medRows" :key="getKey(med.name, i)" class="med-line">
  51. <text class="med-name">{{ med.name }}</text>
  52. <text v-if="med.durationText" class="med-duration">{{ med.durationText }}</text>
  53. </view>
  54. </view>
  55. <!-- 饮食习惯 -->
  56. <view class="form-card">
  57. <view class="card-head">
  58. <text class="card-title">饮食习惯</text>
  59. </view>
  60. <view class="preview-row" v-if="dietPreferences.allergies && dietPreferences.allergies.length > 0">
  61. <text class="preview-label">过敏原</text>
  62. <text class="preview-value">{{ dietPreferences.allergies.join('、') }}</text>
  63. </view>
  64. <view class="preview-row" v-if="dietPreferences.absoluteAvoid && dietPreferences.absoluteAvoid.length > 0">
  65. <text class="preview-label">绝对忌口</text>
  66. <text class="preview-value">{{ dietPreferences.absoluteAvoid.join('、') }}</text>
  67. </view>
  68. <view class="preview-row" v-if="dietPreferences.mustEat && dietPreferences.mustEat.length > 0">
  69. <text class="preview-label">必吃</text>
  70. <text class="preview-value">{{ dietPreferences.mustEat.join('、') }}</text>
  71. </view>
  72. <view class="preview-row" v-if="dietPreferences.flavorPref && dietPreferences.flavorPref.length > 0">
  73. <text class="preview-label">口味</text>
  74. <text class="preview-value">{{ dietPreferences.flavorPref.join('、') }}</text>
  75. </view>
  76. <view class="preview-row" v-if="dietPreferences.cuisinePref && dietPreferences.cuisinePref.length > 0">
  77. <text class="preview-label">菜系</text>
  78. <text class="preview-value">{{ dietPreferences.cuisinePref.join('、') }}</text>
  79. </view>
  80. <view class="preview-row" v-if="dietPreferences.healthGoals && dietPreferences.healthGoals.length > 0">
  81. <text class="preview-label">健康目标</text>
  82. <text class="preview-value">{{ dietPreferences.healthGoals.join('、') }}</text>
  83. </view>
  84. <text class="empty-hint" v-if="!hasDiet && noPreference">无特殊偏好</text>
  85. <text class="empty-hint" v-else-if="!hasDiet">未填写饮食习惯</text>
  86. </view>
  87. <!-- 保存并生成 -->
  88. <view class="btn-pair">
  89. <button class="btn-prev" @click="goBack">上一步</button>
  90. <button class="btn-generate" :disabled="submitting" @click="onSubmit">
  91. {{ submitting ? '保存中...' : '保存并生成方案' }}
  92. </button>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. export default {
  98. name: 'ConfirmStep',
  99. props: {
  100. healthStatus: {
  101. type: Object,
  102. default: function() { return {} }
  103. },
  104. dietPreferences: {
  105. type: Object,
  106. default: function() { return {} }
  107. },
  108. submitting: {
  109. type: Boolean,
  110. default: false
  111. }
  112. },
  113. computed: {
  114. medRows: function() {
  115. var rows = this.healthStatus.medRows || []
  116. return rows.filter(function(m) { return m && m.name })
  117. },
  118. hasMeds: function() {
  119. return this.medRows.length > 0
  120. },
  121. hasDiet: function() {
  122. var d = this.dietPreferences
  123. return !!(d &&
  124. ((d.allergies && d.allergies.length > 0) ||
  125. (d.absoluteAvoid && d.absoluteAvoid.length > 0) ||
  126. (d.mustEat && d.mustEat.length > 0) ||
  127. (d.flavorPref && d.flavorPref.length > 0) ||
  128. (d.healthGoals && d.healthGoals.length > 0)))
  129. },
  130. noPreference: function() {
  131. return !!(this.dietPreferences && this.dietPreferences.noPreference)
  132. }
  133. },
  134. methods: {
  135. getKey: function(name, i) {
  136. return 'k' + (name || '') + i
  137. },
  138. goBack: function() {
  139. this.$emit('back')
  140. },
  141. onSubmit: function() {
  142. this.$emit('submit', {
  143. healthStatus: this.healthStatus,
  144. dietPreferences: this.dietPreferences
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style scoped>
  151. .confirm-step {
  152. padding: 10rpx 0 30rpx;
  153. }
  154. .step-title-row {
  155. margin-bottom: 20rpx;
  156. }
  157. .step-title {
  158. font-size: 34rpx;
  159. font-weight: 700;
  160. color: #333;
  161. }
  162. .step-sub {
  163. display: block;
  164. font-size: 24rpx;
  165. color: #999;
  166. margin-top: 8rpx;
  167. }
  168. .form-card {
  169. background: #fff;
  170. border-radius: 20rpx;
  171. padding: 24rpx;
  172. margin-bottom: 20rpx;
  173. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  174. }
  175. .card-head {
  176. display: flex;
  177. align-items: center;
  178. justify-content: space-between;
  179. margin-bottom: 16rpx;
  180. }
  181. .card-title {
  182. font-size: 28rpx;
  183. font-weight: 600;
  184. color: #333;
  185. }
  186. .preview-row {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. padding: 12rpx 0;
  191. border-bottom: 2rpx solid #F8FAFC;
  192. }
  193. .preview-label {
  194. font-size: 26rpx;
  195. color: #64748B;
  196. }
  197. .preview-value {
  198. font-size: 26rpx;
  199. color: #334155;
  200. font-weight: 500;
  201. }
  202. .tag-wrap {
  203. display: flex;
  204. flex-wrap: wrap;
  205. }
  206. .tag-item {
  207. padding: 10rpx 20rpx;
  208. border-radius: 999rpx;
  209. background: #F1F5F9;
  210. font-size: 24rpx;
  211. color: #334155;
  212. margin: 0 14rpx 14rpx 0;
  213. }
  214. .tag-date {
  215. color: #94A3B8;
  216. margin-left: 8rpx;
  217. }
  218. .med-line {
  219. display: flex;
  220. justify-content: space-between;
  221. padding: 10rpx 0;
  222. }
  223. .med-name {
  224. font-size: 26rpx;
  225. color: #334155;
  226. }
  227. .med-duration {
  228. font-size: 24rpx;
  229. color: #94A3B8;
  230. }
  231. .empty-hint {
  232. display: block;
  233. font-size: 24rpx;
  234. color: #94A3B8;
  235. padding: 10rpx 0;
  236. }
  237. .btn-pair {
  238. display: flex;
  239. padding: 20rpx 0;
  240. }
  241. .btn-prev,
  242. .btn-generate {
  243. flex: 1;
  244. margin: 0 10rpx;
  245. border-radius: 999rpx;
  246. font-size: 30rpx;
  247. font-weight: 600;
  248. }
  249. .btn-prev {
  250. background: #F1F5F9;
  251. color: #334155;
  252. }
  253. .btn-generate {
  254. background: linear-gradient(135deg, #F97316, #FB923C);
  255. color: #fff;
  256. }
  257. </style>