提交 5c8653fb authored 作者: lidongxu's avatar lidongxu

feat(promotion/plan/detail/tasklist.vue): 新增:勤策移动端_内置网页_促销管理_增加促销员手机号显示和拨打/复制功能

上级 c4fdce9f
......@@ -202,7 +202,8 @@ const getPlanDetail = async () => {
province: o.reported.province, // 省份
city: o.reported.city, // 城市
addr: o.clock.clockInAddress, // 地址
temporaryName: o.reported.temporaryName, // 临时名称
temporaryName: o.reported.temporaryName, // 用户名
phone: o.clock.phone, // 手机号码
photoList: photoDialogList, // 照片列表
}
})
......
......@@ -14,13 +14,17 @@
<van-cell v-for="item, index in planList"
:key="item.id">
<template #title>
<p class="cell-info">
<span>促销员名字:{{ item.temporaryName }}</span>
<div class="cell-info">
<div class="info">
<span>促销员名字:{{ item.temporaryName }}</span>
<span class="phone-link"
@click="showPhonePicker(item)">手机号码:{{ item.phone }}</span>
</div>
<van-button class="delete-btn"
type="danger"
v-if="showDelete(planDetail)"
@click="deleteView(item, index)">删除此打卡记录</van-button>
</p>
</div>
<p>打卡参考地址:{{ item.province + item.city + item.addr }}</p>
</template>
<template #label>
......@@ -50,6 +54,12 @@
@change="onChange">
<template v-slot:index>{{ index + 1 }}</template>
</van-image-preview>
<!-- 手机号码选择器 -->
<van-action-sheet v-model:show="showPicker"
:actions="phoneActions"
cancel-text="取消"
@select="onPickerConfirm" />
</template>
<script setup>
......@@ -95,6 +105,35 @@ const onChange = (ind) => {
index.value = ind
}
// 手机号码选择器相关
const showPicker = ref(false)
const currentPhoneItem = ref(null) // 现在要拨打或复制的信息对象
const phoneActions = ref([
{ name: '拨打电话', value: 'call' },
{ name: '复制号码', value: 'copy' }
])
const showPhonePicker = (item) => {
currentPhoneItem.value = item
showPicker.value = true
}
// 选择器确认事件
const onPickerConfirm = (value) => {
const phone = currentPhoneItem.value.phone
switch (value.value) {
case 'call':
// 拨打电话
window.location.href = `tel:${phone}`
break
case 'copy':
// 复制号码
copyToClipboard(phone)
break
}
showPicker.value = false
}
// 删除计划
// 是否展示删除按钮
const showDelete = (row) => {
......@@ -104,6 +143,39 @@ const showDelete = (row) => {
// return date === currentDate
return true
}
// 复制到剪贴板
const copyToClipboard = (text) => {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(() => {
showNotify({ type: 'success', message: '号码已复制' })
}).catch(() => {
fallbackCopyText(text)
})
} else {
fallbackCopyText(text)
}
}
// 兼容性复制方法
const fallbackCopyText = (text) => {
const textArea = document.createElement('textarea')
textArea.value = text
textArea.style.position = 'fixed'
textArea.style.left = '-999999px'
textArea.style.top = '-999999px'
document.body.appendChild(textArea)
textArea.focus()
textArea.select()
try {
document.execCommand('copy')
showNotify({ type: 'success', message: '号码已复制' })
} catch (err) {
showNotify({ type: 'warning', message: '复制失败,请手动复制' })
}
document.body.removeChild(textArea)
}
// 点击删除
const deleteView = (item, index) => {
// 确认是否删除
......@@ -159,6 +231,17 @@ const deleteView = (item, index) => {
align-items: center;
margin-bottom: 10px;
.info {
display: flex;
flex-direction: column;
justify-content: space-between;
.phone-link {
color: #1989fa;
cursor: pointer;
}
}
.delete-btn {
height: 30px;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论