var app = new Vue({
  el:"#app",
  data:function(){
    return {
      channelcode:"",
      channelname:"",
      scrollpicture:[],
      imgHeight:"620px",
      datalist:[
        // {name:"香港公司注册",desc:"应对2019新电商法合规经营"},
        // {name:"作品著作权",desc:"知产服务，保护您的知识产权"},
        // {name:"个体工商户注册",desc:"应对2019新电商法合规经营"},
        // {name:"国内公司注册",desc:"应对2019新电商法合规经营"}
      ],
    }
  },
  created:function(){
    var channelcode=window.location.search.substr(1).match(new RegExp("(^|&)" + "channelcode" + "=([^&]*)(&|$)", "i"));
    if(channelcode!= null){
      this.channelcode=unescape(channelcode[2]);
    }
    console.log(this.channelcode);
    if(this.channelcode==""){
      this.$message.warning("传递参数channelcode错误");
      return false;
    }
    this.setheight();
    this.findScrollpiature();
    this.findserviceitem();

  },
  methods:{
    postReq(path,data){
      return axios.post(path,data).then(function(r){
        return r.data?r.data:null;
      })
    },
    setheight(){
      var viewwidth=document.body.clientWidth;
      console.log(viewwidth);
      var imgHeight=viewwidth*300/750
      this.imgHeight=imgHeight.toString()+"px";
      console.log("----------------imgHeight------------------");
      console.log(imgHeight);
    },

    findScrollpiature:function(){
      var that=this;
      var params={
        channelcode:that.channelcode
      };
      this.$root.postReq("/web/loopplayCtl/findByChannelcode",params).then(function(d){
        console.log(d);
        if(d.code==1&&d.data&&d.data.length){
          for(var i=0;i<d.data.length;i++){
            if(d.data[i].leftimg){
              that.scrollpicture.push({"url":d.data[i].leftimg});
            }
            if(d.data[i].rightimg){
              that.scrollpicture.push({"url":d.data[i].rightimg});
            }
          }
        }else{
          that.scrollpicture=[
            {"url":"https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_336111545628553577201824131553577needhtml5.png"},
            {"url":"https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_344111545628519966201824131519966needhtml.png"}
          ]
        }
        console.log("-------------scrollpicture-------------------");
        console.log(that.scrollpicture);

      });
    },

    findserviceitem:function(){
      var that=this;
      var params={
        channelcode:that.channelcode
      };
      this.$root.postReq("/web/servicesitemCtl/findByChannelcode",params).then(function(d){
        console.log(d);

        if(d.code==1){
          that.datalist=d.data.data;
          that.channelname=d.data.channelname;
          $("#needhtml5").text(that.channelname);
          $("#app").css("visibility","visible");
        }else{
          that.$message.warning("传递参数错误,请稍后重试");
          $("#app").css("visibility","visible");
        }
      })
    },
    toneedh5:function(code){
      console.log("---------toneedh5------------");
      var that=this;
      window.location.href="https://boss.gongsibao.com/needh5?"+"code="+code+"&channelcode="+this.channelcode

    },


  },

});
