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

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