uni-app 发送短信带地理位置信息
<template>
<div>
<button @click='sendSMS'>发送短信</button>
<button @click='setEmergencyContact'>设置紧急联系人号码</button>
</div>
</template>
<script>
export default {
methods: {
sendSMS() {
uni.showModal({
title: '提示',
content: '确定发送短信吗?',
success: (res) => {
if (res.confirm) {
uni.getLocation({
success: (res) => {
const location = '我的位置是:经度' + res.longitude + ',纬度' + res.latitude
uni.sendSMS({
phoneNumber: '111',
message: location,
success: () => {
uni.showToast({
title: '发送成功',
icon: 'success'
})
},
fail: () => {
uni.showToast({
title: '发送失败',
icon: 'none'
})
}
})
},
fail: () => {
uni.showToast({
title: '获取位置信息失败',
icon: 'none'
})
}
})
}
}
})
},
setEmergencyContact() {
// 设置紧急联系人号码的逻辑
}
}
}
</script>
原文地址: https://www.cveoy.top/t/topic/g5AS 著作权归作者所有。请勿转载和采集!