最新跳转QQ添加好友代码JavaScript代码
代码
function addCustomerService() {
const params = new URLSearchParams(window.location.search);
const qq = params.get('qq');
if (!qq) {
alert('未传入客服qq号');
} else {
var ua = navigator.userAgent;
var isIphone = ua.match(/(iPhone\sOS)\s([\d_]+)/),
isAndroid = ua.match(/(Android)\s+([\d.]+)/);
if (isIphone) {
location.href = `mqq://card/show_pslcard?src_type=internal&version=1&uin=${qq}&card_type=person&source=sharecard`;
} else if (isAndroid) {
location.href = `mqq://card/show_pslcard?src_type=internal&version=1&uin=${qq}&card_type=person&source=sharecard`;
} else {
location.href = `tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin=${qq}`;
}
}
}
window.onload = function () {
addCustomerService();
};
比如我们的网址是 https://www.idc1680.com/qq.html?qq=61018648,此时addCustomerService方法内的params变量值为qq=61018648,qq的值为61018648。
移动端则跳转到:mqq://card/show_pslcard?src_type=internal&version=1&uin=61018648&card_type=person&source=sharecard
电脑端则跳转到:tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin=61018648