webAppComm.js
6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
// 2:跳转到WebViewFragment
// 3:分享
// 4:客服
// 5:跳轉到外部瀏覽器
// 6:打开兑换宝石页面
// 7:绑定手机
// 8:跳转微信绑定页面
// 9:是否分享或帮助
// 10:判断某个app是否存在
// 11:网页标题 (棄用)
// 13:半屏网页声音开启关闭:
// 12:跳转逻辑
// 14:关闭网页
// 15:通用viepager標題
// 16:成功转让黄金萤火虫
// 17:关闭半屏网页,打开自己的礼物面板
// 18: 打開購買VIP
// 19:打開購買守護彈窗
// 20:播放座驾预览
// 23:自動添加直播間聊天消息
// 24:获取网页图片下标
// 25:点击web
// 26:是否显示客服入口
// 27:直接唤起 苹果支付 和 google支付:(萤火虫6000版本新增)
// 28:判断是否在外部可以关闭webview
// 29:webview上面的图标 (旧)
// 30:注销账号后退出
// 31:弹出WEB弹窗
// 32:webview上面的图标 (新)
// 33:打开更多功能面板
function webAppComm() {
this.data = null;
}
//分享
webAppComm.prototype.goShare = function (picImg, shareCode) {
let obj = {
"cid": 3,
"reqCode": new Date().getTime(),
"data": {
"shareContent": {
"pic": cdn + picImg,
"title": langList[langType].share1,
"text": langList[langType].share2,
"webpage": "http://www.yabolive.tv/Nesting/invite/share.html?agentCode=" + sessionStorage.bbb + "&bindType=3",
"shareCode": shareCode
},
"shareType": {
"wechat": 1,
"wechat_moment": 1,
"facebook": 1,
"line": 3,
"link": 3,
"whatsApp": 3,
"twitter": 3
}
}
}
let obj2 = JSON.stringify(obj);
appCollaboration(obj2)
}
//客服
webAppComm.prototype.goCustomerService = function () {
let obj = {
"cid": 4,
"reqCode": new Date().getTime(),
"data": {
"msg": langList[langType].upright7,
"customerLayer": 1,
"uid": 1000,
"face": 'https://app.ixiulive.com/static/images/yhx.png',
"nickname": "客服",
"title": "客服",
}
}
let obj2 = JSON.stringify(obj);
appCollaboration(obj2)
}
//跳转外部浏览器
webAppComm.prototype.goExternalWeb = function (h5Url) {
let obj = {
"cid": 5,
"reqCode": new Date().getTime(),
"data": {
"url": h5Url,
}
}
let obj2 = JSON.stringify(obj);
window.yazhai.appCollaboration(obj2);
}
//打开兑换宝石页面
webAppComm.prototype.goExchangeGem = function () {
let obj = {
"cid": 6,
"reqCode": new Date().getTime(),
"data": {
"msg": '打开兑换寶石'
}
}
let obj2 = JSON.stringify(obj);
appCollaboration(obj2);
}
//绑定手机
webAppComm.prototype.goBindPhone = function () {
let obj2 = {
"cid": 7,
"reqCode": new Date().getTime(),
"data": {
msg: '点击跳转绑定手机页面',
}
}
let obj = JSON.stringify(obj2);
appCollaboration(obj);
}
//绑定微信
webAppComm.prototype.goBindWechat = function () {
let obj2 = {
"cid": 8,
"reqCode": new Date().getTime(),
"data": {
msg: '跳转微信绑定页面'
}
}
let obj = JSON.stringify(obj2);
appCollaboration(obj)
}
//弹出帮助
webAppComm.prototype.goBindWechat = function () {
let obj = {
"cid": 9,
"reqCode": new Date().getTime(),
"data": {
msg: '是否分享或帮助',
shareType: 1,
helpType: 0,
}
}
let obj2 = JSON.stringify(obj)
appCollaboration(obj2)
}
//确认是否有该APP
webAppComm.prototype.ifHasApp = function () {
let obj2 = {
"cid": 10,
"reqCode": new Date().getTime(),
"data": {
msg: '點擊確認有沒有這個APP',
type: 1
}
}
let obj = JSON.stringify(obj2);
appCollaboration(obj)
}
//跳转
webAppComm.prototype.goOthers = function (jumptype, url) {
let arr = { 16: '去儲值', 18: '跳轉到座駕', 3: '跳轉集合功能' };
let obj = {
"cid": 12,
"reqCode": new Date().getTime(),
"data": {
"msg": arr[jumptype],
"jumptype": jumptype, //16: 去储值 18: 跳转到座驾 3:跳转集合功能
"url": url
}
}
let obj2 = JSON.stringify(obj);
appCollaboration(obj2);
}
//关闭网页
webAppComm.prototype.closeWebView = function (callback) {
callback && callback();
let obj = {
"cid": 14,
"reqCode": new Date().getTime(),
}
let obj2 = JSON.stringify(obj);
appCollaboration(obj2);
}
//webview右上角的icon
webAppComm.prototype.showIcons = function (infos) {
let obj = {
"cid": 32, //新的右上角展示
"data": {
"msg": "h5网页右上角显示图标",
"info": infos,
}
}
let obj2 = JSON.stringify(obj);
appCollaboration(obj2);
}
//打开更多功能面板
webAppComm.prototype.openExtra = function (infos) {
var obj = {
"cid": 33, //打开额外功能面板
"data": {
"msg": '打开额外功能面板',
"info": infos
}
}
var obj2 = JSON.stringify(obj);
appCollaboration(obj2);
}
//刷新网页
webAppComm.prototype.refreshWeb = function (callback) {
callback && callback();
location.reload();
}
function appCollaboration(msg) {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {
}
else if (bIsAndroid) {
window.yazhai.appCollaboration(msg);
} else if (bIsIphoneOs || bIsIpad) {
window.webkit.messageHandlers.appCollaboration.postMessage(msg);
}
}
window.$firefly = new webAppComm();