|
|
|
|
@ -61,14 +61,14 @@
|
|
|
|
|
<u-icon name="chat-fill" color="#07c160" size="24"></u-icon>
|
|
|
|
|
<text class="label-text">微信</text>
|
|
|
|
|
</view>
|
|
|
|
|
<text class="contact-value">{{ detail.wechat }}</text>
|
|
|
|
|
<text class="contact-value wechat-clickable" @click="openWechat(detail.wechat)">{{ detail.wechat }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="contact-item" v-if="detail.mobile">
|
|
|
|
|
<view class="contact-label">
|
|
|
|
|
<u-icon name="phone-fill" color="#007aff" size="24"></u-icon>
|
|
|
|
|
<text class="label-text">电话</text>
|
|
|
|
|
</view>
|
|
|
|
|
<text class="contact-value">{{ detail.mobile }}</text>
|
|
|
|
|
<text class="contact-value phone-clickable" @click="makePhoneCall(detail.mobile)">{{ detail.mobile }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="contact-item" v-if="detail.email">
|
|
|
|
|
<view class="contact-label">
|
|
|
|
|
@ -210,6 +210,142 @@
|
|
|
|
|
current: file.url,
|
|
|
|
|
index: index
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 新增方法:拨打电话
|
|
|
|
|
makePhoneCall(phoneNumber) {
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '拨打电话',
|
|
|
|
|
content: `是否拨打 ${phoneNumber}?`,
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
uni.makePhoneCall({
|
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
|
success: () => {
|
|
|
|
|
console.log('拨号成功');
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.error('拨号失败:', err);
|
|
|
|
|
this.$u.toast('拨号失败,请重试');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 新增方法:打开微信
|
|
|
|
|
openWechat(wechatId) {
|
|
|
|
|
console.log('点击微信,微信号:', wechatId);
|
|
|
|
|
|
|
|
|
|
// 尝试使用微信的URL Scheme打开微信
|
|
|
|
|
const wechatUrl = `weixin://`;
|
|
|
|
|
|
|
|
|
|
// 检查是否在APP环境中且有plus对象
|
|
|
|
|
if (typeof window !== 'undefined' && window.plus && plus.runtime) {
|
|
|
|
|
console.log('检测到plus环境,尝试打开微信');
|
|
|
|
|
plus.runtime.openURL(wechatUrl, (err) => {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error('打开微信失败:', err);
|
|
|
|
|
this.showWechatCopyDialog(wechatId);
|
|
|
|
|
} else {
|
|
|
|
|
console.log('微信打开成功');
|
|
|
|
|
this.$u.toast('请在微信中搜索并添加好友');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
console.log('非APP环境或plus不可用,直接显示复制对话框');
|
|
|
|
|
// 非APP环境直接显示复制对话框
|
|
|
|
|
this.showWechatCopyDialog(wechatId);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 显示微信复制对话框
|
|
|
|
|
showWechatCopyDialog(wechatId) {
|
|
|
|
|
console.log('准备显示微信复制对话框,微信号:', wechatId);
|
|
|
|
|
|
|
|
|
|
// 在小程序中使用showModal
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '添加微信好友',
|
|
|
|
|
content: `微信号:${wechatId}\n请复制微信号到微信中搜索添加`,
|
|
|
|
|
confirmText: '复制',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
showCancel: true,
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log('showModal success callback:', res);
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
console.log('用户点击确认,准备复制微信号');
|
|
|
|
|
// 尝试复制微信号到剪贴板
|
|
|
|
|
this.tryCopyToClipboard(wechatId);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.error('showModal fail callback:', err);
|
|
|
|
|
// 如果showModal失败,尝试使用toast提示
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: `微信号:${wechatId}`,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 尝试复制到剪贴板的方法(适配隐私保护指引)
|
|
|
|
|
tryCopyToClipboard(text) {
|
|
|
|
|
// 检查小程序隐私协议是否已同意
|
|
|
|
|
if (typeof wx !== 'undefined' && wx.requirePrivacyAuthorize) {
|
|
|
|
|
// 需要用户同意隐私协议
|
|
|
|
|
wx.requirePrivacyAuthorize({
|
|
|
|
|
success: () => {
|
|
|
|
|
// 用户同意后,执行复制操作
|
|
|
|
|
this.executeCopyToClipboard(text);
|
|
|
|
|
},
|
|
|
|
|
fail: () => {
|
|
|
|
|
// 用户拒绝,显示手动复制提示
|
|
|
|
|
this.showManualCopyTip(text);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// 直接尝试复制
|
|
|
|
|
this.executeCopyToClipboard(text);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 执行复制到剪贴板
|
|
|
|
|
executeCopyToClipboard(text) {
|
|
|
|
|
uni.setClipboardData({
|
|
|
|
|
data: text,
|
|
|
|
|
success: () => {
|
|
|
|
|
console.log('复制成功');
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '微信号已复制到剪贴板',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 2000
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.error('复制失败:', err);
|
|
|
|
|
// 如果复制失败,显示手动复制的提示
|
|
|
|
|
this.showManualCopyTip(text);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 显示手动复制提示
|
|
|
|
|
showManualCopyTip(text) {
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '复制失败',
|
|
|
|
|
content: `微信号:${text}\n\n由于权限限制,请手动复制微信号到微信中搜索添加`,
|
|
|
|
|
confirmText: '知道了',
|
|
|
|
|
showCancel: false,
|
|
|
|
|
success: () => {
|
|
|
|
|
// 可以尝试使用其他方式提示用户
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '请手动复制微信号',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -473,6 +609,28 @@
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.phone-clickable {
|
|
|
|
|
color: #007aff;
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: color 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.phone-clickable:active {
|
|
|
|
|
color: #0056b3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.wechat-clickable {
|
|
|
|
|
color: #07c160;
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: color 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.wechat-clickable:active {
|
|
|
|
|
color: #06ad56;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.contact-placeholder {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|