Brand.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false"><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="品牌街" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div brand-list">
  13. <text class="h2" v-if="recommend_brand && recommend_brand.length">推荐品牌</text>
  14. <view class="ul" v-if="recommend_brand && recommend_brand.length">
  15. <view class="li" v-for="item in recommend_brand" v-bind:key="item.brand_id" @click="goHomeGoodslist(item.brand_id)">
  16. <view class="div p-img" :style="'background-image:url('+item.brand_pic+')'"></view>
  17. </view>
  18. </view>
  19. <view class="div" v-for="(bclass,index) in brand_class" :key="index">
  20. <text class="h2">{{bclass.brand_class}}</text>
  21. <view class="ul">
  22. <view class="li" v-for="item in brand_list[index]" v-bind:key="item.brand_id" @click="goHomeGoodslist(item.brand_id)">
  23. <view class="div p-img" :style="'background-image:url('+item.brand_pic+')'"></view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view></home-base>
  29. </template>
  30. <script>
  31. import {getFontSize} from '@/util/common'
  32. import TitleHeader from '../../TitleHeader'
  33. import { urlencode } from '@/util/common'
  34. import HomeBase from '../HomeBase'
  35. import { getBrandList } from '../../../api/homesearch'
  36. import EmptyRecord from '../../EmptyRecord'
  37. export default {
  38. components:{
  39. TitleHeader,
  40. HomeBase,
  41. EmptyRecord
  42. },
  43. name: 'Brand',
  44. mounted(){
  45. // #ifdef MP-WEIXIN
  46. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  47. // #endif
  48. },
  49. computed:{
  50. fontSize(){
  51. return getFontSize()
  52. },
  53. },
  54. data(){
  55. return {
  56. navHeight: 0,
  57. brand_list: false,
  58. recommend_brand: false,
  59. brand_class: false
  60. }
  61. },
  62. created: function () {
  63. this.getBrandList()
  64. },
  65. methods:{
  66. goBack(){uni.navigateBack({delta:1})},
  67. getBrandList () {
  68. uni.showLoading({ title: '加载中' })
  69. getBrandList(0).then(res => {
  70. uni.hideLoading()
  71. this.brand_list = res.result.brand_c
  72. this.recommend_brand = res.result.brand_r
  73. this.brand_class = res.result.brand_class
  74. }).catch(function (error) {
  75. uni.hideLoading()
  76. uni.showToast({icon:'none',title: error.message})
  77. })
  78. },
  79. goHomeGoodslist (brandId) {
  80. uni.navigateTo({ url: '/pages/home/goodslist/Goodslist'+'?'+urlencode( { b_id: brandId } )})
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped lang="scss">
  86. .container{background:#fff}
  87. .brand-list{
  88. .h2{line-height:2rem;font-size:$subFontSize;padding-left:.5rem;font-weight:700;border-top:1px dashed #eee}
  89. .ul{overflow: hidden;}
  90. .li{
  91. box-sizing: border-box;
  92. text-align: center;
  93. width: 25%;
  94. padding-bottom:20%;
  95. float: left;
  96. position:relative;
  97. .p-img{
  98. position:absolute;
  99. top:.5rem;
  100. bottom:.5rem;
  101. right:.5rem;
  102. left:.5rem;
  103. background-size:contain;
  104. background-position:center;
  105. background-repeat:no-repeat;
  106. }
  107. }
  108. .li:nth-child(4n) {
  109. border-right: 0;
  110. }
  111. }
  112. </style>