金诚优选前端代码
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.

150 lines
2.8 KiB

  1. <template>
  2. <view>
  3. <lf-nav :title="current == 1 ? '品牌' : ''" :showIcon="true" :search="showNavDiy" bgColor="#ffffff"></lf-nav>
  4. <view class="tabs">
  5. <view class="lf-tab" :class="{'tab-active': current == 0}" @click="current = 0">分类</view>
  6. <view class="lf-tab" :class="{'tab-active': current == 1}" @click="current = 1">品牌</view>
  7. </view>
  8. <lf-tabbar></lf-tabbar>
  9. </view>
  10. </template>
  11. <script>
  12. import {
  13. pageLogin,
  14. getUrl,
  15. config
  16. } from '@/common/js/utils.js';
  17. import lfNav from '@/components/lf-nav/lf-nav.vue';
  18. import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue';
  19. export default {
  20. components: {
  21. lfNav,
  22. lfTabbar
  23. },
  24. data() {
  25. return {
  26. classData: '',
  27. screenWidth: '',
  28. activeIndex: 0,
  29. init: false,
  30. imgHeight:'',
  31. current: 0
  32. };
  33. },
  34. computed: {
  35. showNavDiy(){
  36. return this.current == 0;
  37. }
  38. },
  39. onLoad() {
  40. this.classificationList();
  41. wx.getSystemInfo({
  42. success: res => {
  43. this.screenWidth = res.screenWidth;
  44. }
  45. });
  46. },
  47. methods: {
  48. //切换menu
  49. change(e) {
  50. var activeIndex = e.currentTarget.dataset.index;
  51. this.activeIndex = activeIndex;
  52. },
  53. jumpItem(e) {
  54. var url = e.currentTarget.dataset.url;
  55. wx.navigateTo({
  56. url: url
  57. });
  58. },
  59. imgLoad(e) {
  60. var height = e.detail.height;
  61. var width = e.detail.width;
  62. var ratio = width / height;
  63. var screenWidth = this.screenWidth;
  64. this.imgHeight = screenWidth / ratio;
  65. },
  66. classificationList() {
  67. wx.showLoading({
  68. title: '加载中',
  69. mask: true
  70. });
  71. this.$http.get({
  72. api: 'api/home/getHomeCategoryList'
  73. }).then(res => {
  74. if (res.statusCode == 200) {
  75. res = res.data;
  76. if (res.status) {
  77. this.init = true;
  78. this.classData = res.data;
  79. } else {
  80. wx.showModal({
  81. content: '请求失败',
  82. showCancel: false
  83. });
  84. }
  85. } else {
  86. wx.showModal({
  87. content: '请求失败',
  88. showCancel: false
  89. });
  90. }
  91. wx.hideLoading();
  92. }, err => {
  93. wx.showModal({
  94. content: '请求失败',
  95. showCancel: false
  96. });
  97. wx.hideLoading();
  98. });
  99. },
  100. },
  101. };
  102. </script>
  103. <style>
  104. page{
  105. background-color: #FFFFFF;
  106. }
  107. </style>
  108. <style lang="scss" scoped>
  109. .tabs{
  110. width: 750rpx;
  111. height: 90rpx;
  112. display: flex;
  113. justify-content: space-between;
  114. border-bottom: 1rpx solid #e5e5e5;
  115. .lf-tab{
  116. width: 50%;
  117. display: flex;
  118. align-items: center;
  119. justify-content: center;
  120. font-size: 28rpx;
  121. color: #777777;
  122. position: relative;
  123. &.tab-active{
  124. color: #15716E;
  125. }
  126. &.tab-active::after{
  127. content: '';
  128. position: absolute;
  129. bottom: 0;
  130. left: 50%;
  131. width: 80rpx;
  132. height: 10rpx;
  133. background-color: #15716E;
  134. border-radius: 10rpx 10rpx 0 0;
  135. margin-left: -40rpx;
  136. }
  137. }
  138. }
  139. </style>