一键SOS:紧急求救,发送位置短信
<template>
<div>
<div class='sos-btn' @click='sendSMS'>
<span class='sos-text'>SOS</span>
</div>
<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>
<style>
.sos-btn {
display: flex;
justify-content: center;
align-items: center;
width: 80px;
height: 80px;
background-color: red;
border-radius: 50%;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.25);
}
.sos-text {
font-size: 28px;
color: white;
}
</style>
原文地址: https://www.cveoy.top/t/topic/g5EQ 著作权归作者所有。请勿转载和采集!