cate.vue 4.9 KB

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