Authored by shuaiguo

Merge branch 'refs/heads/feature/coupon' into develop

{
"name": "yohobuywap-node-activity",
"version": "6.9.24",
"version": "6.10.0-beta01",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -1228,27 +1228,46 @@ function miniProgramHandleInit() {
// 3、绑定相关触发函数
// /* eslint-disable */
function setXianyuShareInfo() {
// var VConsole = require('vconsole');
// var vConsole = new VConsole();
// const webShareData = {
// title: $('#shareTitle').val(),
// desc: $('#shareImg').val(),
// imgUrl: $('#shareDesc').val(),
// link: $('#shareLink').val()
// };
// const parames = {
// shareType: 'activity', // 类型,默认activity
// image: webShareData.imgUrl,
// url: `${webShareData.link}?isNeedRefresh=false`, // 分享链接
// link: `${webShareData.link}?isNeedRefresh=false`, // 和url保持
// title: `淘口令#${webShareData.title}`, // 分享标题
// text: '' // 分享描述
// };
// XianyuJSBridge.hideLoadingBox().setNavRightItem(parames);
// let VConsole = require('vconsole');
// let vconsole = new VConsole();
// 隐藏闲鱼loading加载框
XianyuJSBridge.hideLoadingBox();
// 配置分享信息 在../common/share.js | /activity/share ajax接口请求成功会往input填值操作
// 防止分享数据未赋值成功, 设置分享信息,8秒ajax未成功 即清除分享赋值动作
let timeNum = 0;
let timer = setInterval(() => {
timeNum += 1000;
if (timeNum === 5000) {
clearInterval(timer);
}
if ($('#shareTitle').val() !== '' || $('#shareLink').val() !== '') {
clearInterval(timer);
const webShareData = {
title: $('#shareTitle').val(),
desc: $('#shareDesc').val(),
imgUrl: $('#shareImg').val(),
link: $('#shareLink').val().replace('https://', 'http://').replace('6808', '6810')
};
const parames = {
shareType: 'activity', // 类型,默认activity
image: webShareData.imgUrl,
url: webShareData.link, // 分享链接
link: webShareData.link, // 和url保持
title: `淘口令#${webShareData.title}`, // 分享标题
text: '' // 分享描述
};
XianyuJSBridge.setNavRightItem(parames);
}
}, 1000);
}
function xianyuAppHandleInit() {
if (/AliApp/i.test(navigator.userAgent)) {
require('./xianyu');
... ...
... ... @@ -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;
... ...
... ... @@ -108,6 +108,19 @@ if (qs && qs.share_id) {
shareData.desc = res.data.content || res.data.title;
shareData.imgUrl = res.data.pic;
shareData.title = res.data.title;
// 为input对象赋值,页面存储分享信息
if (/AliApp/i.test(navigator.userAgent)) {
shareData.link = res.data.url;
shareData.link += '&isNeedRefresh=false';
$('#shareLink').val(shareData.link);
}
$('#shareTitle').val(shareData.title);
$('#shareImg').val(shareData.imgUrl);
$('#shareDesc').val(shareData.desc);
}
}
});
... ...