...
|
...
|
@@ -6,78 +6,84 @@ |
|
|
* @ version: v1.0.0
|
|
|
*
|
|
|
*/
|
|
|
const XianyuJSBridge = {
|
|
|
// 判断是否在闲鱼环境内
|
|
|
get isAliApp () {
|
|
|
return /AliApp/i.test(navigator.userAgent || '');
|
|
|
},
|
|
|
/*
|
|
|
* @ description: 导航栏右侧自定义按钮 设为关闭
|
|
|
* @ author: huzhiming
|
|
|
* @ date: 2019-11-14 16:15:07
|
|
|
* @ version: v1.0.0
|
|
|
*/
|
|
|
closeNavRightItem () {
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVIdleFishApi', 'setHideNavigatorRightItem', {}, () => { }, () => { })
|
|
|
}
|
|
|
return this;
|
|
|
},
|
|
|
const XianyuJSBridge = {
|
|
|
// 判断是否在闲鱼环境内
|
|
|
get isAliApp () {
|
|
|
return /AliApp/i.test(navigator.userAgent || '');
|
|
|
},
|
|
|
get isAndroid () {
|
|
|
return /(Android)/i.test(navigator.userAgent || '');
|
|
|
},
|
|
|
/*
|
|
|
* @ description: 导航栏右侧自定义按钮 设为关闭
|
|
|
* @ author: huzhiming
|
|
|
* @ date: 2019-11-14 16:15:07
|
|
|
* @ version: v1.0.0
|
|
|
*/
|
|
|
closeNavRightItem () {
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVIdleFishApi', 'setHideNavigatorRightItem', {}, () => { }, () => { })
|
|
|
}
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
// 导航栏右侧自定义按钮 设为可见
|
|
|
setNavRightItem (shareParam = null) {
|
|
|
window._xianyuShare = () => {
|
|
|
this.setXianyuShare(shareParam);
|
|
|
}
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVIdleFishApi', 'setNavigatorRightItem', {
|
|
|
title: '∙∙∙', // 按钮名称
|
|
|
func: '_xianyuShare' // func: 'test' //点击调用函数 注意调用的函数必须挂载在window上
|
|
|
}, function(data) {
|
|
|
console.log('setNavigatorRightItem success:', data);
|
|
|
}, function(e) {
|
|
|
console.log('setNavigatorRightItem error:', e);
|
|
|
});
|
|
|
}
|
|
|
return this;
|
|
|
},
|
|
|
// 导航栏右侧自定义按钮 设为可见
|
|
|
setNavRightItem (shareParam = null) {
|
|
|
console.log('setNavRightItem', shareParam);
|
|
|
|
|
|
/*
|
|
|
* @ description: 配置分享参数进行分享操作
|
|
|
* @ author: huzhiming
|
|
|
* @ date: 2019-11-05 10:38:24
|
|
|
* @ version: v1.0.0
|
|
|
*/
|
|
|
setXianyuShare (param = {
|
|
|
shareType: 'activity', // 类型,默认activity
|
|
|
image: '//img11.static.yhbimg.com/goodsimg/2018/12/24/17/01070adae9791c70ed02593550437cf30e.jpg?imageMogr2/thumbnail/600x600/background/d2hpdGU=/position/center/quality/80',
|
|
|
url: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 分享链接
|
|
|
link: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 和url保持
|
|
|
title: '闲鱼潮品首页', // 分享标题
|
|
|
text: '' // 分享描述
|
|
|
}) {
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVIdleFishApi', 'showShareMenu', param, (data) => {
|
|
|
console.log('success:', JSON.stringify(data), typeof data.isCancel);
|
|
|
// if (data.isCancel === 'false') {}
|
|
|
}, function(e) {
|
|
|
console.log('fail:', JSON.stringify(e));
|
|
|
});
|
|
|
}
|
|
|
return this;
|
|
|
},
|
|
|
window._xianyuShare = () => {
|
|
|
this.setXianyuShare(shareParam);
|
|
|
}
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVIdleFishApi', 'setNavigatorRightItem', {
|
|
|
title: '∙∙∙', // 按钮名称
|
|
|
icon: this.isAndroid ? ' http://cdn.yoho.cn/xianyu/share-btn.png' : '',
|
|
|
func: '_xianyuShare' // func: 'test' //点击调用函数 注意调用的函数必须挂载在window上
|
|
|
}, function(data) {
|
|
|
console.log('setNavigatorRightItem success:', data);
|
|
|
}, function(e) {
|
|
|
console.log('setNavigatorRightItem error:', e);
|
|
|
});
|
|
|
}
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
// 隐藏 webview loadingBox
|
|
|
hideLoadingBox () {
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVUI', 'hideLoadingBox', {}, function(e) {
|
|
|
console.log('success: ' + JSON.stringify(e));
|
|
|
}, function(e) {
|
|
|
console.log('failure: ' + JSON.stringify(e));
|
|
|
});
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
/*
|
|
|
* @ description: 配置分享参数进行分享操作
|
|
|
* @ author: huzhiming
|
|
|
* @ date: 2019-11-05 10:38:24
|
|
|
* @ version: v1.0.0
|
|
|
*/
|
|
|
setXianyuShare (param = {
|
|
|
shareType: 'activity', // 类型,默认activity
|
|
|
image: '//img11.static.yhbimg.com/goodsimg/2018/12/24/17/01070adae9791c70ed02593550437cf30e.jpg?imageMogr2/thumbnail/600x600/background/d2hpdGU=/position/center/quality/80',
|
|
|
url: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 分享链接
|
|
|
link: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 和url保持
|
|
|
title: '闲鱼潮品首页', // 分享标题
|
|
|
text: '' // 分享描述
|
|
|
}) {
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVIdleFishApi', 'showShareMenu', param, (data) => {
|
|
|
console.log('success:', JSON.stringify(data), typeof data.isCancel);
|
|
|
// if (data.isCancel === 'false') {}
|
|
|
}, function(e) {
|
|
|
console.log('fail:', JSON.stringify(e));
|
|
|
});
|
|
|
}
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
// 隐藏 webview loadingBox
|
|
|
hideLoadingBox () {
|
|
|
if (this.isAliApp && window.WindVane) {
|
|
|
window.WindVane.call('WVUI', 'hideLoadingBox', {}, function(e) {
|
|
|
console.log('success: ' + JSON.stringify(e));
|
|
|
}, function(e) {
|
|
|
console.log('failure: ' + JSON.stringify(e));
|
|
|
});
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = XianyuJSBridge; |
...
|
...
|
|