cate.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. overflow-y:auto;
  120. width: 200rpx;
  121. flex: 0 0 200rpx;
  122. /*background-color: #f6f6f6;*/
  123. .left-content {
  124. .title-content {
  125. width: 100%;
  126. height: 100rpx;
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. font-size: 25rpx;
  131. border-bottom: 1px solid #dedede;
  132. cursor: pointer;
  133. &:last-child {
  134. border-bottom: 0;
  135. }
  136. &.onSelected {
  137. background-color: #fff;
  138. position: relative;
  139. color: #feb436;
  140. &::before {
  141. content: '';
  142. position: absolute;
  143. left: 0;
  144. top: 0;
  145. width: 10rpx;
  146. height: 100%;
  147. background: linear-gradient(124deg, #feb436 0%, #fb7c22 100%);
  148. }
  149. }
  150. }
  151. }
  152. }
  153. .right-wrapper {
  154. overflow-y:auto;
  155. flex: 1;
  156. .right-content {
  157. width: 100%;
  158. padding: 20rpx 0;
  159. border-left: 1rpx solid #efefef;
  160. box-sizing: border-box;
  161. .banner-wrapper {
  162. padding: 0 20rpx;
  163. .swiper-content {
  164. width: 100%;
  165. height: 180rpx;
  166. margin-bottom: 20rpx;
  167. .swiper-item {
  168. .swiper-img {
  169. width: 100%;
  170. height: 180rpx;
  171. }
  172. }
  173. }
  174. }
  175. .product-wrapper {
  176. .category-item {
  177. .category-title {
  178. height: 60rpx;
  179. font-size: 26rpx;
  180. line-height: 60rpx;
  181. font-weight: 500;
  182. background-color: #f6f6f6;
  183. padding-left: 20rpx;
  184. color: #000;
  185. }
  186. .category-content {
  187. display: flex;
  188. flex-direction: row;
  189. flex-flow: wrap;
  190. padding: 20rpx 20rpx 0;
  191. .product-item {
  192. width: 33%;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: center;
  196. align-items: center;
  197. margin-bottom: 20rpx;
  198. .product-img {
  199. width: 120rpx;
  200. height: 120rpx;
  201. margin-bottom: 10rpx;
  202. margin-left: -22rpx;
  203. }
  204. .product-title {
  205. font-size: 23rpx;
  206. height: 50rpx;
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. </style>