效果图

网页版:
<script>
jQuery(function () {
function createBtnHtml() {
return "<span id='contactTA_btn' style='" +
"display:inline-flex;align-items:center;margin-left:6px;" +
"padding:2px 8px;" +
"background:#1E88E5;color:#fff;border-radius:4px;" +
"cursor:pointer;font-size:12px;font-weight:500;" +
"user-select:none;line-height:16px;" +
"'>" +
"<img src='https://p6-lark-brand-image-sign.byteimg.com/tos-cn-i-q8fs7p473g/d536e014400645dfb6fa6fc9d6cbba19.png~tplv-q8fs7p473g-image.image?rk3s=fb957577&x-expires=1795685283&x-signature=OK7XC5ue9Fe0QkFok31nwveJWs8%3D' " +
"style='width:16px;height:16px;margin-right:4px;vertical-align:middle;border-radius:2px;' />" +
"联系TA</span>";
}
function insertBtn() {
var openid = jQuery("#field14372").val();
var span = jQuery("#field7512span");
if(!span.length || !openid || openid.trim()===''){
setTimeout(insertBtn,200);
return;
}
if(jQuery("#contactTA_btn").length) return;
span.after(createBtnHtml());
jQuery("#contactTA_btn").on("click touchstart",function(e){
e.preventDefault();
window.open("https://applink.feishu.cn/client/chat/open?openId=" + openid,"_blank");
});
// hover + 按下反馈
jQuery("#contactTA_btn").hover(
function(){jQuery(this).css("background","#1565C0");},
function(){jQuery(this).css("background","#1E88E5");}
).on("mousedown touchstart",function(){
jQuery(this).css("transform","scale(0.95)");
}).on("mouseup touchend touchcancel",function(){
jQuery(this).css("transform","scale(1)");
});
console.log("按钮已插入(官方图标版)");
}
insertBtn();
});
</script>
H5版:
<script>
jQuery(function () {
function createBtn(openid) {
if(!openid) return;
var btn = jQuery("<div id='contactTA_btn' style='" +
"position:fixed;bottom:20px;right:20px;" +
"padding:6px 12px;background:#1E88E5;color:#fff;" +
"border-radius:24px;font-size:14px;font-weight:500;" +
"display:flex;align-items:center;cursor:pointer;z-index:9999;" +
"'>" +
"<img src='https://p6-lark-brand-image-sign.byteimg.com/tos-cn-i-q8fs7p473g/d536e014400645dfb6fa6fc9d6cbba19.png~tplv-q8fs7p473g-image.image?rk3s=fb957577&x-expires=1795685283&x-signature=OK7XC5ue9Fe0QkFok31nwveJWs8%3D' " +
"style='width:20px;height:20px;margin-right:6px;border-radius:3px;'/>" +
"联系TA</div>"
);
jQuery("body").append(btn);
btn.on("click touchstart", function(e){
e.preventDefault();
window.location.href = "https://applink.feishu.cn/client/chat/open?openId=" + openid;
});
btn.on("mousedown touchstart", function(){
jQuery(this).css("transform","scale(0.95)");
}).on("mouseup touchend touchcancel", function(){
jQuery(this).css("transform","scale(1)");
});
}
function waitOpenId() {
// 尝试获取 input 值或 data-value
var field = jQuery("#field14372");
var openid = field.val() || field.attr("data-value") || "";
if(openid){
createBtn(openid);
} else {
setTimeout(waitOpenId,200); // 200ms 后重试
}
}
waitOpenId();
});
</script>