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.

38 lines
850 B

/**
* 延时函数
* @param {number} ms - 延迟时间毫秒
* @returns {Promise} - 返回一个 Promise在指定时间后 resolve
*/
export function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export function getLatLng() {
return new Promise((reslove) => {
uni.getLocation({
type: 'gcj02',
success: function(res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
reslove({
lat: res.latitude,
lng: res.longitude
})
},
fail: function(res) {
reslove({
lat: null,
lng: null
})
}
});
});
}
// 使用示例:
// async function example() {
// console.log('开始');
// await delay(2000); // 延时 2 秒
// console.log('2秒后执行');
// }