普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

370 lines
8.4 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="营养方案" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />
  4. <view class="main">
  5. <reportCard>
  6. <view class="section header">
  7. <view>营养师基于你生活习惯和营养目标推荐</view>
  8. <view class="highlight">量身定制的营养方案</view>
  9. </view>
  10. <view class="section" v-for="(step, index) in list" :key="step.key">
  11. <view class="flex section-header">
  12. <view class="section-header-index">
  13. <text>{{ index + 1 }}</text>
  14. <image class="section-header-index-icon" :src="step.url" mode="widthFix"></image>
  15. </view>
  16. <view class="section-header-title">
  17. <view class="section-header-title-name">{{ step.name }}</view>
  18. <view class="section-header-title-desc">{{ step.desc }}</view>
  19. </view>
  20. </view>
  21. <view class="section-content">
  22. <view class="card" v-for="(item, idx) in step.children" :key="item.key" >
  23. <productCard :data="item" @select="onSelect(index, idx, $event)" ></productCard>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="section tips">
  28. *以上是根据你的营养目标以及饮食运动作息状况给出的针对性健康建议可以辅助你达成营养目标同时养成良好的生活习惯
  29. </view>
  30. </reportCard>
  31. </view>
  32. <view class="flex bottom">
  33. <view class="left">
  34. <button class="btn btn-comment">
  35. <view>查看评价</view>
  36. <view class="flex"><text class="highlight">{{ `${comment}` }}</text><uv-icon name="arrow-right" color="#C6C6C6" size="28rpx"></uv-icon></view>
  37. </button>
  38. </view>
  39. <view class="flex right">
  40. <button
  41. class="flex btn btn-cart"
  42. :disabled="!selectedCount"
  43. :class="[selectedCount ? '' : 'is-disabled']"
  44. @click="onAddCart"
  45. >
  46. <text>加入购物车</text>
  47. </button>
  48. <button
  49. class="flex btn btn-settle"
  50. :class="[selectedCount ? '' : 'is-disabled']"
  51. :disabled="!selectedCount"
  52. @click="onBuy"
  53. >
  54. <text>结算</text>
  55. <text v-if="selectedCount">{{ `(${selectedCount})` }}</text>
  56. </button>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import reportCard from '@/pages_order/components/reportCard.vue';
  63. import productCard from './productCard.vue';
  64. export default {
  65. components: {
  66. reportCard,
  67. productCard,
  68. },
  69. data() {
  70. return {
  71. list: [],
  72. comment: 0,
  73. }
  74. },
  75. computed: {
  76. selectedCount() {
  77. let count = 0
  78. this.list.forEach(step => {
  79. step.children.forEach(item => {
  80. item.selected && count++
  81. })
  82. })
  83. return count
  84. },
  85. },
  86. onLoad() {
  87. const detectionList = [
  88. {
  89. id: '0011',
  90. url: '',
  91. name: '眼科检查',
  92. desc: '早期发现眼部疾病',
  93. originalPrice: 168,
  94. price: 68.00,
  95. unit: '次',
  96. count: 1,
  97. selected: false,
  98. },
  99. ]
  100. const baseList = [
  101. {
  102. id: '0021',
  103. url: '',
  104. name: '全株印度人参',
  105. desc: '安享睡眠情绪舒展',
  106. originalPrice: 688,
  107. price: 1664,
  108. unit: '月',
  109. count: 1,
  110. selected: false,
  111. customized: true,
  112. },
  113. {
  114. id: '0022',
  115. url: '',
  116. name: '御氧虾青素',
  117. desc: '安享睡眠情绪舒展',
  118. originalPrice: 688,
  119. price: 1664,
  120. unit: '月',
  121. count: 1,
  122. selected: false,
  123. customized: true,
  124. },
  125. {
  126. id: '0023',
  127. url: '',
  128. name: '全株印度人参',
  129. desc: '安享睡眠情绪舒展',
  130. originalPrice: 688,
  131. price: 1664,
  132. unit: '月',
  133. count: 1,
  134. selected: false,
  135. customized: true,
  136. },
  137. {
  138. id: '0024',
  139. url: '',
  140. name: '全株印度人参',
  141. desc: '安享睡眠情绪舒展',
  142. originalPrice: 688,
  143. price: 1664,
  144. unit: '月',
  145. count: 1,
  146. selected: false,
  147. customized: true,
  148. },
  149. ]
  150. this.list = [
  151. {
  152. id: '001',
  153. name: '检测方案',
  154. desc: '刚开始健康检测?专家推荐先做这几项',
  155. url: '/pages_order/static/report/report-nutrition-1.png',
  156. children: detectionList
  157. },
  158. {
  159. id: '002',
  160. name: '基础方案',
  161. desc: `刚开始吃维生素?营养师建议从这${baseList.length}颗开始`,
  162. url: '/pages_order/static/report/report-nutrition-2.png',
  163. children: baseList
  164. },
  165. ]
  166. this.comment = 23898
  167. },
  168. methods: {
  169. onSelect(stepIdx, childIdx, selected) {
  170. this.list[stepIdx].children[childIdx].selected = selected
  171. },
  172. getSelectedList() {
  173. return this.list.reduce((arr, step) => {
  174. const selectedArr = step.children.filter(product => product.selected)
  175. return arr.concat(selectedArr)
  176. }, [])
  177. },
  178. onAddCart() {
  179. const selectedList = this.getSelectedList()
  180. this.$store.commit('addCart', selectedList)
  181. },
  182. onBuy() {
  183. const selectedList = this.getSelectedList()
  184. this.$store.commit('createOrder', selectedList)
  185. },
  186. },
  187. }
  188. </script>
  189. <style scoped lang="scss">
  190. .page__view {
  191. width: 100vw;
  192. min-height: 100vh;
  193. background-color: $uni-bg-color;
  194. position: relative;
  195. /deep/ .nav-bar__view {
  196. position: fixed;
  197. top: 0;
  198. left: 0;
  199. }
  200. }
  201. .main {
  202. padding: calc(var(--status-bar-height) + 152rpx) 32rpx 272rpx 32rpx;
  203. }
  204. .section {
  205. & + & {
  206. margin-top: 48rpx;
  207. padding-top: 12rpx;
  208. border-top: 2rpx dashed #989898;
  209. }
  210. &-header {
  211. justify-content: flex-start;
  212. &-index {
  213. position: relative;
  214. font-family: HarmonyOS Sans;
  215. font-weight: 700;
  216. font-size: 96rpx;
  217. line-height: 1.4;
  218. color: #D9D9D9;
  219. &-icon {
  220. position: absolute;
  221. left: 34rpx;
  222. top: 70rpx;
  223. width: 40rpx;
  224. height: 40rpx;
  225. }
  226. }
  227. &-title {
  228. margin-left: 32rpx;
  229. font-family: PingFang SC;
  230. line-height: 1.4;
  231. color: #252545;
  232. &-name {
  233. font-weight: 600;
  234. font-size: 40rpx;
  235. }
  236. &-desc {
  237. font-weight: 400;
  238. font-size: 26rpx;
  239. }
  240. }
  241. }
  242. &-content {
  243. padding-top: 18rpx;
  244. }
  245. }
  246. .section.header {
  247. font-family: PingFang SC;
  248. font-weight: 400;
  249. font-size: 36rpx;
  250. line-height: 1.2;
  251. color: #252545CC;
  252. .highlight {
  253. font-size: 48rpx;
  254. line-height: 1.4;
  255. font-weight: 600;
  256. font-family: PingFang SC;
  257. color: transparent;
  258. background-image: linear-gradient(to right, #4B348F, #845CFA);
  259. background-clip: text;
  260. display: inline-block;
  261. }
  262. }
  263. .tips {
  264. font-family: PingFang SC;
  265. font-weight: 400;
  266. font-size: 18rpx;
  267. line-height: 1.4;
  268. color: #989898;
  269. }
  270. .card {
  271. & + & {
  272. margin-top: 32rpx;
  273. }
  274. }
  275. .bottom {
  276. width: 100%;
  277. position: fixed;
  278. left: 0;
  279. bottom: 0;
  280. padding: 24rpx 40rpx 92rpx 40rpx;
  281. box-sizing: border-box;
  282. background: #FFFFFF;
  283. column-gap: 16rpx;
  284. .left {
  285. }
  286. .right {
  287. flex: 1;
  288. column-gap: 32rpx;
  289. }
  290. .btn {
  291. &-comment {
  292. display: inline-block;
  293. width: auto;
  294. text-align: left;
  295. font-family: PingFang SC;
  296. font-weight: 400;
  297. font-size: 24rpx;
  298. line-height: 1.4;
  299. color: #626262;
  300. .highlight {
  301. margin-right: 4rpx;
  302. font-family: 600;
  303. font-size: 30rpx;
  304. color: #252545;
  305. }
  306. }
  307. &-cart {
  308. flex: 1;
  309. padding: 14rpx 0;
  310. font-family: PingFang SC;
  311. font-size: 36rpx;
  312. font-weight: 500;
  313. line-height: 1;
  314. color: #252545;
  315. border: 2rpx solid #252545;
  316. border-radius: 41rpx;
  317. }
  318. &-settle {
  319. flex: 1;
  320. padding: 16rpx 0;
  321. font-family: PingFang SC;
  322. font-size: 36rpx;
  323. font-weight: 500;
  324. line-height: 1;
  325. color: #FFFFFF;
  326. background-image: linear-gradient(to right, #4B348F, #845CFA);
  327. border-radius: 41rpx;
  328. }
  329. &.is-disabled {
  330. opacity: 0.5;
  331. }
  332. }
  333. }
  334. </style>