productcategory.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="pages producttype-wrap">
  3. <view class="producttype">
  4. <view class="producttype-nav">
  5. <view v-for="(item,index) in navitem" :key="index" @click="typeclick(index)" :class="{active:index==ins}" class="producttype-nav-item">{{ item.name }}</view>
  6. </view>
  7. <view class="producttype-con">
  8. <view class="search">
  9. <view class="searchTxt">
  10. <uni-search-bar :placeholder="searchtxt" @confirm="search" ></uni-search-bar>
  11. </view>
  12. </view>
  13. <view class="search-typelist">
  14. <view v-for="(item,index) in typelist" :key="index" @click="publishtype(item.id,item.name)" class="search-typelist-item">
  15. <view class="search-typelist-item-serial">{{ index +1 }}</view>
  16. <view class="search-typelist-item-name">{{item.name}}</view>
  17. </view>
  18. </view>
  19. <!-- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  20. <view class="search-typelist">
  21. <view v-for="(item,index) in typelist" :key="index" @click="publishtype(item.name)" class="search-typelist-item">
  22. <view class="search-typelist-item-serial">{{ index +1 }}</view>
  23. <view class="search-typelist-item-name">{{item.name}}</view>
  24. </view>
  25. </view>
  26. </mescroll-body> -->
  27. </view>
  28. <!-- producttype-con end -->
  29. </view>
  30. <!-- fix-content end -->
  31. </view>
  32. </template>
  33. <script>
  34. import uniSearchBar from '@/components/uni-search-bar/uni-search-bar.vue'
  35. export default {
  36. components: {
  37. uniSearchBar,
  38. },
  39. data() {
  40. return {
  41. params:{
  42. token:'',
  43. },
  44. searchtxt:'产品名称',
  45. //nav active
  46. ins:0,
  47. //菜单类别
  48. navitem:[],
  49. //热门列表
  50. // hotlist:[
  51. // ],
  52. //typelist
  53. typelist:[],
  54. //显示的分类标题
  55. nowtype:'',
  56. }
  57. },
  58. onShow() {
  59. let serf = this;
  60. //检查登录,获取token
  61. // let loginRes = this.checkLogin('/pages/index/index', '2');
  62. // if(!loginRes){return false;}
  63. // serf.params.token=loginRes[0];
  64. },
  65. onLoad() {
  66. this.nowtype = this.navitem[this.ins];
  67. this.params.product = this.nowtype;
  68. //获取产品分类
  69. // ,{header: {Authorization:this.params.tokenhead+this.params.token}}
  70. this.$api.http.get(this.config.apiBaseurl+'/product/categoryTreeList').then(res => {
  71. console.log('产品分类',res);
  72. this.navitem = res.data.data;
  73. this.nowtype = this.navitem[this.ins].name;
  74. // this.params.productCategoryId = this.navitem[this.ins].id;
  75. this.searchtxt = this.navitem[this.ins].name;
  76. this.typelist = this.navitem[this.ins].children;
  77. // this.downCallback();
  78. }).catch(err => {
  79. console.log(err)
  80. });
  81. },
  82. methods: {
  83. //搜索
  84. search(e) {
  85. // console.log(e);
  86. uni.navigateTo({
  87. url:`/pages/searchresults/searchresults?keyword=${e.value}`,
  88. })
  89. },
  90. //左侧导航点击
  91. typeclick(num){
  92. this.ins=num;
  93. this.nowtype = this.navitem[num];
  94. this.searchtxt = this.navitem[this.ins].name;
  95. this.typelist = this.navitem[this.ins].children;
  96. },
  97. //产品点击
  98. publishtype(id,name){
  99. // console.log(id,name);
  100. uni.navigateTo({
  101. url:`/pages/searchresults/searchresults?productCategoryId=${id}&name=${name}`,
  102. })
  103. },
  104. }
  105. }
  106. </script>
  107. <style scoped>
  108. @import url("./productcategory.css");
  109. </style>