cate.vue 5.3 KB

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