common.js
2.7 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
// var baseUrl = 'http://kindapp.w.bronet.cn/api/';
var baseUrl = 'http://192.168.1.3/api/';
function sendAjax(post, url, params, header, callback) {
$.ajax({
url: baseUrl + url,
method: post,
data: params,
headers: header,
success: function (res) {
callback(JSON.parse(res))
},
fail: function (err) {
console.log('error')
}
})
}
function show() {
var current = (current + 45) % 360;
// document.getElementById('target').style.transform = 'rotate(' + current + 'deg)';
$('#target').css('transform', 'rotate(' + current + 'deg)');
console.log( $('#target').css('transform', 'rotate(' + current + 'deg)'));
$('#show_menu').toggle()
}
function getDevice() {
var login_device = '';
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 wx = sUserAgent.match(/MicroMessenger/i) == "micromessenger"
var mac = sUserAgent.match(/macintosh|mac os x/i) == "mac"
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
var UA = window.navigator.userAgent;
isAndorid = /android/i.test(UA),
isIphone = /iphone/i.test(UA),
//isIphone = /(?:iPhone)/.test(UA),
isPad = /ipad/i.test(UA),
isDolphin = typeof dolphin !== 'undefined';
device = isAndorid ? 'android' : isIphone ? 'iphone' : isPad ? 'ipad' : mac ? 'mac' : 'mobile';
switch (device) {
case 'iphone':
login_device = device;
break;
case 'android':
login_device = device;
break;
case 'ipad':
login_device = device;
break;
default:
login_device = device;
break;
}
} else {
pc_device = wx ? 'wx' : mac ? 'mac' : 'pc';
login_device = pc_device;
}
return login_device
}
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return null; //返回参数值
}