普兆健康管家前端代码仓库
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.

185 lines
4.2 KiB

  1. <template>
  2. <view>
  3. <swiper
  4. class="swiper"
  5. :current="current"
  6. :autoplay="true"
  7. :display-multiple-items="1.5"
  8. @change="onChange"
  9. >
  10. <swiper-item v-for="item in list" :key="item.id" style="display: inline-block;">
  11. <view class="swiper-item">
  12. <view class="swiper-item-content">
  13. <!-- todo: check img url? -->
  14. <image class="img" src="@/pages_order/static/temp-1.png" mode="widthFix"></image>
  15. <view class="content">
  16. <view>
  17. <view
  18. v-for="(line, lIdx) in item.arr"
  19. :key="lIdx"
  20. :class="line.class"
  21. >
  22. {{ line.text }}
  23. </view>
  24. </view>
  25. <button class="btn flex" @click="jumpToTest(item.paperId)">
  26. <image class="btn-icon" src="@/pages_order/static/index/btn-icon.png" mode="widthFix"></image>
  27. <text>{{ item.btnTxt }}</text>
  28. </button>
  29. </view>
  30. </view>
  31. </view>
  32. </swiper-item>
  33. <swiper-item style="display: inline-block;">
  34. <view class="swiper-item"></view>
  35. </swiper-item>
  36. </swiper>
  37. <indicator :current="current" :length="list.length" @click="current = $event"></indicator>
  38. </view>
  39. </template>
  40. <script>
  41. import indicator from '@/components/home/indicator.vue'
  42. export default {
  43. components: {
  44. indicator,
  45. },
  46. data() {
  47. return {
  48. current: 0,
  49. list: [],
  50. }
  51. },
  52. created() {
  53. this.getData()
  54. },
  55. methods: {
  56. async getData() {
  57. try {
  58. let result = await this.$fetch('getPersonalized')
  59. this.list = result.map(item => {
  60. const { id, title, subTitle, info, btnTxt, paperId } = item
  61. return {
  62. id,
  63. // todo: check img url?
  64. // url
  65. arr: [
  66. { text: title, class: 'font1' },
  67. { text: subTitle, class: 'font2' },
  68. { text: info, class: 'font3' },
  69. ],
  70. btnTxt,
  71. paperId,
  72. }
  73. })
  74. } catch (err) {
  75. }
  76. },
  77. jumpToTest(paperId) {
  78. this.$utils.navigateTo(`/pages_order/report/test/intro?id=${paperId}`)
  79. },
  80. onChange(e) {
  81. this.current = e.detail.current
  82. }
  83. },
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .swiper {
  88. width: 100vw;
  89. height: 320rpx;
  90. padding-left: 22rpx;
  91. &-item {
  92. width: 512rpx;
  93. height: 320rpx;
  94. padding: 24rpx 30rpx 40rpx 10rpx;
  95. box-sizing: border-box;
  96. &-content {
  97. position: relative;
  98. width: 100%;
  99. height: 100%;
  100. padding: 12rpx;
  101. box-sizing: border-box;
  102. border-radius: 32rpx;
  103. background-image: linear-gradient(#FAFAFF, #F3F3F3);
  104. box-shadow: -5rpx -5rpx 10rpx 0 #FFFFFF,
  105. 10rpx 10rpx 20rpx 0 #AAAACC80,
  106. 4rpx 4rpx 10rpx 0 #AAAACC40,
  107. -2rpx -2rpx 5rpx 0 #FFFFFF;
  108. .img {
  109. position: absolute;
  110. right: 24rpx;
  111. bottom: 24rpx;
  112. width: 200rpx;
  113. height: auto;
  114. }
  115. .content {
  116. position: absolute;
  117. left: 0;
  118. top: 0;
  119. width: 100%;
  120. height: 100%;
  121. padding: 24rpx;
  122. box-sizing: border-box;
  123. .font1 {
  124. font-size: 30rpx;
  125. font-weight: 600;
  126. line-height: 1.4;
  127. font-family: PingFang SC;
  128. color: #252545;
  129. }
  130. .font2 {
  131. font-size: 26rpx;
  132. font-weight: 400;
  133. line-height: 1.4;
  134. font-family: PingFang SC;
  135. color: #989898;
  136. }
  137. .font3 {
  138. font-size: 24rpx;
  139. font-weight: 400;
  140. line-height: 1.4;
  141. font-family: PingFang SC;
  142. color: #252545;
  143. }
  144. .btn {
  145. margin-top: 32rpx;
  146. display: inline-flex;
  147. padding: 14rpx 24rpx;
  148. font-size: 24rpx;
  149. font-family: PingFang SC;
  150. font-weight: 400;
  151. line-height: 1.4;
  152. color: #252545;
  153. border: 1rpx solid #252545;
  154. border-radius: 28rpx;
  155. &-icon {
  156. width: 28rpx;
  157. height: 28rpx;
  158. margin-right: 8rpx;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. </style>