common2.js
8.59 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
var mySwiper = null,
mySwiper2 = null;
var mask1 = null,
mask2 = null; //彈窗
var interval1 = null,
interval2 = null,
interval3 = null;
var flag1 = true,
flag2 = true,
flag3 = true;
var _url = 'http://ceshi.yabolive.tv/web';
var _url2 = 'http://test.ybact.yazhaiyabo.com/';
var _url3 = 'http://ceshi.yabolive.tv';
if(location.href.indexOf('activity.yazhaiyabo.com') > -1) {
_url = 'https://webserver.yabolive.net';
_url2 = 'https://activity.yazhaiyabo.com/';
_url3 = 'https://webserver.yabolive.net';
}
var cdn = 'https://big.bgp.ourpow.com/comm';
function $ajax(opt) {
return new Promise(function(resolve, reject) {
opt = opt || {};
opt.method = opt.type || 'POST';
opt.url = _url + opt.url || '';
opt.async = opt.async || true;
opt.data = opt.data || null;
opt.dataType = opt.dataType || 'json';
opt.success = opt.success || function() {};
var xmlHttp = null;
if(XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}
var params = ['uid=' + getRequest().uid, 'cid=web_gw', 'os=WEB', 'token=' + getRequest().token, 'lang=' + (getRequest().lang || 2)];
for(var key in opt.data) {
params.push(key + '=' + (opt.data[key] || ''));
}
var postData = params.join('&');
if(opt.method.toUpperCase() === 'POST') {
xmlHttp.open(opt.method, opt.url, opt.async);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
xmlHttp.send(postData);
} else if(opt.method.toUpperCase() === 'GET') {
xmlHttp.open(opt.method, opt.url + '?' + postData, opt.async);
xmlHttp.send(null);
}
xmlHttp.onreadystatechange = function() {
var res;
if(this.readyState != 4)return;
if( this.status == 200 || this.status == 304) {
res = this.responseText;
if(opt.dataType == 'json') {
res = JSON.parse(res);
}
resolve(res);
} else {
reject(new Error(this.statusText));
}
};
xmlHttp.onerror = function() {
reject(new Error(this.statusText));
};
})
}
var currencyUnit = ''; //寶石 貨幣單位
var currencyImg = ''; //寶石圖片
var incomeUnit = ''; //螢火 收益單位
var incomeImg = ''; //螢火圖片
var headUrl = ''; //默認頭像url
var currencyImg2 = ''; //寶石圖片 小
var giftObjImg = '';
function getInit() {
return new Promise(function(resovle, reject) {
$ajax({
url: '/active201904/getUserInfo.html',
}).then(function(res) {
if(res.vest == 41) {
if(url_get_params().appversion < 5960) {
currencyUnit = '樱花'; //貨幣單位
incomeUnit = '花瓣'; //收益單位
headUrl = 'https://app.ixiulive.com/static/images/headc.png';
currencyImg = '<img class="current2" src="https://app.ixiulive.com/static/images/current2.png" />';
currencyImg2 = 'https://app.ixiulive.com/static/images/current2s.png';
incomeImg = '<img class="income2" src="https://app.ixiulive.com/static/images/income2.png" />';
giftObjImg = 'https://app.ixiulive.com/static/images/current2.png';
} else {
currencyUnit = '寶石'; //貨幣單位
incomeUnit = '羽毛'; //收益單位
headUrl = 'https://app.ixiulive.com/static/images/head2.png';
currencyImg = '<img class="current4" src="https://app.ixiulive.com/static/images/current4.png" />';
currencyImg2 = 'https://app.ixiulive.com/static/images/current4s.png';
incomeImg = '<img class="income4" src="https://app.ixiulive.com/static/images/income4.png" />';
giftObjImg = 'https://app.ixiulive.com/static/images/current4.png';
}
} else if(res.vest == 40) {
currencyUnit = '金幣'; //貨幣單位
incomeUnit = '金豆'; //收益單位
headUrl = 'https://app.ixiulive.com/static/images/headp.png';
currencyImg = '<img class="current3" src="https://app.ixiulive.com/static/images/current3.png" />';
currencyImg2 = 'https://app.ixiulive.com/static/images/current3s.png';
incomeImg = '<img class="income3" src="https://app.ixiulive.com/static/images/income3.png" />';
giftObjImg = 'https://app.ixiulive.com/static/images/current3.png';
} else if(res.vest == 50 || res.vest == 60) {
currencyUnit = '寶石'; //貨幣單位
incomeUnit = '羽毛'; //收益單位
headUrl = 'https://app.ixiulive.com/static/images/head2.png';
currencyImg = '<img class="current4" src="https://app.ixiulive.com/static/images/current4.png" />';
currencyImg2 = 'https://app.ixiulive.com/static/images/current4s.png';
incomeImg = '<img class="income4" src="https://app.ixiulive.com/static/images/income4.png" />';
giftObjImg = 'https://app.ixiulive.com/static/images/current4.png';
} else {
currencyUnit = '寶石'; //貨幣單位
incomeUnit = '螢火'; //收益單位
headUrl = 'https://zhibocdn.yabolive.net/comm/user/boy.png';
currencyImg = '<img class="current1" src="https://app.ixiulive.com/static/images/current1.png" />';
currencyImg2 = 'https://app.ixiulive.com/static/images/current1s.png';
incomeImg = '<img class="income1" src="https://app.ixiulive.com/static/images/income11.png" />';
giftObjImg = 'https://app.ixiulive.com/static/images/current1.png';
}
resovle(res);
})
})
}
//跳转到规则
function goRule(){
window.location.href = 'rule.html' + location.search;
}
//关闭弹窗
function closeMasking(){
layer.closeAll();
}
function getTime(time) {
var timezone = 8; //目标时区时间,东八区
var offset_GMT = new Date(time).getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟
var nowDate = new Date(time).getTime(); // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
var data = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000);
var year = data.getFullYear();
var month = data.getMonth() + 1;
var day = data.getDate();
var hour = data.getHours();
var minute = data.getMinutes();
var sec = data.getSeconds();
var obj = {
"year": year,
"month": add0(month),
"day": add0(day),
"hour": add0(hour),
"minute": add0(minute),
"sec": add0(sec),
}
return obj;
}
//加0
function add0(m) {
return m < 10 ? '0' + m + "" : m + ""
}
function layerOpen(){
var self = this;
var arg = arguments;
layer.open({
type: 1,
title: false,
shadeClose: true,
shade: .65,
area: ['10rem', ''],
closeBtn: 0,
content: $('.'+arg[0]),
end: function() {
if(arg[1]==undefined){
flag1 = true;
} else {
self['flag'+arg[1]] = true;
}
if(arg.length>2 && typeof arg[2] == 'function'){
arg[2].apply(self,arg);
}
}
})
}
//多語言
var langList = [
{
"upright1":"活動",
"upright2":"客服",
"upright3":"說明",
"upright4":"記錄",
"upright5":"分享",
"upright6":"在線客服",
"upright7":"Hi,請問有什麼可以幫到您?",
},
{
"upright1":"Activity",
"upright2":"Online service",
"upright3":"Rules",
"upright4":"Record",
"upright5":"Share",
"upright6":"Customer service",
"upright7":"Hi, what can I do for you?",
}
]
var langType = 0;
var langCon = getRequest().lang;
if(langCon==undefined || langCon == 'undefined'){
langCon = sessionStorage.lang;
}
//当没有语言参数时 默认为繁体
if(langCon==undefined || langCon == 'undefined'){
langCon = 2;
}
if(langCon == 2){
langType = 0;
} else {
langType = 1;
}
//获取url参数
function getRequest() {
var url = location.href;
var theRequest = new Object();
if(url.indexOf("?") != -1) {
var str = url.substr(url.indexOf("?") + 1);
strs = str.split("&");
for(var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
function close() {
var obj = {
"cid": 14,
"reqCode": new Date().getTime(),
"data": {
"msg": '關閉半屏網頁',
}
}
var obj2 = JSON.stringify(obj);
appCollaboration(obj2);
}
function appCollaboration(msg) {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if(!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {} else if(bIsAndroid) {
window.yazhai.appCollaboration(msg);
} else if(bIsIphoneOs || bIsIpad) {
window.webkit.messageHandlers.appCollaboration.postMessage(msg);
}
}
//客户端回调结果
function appCallback(msg) {
console.log(msg);
}