ssoInit.js
3.42 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
window.em_ssoInit && em_ssoInit();
var retryTimes = 0;
function getEm(callback){
if(window.em){
callback && callback(em);
return;
}
setTimeout(function(){
if(window.em){
callback && callback(em);
}else{
if(retryTimes < 10){
retryTimes++;
getEm(callback);
}else{
alert('em对象不存在,重试次数:' + retryTimes);
}
}
}, 100);
}
function invokeEmApi(name){
var args = [].slice.call(arguments).slice(1);
em.ready(function(){
em[name].apply(em, args);
});
}
function scanQRCode4EM7(callback){
getEm(function(em){
invokeEmApi("scanQRCode", {
needResult:1,
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
callback && callback(res.resultStr);
}
});
});
}
function getLocation4EM7(callback){
getEm(function(em){
invokeEmApi("getLocation", {
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: function (res) {
callback && callback(","+res.latitude+","+res.longitude+",");
}
});
});
}
function chooseImage4EM7(sourceType, callback){
getEm(function(em){
invokeEmApi("chooseImage", {
count: 1, // 最大可选照片数,默认9
sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有 ['album', 'camera']
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表
top && typeof(top.showLoading) === 'function' && top.showLoading();
localIds.forEach(function(localId){
em.getLocalImgData({
localId: localId,
success: function(res){
top && typeof(top.hideLoading) === 'function' && top.hideLoading();
callback && callback("data:image/jpeg;base64," + res.localData);
}
});
});
}
});
});
}
function getAudioRecord4EM7(callback){
getEm(function(em){
invokeEmApi("getAudioRecord", {
success: function(res){
var localData = res.localData;
callback && callback(localData);
}
});
});
}
function navigationLBS4EM7(startLat, startLng, endLat, endLng, destAddr){
getEm(function(em){
invokeEmApi("navigationLBS", {
startLatitude: startLat,
startLongitude: startLng,
endLatitude: endLat,
endLongitude: endLng,
address: destAddr
});
});
}
function downloadImage4EM7(url){
getEm(function(em){
invokeEmApi("downloadImage", {
url: url,
isShowProgressTips: 1,
success: function(){
top && typeof(top.Dialog) === 'function' && top.Dialog('保存成功');
}
});
});
}
function downloadAttach4EM7(url, title, type){
getEm(function(em){
invokeEmApi("openLink", {
title: title,
url: url,
openType: type || 2 // 打开方式 1:当前窗口 2:新窗口 3:系统默认浏览器
});
});
}