金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.7 KiB

  1. <template>
  2. <view style="height: 100%;">
  3. <lf-nav title="分类"></lf-nav>
  4. <view id="classification" style="height: 100%;">
  5. <view :class="classData.type == 'upper_lower' ? '' : 'hiddens'" style="height: 100%;">
  6. <view v-if="init && classData.type == 'upper_lower'">
  7. <view class="class__banner" v-if="classData.CategoryListAd && classData.CategoryListAd.length">
  8. <swiper :style="{height:imgHeight+'px'}" indicator-dots="true" autoplay="true" circular="true">
  9. <swiper-item v-for="(item,index) in classData.CategoryListAd" :key="index">
  10. <image mode="widthFix" @load="imgLoad" :src="item.image" :data-url="item.link" @tap="jumpItem"></image>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. <view class="class__item_box">
  15. <view class="class__item" v-for="(item,index) in classData.CategoryList" :key="index">
  16. <view class="img_item" :data-url="item.link" @tap="jumpItem">
  17. <image :src="item.image"></image>
  18. <view class="img_text">
  19. <view class="text_top">
  20. <view class="text_line"></view>
  21. <view class="text_content">
  22. {{item.name}}
  23. </view>
  24. <view class="text_line"></view>
  25. </view>
  26. <view class="text_btn">
  27. 查看全部
  28. </view>
  29. </view>
  30. </view>
  31. <view class="class__tag">
  32. <view class="tag__item" v-for="(items,idx) in item.items" :key="idx">
  33. <view class="tag_flex" :data-url="items.link" @tap="jumpItem">
  34. <view class="tag_img">
  35. <image :src="items.image"></image>
  36. </view>
  37. <view class="tag_text">
  38. {{items.name}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view v-if="init && classData.type == 'left_right'" style="height: 100%;">
  47. <view class="classifical" style="height: 100%;">
  48. <view class="left-menu">
  49. <view class="item" :class="activeIndex == key ? 'active' : ''" v-for="(i,key) in classData.CategoryList" :key="key"
  50. @tap="change" :data-index="key">{{i.name}}</view>
  51. </view>
  52. <view class="right-content" style="height: 100%;">
  53. <view class="title" @tap="jumpItem" :data-url="classData.CategoryList[activeIndex].link">
  54. <span>{{classData.CategoryList[activeIndex].name}}</span>
  55. <span class="iconfont icon--xiangyoujiantou"></span>
  56. </view>
  57. <view v-for="(item,index) in classData.CategoryList" :key="index" v-show="activeIndex == index">
  58. <view class="list">
  59. <view class="list-item" v-for="(list,idx) in item.items" :key="idx" @tap="jumpItem" :data-url="list.link">
  60. <view class="photo">
  61. <image :src="list.image" mode="widthFix"></image>
  62. </view>
  63. <view class="txt">{{list.name}}</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <lf-tabbar></lf-tabbar>
  73. </view>
  74. </template>
  75. <script>
  76. import {
  77. pageLogin,
  78. getUrl,
  79. config
  80. } from '@/common/js/utils.js';
  81. import lfNav from '@/components/lf-nav/lf-nav.vue';
  82. import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue';
  83. export default {
  84. components: {
  85. lfNav,
  86. lfTabbar
  87. },
  88. data() {
  89. return {
  90. classData: '',
  91. screenWidth: '',
  92. activeIndex: 0,
  93. init: false,
  94. imgHeight:''
  95. };
  96. },
  97. onLoad() {
  98. this.classificationList();
  99. wx.getSystemInfo({
  100. success: res => {
  101. this.screenWidth = res.screenWidth;
  102. }
  103. });
  104. },
  105. methods: {
  106. //切换menu
  107. change(e) {
  108. var activeIndex = e.currentTarget.dataset.index;
  109. this.activeIndex = activeIndex;
  110. },
  111. jumpItem(e) {
  112. var url = e.currentTarget.dataset.url;
  113. wx.navigateTo({
  114. url: url
  115. });
  116. },
  117. imgLoad(e) {
  118. var height = e.detail.height;
  119. var width = e.detail.width;
  120. var ratio = width / height;
  121. var screenWidth = this.screenWidth;
  122. this.imgHeight = screenWidth / ratio;
  123. },
  124. classificationList() {
  125. wx.showLoading({
  126. title: '加载中',
  127. mask: true
  128. });
  129. this.$http.get({
  130. api: 'api/home/getHomeCategoryList'
  131. }).then(res => {
  132. if (res.statusCode == 200) {
  133. res = res.data;
  134. if (res.status) {
  135. this.init = true;
  136. this.classData = res.data;
  137. } else {
  138. wx.showModal({
  139. content: '请求失败',
  140. showCancel: false
  141. });
  142. }
  143. } else {
  144. wx.showModal({
  145. content: '请求失败',
  146. showCancel: false
  147. });
  148. }
  149. wx.hideLoading();
  150. }, err => {
  151. wx.showModal({
  152. content: '请求失败',
  153. showCancel: false
  154. });
  155. wx.hideLoading();
  156. });
  157. },
  158. },
  159. };
  160. </script>
  161. <style rel="stylesheet/less" lang="less">
  162. @import "classification";
  163. </style>