封装了一个工具类,如果传入参数phone
,则发给指定联系人,不传入phone
,则到WhatsApp
应用中选择联系人进行分享
util.js
/**
* 调起第三方 whatsApp 应用进行内容分享
* 如果传入参数phone,则发给指定人,如果不传入参数,则可以选择联系人进行分享
* @param {Object} phone
*/
export function share(phone) {
const curHref = window.location.href;
// content是自己定义的一些需要分享的内容;
let shareStr = 'I\'ve found a fantastic item on Motovill - the online marketplace for used car trading.You should definitely have a look:';
let toSomeoneStr = 'Hi,I\'m interested!';
let content = phone ? toSomeoneStr : shareStr;
content += '\n'+ curHref;
isMobile(