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

189 lines
4.2 KiB

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