cate.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template name="cate">
  2. <view slot="links">
  3. <view class="category">
  4. <view class="category-wrapper" v-if="fetch.cate.length>0">
  5. <!-- 左边导航 -->
  6. <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. </view>
  11. <!-- 右边内容 -->
  12. <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,fetch.num)">
  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. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: "cate",
  46. props: {
  47. content_id : {
  48. type : String,
  49. value : null
  50. },
  51. page_id : {
  52. type : String,
  53. value : null
  54. },
  55. width : {
  56. type : String,
  57. default : '100%'
  58. },
  59. param : {},
  60. index : 0
  61. },
  62. data() {
  63. return {
  64. swiperList: [],
  65. fetch : {},
  66. }
  67. },
  68. created() {
  69. this.fetch = this.param;
  70. },
  71. methods:{
  72. getData : function() {
  73. this.$emit('getCate');
  74. },
  75. getInfo : function(t) {
  76. //触底刷新
  77. },
  78. choose : function(id) {
  79. if (this.fetch.show[id] == 1) {
  80. return;
  81. }
  82. for(var i in this.fetch.show) {
  83. if (id == i) {
  84. this.fetch.show[id] = 1;
  85. } else {
  86. this.fetch.show[i] = 2;
  87. }
  88. }
  89. },
  90. go : function(index, page_id, num) {
  91. index = index + num;
  92. if (this.page_id != page_id) {
  93. this.Dever.location('dream/view?id=' + this.info_id + '&page_id='+page_id+'&index=' + index);
  94. } else {
  95. this.$emit('goIndex', index);
  96. }
  97. },
  98. },
  99. }
  100. </script>
  101. <style lang="less">
  102. .category-content {
  103. margin-bottom: 20rpx;
  104. }
  105. .category {
  106. .category-wrapper {
  107. width: 100%;
  108. display: flex;
  109. flex-direction: row;
  110. position: absolute;
  111. top: 0;
  112. bottom: 0;
  113. left: 0;
  114. .left-wrapper {
  115. width: 200rpx;
  116. flex: 0 0 200rpx;
  117. /*background-color: #f6f6f6;*/
  118. .left-content {
  119. .title-content {
  120. width: 100%;
  121. height: 100rpx;
  122. display: flex;
  123. justify-content: center;
  124. align-items: center;
  125. font-size: 25rpx;
  126. border-bottom: 1px solid #dedede;
  127. cursor: pointer;
  128. &:last-child {
  129. border-bottom: 0;
  130. }
  131. &.onSelected {
  132. background-color: #fff;
  133. position: relative;
  134. color: #feb436;
  135. &::before {
  136. content: '';
  137. position: absolute;
  138. left: 0;
  139. top: 0;
  140. width: 10rpx;
  141. height: 100%;
  142. background: linear-gradient(124deg, #feb436 0%, #fb7c22 100%);
  143. }
  144. }
  145. }
  146. }
  147. }
  148. .right-wrapper {
  149. flex: 1;
  150. .right-content {
  151. width: 100%;
  152. padding: 20rpx 0;
  153. border-left: 1rpx solid #efefef;
  154. box-sizing: border-box;
  155. .banner-wrapper {
  156. padding: 0 20rpx;
  157. .swiper-content {
  158. width: 100%;
  159. height: 180rpx;
  160. margin-bottom: 20rpx;
  161. .swiper-item {
  162. .swiper-img {
  163. width: 100%;
  164. height: 180rpx;
  165. }
  166. }
  167. }
  168. }
  169. .product-wrapper {
  170. .category-item {
  171. .category-title {
  172. height: 60rpx;
  173. font-size: 26rpx;
  174. line-height: 60rpx;
  175. font-weight: 500;
  176. background-color: #f6f6f6;
  177. padding-left: 20rpx;
  178. color: #000;
  179. }
  180. .category-content {
  181. display: flex;
  182. flex-direction: row;
  183. flex-flow: wrap;
  184. padding: 20rpx 20rpx 0;
  185. .product-item {
  186. width: 33%;
  187. display: flex;
  188. flex-direction: column;
  189. justify-content: center;
  190. align-items: center;
  191. margin-bottom: 20rpx;
  192. .product-img {
  193. width: 120rpx;
  194. height: 140rpx;
  195. margin-bottom: 10rpx;
  196. }
  197. .product-title {
  198. font-size: 23rpx;
  199. height: 50rpx;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. </style>