SsService.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="service">
  3. <template v-if="globalStore.service" v-for="(item, index) in globalStore.service">
  4. <view class="service-item" :class="getItemClass(index)" @tap="loadService(item)">
  5. <view class="service-item-content">
  6. <view class="service-item-content-child">
  7. <view class="title">{{ item.categoryName }}</view>
  8. <view class="subject">{{ item.profileWap }}</view>
  9. </view>
  10. </view>
  11. <div v-if="index === 2" class="service-item-bg">
  12. <image class="service-item-image" mode="aspectFit" :src="getImageUrl(item.imgUrl)" />
  13. </div>
  14. <image v-else class="service-item-image" mode="aspectFit" :src="getImageUrl(item.imgUrl)" />
  15. </view>
  16. </template>
  17. </view>
  18. </template>
  19. <script>
  20. import { useGlobalStore } from '../stores/global';
  21. export default {
  22. data() {
  23. return {
  24. globalStore: useGlobalStore()
  25. };
  26. },
  27. methods: {
  28. getItemClass(index) {
  29. switch (index % 5) {
  30. case 0:
  31. return ' hover-scale';
  32. case 1:
  33. return ' hover-scale yellow right';
  34. case 2:
  35. return ' center';
  36. case 3:
  37. return ' hover-scale yellow bottom no-margin-bottom';
  38. case 4:
  39. return ' hover-scale right bottom no-margin-bottom';
  40. }
  41. },
  42. loadService(item) {
  43. this.$emit('loadService', item.id, item.categoryName, item.imgUrl)
  44. }
  45. }
  46. };
  47. </script>
  48. <style scoped lang="scss">
  49. .service {
  50. display: flex;
  51. flex-wrap: wrap;
  52. justify-content: space-between;
  53. position: relative;
  54. margin-bottom: 32rpx;
  55. .service-item {
  56. width: calc(50% - 14rpx);
  57. position: relative;
  58. height: 168rpx;
  59. border-radius: 40rpx;
  60. overflow: hidden;
  61. background: linear-gradient(180deg, #fafffd, #e1f5f8);
  62. box-shadow: 0 8rpx 40rpx 0 rgba(52, 149, 239, 0.4);
  63. margin-bottom: 32rpx;
  64. .service-item-content {
  65. position: absolute;
  66. top: 0;
  67. left: 0;
  68. right: 0;
  69. bottom: 0;
  70. z-index: 2;
  71. padding: 32rpx 24rpx;
  72. .service-item-content-child {
  73. position: absolute;
  74. width: calc(100% - 48rpx);
  75. .title {
  76. font-size: 28rpx;
  77. color: #101333;
  78. font-weight: bold;
  79. }
  80. .subject {
  81. font-size: 26rpx;
  82. color: #7e8aa2;
  83. }
  84. }
  85. }
  86. .service-item-image {
  87. position: absolute;
  88. bottom: 0;
  89. z-index: 1;
  90. width: 136rpx;
  91. height: 120rpx;
  92. right: 64rpx;
  93. opacity: 0.3;
  94. }
  95. &.yellow {
  96. background: linear-gradient(180deg, #ffffff, #f6f0ef);
  97. }
  98. &.right {
  99. text-align: right;
  100. .service-item-image {
  101. right: unset;
  102. left: 122rpx;
  103. left: 66rpx;
  104. }
  105. }
  106. &.bottom {
  107. .service-item-content {
  108. .service-item-content-child {
  109. position: absolute;
  110. bottom: 32rpx;
  111. }
  112. }
  113. }
  114. &.no-margin-bottom {
  115. margin-bottom: 0;
  116. }
  117. &.center {
  118. position: absolute;
  119. top: 50%;
  120. left: 50%;
  121. transform: translate(-50%, -50%);
  122. z-index: 10;
  123. text-align: center;
  124. width: 240rpx;
  125. height: 240rpx;
  126. border-radius: 6rem;
  127. box-shadow: inset 0 8rpx 40rpx 0 rgba(52, 149, 239, 0.4);
  128. background: linear-gradient(90deg, #c2dff9, #c6e2fa);
  129. .service-item-content {
  130. width: 100%;
  131. padding: unset;
  132. .service-item-content-child {
  133. position: absolute;
  134. top: 50%;
  135. left: 50%;
  136. transform: translate(-50%, -50%);
  137. }
  138. }
  139. .service-item-bg {
  140. position: absolute;
  141. top: 24rpx;
  142. left: 24rpx;
  143. right: 24rpx;
  144. bottom: 24rpx;
  145. border-radius: 160rpx;
  146. z-index: 1;
  147. background: linear-gradient(180deg, #ffffff, #e8ebff);
  148. box-shadow: 0 8rpx 40rpx 0 rgba(52, 149, 239, 0.4);
  149. }
  150. .service-item-image {
  151. top: 50%;
  152. left: 50%;
  153. right: unset;
  154. bottom: unset;
  155. width: 132rpx;
  156. height: 136rpx;
  157. transform: translate(-50%, -50%);
  158. }
  159. }
  160. }
  161. }
  162. </style>