cate.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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,v.page_id, 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, parent_page_id, page_id, num) {
  91. if (this.page_id != page_id) {
  92. var self = this;
  93. this.Dever.post('app/collection/?l=api.getCodeByPage', {code:this.Dever.config.code,parent_page_id:parent_page_id,page_id:page_id,index:index}, function(t) {
  94. self.Dever.location('dream/view?code=' + t.code + '&name=' + self.Dever.config.name);
  95. })
  96. //this.Dever.location('dream/view?id=' + this.info_id + '&page_id='+page_id+'&index=' + index);
  97. } else {
  98. index = parseInt(index) + parseInt(num);
  99. this.$emit('goIndex', index);
  100. }
  101. },
  102. },
  103. }
  104. </script>
  105. <style lang="less">
  106. .category-content {
  107. margin-bottom: 20rpx;
  108. }
  109. .category {
  110. .category-wrapper {
  111. width: 100%;
  112. display: flex;
  113. flex-direction: row;
  114. position: absolute;
  115. top: 0;
  116. bottom: 0;
  117. left: 0;
  118. .left-wrapper {
  119. width: 200rpx;
  120. flex: 0 0 200rpx;
  121. /*background-color: #f6f6f6;*/
  122. .left-content {
  123. .title-content {
  124. width: 100%;
  125. height: 100rpx;
  126. display: flex;
  127. justify-content: center;
  128. align-items: center;
  129. font-size: 25rpx;
  130. border-bottom: 1px solid #dedede;
  131. cursor: pointer;
  132. &:last-child {
  133. border-bottom: 0;
  134. }
  135. &.onSelected {
  136. background-color: #fff;
  137. position: relative;
  138. color: #feb436;
  139. &::before {
  140. content: '';
  141. position: absolute;
  142. left: 0;
  143. top: 0;
  144. width: 10rpx;
  145. height: 100%;
  146. background: linear-gradient(124deg, #feb436 0%, #fb7c22 100%);
  147. }
  148. }
  149. }
  150. }
  151. }
  152. .right-wrapper {
  153. flex: 1;
  154. .right-content {
  155. width: 100%;
  156. padding: 20rpx 0;
  157. border-left: 1rpx solid #efefef;
  158. box-sizing: border-box;
  159. .banner-wrapper {
  160. padding: 0 20rpx;
  161. .swiper-content {
  162. width: 100%;
  163. height: 180rpx;
  164. margin-bottom: 20rpx;
  165. .swiper-item {
  166. .swiper-img {
  167. width: 100%;
  168. height: 180rpx;
  169. }
  170. }
  171. }
  172. }
  173. .product-wrapper {
  174. .category-item {
  175. .category-title {
  176. height: 60rpx;
  177. font-size: 26rpx;
  178. line-height: 60rpx;
  179. font-weight: 500;
  180. background-color: #f6f6f6;
  181. padding-left: 20rpx;
  182. color: #000;
  183. }
  184. .category-content {
  185. display: flex;
  186. flex-direction: row;
  187. flex-flow: wrap;
  188. padding: 20rpx 20rpx 0;
  189. .product-item {
  190. width: 33%;
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: center;
  194. align-items: center;
  195. margin-bottom: 20rpx;
  196. .product-img {
  197. width: 120rpx;
  198. height: 120rpx;
  199. margin-bottom: 10rpx;
  200. margin-left: -22rpx;
  201. }
  202. .product-title {
  203. font-size: 23rpx;
  204. height: 50rpx;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. </style>