{
  template: '${tmpl}',
    data: function () {
      return {
        selected: '1',
        smallList: null,
        productList: [],
        type: [],
        currentType: '',
        title: "",
        loading: false,
      }
    },
  mounted: function () {
    /* 获取首页传过来的ip,并获取所有ip */
    /*首页给ip用首页ip  */
    if (this.$route.query.current) {
      console.log(this.$route.query, "11111111111111111sss");
      if (!this.currentType) {
        this.currentType = this.$route.query.current;
      }
      let type = JSON.parse(this.$route.query.allItemType);
      this.type = type;
      console.log(this.type, this.currentType);
      let index = this.type.indexOf(this.currentType);
      this.getList(index);
    } else {
      this.loading = true;
      this.$root.postReq("/web/producttypeCtl/getProductTypeList").then((res) => {
        console.log(res, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        this.loading = false;

        res.data.forEach(item => {
          this.type.push(item.itemType);
        });
        this.currentType = this.type[0];
        let index = this.type.indexOf(this.currentType);
        this.getList(index);
      });

    }
    switch (this.currentType) {
      /*控制当前页面 */
      case "ip":
        this.selected = '1';
        break;
      case "pa":
        this.selected = '2';
        break;
      case "ic":
        this.selected = '3';
        break;
      case "LX201906101755oFppND":
        this.selected = '4';
        break;
      case "LX201906111013bmwgjj":
        this.selected = '5';
        break;
      default:
        this.selected = '1';
        break;
    };


  },
  watch: {
    selected(n, o){
      /*
      监听选项变化
      数据缓存也在这里做;
      */
      console.log(n, o, "=====================", this.type);
      switch (n) {
        case "1":
          this.getList(n - 1);
          this.currentType = this.type[n];
          break;
        case "2":
          this.currentType = this.type[n];
          this.getList(n - 1);
          break;
        case "3":
          this.currentType = this.type[n];
          this.getList(n - 1);
          break;
        case "4":
          this.currentType = this.type[n];
          this.getList(n - 1);
          break;
        case "5":
          this.currentType = this.type[n];
          this.getList(n - 1);
          break;
      };
    }
  },
  created: function () {

  },
  methods: {
    /* 获取列表数据 */
    getList(selected){
      this.loading = true;
      /*
        根据不同标题请求数据
      */
      this.$root.postReq('/web/producttypeCtl/getProductList', {
        "type_code": this.type[selected]
      }).then((res) => {
        this.loading = false;

        console.log(res);
        this.smallList = res.data[0].smallList;
      })
    },
    goNewAddress() {
      this.$router.push({
        path: "/mobilenewaddress"
      });
    },
    goCompanyDetail(index, item) {
      let data = JSON.stringify(item.productList[index]);
      this.$router.push({
        path: "/mobileserverdetail", query: { data }
      });

    }
    /*
    getLoginUser : function (){
      var self =this;
      this.$root.postReq("/web/userCtl/loginUser",{}).then(function(d){
        if(d.status==0){
          self.loginUser = d.data;
        }
      });
    }
    */
  },
  vname: "gsb-mobileservicetype"
}