cate.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="category">
  3. <view class="category-wrapper" v-if="fetch.cate.length>0">
  4. <!-- 左边导航 -->
  5. <scroll-view scroll-y="true" class="left-wrapper" scroll-with-animation="true">
  6. <view class="left-content">
  7. <view class="title-content" :class="fetch.show[v.id] == 1?'onSelected':''" v-for="(v,k) in fetch.cate" :key="v.id" @click="choose(v.id)">{{v.name}}</view>
  8. </view>
  9. </scroll-view>
  10. <!-- 右边内容 -->
  11. <scroll-view scroll-y="true" class="right-wrapper" scroll-with-animation="true">
  12. <view class="right-content">
  13. <!-- banner区域 -->
  14. <view class="banner-wrapper" v-if="swiperList.length > 0">
  15. <swiper class="swiper-content" :autoplay="true" :interval="3000" :circular="true">
  16. <swiper-item class="swiper-item" v-for="imgs in swiperList" :key="imgs.id">
  17. <image class="swiper-img" :src="imgs.src"></image>
  18. </swiper-item>
  19. </swiper>
  20. </view>
  21. <!-- 产品区 -->
  22. <view class="product-wrapper">
  23. <view class="category-item" :id="'list'+v.id" v-for="(v,k) in fetch.child" :key="k" v-if="fetch.show[v.page_id] == 1">
  24. <view class="category-title">{{v.name}}</view>
  25. <view class="category-content">
  26. <view class="product-item" v-for="(v1,k1) in v.content" :key="k1" @click="go(v1.id,v1.page_id)">
  27. <image class="product-img" :src="v1.pic"></image>
  28. <text class="product-title">{{v1.name}}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. fetch: {
  43. cate : [],
  44. show : {},
  45. child : [],
  46. },
  47. cur : 0,
  48. swiperList: [],
  49. parent_page: 0,
  50. page : 0,
  51. id : 0,
  52. }
  53. },
  54. onLoad(option) {
  55. this.id = option.id;
  56. this.parent_page = option.parent_page;
  57. this.page = option.page;
  58. this.cur = this.parent_page;
  59. this.getData();
  60. },
  61. methods: {
  62. getData : function() {
  63. this.Dever.get(this, 'app/collection/?l=api.category', {id:this.id, parent_page:this.parent_page, page:this.page});
  64. },
  65. choose : function(id) {
  66. if (this.fetch.show[id] == 1) {
  67. return;
  68. }
  69. this.fetch.show[id] = 1;
  70. this.fetch.show[this.cur] = 2;
  71. this.cur = id;
  72. },
  73. go : function(id, page_id) {
  74. this.Dever.location('dream/view?id=' + this.id + '&page_id='+page_id+'&index=' + id);
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="less">
  80. .category {
  81. .category-wrapper {
  82. width: 100%;
  83. display: flex;
  84. flex-direction: row;
  85. position: absolute;
  86. top: 0;
  87. bottom: 0;
  88. .left-wrapper {
  89. width: 200rpx;
  90. flex: 0 0 200rpx;
  91. background-color: #f6f6f6;
  92. .left-content {
  93. .title-content {
  94. width: 100%;
  95. height: 100rpx;
  96. display: flex;
  97. justify-content: center;
  98. align-items: center;
  99. font-size: 25rpx;
  100. border-bottom: 1px solid #dedede;
  101. cursor: pointer;
  102. &:last-child {
  103. border-bottom: 0;
  104. }
  105. &.onSelected {
  106. background-color: #fff;
  107. position: relative;
  108. color: #feb436;
  109. &::before {
  110. content: '';
  111. position: absolute;
  112. left: 0;
  113. top: 0;
  114. width: 10rpx;
  115. height: 100%;
  116. background: linear-gradient(124deg, #feb436 0%, #fb7c22 100%);
  117. }
  118. }
  119. }
  120. }
  121. }
  122. .right-wrapper {
  123. flex: 1;
  124. .right-content {
  125. width: 100%;
  126. padding: 20rpx 0;
  127. border-left: 1rpx solid #efefef;
  128. box-sizing: border-box;
  129. .banner-wrapper {
  130. padding: 0 20rpx;
  131. .swiper-content {
  132. width: 100%;
  133. height: 180rpx;
  134. margin-bottom: 20rpx;
  135. .swiper-item {
  136. .swiper-img {
  137. width: 100%;
  138. height: 180rpx;
  139. }
  140. }
  141. }
  142. }
  143. .product-wrapper {
  144. .category-item {
  145. .category-title {
  146. height: 60rpx;
  147. font-size: 26rpx;
  148. line-height: 60rpx;
  149. font-weight: 500;
  150. background-color: #f6f6f6;
  151. padding-left: 20rpx;
  152. color: #000;
  153. }
  154. .category-content {
  155. display: flex;
  156. flex-direction: row;
  157. flex-flow: wrap;
  158. padding: 20rpx 20rpx 0;
  159. .product-item {
  160. width: 33%;
  161. display: flex;
  162. flex-direction: column;
  163. justify-content: center;
  164. align-items: center;
  165. margin-bottom: 20rpx;
  166. .product-img {
  167. width: 120rpx;
  168. height: 140rpx;
  169. margin-bottom: 10rpx;
  170. }
  171. .product-title {
  172. font-size: 23rpx;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. </style>