完成电话拨打功能

This commit is contained in:
wangyifeng 2025-03-14 09:49:30 +08:00
parent 2304ddfc45
commit 747653f54a
3 changed files with 122 additions and 4 deletions

View File

@ -6,7 +6,11 @@
props.subBtnText ? 'apposition-btn-style' : '', props.subBtnText ? 'apposition-btn-style' : '',
]" ]"
> >
<wd-button custom-class="custom-sub-btn-class" v-if="props.subBtnText"> <wd-button
custom-class="custom-sub-btn-class"
v-if="props.subBtnText"
@click="clickSubBtn"
>
{{ props.subBtnText }} {{ props.subBtnText }}
</wd-button> </wd-button>
<wd-button <wd-button
@ -24,7 +28,7 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import { defineProps, defineEmits } from 'vue' import { defineProps, defineEmits } from 'vue'
const state = reactive({}) const state = reactive({})
const emits = defineEmits(['clickBtn']) const emits = defineEmits(['clickSubBtn', 'clickBtn'])
const props = defineProps({ const props = defineProps({
isBottom: false, // isBottom: false, //
btnText: '', // btnText: '', //
@ -33,7 +37,12 @@ const props = defineProps({
plain: false, // plain: false, //
}) })
// //
const clickSubBtn = () => {
emits('clickSubBtn')
}
//
const clickBtn = () => { const clickBtn = () => {
emits('clickBtn') emits('clickBtn')
} }

View File

@ -64,10 +64,37 @@
:btnText="$t('user.detail.sendMsg')" :btnText="$t('user.detail.sendMsg')"
:subBtnText="$t('user.detail.ringBell')" :subBtnText="$t('user.detail.ringBell')"
@clickBtn="toTalkUser" @clickBtn="toTalkUser"
@clickSubBtn="handleCall"
></customBtn> ></customBtn>
</template> </template>
</ZPaging> </ZPaging>
</div> </div>
<tm-drawer
placement="bottom"
v-model:show="state.isShowPhoneCall"
:hideHeader="true"
:height="416"
:round="6"
>
<div class="do-phone-call">
<div class="do-phone-call-header">
<span>{{ $t('popup.title.phone') }}</span>
<img
src="/src/static/image/login/check-circle-filled@3x.png"
@click="hidePhoneCallPopup"
/>
</div>
<div class="do-phone-call-number">
<span>{{ state.phoneNumber }}</span>
</div>
<div class="do-phone-call-btn">
<customBtn
:btnText="$t('do.phone.call')"
@clickBtn="doPhoneCall"
></customBtn>
</div>
</div>
</tm-drawer>
</div> </div>
</template> </template>
<script setup> <script setup>
@ -88,6 +115,8 @@ const state = reactive({
erpUserId: '', //erpid erpUserId: '', //erpid
userInfo: null, // userInfo: null, //
userBasicInfos: [], // userBasicInfos: [], //
isShowPhoneCall: true, //
phoneNumber: '', //
}) })
onLoad((options) => { onLoad((options) => {
@ -167,6 +196,7 @@ const getUserInfo = () => {
value: data.enter_date, value: data.enter_date,
}, },
] ]
state.phoneNumber = data.tel_num
} else { } else {
} }
}) })
@ -174,10 +204,33 @@ const getUserInfo = () => {
resp.catch(() => {}) resp.catch(() => {})
} }
//
const handleCall = () => {
state.isShowPhoneCall = true
}
//
const hidePhoneCallPopup = () => {
state.isShowPhoneCall = false
}
// //
const toTalkUser = () => { const toTalkUser = () => {
talkStore.toTalk(1, state.userInfo.sys_id, state.erpUserId) talkStore.toTalk(1, state.userInfo.sys_id, state.erpUserId)
} }
//
const doPhoneCall = () => {
uni.makePhoneCall({
phoneNumber: state.phoneNumber,
success: () => {
console.log('拨号成功')
},
fail: (err) => {
console.error('失败:', err)
},
})
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.outer-layer { .outer-layer {
@ -290,4 +343,58 @@ const toTalkUser = () => {
} }
} }
} }
.do-phone-call {
.do-phone-call-header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 42rpx 0;
position: relative;
span {
font-size: 28rpx;
line-height: 40rpx;
color: #747474;
font-weight: 400;
}
img {
position: absolute;
top: 44rpx;
right: 30rpx;
width: 36rpx;
height: 36rpx;
}
}
.do-phone-call-number {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 32rpx 0;
border-top: 2rpx solid #e7e7e7;
border-bottom: 2rpx solid #e7e7e7;
span {
font-size: 32rpx;
line-height: 44rpx;
color: #1a1a1a;
font-weight: 400;
}
}
.do-phone-call-btn {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 50rpx 0;
:deep(.custom-btn-class) {
width: 690rpx;
font-size: 32rpx;
line-height: 44rpx;
padding: 18rpx 0;
height: 80rpx;
background: linear-gradient(to right, #674bbc, #46299d);
}
}
}
</style> </style>

View File

@ -150,5 +150,7 @@
"button.text.close": "关闭", "button.text.close": "关闭",
"choose.deps.all": "全部", "choose.deps.all": "全部",
"choose.deps.current": "当前", "choose.deps.current": "当前",
"chat.mention.select": "选择提醒的人" "chat.mention.select": "选择提醒的人",
"do.phone.call": "拨打",
"popup.title.phone": "电话"
} }