You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
function dataURLToBlob(cropperData) { |
|
let arr = cropperData.split(","); |
|
console.log('arr',arr) |
|
let mime = arr[0].match(/:(.*?);/)[1]; |
|
let blobStr = atob(arr[1]); |
|
let n = blobStr.length; |
|
let u8arr = new Uint8Array(n); |
|
while (n--) { |
|
u8arr[n] = blobStr.charCodeAt(n); |
|
} |
|
return URL.createObjectURL(new Blob([u8arr], { type: mime })) |
|
} |
|
|
|
export default { |
|
build() { |
|
uni.chooseImage = (params) => { |
|
try { |
|
if('compile' in params)params.compile(); |
|
eshimin.getLocalPicture({ |
|
onResponse:function (res) { |
|
if('success' in params)params.success([dataURLToBlob(res.img)]); |
|
} |
|
}); |
|
}catch (e){ |
|
console.log(e) |
|
if('fail' in params)params.fail(e); |
|
} |
|
} |
|
uni.getLocation = (params) => { |
|
try { |
|
console.log('getLocation', params) |
|
if('compile' in params)params.compile(); |
|
eshimin.getLocation({ |
|
onResponse:function (res) { |
|
if('success' in params)params.success(res); |
|
} |
|
}); |
|
}catch (e){ |
|
console.log(e) |
|
if('fail' in params)params.fail(e); |
|
} |
|
} |
|
uni.makePhoneCall = (params) => { |
|
try { |
|
console.log('makePhoneCall', params) |
|
if('compile' in params)params.compile(); |
|
eshimin.getLocation({ |
|
phoneNum:params.phoneNumber, |
|
onResponse:function (res) { |
|
if('success' in params)params.success(res); |
|
} |
|
}); |
|
}catch (e){ |
|
console.log(e) |
|
if('fail' in params)params.fail(e); |
|
} |
|
} |
|
}, |
|
}; |
|
|
|
|