index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="page">
  3. <loadSke :loading="loading" :list="typeList">
  4. <view class="tabs">
  5. <view class="tab" :class="{selected:index==active}" @click="tabClick(index)"
  6. v-for="(item,index) in typeList" :key='index'>
  7. {{item.type_name}}
  8. </view>
  9. </view>
  10. <scroll-view class='scroll-view' :scroll-into-view="scrollId" :scroll-y='true' :scroll-with-animation='true' @scroll='scrollChange'>
  11. <view class="box" v-for="(item,index) in typeList" :key='index' :id="'scroll'+index">
  12. <view class="type_name">
  13. <m-icon type="name_left" color="red" />
  14. <text>{{item.type_name}}</text>
  15. <m-icon type="name_right" color="red" />
  16. </view>
  17. <view class="type-box">
  18. <view class="type" v-for="(itemSon,indexSon) in item.list" :key='indexSon'
  19. @click="$utils.goPage('/pages/fulu/placeorder',null,{product_ids:itemSon.product_ids,icon:itemSon.icon,remark:itemSon.remark})">
  20. <view class="top-des">
  21. <image class="icon" :src="itemSon.icon" mode="scaleToFill"></image>
  22. <view class="right">
  23. <text class="name">{{itemSon.name}}</text>
  24. <text class="introduction">{{itemSon.introduction}}</text>
  25. </view>
  26. </view>
  27. <text class="btn">立即充值</text>
  28. </view>
  29. </view>
  30. </view>
  31. </scroll-view>
  32. </loadSke>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data: () => ({
  38. active: 0,
  39. typeList: [],
  40. loading: true,
  41. scrollId: 'scroll0'
  42. }),
  43. async mounted() {
  44. this.loading = true
  45. let res = await this.$api.fulu.goods.getTypeList()
  46. console.log(res)
  47. this.typeList = res.data
  48. this.$nextTick(() => {
  49. this.loading = false
  50. })
  51. },
  52. methods: {
  53. tabClick(index) {
  54. this.active = index
  55. this.scrollId = 'scroll' + index
  56. },
  57. scrollChange(e){
  58. console.log(e)
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .page {
  65. .tabs {
  66. display: flex;
  67. justify-content: space-around;
  68. align-items: center;
  69. background-color: #FFFFFF;
  70. padding: 0 20rpx;
  71. position: sticky;
  72. top: 0;
  73. left: 0;
  74. z-index: 1;
  75. overflow-x: auto;
  76. .tab {
  77. text-align: center;
  78. flex-shrink: 0;
  79. width: 250rpx;
  80. padding: 20rpx 0;
  81. height: 80rpx;
  82. box-sizing: border-box;
  83. }
  84. .selected {
  85. position: relative;
  86. &::after {
  87. content: '';
  88. width: 80rpx;
  89. height: 6rpx;
  90. background-color: red;
  91. position: absolute;
  92. bottom: 0;
  93. left: 50%;
  94. transform: translateX(-50%);
  95. }
  96. }
  97. }
  98. .scroll-view{
  99. height: calc(100vh - 100rpx);
  100. }
  101. .box {
  102. margin-top: 20rpx;
  103. background-color: #FFFFFF;
  104. &:nth-last-of-type(1) {
  105. height: calc(100vh - 100rpx);
  106. }
  107. .type_name {
  108. display: flex;
  109. justify-content: center;
  110. align-items: center;
  111. padding: 20rpx;
  112. }
  113. .type-box {
  114. display: flex;
  115. justify-content: flex-start;
  116. align-items: center;
  117. flex-wrap: wrap;
  118. padding-left: 20rpx;
  119. .type {
  120. width: 345rpx;
  121. background: linear-gradient(0deg, #FDDEAF, #FDF3D8);
  122. margin-right: auto;
  123. margin-bottom: 20rpx;
  124. border-radius: 20rpx;
  125. padding: 30rpx;
  126. box-sizing: border-box;
  127. display: flex;
  128. flex-direction: column;
  129. justify-content: center;
  130. align-items: center;
  131. .top-des {
  132. width: 100%;
  133. display: flex;
  134. justify-content: flex-start;
  135. align-items: center;
  136. .icon {
  137. width: 91rpx;
  138. height: 75rpx;
  139. margin-right: 20rpx;
  140. }
  141. .right {
  142. display: flex;
  143. flex-direction: column;
  144. align-items: center;
  145. .name {
  146. color: #744520;
  147. font-size: 30rpx;
  148. font-weight: 500;
  149. }
  150. .introduction {
  151. margin-top: 15rpx;
  152. font-weight: 400;
  153. color: #744520;
  154. font-size: 26rpx;
  155. white-space: nowrap;
  156. }
  157. }
  158. }
  159. .btn {
  160. margin-top: 30rpx;
  161. width: 166rpx;
  162. height: 60rpx;
  163. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  164. border-radius: 30px;
  165. padding: 18rpx;
  166. box-sizing: border-box;
  167. font-size: 26rpx;
  168. font-weight: 400;
  169. color: #FFFFFF;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. </style>