flat: 添加地图
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
function onDialingPhoneNumber(phone) {
|
||||
export function onDialingPhoneNumber(phone) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: phone, // 电话号码
|
||||
@@ -11,8 +11,39 @@ function onDialingPhoneNumber(phone) {
|
||||
});
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 个位数,加0前缀
|
||||
* @param {*} number
|
||||
* @returns
|
||||
*/
|
||||
export function addZeroPrefix(number) {
|
||||
return number < 10 ? `0${number}` : number
|
||||
}
|
||||
|
||||
export function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
|
||||
const R = 6371; // 地球平均半径,单位为公里
|
||||
const dLat = deg2rad(lat2 - lat1);
|
||||
const dLon = deg2rad(lon2 - lon1);
|
||||
const a =
|
||||
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
||||
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
|
||||
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
||||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
const d = R * c;
|
||||
return {
|
||||
km: d,
|
||||
m: d * 1000
|
||||
};
|
||||
}
|
||||
|
||||
// 将角度转换为弧度
|
||||
function deg2rad(deg) {
|
||||
return deg * (Math.PI / 180);
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
onDialingPhoneNumber
|
||||
onDialingPhoneNumber,
|
||||
addZeroPrefix,
|
||||
getDistanceFromLatLonInKm
|
||||
}
|
||||
Reference in New Issue
Block a user