diy_video.js
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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]);*/
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
});
}
}
})
}
}
})