var t = getApp(),
  a = t.request,
  os = t.globalData.setting;

Component({
  properties: {
    object: {
      type: Object,
      value: null
    },
    // 这里定义了innerText属性，属性值可以在组件使用时指定

  },
  data: {
    // 这里是一些组件内部数据
    someData: {},
    videoUrl: "",
	url:os.imghost
  },

  ready: function () {	 
	 //-- 如果是本地视频的时候 -- 
	 if(this.properties.object.style!=2){	
		 //网络地址
		 this.create_url();
	 }else{
		 this.setData({videoUrl:this.properties.object.src});
	 }	   
  },
  methods: {
    // 这里是一个自定义方法
    create_url: function () {
      console.log('create_url');
      var that = this;
      /*获取文本框中的值*/
      var text = this.properties.object.wxapp_code;
      /*console.log("整个的地址"+text);*/
      var arr = new Array(), arrs = new Array();
      arr = text.split('vid=');
      /*console.log("截取vid后面的"+arr[1]);*/
	  if(!arr || arr.length<=0 || !arr[1]) return false;
	  
      arrs = arr[1].split('"');
      /*	console.log("截取&前面的的"+arrs[0]);*/
      var vipid = arrs[0];

      var url = "https://vv.video.qq.com/getinfo?vid=" + vipid + "&platform=101001&charge=0&otype=json";
      wx.request({
        url: url,
        success: function (res) {
          var dataJson = res.data.replace(/QZOutputJson=/, '') + "qwe";
          var dataJson1 = dataJson.replace(/;qwe/, '');
          var data = JSON.parse(dataJson1);
          if (data.vl != undefined) {
            var host = data['vl']['vi'][0]['ul']['ui'][2]['url']
            var fn = data.vl.vi[0].fn;
            var fvkey = data.vl.vi[0].fvkey;
            /* console.log("有参数吗"+fn+"有参数吗"+fvkey);*/
            var wxapp_url = host + fn + '?vkey=' + fvkey;
            that.setData({
              videoUrl: wxapp_url
            });
          }
        }
      })

    }
  }
})