feat(card): save-contact 原生页新增 action=mail 分支——web-view 内 mailto 死链的复制兜底

- onLoad action=mail 时: uni.setClipboardData 复制邮箱(showToast:false) +
  自定义 toast「邮箱已复制,去邮件 App 粘贴发送」+ 1.4s 后 navigateBack
  返回 wap 名片页
- 复制失败时把邮箱原文带进 toast, 便于用户手动抄写
- 与后端 _mini_bridge.html 双环境分发配套(backend ebf355a)
This commit is contained in:
2026-10-23 15:28:47 +08:00
parent 0c0a6a1cb8
commit 0b3a49f0d1

View File

@@ -35,6 +35,7 @@
* 入参(query, 均需 encodeURIComponent):
* name/mobile/company/job_title/email/website/address/remark/wechat 名片字段
* action=call 时进入页面直接拨号(wap 页「打电话」按钮也可走本页)
* action=mail 时复制 email 到剪贴板并返回(web-view 内 mailto: 不生效的兜底)
*/
export default {
data() {
@@ -70,6 +71,10 @@ export default {
if (options && options.action === 'call' && this.form.mobile) {
this.callNow();
}
// 发邮件动作: web-view 内 mailto: 不生效, 复制邮箱后返回名片页
if (options && options.action === 'mail' && this.form.email) {
this.copyEmail();
}
},
onReady() {
// 微信真机才生效(模拟器 bug 见 docs/weixin-bug.md), onShow 兜底见下
@@ -91,6 +96,22 @@ export default {
fail: () => {}
});
},
// 发邮件兜底: 小程序无唤起邮件 App 的 API, 复制邮箱 + 提示后返回原名片页
copyEmail() {
uni.setClipboardData({
data: this.form.email,
showToast: false,
success: () => {
uni.showToast({ title: '邮箱已复制,去邮件 App 粘贴发送', icon: 'none', duration: 2000 });
setTimeout(() => {
uni.navigateBack({ fail: () => {} });
}, 1400);
},
fail: () => {
uni.showToast({ title: '复制失败,邮箱:' + this.form.email, icon: 'none', duration: 3000 });
}
});
},
saveToContacts() {
if (this.saving) return;
if (!this.form.name && !this.form.mobile) {