|
|
1
|
+
|
1
|
import $ from 'yoho-jquery';
|
2
|
import $ from 'yoho-jquery';
|
2
|
|
3
|
|
3
|
function XianyuLinkHandle() {
|
4
|
function XianyuLinkHandle() {
|
|
@@ -38,3 +39,86 @@ function XianyuLinkHandle() { |
|
@@ -38,3 +39,86 @@ function XianyuLinkHandle() { |
38
|
}
|
39
|
}
|
39
|
|
40
|
|
40
|
export default new XianyuLinkHandle();
|
41
|
export default new XianyuLinkHandle();
|
|
|
42
|
+
|
|
|
43
|
+/* eslint-disable */
|
|
|
44
|
+/*
|
|
|
45
|
+ * @ description: js调用闲鱼相关API方法封装
|
|
|
46
|
+ * @ author: huzhiming
|
|
|
47
|
+ * @ date: 2019-12-03 09:45:05
|
|
|
48
|
+ * @ version: v1.0.0
|
|
|
49
|
+ *
|
|
|
50
|
+*/
|
|
|
51
|
+export const XianyuJSBridge = {
|
|
|
52
|
+ // 判断是否在闲鱼环境内
|
|
|
53
|
+ get isAliApp () {
|
|
|
54
|
+ return /AliApp/i.test(navigator.userAgent || '');
|
|
|
55
|
+ },
|
|
|
56
|
+ /*
|
|
|
57
|
+ * @ description: 导航栏右侧自定义按钮 设为关闭
|
|
|
58
|
+ * @ author: huzhiming
|
|
|
59
|
+ * @ date: 2019-11-14 16:15:07
|
|
|
60
|
+ * @ version: v1.0.0
|
|
|
61
|
+ */
|
|
|
62
|
+ closeNavRightItem () {
|
|
|
63
|
+ if (this.isAliApp && window.WindVane) {
|
|
|
64
|
+ window.WindVane.call('WVIdleFishApi', 'setHideNavigatorRightItem', {}, () => { }, () => { })
|
|
|
65
|
+ }
|
|
|
66
|
+ return this;
|
|
|
67
|
+ },
|
|
|
68
|
+
|
|
|
69
|
+ // 导航栏右侧自定义按钮 设为可见
|
|
|
70
|
+ setNavRightItem (shareParam = null) {
|
|
|
71
|
+ window._xianyuShare = () => {
|
|
|
72
|
+ this.setXianyuShare(shareParam);
|
|
|
73
|
+ }
|
|
|
74
|
+ if (this.isAliApp && window.WindVane) {
|
|
|
75
|
+ window.WindVane.call('WVIdleFishApi', 'setNavigatorRightItem', {
|
|
|
76
|
+ title: '∙∙∙', // 按钮名称
|
|
|
77
|
+ func: '_xianyuShare' // func: 'test' //点击调用函数 注意调用的函数必须挂载在window上
|
|
|
78
|
+ }, function(data) {
|
|
|
79
|
+ console.log('setNavigatorRightItem success:', data);
|
|
|
80
|
+ }, function(e) {
|
|
|
81
|
+ console.log('setNavigatorRightItem error:', e);
|
|
|
82
|
+ });
|
|
|
83
|
+ }
|
|
|
84
|
+ return this;
|
|
|
85
|
+ },
|
|
|
86
|
+
|
|
|
87
|
+ /*
|
|
|
88
|
+ * @ description: 配置分享参数进行分享操作
|
|
|
89
|
+ * @ author: huzhiming
|
|
|
90
|
+ * @ date: 2019-11-05 10:38:24
|
|
|
91
|
+ * @ version: v1.0.0
|
|
|
92
|
+ */
|
|
|
93
|
+ setXianyuShare (param = {
|
|
|
94
|
+ shareType: 'activity', // 类型,默认activity
|
|
|
95
|
+ image: '//img11.static.yhbimg.com/goodsimg/2018/12/24/17/01070adae9791c70ed02593550437cf30e.jpg?imageMogr2/thumbnail/600x600/background/d2hpdGU=/position/center/quality/80',
|
|
|
96
|
+ url: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 分享链接
|
|
|
97
|
+ link: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 和url保持
|
|
|
98
|
+ title: '闲鱼潮品首页', // 分享标题
|
|
|
99
|
+ text: '' // 分享描述
|
|
|
100
|
+ }) {
|
|
|
101
|
+ if (this.isAliApp && window.WindVane) {
|
|
|
102
|
+ window.WindVane.call('WVIdleFishApi', 'showShareMenu', param, (data) => {
|
|
|
103
|
+ console.log('success:', JSON.stringify(data), typeof data.isCancel);
|
|
|
104
|
+ // if (data.isCancel === 'false') {}
|
|
|
105
|
+ }, function(e) {
|
|
|
106
|
+ console.log('fail:', JSON.stringify(e));
|
|
|
107
|
+ });
|
|
|
108
|
+ }
|
|
|
109
|
+ return this;
|
|
|
110
|
+ },
|
|
|
111
|
+
|
|
|
112
|
+ // 隐藏 webview loadingBox
|
|
|
113
|
+ hideLoadingBox () {
|
|
|
114
|
+ if (this.isAliApp && window.WindVane) {
|
|
|
115
|
+ window.WindVane.call('WVUI', 'hideLoadingBox', {}, function(e) {
|
|
|
116
|
+ console.log('success: ' + JSON.stringify(e));
|
|
|
117
|
+ }, function(e) {
|
|
|
118
|
+ console.log('failure: ' + JSON.stringify(e));
|
|
|
119
|
+ });
|
|
|
120
|
+ }
|
|
|
121
|
+ return this;
|
|
|
122
|
+ }
|
|
|
123
|
+};
|
|
|
124
|
+ |