wuzhenkun
2021-02-18 95033a06a92d00cbf9c103c8512e1b1c7a7646e5
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
//1. data
var callback;
var initReadyCallback;
var login_data = {
    userId: null,
    params: {}
}
 
var img_data={
    
}
 
//2. function
function onInitReady(callback) {
    if (login_data.userId) {
        callback(login_data);
    }
    else {
        initReadyCallback = callback;
    }
}
 
// function setLoginUser(ocValueOne) {
//     login_data = ocValueOne;
// }
 
function setRouteParams(ocValueOne) {
    if(ocValueOne instanceof String) {
    ocValueOne = JSON.pause(ocValueOne);
    }
   login_data = ocValueOne;
   
   if (initReadyCallback) {
       initReadyCallback(login_data);
   }
   
   console.info("JS INIT");
   console.info(JSON.stringify(login_data));
}
 
function setMessageImg(ocValueOne){
    img_data = ocValueOne;
}
 
window.onresize = function(){
    getRem(720,100)
};
 
function getRem(pwidth,prem, callback) {
    var html = document.getElementsByTagName("html")[0];
    var oWidth = document.body.clientWidth || document.documentElement.clientWidth;
    html.style.fontSize = oWidth/pwidth*prem + "px";
    if(callback) {
        callback();
    }
}
 
//调用Android或ios的事件
function toIosOrAndroid(functionName, parameter, callback) {
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    var systemType = null;
    if (isiOS) {
        systemType = ios;
    }
    else if (isAndroid) {
        systemType = android;
    }
    if (systemType[functionName]) {
        systemType[functionName](parameter);
        if(callback) {
            callback();
        }
    }
}
 
function showloading(itemid) {
    document.getElementById(itemid).style.display = "display";
}
function hideloading(itemid) {
    document.getElementById(itemid).style.display = "none";
}
 
function h5ToApp(fun, pam, callback) {
    window.webBridge.callAppRouter(fun, pam, function(err, resultObj) {
        if (callback) {
            callback(err, resultObj)
        }
    });
}
 
function app_click(fun, pam, callback) {
    if(!pam.params.pageInfo){
        pam.params.pageInfo = null;
    }
    window.webBridge.callAppRouter(fun, pam, function(err, resultObj) {
        if (callback) {
            callback(err, resultObj)
        }
    });
}
 
function setRightBtn(fun, pam, callback) {
    window.webBridge.callAppRouter(fun, pam, function(err, resultObj) {
        if (callback) {
            callback(err, resultObj)
        }
    });
}
 
function rightBtnPush(fun, pam, callback) {
    if(!pam.params.pageInfo){
        pam.params.pageInfo = null;
    }
    window.webBridge.callAppRouter(fun, pam, function(err, resultObj) {
        if (callback) {
            callback(err, resultObj)
        }
    });
}
 
function click_row2(path) {
    mui.openWindow({
      url: path + '.html'
    });
}
 
//function showMessage(type, message)
function showMessage(type) {
    console.info("error:"+type);
}
    
// app_click("route", pam, callback);
 
function ajaxPost(url,params,onSuccess, onError) {
     if (url.indexOf("http") < 0) {
      url = serverURL + url;
     }
     
    mui.ajax(url, {
        data: params,
        headers: {'Content-Type':'application/json',
                 'token': 'client:id:1349969932817141761'},
        success: function(result) {
            if(onSuccess) {
                onSuccess(result);
            }
        },
        error: function (type,errorThrown) {
            showMessage(type);
            if(onError) {
                onError(type,errorThrown)
            }
        }
    });
}
 
function ajaxGet(url, onSuccess, onError) {
     if (url.indexOf("http") < 0) {
      url = serverURL + url;
     }
 
     mui.ajax(url, {
          headers: {'Content-Type':'application/json'},
          type: 'GET',
          success: function(result) {
               if (onSuccess) {
                onSuccess(result);
               }
          },
          error: function (xhr, type, errorThrown) {
               showMessage(type);
               if (onError) {
                onError(xhr, type, errorThrown)
               }
          }
     });
}