httpGet
参数:
返回值(对象):
例子:
var ret = httpGet('https://xxx.com?a=12&b=afb', {Accept: 'text/plain'});
console.log('ret:' + ret);
httpPost
参数:
返回值(对象):
例子:
// 以下两个请求效果完全一样
var ret = httpPost('https://xxx.com?a=12&b=afb', {name: 'abc', value: 'ddd'}, {'Content-Type': 'json'});
console.log('ret:' + ret);
ret = httpPost('https://xxx.com?a=12&b=afb', {name: 'abc', value: 'ddd'}, 'json');
console.log('ret:' + ret);
// post上传文件
var file = new File('/sdcard/xx.jpg');
var data = {file: file, filename: 'xx'};
var ret = httpPost('http://test.com/upload_file', data, 'multipart');
console.log('ret:' + ret);
downloadFile
属性:
例子:
function main() {
var filePath = downloadFile('https://downsc.chinaz.net/Files/DownLoad/sound1/202303/y1687.wav', '/sdcard/path', 'b.wav');
console.log('end:', filePath);
}
// 回调函数,系统会自动调用
function cbMessage(msgId, p1, p2) {
if (msgId == 'msg_download_start') {
Toast.show('开始下载中...');
} else if (msgId == 'msg_download_progress') {
Toast.show('下载进度:' + p1 + '%');
} else if (msgId == 'msg_download_success') {
Toast.show('下载成功');
} else if (msgId == 'msg_download_failed') {
Toast.show('下载失败');
}
}
callMicroService
属性:
例子:
var ret = callMicroService('data', [12, 'aaa']);
console.log('ret:' + ret);
callWebService
属性:
例子:
var ret = callWebService('https://add.com', {name: 'jack'});
console.log('ret:' + ret);
encodeURI
参数:
例子:
var ret = encodeURI(data);
console.log('ret:' + ret);
decodeURI
参数:
例子:
var ret = decodeURI(data);
console.log('ret:' + ret);