<template>
  <view class="search">
    <searchShuru isdel=true @sousuo="sousuo"></searchShuru>
    <searchTab tabtittle="综合,销量,价格" @shaixuan="shaixuan"></searchTab>
    <!-- <searchChexing chexing="车型：江淮安驰=小公主 2001款 0.8L 手动 国"></searchChexing> -->
    <view v-for="(i,j) in shoplist" :key="j" @click="todetail" :data-id="i.goods_id">
       <searchShop  :shopname="i.goods_name" :tag="i.ms" :pic="i.imgpaththumb" :pri="i.price" :zhushi="i.pingjia_num+'条评价'+i.pingjia_bfb+'%好评'"
    ></searchShop>
    </view>
   
  </view>
</template>
       
<script>
import searchShuru from "../../components/search/searchShuru";
import searchTab from "../../components/search/searchTap";
import searchChexing from "../../components/search/searchChexing";
import searchShop from "../../components/search/searchShop";
import requestP from "../../static/js/request.js";
export default {
  components: {
    searchShuru,
    searchTab,
    searchChexing,
    searchShop
  },
  data(){
    return {
      shoplist:[],
      px:0,
      so:"",
      type:0
    }
  },
  onLoad(e){
    console.log(e)
    this.so = e
    this.type =0
    if(e != ""){
      requestP
      .requestP({
        url: "goods/search_goods_list",
        data:{
          cat_id:e.typeid
        }
      }).then((res)=>{
        this.shoplist=res.data.data
      })
    }
     
  },
  methods:{
    todetail(e){
      console.log(e.currentTarget.dataset.id)
      	uni.navigateTo({
					url:"/pages/shopdetail/shopdetail?shopid="+e.currentTarget.dataset.id
				})
    },
    pin(e){
 console.log(e)
    this.so = e
    this.type =0
    if(e != ""){
      requestP
      .requestP({
        url: "goods/search_goods_list",
        data:{
          px:this.px,
          cat_id:e.typeid
        }
      }).then((res)=>{
        this.shoplist=res.data.data
      })
    }
    },
    sousuo(a){
      this.so = a 
      this.type = 1
requestP
      .requestP({
        url: "goods/search_goods_list",
        data:{
          select_info:a,
          px:this.px
        }
      }).then((res)=>{
        this.shoplist=res.data.data
      })
    },
    shaixuan(a){
      this.px =a
      // sousuo()
      if(this.type == 0){
        this.pin(this.so)
      }else{ 
        this.todetail(this.so)
      }
    }
  }
};
</script>

<style lang="scss">
</style>
