@dcloudio/uni-app-plus 2.0.0 → 2.0.1-32920211122002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automator.view.js +1 -1
- package/dist/index.js +505 -138
- package/dist/index.v3.js +1262 -365
- package/dist/view.css +1 -1
- package/dist/view.umd.js +21028 -11114
- package/dist/view.umd.min.js +2 -2
- package/lib/uni.automator.js +1 -1
- package/package.json +2 -2
- package/template/common/__uniappchooselocation.js +1 -1
- package/template/common/__uniapperror.png +0 -0
- package/template/v3/__uniappquill.js +1 -1
- package/template/v3/__uniappquillimageresize.js +1 -1
package/dist/index.v3.js
CHANGED
|
@@ -13,7 +13,8 @@ var serviceContext = (function () {
|
|
|
13
13
|
'base64ToArrayBuffer',
|
|
14
14
|
'arrayBufferToBase64',
|
|
15
15
|
'addInterceptor',
|
|
16
|
-
'removeInterceptor'
|
|
16
|
+
'removeInterceptor',
|
|
17
|
+
'interceptors'
|
|
17
18
|
];
|
|
18
19
|
|
|
19
20
|
const network = [
|
|
@@ -27,7 +28,8 @@ var serviceContext = (function () {
|
|
|
27
28
|
'onSocketMessage',
|
|
28
29
|
'closeSocket',
|
|
29
30
|
'onSocketClose',
|
|
30
|
-
'getUpdateManager'
|
|
31
|
+
'getUpdateManager',
|
|
32
|
+
'configMTLS'
|
|
31
33
|
];
|
|
32
34
|
|
|
33
35
|
const route = [
|
|
@@ -192,7 +194,10 @@ var serviceContext = (function () {
|
|
|
192
194
|
'getRightWindowStyle',
|
|
193
195
|
'setTopWindowStyle',
|
|
194
196
|
'setLeftWindowStyle',
|
|
195
|
-
'setRightWindowStyle'
|
|
197
|
+
'setRightWindowStyle',
|
|
198
|
+
'getLocale',
|
|
199
|
+
'setLocale',
|
|
200
|
+
'onLocaleChange'
|
|
196
201
|
];
|
|
197
202
|
|
|
198
203
|
const event = [
|
|
@@ -225,8 +230,11 @@ var serviceContext = (function () {
|
|
|
225
230
|
'login',
|
|
226
231
|
'checkSession',
|
|
227
232
|
'getUserInfo',
|
|
233
|
+
'getUserProfile',
|
|
228
234
|
'preLogin',
|
|
229
235
|
'closeAuthView',
|
|
236
|
+
'getCheckBoxState',
|
|
237
|
+
'getUniverifyManager',
|
|
230
238
|
'share',
|
|
231
239
|
'shareWithSystem',
|
|
232
240
|
'showShareMenu',
|
|
@@ -251,7 +259,9 @@ var serviceContext = (function () {
|
|
|
251
259
|
|
|
252
260
|
const ad = [
|
|
253
261
|
'createRewardedVideoAd',
|
|
254
|
-
'createFullScreenVideoAd'
|
|
262
|
+
'createFullScreenVideoAd',
|
|
263
|
+
'createInterstitialAd',
|
|
264
|
+
'createInteractiveAd'
|
|
255
265
|
];
|
|
256
266
|
|
|
257
267
|
const apis = [
|
|
@@ -285,6 +295,84 @@ var serviceContext = (function () {
|
|
|
285
295
|
window.addEventListener('test-passive', null, opts);
|
|
286
296
|
} catch (e) {}
|
|
287
297
|
|
|
298
|
+
let realAtob;
|
|
299
|
+
|
|
300
|
+
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
301
|
+
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
|
302
|
+
|
|
303
|
+
if (typeof atob !== 'function') {
|
|
304
|
+
realAtob = function (str) {
|
|
305
|
+
str = String(str).replace(/[\t\n\f\r ]+/g, '');
|
|
306
|
+
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
|
|
307
|
+
|
|
308
|
+
// Adding the padding if missing, for semplicity
|
|
309
|
+
str += '=='.slice(2 - (str.length & 3));
|
|
310
|
+
var bitmap; var result = ''; var r1; var r2; var i = 0;
|
|
311
|
+
for (; i < str.length;) {
|
|
312
|
+
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
|
|
313
|
+
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
|
|
314
|
+
|
|
315
|
+
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
|
|
316
|
+
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
|
|
317
|
+
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
|
|
318
|
+
}
|
|
319
|
+
return result
|
|
320
|
+
};
|
|
321
|
+
} else {
|
|
322
|
+
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
|
|
323
|
+
realAtob = atob;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function b64DecodeUnicode (str) {
|
|
327
|
+
return decodeURIComponent(realAtob(str).split('').map(function (c) {
|
|
328
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
329
|
+
}).join(''))
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function getCurrentUserInfo () {
|
|
333
|
+
const token = ( uni ).getStorageSync('uni_id_token') || '';
|
|
334
|
+
const tokenArr = token.split('.');
|
|
335
|
+
if (!token || tokenArr.length !== 3) {
|
|
336
|
+
return {
|
|
337
|
+
uid: null,
|
|
338
|
+
role: [],
|
|
339
|
+
permission: [],
|
|
340
|
+
tokenExpired: 0
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
let userInfo;
|
|
344
|
+
try {
|
|
345
|
+
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
|
|
346
|
+
} catch (error) {
|
|
347
|
+
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
|
|
348
|
+
}
|
|
349
|
+
userInfo.tokenExpired = userInfo.exp * 1000;
|
|
350
|
+
delete userInfo.exp;
|
|
351
|
+
delete userInfo.iat;
|
|
352
|
+
return userInfo
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function uniIdMixin (Vue) {
|
|
356
|
+
Vue.prototype.uniIDHasRole = function (roleId) {
|
|
357
|
+
const {
|
|
358
|
+
role
|
|
359
|
+
} = getCurrentUserInfo();
|
|
360
|
+
return role.indexOf(roleId) > -1
|
|
361
|
+
};
|
|
362
|
+
Vue.prototype.uniIDHasPermission = function (permissionId) {
|
|
363
|
+
const {
|
|
364
|
+
permission
|
|
365
|
+
} = getCurrentUserInfo();
|
|
366
|
+
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
|
|
367
|
+
};
|
|
368
|
+
Vue.prototype.uniIDTokenValid = function () {
|
|
369
|
+
const {
|
|
370
|
+
tokenExpired
|
|
371
|
+
} = getCurrentUserInfo();
|
|
372
|
+
return tokenExpired > Date.now()
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
288
376
|
const _toString = Object.prototype.toString;
|
|
289
377
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
290
378
|
|
|
@@ -292,6 +380,10 @@ var serviceContext = (function () {
|
|
|
292
380
|
return typeof fn === 'function'
|
|
293
381
|
}
|
|
294
382
|
|
|
383
|
+
function isStr (str) {
|
|
384
|
+
return typeof str === 'string'
|
|
385
|
+
}
|
|
386
|
+
|
|
295
387
|
function isObject (obj) {
|
|
296
388
|
return obj !== null && typeof obj === 'object'
|
|
297
389
|
}
|
|
@@ -640,7 +732,7 @@ var serviceContext = (function () {
|
|
|
640
732
|
}
|
|
641
733
|
if (res === false) {
|
|
642
734
|
return {
|
|
643
|
-
then () {}
|
|
735
|
+
then () { }
|
|
644
736
|
}
|
|
645
737
|
}
|
|
646
738
|
}
|
|
@@ -688,15 +780,15 @@ var serviceContext = (function () {
|
|
|
688
780
|
if (hook !== 'returnValue') {
|
|
689
781
|
interceptor[hook] = globalInterceptors[hook].slice();
|
|
690
782
|
}
|
|
691
|
-
});
|
|
692
|
-
const scopedInterceptor = scopedInterceptors[method];
|
|
693
|
-
if (scopedInterceptor) {
|
|
694
|
-
Object.keys(scopedInterceptor).forEach(hook => {
|
|
695
|
-
if (hook !== 'returnValue') {
|
|
696
|
-
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
|
|
697
|
-
}
|
|
698
|
-
});
|
|
699
|
-
}
|
|
783
|
+
});
|
|
784
|
+
const scopedInterceptor = scopedInterceptors[method];
|
|
785
|
+
if (scopedInterceptor) {
|
|
786
|
+
Object.keys(scopedInterceptor).forEach(hook => {
|
|
787
|
+
if (hook !== 'returnValue') {
|
|
788
|
+
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
}
|
|
700
792
|
return interceptor
|
|
701
793
|
}
|
|
702
794
|
|
|
@@ -720,16 +812,20 @@ var serviceContext = (function () {
|
|
|
720
812
|
if (!isPromise(res)) {
|
|
721
813
|
return res
|
|
722
814
|
}
|
|
723
|
-
return
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
815
|
+
return new Promise((resolve, reject) => {
|
|
816
|
+
res.then(res => {
|
|
817
|
+
if (res[0]) {
|
|
818
|
+
reject(res[0]);
|
|
819
|
+
} else {
|
|
820
|
+
resolve(res[1]);
|
|
821
|
+
}
|
|
822
|
+
});
|
|
727
823
|
})
|
|
728
824
|
}
|
|
729
825
|
};
|
|
730
826
|
|
|
731
827
|
const SYNC_API_RE =
|
|
732
|
-
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
|
|
828
|
+
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/;
|
|
733
829
|
|
|
734
830
|
const CONTEXT_API_RE = /^create|Manager$/;
|
|
735
831
|
|
|
@@ -1093,18 +1189,20 @@ var serviceContext = (function () {
|
|
|
1093
1189
|
scanCode: scanCode
|
|
1094
1190
|
});
|
|
1095
1191
|
|
|
1192
|
+
const isArray = Array.isArray;
|
|
1096
1193
|
const isObject$1 = (val) => val !== null && typeof val === 'object';
|
|
1194
|
+
const defaultDelimiters = ['{', '}'];
|
|
1097
1195
|
class BaseFormatter {
|
|
1098
1196
|
constructor() {
|
|
1099
1197
|
this._caches = Object.create(null);
|
|
1100
1198
|
}
|
|
1101
|
-
interpolate(message, values) {
|
|
1199
|
+
interpolate(message, values, delimiters = defaultDelimiters) {
|
|
1102
1200
|
if (!values) {
|
|
1103
1201
|
return [message];
|
|
1104
1202
|
}
|
|
1105
1203
|
let tokens = this._caches[message];
|
|
1106
1204
|
if (!tokens) {
|
|
1107
|
-
tokens = parse(message);
|
|
1205
|
+
tokens = parse(message, delimiters);
|
|
1108
1206
|
this._caches[message] = tokens;
|
|
1109
1207
|
}
|
|
1110
1208
|
return compile(tokens, values);
|
|
@@ -1112,24 +1210,24 @@ var serviceContext = (function () {
|
|
|
1112
1210
|
}
|
|
1113
1211
|
const RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
|
|
1114
1212
|
const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
|
|
1115
|
-
function parse(format) {
|
|
1213
|
+
function parse(format, [startDelimiter, endDelimiter]) {
|
|
1116
1214
|
const tokens = [];
|
|
1117
1215
|
let position = 0;
|
|
1118
1216
|
let text = '';
|
|
1119
1217
|
while (position < format.length) {
|
|
1120
1218
|
let char = format[position++];
|
|
1121
|
-
if (char ===
|
|
1219
|
+
if (char === startDelimiter) {
|
|
1122
1220
|
if (text) {
|
|
1123
1221
|
tokens.push({ type: 'text', value: text });
|
|
1124
1222
|
}
|
|
1125
1223
|
text = '';
|
|
1126
1224
|
let sub = '';
|
|
1127
1225
|
char = format[position++];
|
|
1128
|
-
while (char !== undefined && char !==
|
|
1226
|
+
while (char !== undefined && char !== endDelimiter) {
|
|
1129
1227
|
sub += char;
|
|
1130
1228
|
char = format[position++];
|
|
1131
1229
|
}
|
|
1132
|
-
const isClosed = char ===
|
|
1230
|
+
const isClosed = char === endDelimiter;
|
|
1133
1231
|
const type = RE_TOKEN_LIST_VALUE.test(sub)
|
|
1134
1232
|
? 'list'
|
|
1135
1233
|
: isClosed && RE_TOKEN_NAMED_VALUE.test(sub)
|
|
@@ -1137,12 +1235,12 @@ var serviceContext = (function () {
|
|
|
1137
1235
|
: 'unknown';
|
|
1138
1236
|
tokens.push({ value: sub, type });
|
|
1139
1237
|
}
|
|
1140
|
-
else if (char === '%') {
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
}
|
|
1238
|
+
// else if (char === '%') {
|
|
1239
|
+
// // when found rails i18n syntax, skip text capture
|
|
1240
|
+
// if (format[position] !== '{') {
|
|
1241
|
+
// text += char
|
|
1242
|
+
// }
|
|
1243
|
+
// }
|
|
1146
1244
|
else {
|
|
1147
1245
|
text += char;
|
|
1148
1246
|
}
|
|
@@ -1153,7 +1251,7 @@ var serviceContext = (function () {
|
|
|
1153
1251
|
function compile(tokens, values) {
|
|
1154
1252
|
const compiled = [];
|
|
1155
1253
|
let index = 0;
|
|
1156
|
-
const mode =
|
|
1254
|
+
const mode = isArray(values)
|
|
1157
1255
|
? 'list'
|
|
1158
1256
|
: isObject$1(values)
|
|
1159
1257
|
? 'named'
|
|
@@ -1191,6 +1289,11 @@ var serviceContext = (function () {
|
|
|
1191
1289
|
return compiled;
|
|
1192
1290
|
}
|
|
1193
1291
|
|
|
1292
|
+
const LOCALE_ZH_HANS = 'zh-Hans';
|
|
1293
|
+
const LOCALE_ZH_HANT = 'zh-Hant';
|
|
1294
|
+
const LOCALE_EN = 'en';
|
|
1295
|
+
const LOCALE_FR = 'fr';
|
|
1296
|
+
const LOCALE_ES = 'es';
|
|
1194
1297
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1195
1298
|
const hasOwn$1 = (val, key) => hasOwnProperty$1.call(val, key);
|
|
1196
1299
|
const defaultFormatter = new BaseFormatter();
|
|
@@ -1205,31 +1308,31 @@ var serviceContext = (function () {
|
|
|
1205
1308
|
return;
|
|
1206
1309
|
}
|
|
1207
1310
|
locale = locale.trim().replace(/_/g, '-');
|
|
1208
|
-
if (messages[locale]) {
|
|
1311
|
+
if (messages && messages[locale]) {
|
|
1209
1312
|
return locale;
|
|
1210
1313
|
}
|
|
1211
1314
|
locale = locale.toLowerCase();
|
|
1212
1315
|
if (locale.indexOf('zh') === 0) {
|
|
1213
|
-
if (locale.indexOf('-hans')
|
|
1214
|
-
return
|
|
1316
|
+
if (locale.indexOf('-hans') > -1) {
|
|
1317
|
+
return LOCALE_ZH_HANS;
|
|
1215
1318
|
}
|
|
1216
|
-
if (locale.indexOf('-hant')
|
|
1217
|
-
return
|
|
1319
|
+
if (locale.indexOf('-hant') > -1) {
|
|
1320
|
+
return LOCALE_ZH_HANT;
|
|
1218
1321
|
}
|
|
1219
1322
|
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
|
|
1220
|
-
return
|
|
1323
|
+
return LOCALE_ZH_HANT;
|
|
1221
1324
|
}
|
|
1222
|
-
return
|
|
1325
|
+
return LOCALE_ZH_HANS;
|
|
1223
1326
|
}
|
|
1224
|
-
const lang = startsWith(locale, [
|
|
1327
|
+
const lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]);
|
|
1225
1328
|
if (lang) {
|
|
1226
1329
|
return lang;
|
|
1227
1330
|
}
|
|
1228
1331
|
}
|
|
1229
1332
|
class I18n {
|
|
1230
1333
|
constructor({ locale, fallbackLocale, messages, watcher, formater, }) {
|
|
1231
|
-
this.locale =
|
|
1232
|
-
this.fallbackLocale =
|
|
1334
|
+
this.locale = LOCALE_EN;
|
|
1335
|
+
this.fallbackLocale = LOCALE_EN;
|
|
1233
1336
|
this.message = {};
|
|
1234
1337
|
this.messages = {};
|
|
1235
1338
|
this.watchers = [];
|
|
@@ -1237,8 +1340,8 @@ var serviceContext = (function () {
|
|
|
1237
1340
|
this.fallbackLocale = fallbackLocale;
|
|
1238
1341
|
}
|
|
1239
1342
|
this.formater = formater || defaultFormatter;
|
|
1240
|
-
this.messages = messages;
|
|
1241
|
-
this.setLocale(locale);
|
|
1343
|
+
this.messages = messages || {};
|
|
1344
|
+
this.setLocale(locale || LOCALE_EN);
|
|
1242
1345
|
if (watcher) {
|
|
1243
1346
|
this.watchLocale(watcher);
|
|
1244
1347
|
}
|
|
@@ -1246,10 +1349,17 @@ var serviceContext = (function () {
|
|
|
1246
1349
|
setLocale(locale) {
|
|
1247
1350
|
const oldLocale = this.locale;
|
|
1248
1351
|
this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale;
|
|
1352
|
+
if (!this.messages[this.locale]) {
|
|
1353
|
+
// 可能初始化时不存在
|
|
1354
|
+
this.messages[this.locale] = {};
|
|
1355
|
+
}
|
|
1249
1356
|
this.message = this.messages[this.locale];
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1357
|
+
// 仅发生变化时,通知
|
|
1358
|
+
if (oldLocale !== this.locale) {
|
|
1359
|
+
this.watchers.forEach((watcher) => {
|
|
1360
|
+
watcher(this.locale, oldLocale);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1253
1363
|
}
|
|
1254
1364
|
getLocale() {
|
|
1255
1365
|
return this.locale;
|
|
@@ -1260,14 +1370,27 @@ var serviceContext = (function () {
|
|
|
1260
1370
|
this.watchers.splice(index, 1);
|
|
1261
1371
|
};
|
|
1262
1372
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1373
|
+
add(locale, message, override = true) {
|
|
1374
|
+
const curMessages = this.messages[locale];
|
|
1375
|
+
if (curMessages) {
|
|
1376
|
+
if (override) {
|
|
1377
|
+
Object.assign(curMessages, message);
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
Object.keys(message).forEach((key) => {
|
|
1381
|
+
if (!hasOwn$1(curMessages, key)) {
|
|
1382
|
+
curMessages[key] = message[key];
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1266
1386
|
}
|
|
1267
1387
|
else {
|
|
1268
1388
|
this.messages[locale] = message;
|
|
1269
1389
|
}
|
|
1270
1390
|
}
|
|
1391
|
+
f(message, values, delimiters) {
|
|
1392
|
+
return this.formater.interpolate(message, values, delimiters).join('');
|
|
1393
|
+
}
|
|
1271
1394
|
t(key, locale, values) {
|
|
1272
1395
|
let message = this.message;
|
|
1273
1396
|
if (typeof locale === 'string') {
|
|
@@ -1285,94 +1408,118 @@ var serviceContext = (function () {
|
|
|
1285
1408
|
}
|
|
1286
1409
|
}
|
|
1287
1410
|
|
|
1288
|
-
function
|
|
1289
|
-
|
|
1290
|
-
|
|
1411
|
+
function watchAppLocale(appVm, i18n) {
|
|
1412
|
+
// 需要保证 watch 的触发在组件渲染之前
|
|
1413
|
+
if (appVm.$watchLocale) {
|
|
1414
|
+
// vue2
|
|
1415
|
+
appVm.$watchLocale((newLocale) => {
|
|
1291
1416
|
i18n.setLocale(newLocale);
|
|
1292
|
-
}, {
|
|
1293
|
-
immediate: true,
|
|
1294
1417
|
});
|
|
1418
|
+
}
|
|
1419
|
+
else {
|
|
1420
|
+
appVm.$watch(() => appVm.$locale, (newLocale) => {
|
|
1421
|
+
i18n.setLocale(newLocale);
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1295
1424
|
}
|
|
1296
1425
|
function getDefaultLocale() {
|
|
1297
|
-
if (typeof
|
|
1298
|
-
return
|
|
1426
|
+
if (typeof uni !== 'undefined' && uni.getLocale) {
|
|
1427
|
+
return uni.getLocale();
|
|
1299
1428
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
return
|
|
1429
|
+
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
|
|
1430
|
+
if (typeof global !== 'undefined' && global.getLocale) {
|
|
1431
|
+
return global.getLocale();
|
|
1303
1432
|
}
|
|
1304
|
-
return
|
|
1433
|
+
return LOCALE_EN;
|
|
1305
1434
|
}
|
|
1306
|
-
function initVueI18n(
|
|
1435
|
+
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
|
|
1436
|
+
// 兼容旧版本入参
|
|
1437
|
+
if (typeof locale !== 'string') {
|
|
1438
|
+
[locale, messages] = [
|
|
1439
|
+
messages,
|
|
1440
|
+
locale,
|
|
1441
|
+
];
|
|
1442
|
+
}
|
|
1443
|
+
if (typeof locale !== 'string') {
|
|
1444
|
+
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
|
|
1445
|
+
locale = getDefaultLocale();
|
|
1446
|
+
}
|
|
1447
|
+
if (typeof fallbackLocale !== 'string') {
|
|
1448
|
+
fallbackLocale =
|
|
1449
|
+
(typeof __uniConfig !== 'undefined' && __uniConfig.fallbackLocale) ||
|
|
1450
|
+
LOCALE_EN;
|
|
1451
|
+
}
|
|
1307
1452
|
const i18n = new I18n({
|
|
1308
|
-
locale
|
|
1453
|
+
locale,
|
|
1309
1454
|
fallbackLocale,
|
|
1310
1455
|
messages,
|
|
1456
|
+
watcher,
|
|
1311
1457
|
});
|
|
1312
1458
|
let t = (key, values) => {
|
|
1313
1459
|
if (typeof getApp !== 'function') {
|
|
1314
|
-
// app
|
|
1460
|
+
// app view
|
|
1315
1461
|
/* eslint-disable no-func-assign */
|
|
1316
1462
|
t = function (key, values) {
|
|
1317
1463
|
return i18n.t(key, values);
|
|
1318
1464
|
};
|
|
1319
1465
|
}
|
|
1320
1466
|
else {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
if (
|
|
1341
|
-
|
|
1467
|
+
let isWatchedAppLocale = false;
|
|
1468
|
+
t = function (key, values) {
|
|
1469
|
+
const appVm = getApp().$vm;
|
|
1470
|
+
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
|
|
1471
|
+
// options: {
|
|
1472
|
+
// type: Array,
|
|
1473
|
+
// default () {
|
|
1474
|
+
// return [{
|
|
1475
|
+
// icon: 'shop',
|
|
1476
|
+
// text: t("uni-goods-nav.options.shop"),
|
|
1477
|
+
// }, {
|
|
1478
|
+
// icon: 'cart',
|
|
1479
|
+
// text: t("uni-goods-nav.options.cart")
|
|
1480
|
+
// }]
|
|
1481
|
+
// }
|
|
1482
|
+
// },
|
|
1483
|
+
if (appVm) {
|
|
1484
|
+
// 触发响应式
|
|
1485
|
+
appVm.$locale;
|
|
1486
|
+
if (!isWatchedAppLocale) {
|
|
1487
|
+
isWatchedAppLocale = true;
|
|
1488
|
+
watchAppLocale(appVm, i18n);
|
|
1342
1489
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
}
|
|
1490
|
+
}
|
|
1491
|
+
return i18n.t(key, values);
|
|
1492
|
+
};
|
|
1346
1493
|
}
|
|
1347
1494
|
return t(key, values);
|
|
1348
1495
|
};
|
|
1349
1496
|
return {
|
|
1497
|
+
i18n,
|
|
1498
|
+
f(message, values, delimiters) {
|
|
1499
|
+
return i18n.f(message, values, delimiters);
|
|
1500
|
+
},
|
|
1350
1501
|
t(key, values) {
|
|
1351
1502
|
return t(key, values);
|
|
1352
1503
|
},
|
|
1504
|
+
add(locale, message, override = true) {
|
|
1505
|
+
return i18n.add(locale, message, override);
|
|
1506
|
+
},
|
|
1507
|
+
watch(fn) {
|
|
1508
|
+
return i18n.watchLocale(fn);
|
|
1509
|
+
},
|
|
1353
1510
|
getLocale() {
|
|
1354
1511
|
return i18n.getLocale();
|
|
1355
1512
|
},
|
|
1356
1513
|
setLocale(newLocale) {
|
|
1357
1514
|
return i18n.setLocale(newLocale);
|
|
1358
1515
|
},
|
|
1359
|
-
mixin: {
|
|
1360
|
-
beforeCreate() {
|
|
1361
|
-
const unwatch = i18n.watchLocale(() => {
|
|
1362
|
-
this.$forceUpdate();
|
|
1363
|
-
});
|
|
1364
|
-
this.$once('hook:beforeDestroy', function () {
|
|
1365
|
-
unwatch();
|
|
1366
|
-
});
|
|
1367
|
-
},
|
|
1368
|
-
methods: {
|
|
1369
|
-
$$t(key, values) {
|
|
1370
|
-
return t(key, values);
|
|
1371
|
-
},
|
|
1372
|
-
},
|
|
1373
|
-
},
|
|
1374
1516
|
};
|
|
1375
1517
|
}
|
|
1518
|
+
function isI18nStr(value, delimiters) {
|
|
1519
|
+
return value.indexOf(delimiters[0]) > -1;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
const NAVBAR_HEIGHT = 44;
|
|
1376
1523
|
|
|
1377
1524
|
var en = {
|
|
1378
1525
|
"uni.app.quit": "Press back button again to exit",
|
|
@@ -1388,7 +1535,7 @@ var serviceContext = (function () {
|
|
|
1388
1535
|
"uni.chooseVideo.cancel": "Cancel",
|
|
1389
1536
|
"uni.chooseVideo.sourceType.album": "Album",
|
|
1390
1537
|
"uni.chooseVideo.sourceType.camera": "Camera",
|
|
1391
|
-
"uni.
|
|
1538
|
+
"uni.chooseFile.notUserActivation": "File chooser dialog can only be shown with a user activation",
|
|
1392
1539
|
"uni.previewImage.button.save": "Save Image",
|
|
1393
1540
|
"uni.previewImage.save.success": "Saved successfully",
|
|
1394
1541
|
"uni.previewImage.save.fail": "Save failed",
|
|
@@ -1404,7 +1551,9 @@ var serviceContext = (function () {
|
|
|
1404
1551
|
"uni.video.danmu": "Danmu",
|
|
1405
1552
|
"uni.video.volume": "Volume",
|
|
1406
1553
|
"uni.button.feedback.title": "feedback",
|
|
1407
|
-
"uni.button.feedback.send": "send"
|
|
1554
|
+
"uni.button.feedback.send": "send",
|
|
1555
|
+
"uni.chooseLocation.search": "Find Place",
|
|
1556
|
+
"uni.chooseLocation.cancel": "Cancel"
|
|
1408
1557
|
};
|
|
1409
1558
|
|
|
1410
1559
|
var es = {
|
|
@@ -1421,6 +1570,7 @@ var serviceContext = (function () {
|
|
|
1421
1570
|
"uni.chooseVideo.cancel": "Cancelar",
|
|
1422
1571
|
"uni.chooseVideo.sourceType.album": "Álbum",
|
|
1423
1572
|
"uni.chooseVideo.sourceType.camera": "Cámara",
|
|
1573
|
+
"uni.chooseFile.notUserActivation": "El cuadro de diálogo del selector de archivos solo se puede mostrar con la activación del usuario",
|
|
1424
1574
|
"uni.previewImage.cancel": "Cancelar",
|
|
1425
1575
|
"uni.previewImage.button.save": "Guardar imagen",
|
|
1426
1576
|
"uni.previewImage.save.success": "Guardado exitosamente",
|
|
@@ -1437,7 +1587,9 @@ var serviceContext = (function () {
|
|
|
1437
1587
|
"uni.video.danmu": "Danmu",
|
|
1438
1588
|
"uni.video.volume": "Volumen",
|
|
1439
1589
|
"uni.button.feedback.title": "realimentación",
|
|
1440
|
-
"uni.button.feedback.send": "enviar"
|
|
1590
|
+
"uni.button.feedback.send": "enviar",
|
|
1591
|
+
"uni.chooseLocation.search": "Encontrar",
|
|
1592
|
+
"uni.chooseLocation.cancel": "Cancelar"
|
|
1441
1593
|
};
|
|
1442
1594
|
|
|
1443
1595
|
var fr = {
|
|
@@ -1454,6 +1606,7 @@ var serviceContext = (function () {
|
|
|
1454
1606
|
"uni.chooseVideo.cancel": "Annuler",
|
|
1455
1607
|
"uni.chooseVideo.sourceType.album": "Album",
|
|
1456
1608
|
"uni.chooseVideo.sourceType.camera": "Caméra",
|
|
1609
|
+
"uni.chooseFile.notUserActivation": "La boîte de dialogue du sélecteur de fichier ne peut être affichée qu'avec une activation par l'utilisateur",
|
|
1457
1610
|
"uni.previewImage.cancel": "Annuler",
|
|
1458
1611
|
"uni.previewImage.button.save": "Guardar imagen",
|
|
1459
1612
|
"uni.previewImage.save.success": "Enregistré avec succès",
|
|
@@ -1470,7 +1623,9 @@ var serviceContext = (function () {
|
|
|
1470
1623
|
"uni.video.danmu": "Danmu",
|
|
1471
1624
|
"uni.video.volume": "Le Volume",
|
|
1472
1625
|
"uni.button.feedback.title": "retour d'information",
|
|
1473
|
-
"uni.button.feedback.send": "envoyer"
|
|
1626
|
+
"uni.button.feedback.send": "envoyer",
|
|
1627
|
+
"uni.chooseLocation.search": "Trouve",
|
|
1628
|
+
"uni.chooseLocation.cancel": "Annuler"
|
|
1474
1629
|
};
|
|
1475
1630
|
|
|
1476
1631
|
var zhHans = {
|
|
@@ -1487,6 +1642,7 @@ var serviceContext = (function () {
|
|
|
1487
1642
|
"uni.chooseVideo.cancel": "取消",
|
|
1488
1643
|
"uni.chooseVideo.sourceType.album": "从相册选择",
|
|
1489
1644
|
"uni.chooseVideo.sourceType.camera": "拍摄",
|
|
1645
|
+
"uni.chooseFile.notUserActivation": "文件选择器对话框只能在用户激活时显示",
|
|
1490
1646
|
"uni.previewImage.cancel": "取消",
|
|
1491
1647
|
"uni.previewImage.button.save": "保存图像",
|
|
1492
1648
|
"uni.previewImage.save.success": "保存图像到相册成功",
|
|
@@ -1503,7 +1659,9 @@ var serviceContext = (function () {
|
|
|
1503
1659
|
"uni.video.danmu": "弹幕",
|
|
1504
1660
|
"uni.video.volume": "音量",
|
|
1505
1661
|
"uni.button.feedback.title": "问题反馈",
|
|
1506
|
-
"uni.button.feedback.send": "发送"
|
|
1662
|
+
"uni.button.feedback.send": "发送",
|
|
1663
|
+
"uni.chooseLocation.search": "搜索地点",
|
|
1664
|
+
"uni.chooseLocation.cancel": "取消"
|
|
1507
1665
|
};
|
|
1508
1666
|
|
|
1509
1667
|
var zhHant = {
|
|
@@ -1520,6 +1678,7 @@ var serviceContext = (function () {
|
|
|
1520
1678
|
"uni.chooseVideo.cancel": "取消",
|
|
1521
1679
|
"uni.chooseVideo.sourceType.album": "從相冊選擇",
|
|
1522
1680
|
"uni.chooseVideo.sourceType.camera": "拍攝",
|
|
1681
|
+
"uni.chooseFile.notUserActivation": "文件選擇器對話框只能在用戶激活時顯示",
|
|
1523
1682
|
"uni.previewImage.cancel": "取消",
|
|
1524
1683
|
"uni.previewImage.button.save": "保存圖像",
|
|
1525
1684
|
"uni.previewImage.save.success": "保存圖像到相冊成功",
|
|
@@ -1536,7 +1695,9 @@ var serviceContext = (function () {
|
|
|
1536
1695
|
"uni.video.danmu": "彈幕",
|
|
1537
1696
|
"uni.video.volume": "音量",
|
|
1538
1697
|
"uni.button.feedback.title": "問題反饋",
|
|
1539
|
-
"uni.button.feedback.send": "發送"
|
|
1698
|
+
"uni.button.feedback.send": "發送",
|
|
1699
|
+
"uni.chooseLocation.search": "搜索地點",
|
|
1700
|
+
"uni.chooseLocation.cancel": "取消"
|
|
1540
1701
|
};
|
|
1541
1702
|
|
|
1542
1703
|
const messages = {
|
|
@@ -1547,18 +1708,147 @@ var serviceContext = (function () {
|
|
|
1547
1708
|
'zh-Hant': zhHant
|
|
1548
1709
|
};
|
|
1549
1710
|
|
|
1550
|
-
|
|
1711
|
+
let locale;
|
|
1551
1712
|
|
|
1552
|
-
|
|
1713
|
+
{
|
|
1714
|
+
if (typeof weex === 'object') {
|
|
1715
|
+
locale = weex.requireModule('plus').getLanguage();
|
|
1716
|
+
} else {
|
|
1717
|
+
locale = '';
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
const i18n = initVueI18n(
|
|
1722
|
+
locale,
|
|
1723
|
+
messages
|
|
1724
|
+
);
|
|
1553
1725
|
const t = i18n.t;
|
|
1554
|
-
const
|
|
1726
|
+
const i18nMixin = (i18n.mixin = {
|
|
1727
|
+
beforeCreate () {
|
|
1728
|
+
const unwatch = i18n.i18n.watchLocale(() => {
|
|
1729
|
+
this.$forceUpdate();
|
|
1730
|
+
});
|
|
1731
|
+
this.$once('hook:beforeDestroy', function () {
|
|
1732
|
+
unwatch();
|
|
1733
|
+
});
|
|
1734
|
+
},
|
|
1735
|
+
methods: {
|
|
1736
|
+
$$t (key, values) {
|
|
1737
|
+
return t(key, values)
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
const getLocale = i18n.getLocale;
|
|
1742
|
+
|
|
1743
|
+
function initAppLocale (Vue, appVm, locale) {
|
|
1744
|
+
const state = Vue.observable({
|
|
1745
|
+
locale: locale || i18n.getLocale()
|
|
1746
|
+
});
|
|
1747
|
+
const localeWatchers = [];
|
|
1748
|
+
appVm.$watchLocale = fn => {
|
|
1749
|
+
localeWatchers.push(fn);
|
|
1750
|
+
};
|
|
1751
|
+
Object.defineProperty(appVm, '$locale', {
|
|
1752
|
+
get () {
|
|
1753
|
+
return state.locale
|
|
1754
|
+
},
|
|
1755
|
+
set (v) {
|
|
1756
|
+
state.locale = v;
|
|
1757
|
+
localeWatchers.forEach(watch => watch(v));
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
const I18N_JSON_DELIMITERS = ['%', '%'];
|
|
1763
|
+
|
|
1764
|
+
function getLocaleMessage () {
|
|
1765
|
+
const locale = uni.getLocale();
|
|
1766
|
+
const locales = __uniConfig.locales;
|
|
1767
|
+
return (
|
|
1768
|
+
locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {}
|
|
1769
|
+
)
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
function formatI18n (message) {
|
|
1773
|
+
if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
|
|
1774
|
+
return i18n.f(message, getLocaleMessage(), I18N_JSON_DELIMITERS)
|
|
1775
|
+
}
|
|
1776
|
+
return message
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
function resolveJsonObj (jsonObj, names) {
|
|
1780
|
+
if (names.length === 1) {
|
|
1781
|
+
if (jsonObj) {
|
|
1782
|
+
const value = jsonObj[names[0]];
|
|
1783
|
+
if (isStr(value) && isI18nStr(value, I18N_JSON_DELIMITERS)) {
|
|
1784
|
+
return jsonObj
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return
|
|
1788
|
+
}
|
|
1789
|
+
const name = names.shift();
|
|
1790
|
+
return resolveJsonObj(jsonObj && jsonObj[name], names)
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
function defineI18nProperties (obj, names) {
|
|
1794
|
+
return names.map(name => defineI18nProperty(obj, name))
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
function defineI18nProperty (obj, names) {
|
|
1798
|
+
const jsonObj = resolveJsonObj(obj, names);
|
|
1799
|
+
if (!jsonObj) {
|
|
1800
|
+
return false
|
|
1801
|
+
}
|
|
1802
|
+
const prop = names[names.length - 1];
|
|
1803
|
+
let value = jsonObj[prop];
|
|
1804
|
+
Object.defineProperty(jsonObj, prop, {
|
|
1805
|
+
get () {
|
|
1806
|
+
return formatI18n(value)
|
|
1807
|
+
},
|
|
1808
|
+
set (v) {
|
|
1809
|
+
value = v;
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1812
|
+
return true
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
function isEnableLocale () {
|
|
1816
|
+
return __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
function initNavigationBarI18n (navigationBar) {
|
|
1820
|
+
if (isEnableLocale()) {
|
|
1821
|
+
return defineI18nProperties(navigationBar, [
|
|
1822
|
+
['titleText'],
|
|
1823
|
+
['searchInput', 'placeholder']
|
|
1824
|
+
])
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
function initI18n () {
|
|
1829
|
+
const localeKeys = Object.keys(__uniConfig.locales || {});
|
|
1830
|
+
if (localeKeys.length) {
|
|
1831
|
+
localeKeys.forEach((locale) =>
|
|
1832
|
+
i18n.add(locale, __uniConfig.locales[locale])
|
|
1833
|
+
);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1555
1836
|
|
|
1556
1837
|
const setClipboardData = {
|
|
1557
|
-
|
|
1838
|
+
data: {
|
|
1839
|
+
type: String,
|
|
1840
|
+
required: true
|
|
1841
|
+
},
|
|
1842
|
+
showToast: {
|
|
1843
|
+
type: Boolean,
|
|
1844
|
+
default: true
|
|
1845
|
+
},
|
|
1846
|
+
beforeSuccess (res, params) {
|
|
1847
|
+
if (!params.showToast) return
|
|
1558
1848
|
const title = t('uni.setClipboardData.success');
|
|
1559
1849
|
if (title) {
|
|
1560
1850
|
uni.showToast({
|
|
1561
|
-
title
|
|
1851
|
+
title,
|
|
1562
1852
|
icon: 'success',
|
|
1563
1853
|
mask: false,
|
|
1564
1854
|
style: {
|
|
@@ -1629,10 +1919,13 @@ var serviceContext = (function () {
|
|
|
1629
1919
|
function getRealPath (filePath) {
|
|
1630
1920
|
if (filePath.indexOf('/') === 0) {
|
|
1631
1921
|
if (filePath.indexOf('//') === 0) {
|
|
1632
|
-
|
|
1633
|
-
} else {
|
|
1634
|
-
return addBase(filePath.substr(1))
|
|
1922
|
+
return 'https:' + filePath
|
|
1635
1923
|
}
|
|
1924
|
+
// 平台绝对路径 安卓、iOS
|
|
1925
|
+
if (filePath.startsWith('/storage/') || filePath.startsWith('/sdcard/') || filePath.includes('/Containers/Data/Application/')) {
|
|
1926
|
+
return 'file://' + filePath
|
|
1927
|
+
}
|
|
1928
|
+
return addBase(filePath.substr(1))
|
|
1636
1929
|
}
|
|
1637
1930
|
// 网络资源或base64
|
|
1638
1931
|
if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) {
|
|
@@ -2165,11 +2458,24 @@ var serviceContext = (function () {
|
|
|
2165
2458
|
timeout: {
|
|
2166
2459
|
type: Number
|
|
2167
2460
|
}
|
|
2461
|
+
};
|
|
2462
|
+
|
|
2463
|
+
const configMTLS = {
|
|
2464
|
+
certificates: {
|
|
2465
|
+
type: Array,
|
|
2466
|
+
required: true,
|
|
2467
|
+
validator (value) {
|
|
2468
|
+
if (value.some(item => toRawType(item.host) !== 'String')) {
|
|
2469
|
+
return '参数配置错误,请确认后重试'
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2168
2473
|
};
|
|
2169
2474
|
|
|
2170
2475
|
var require_context_module_0_25 = /*#__PURE__*/Object.freeze({
|
|
2171
2476
|
__proto__: null,
|
|
2172
|
-
request: request
|
|
2477
|
+
request: request,
|
|
2478
|
+
configMTLS: configMTLS
|
|
2173
2479
|
});
|
|
2174
2480
|
|
|
2175
2481
|
const method$1 = {
|
|
@@ -2246,7 +2552,7 @@ var serviceContext = (function () {
|
|
|
2246
2552
|
type: String,
|
|
2247
2553
|
validator (value, params) {
|
|
2248
2554
|
if (value) {
|
|
2249
|
-
params.
|
|
2555
|
+
params.filePath = getRealPath(value);
|
|
2250
2556
|
}
|
|
2251
2557
|
}
|
|
2252
2558
|
},
|
|
@@ -2734,7 +3040,7 @@ var serviceContext = (function () {
|
|
|
2734
3040
|
icon: {
|
|
2735
3041
|
default: 'success',
|
|
2736
3042
|
validator (icon, params) {
|
|
2737
|
-
if (['success', 'loading', 'none'].indexOf(icon) === -1) {
|
|
3043
|
+
if (['success', 'loading', 'error', 'none'].indexOf(icon) === -1) {
|
|
2738
3044
|
params.icon = 'success';
|
|
2739
3045
|
}
|
|
2740
3046
|
}
|
|
@@ -3312,7 +3618,7 @@ var serviceContext = (function () {
|
|
|
3312
3618
|
const errMsg = res.errMsg;
|
|
3313
3619
|
|
|
3314
3620
|
if (errMsg.indexOf(apiName + ':ok') === 0) {
|
|
3315
|
-
isFn(beforeSuccess) && beforeSuccess(res);
|
|
3621
|
+
isFn(beforeSuccess) && beforeSuccess(res, params);
|
|
3316
3622
|
|
|
3317
3623
|
hasSuccess && success(res);
|
|
3318
3624
|
|
|
@@ -3850,7 +4156,7 @@ var serviceContext = (function () {
|
|
|
3850
4156
|
|
|
3851
4157
|
// 无协议的情况补全 https
|
|
3852
4158
|
if (filePath.indexOf('//') === 0) {
|
|
3853
|
-
|
|
4159
|
+
return 'https:' + filePath
|
|
3854
4160
|
}
|
|
3855
4161
|
|
|
3856
4162
|
// 网络资源或base64
|
|
@@ -3865,6 +4171,10 @@ var serviceContext = (function () {
|
|
|
3865
4171
|
const wwwPath = 'file://' + _handleLocalPath('_www');
|
|
3866
4172
|
// 绝对路径转换为本地文件系统路径
|
|
3867
4173
|
if (filePath.indexOf('/') === 0) {
|
|
4174
|
+
// 平台绝对路径 安卓、iOS
|
|
4175
|
+
if (filePath.startsWith('/storage/') || filePath.startsWith('/sdcard/') || filePath.includes('/Containers/Data/Application/')) {
|
|
4176
|
+
return 'file://' + filePath
|
|
4177
|
+
}
|
|
3868
4178
|
return wwwPath + filePath
|
|
3869
4179
|
}
|
|
3870
4180
|
// 相对资源
|
|
@@ -4537,6 +4847,9 @@ var serviceContext = (function () {
|
|
|
4537
4847
|
},
|
|
4538
4848
|
openMapApp (ctx, args) {
|
|
4539
4849
|
return invokeVmMethod(ctx, 'openMapApp', args)
|
|
4850
|
+
},
|
|
4851
|
+
on (ctx, args) {
|
|
4852
|
+
return ctx.on(args.name, args.callback)
|
|
4540
4853
|
}
|
|
4541
4854
|
};
|
|
4542
4855
|
|
|
@@ -5800,8 +6113,6 @@ var serviceContext = (function () {
|
|
|
5800
6113
|
}
|
|
5801
6114
|
}
|
|
5802
6115
|
|
|
5803
|
-
const NAVBAR_HEIGHT = 44;
|
|
5804
|
-
|
|
5805
6116
|
const TABBAR_HEIGHT = 50;
|
|
5806
6117
|
const isIOS$1 = plus.os.name === 'iOS';
|
|
5807
6118
|
let config;
|
|
@@ -5844,7 +6155,7 @@ var serviceContext = (function () {
|
|
|
5844
6155
|
/**
|
|
5845
6156
|
* 动态设置 tabBar 某一项的内容
|
|
5846
6157
|
*/
|
|
5847
|
-
function setTabBarItem$1 (index, text, iconPath, selectedIconPath) {
|
|
6158
|
+
function setTabBarItem$1 (index, text, iconPath, selectedIconPath, visible) {
|
|
5848
6159
|
const item = {
|
|
5849
6160
|
index
|
|
5850
6161
|
};
|
|
@@ -5857,7 +6168,17 @@ var serviceContext = (function () {
|
|
|
5857
6168
|
if (selectedIconPath) {
|
|
5858
6169
|
item.selectedIconPath = getRealPath$1(selectedIconPath);
|
|
5859
6170
|
}
|
|
5860
|
-
|
|
6171
|
+
if (visible !== undefined) {
|
|
6172
|
+
item.visible = config.list[index].visible = visible;
|
|
6173
|
+
delete item.index;
|
|
6174
|
+
|
|
6175
|
+
const tabbarItems = config.list.map(item => ({ visible: item.visible }));
|
|
6176
|
+
tabbarItems[index] = item;
|
|
6177
|
+
|
|
6178
|
+
tabBar && tabBar.setTabBarItems({ list: tabbarItems });
|
|
6179
|
+
} else {
|
|
6180
|
+
tabBar && tabBar.setTabBarItem(item);
|
|
6181
|
+
}
|
|
5861
6182
|
}
|
|
5862
6183
|
/**
|
|
5863
6184
|
* 动态设置 tabBar 的整体样式
|
|
@@ -5986,7 +6307,7 @@ var serviceContext = (function () {
|
|
|
5986
6307
|
let deviceId;
|
|
5987
6308
|
|
|
5988
6309
|
function deviceId$1 () {
|
|
5989
|
-
deviceId = deviceId || plus.
|
|
6310
|
+
deviceId = deviceId || plus.device.uuid;
|
|
5990
6311
|
return deviceId
|
|
5991
6312
|
}
|
|
5992
6313
|
|
|
@@ -5997,6 +6318,7 @@ var serviceContext = (function () {
|
|
|
5997
6318
|
function getSystemInfo () {
|
|
5998
6319
|
const platform = plus.os.name.toLowerCase();
|
|
5999
6320
|
const ios = platform === 'ios';
|
|
6321
|
+
const isAndroid = platform === 'android';
|
|
6000
6322
|
const {
|
|
6001
6323
|
screenWidth,
|
|
6002
6324
|
screenHeight
|
|
@@ -6063,7 +6385,7 @@ var serviceContext = (function () {
|
|
|
6063
6385
|
windowHeight,
|
|
6064
6386
|
statusBarHeight,
|
|
6065
6387
|
language: plus.os.language,
|
|
6066
|
-
system: plus.os.version
|
|
6388
|
+
system: `${ios ? 'iOS' : isAndroid ? 'Android' : ''} ${plus.os.version}`,
|
|
6067
6389
|
version: plus.runtime.innerVersion,
|
|
6068
6390
|
fontSizeSetting: '',
|
|
6069
6391
|
platform,
|
|
@@ -6196,16 +6518,10 @@ var serviceContext = (function () {
|
|
|
6196
6518
|
filePath,
|
|
6197
6519
|
fileType
|
|
6198
6520
|
} = {}, callbackId) {
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
});
|
|
6204
|
-
}, err => {
|
|
6205
|
-
invoke$1(callbackId, {
|
|
6206
|
-
errMsg: 'openDocument:fail ' + err.message
|
|
6207
|
-
});
|
|
6208
|
-
});
|
|
6521
|
+
const successCallback = warpPlusSuccessCallback(callbackId, 'saveFile');
|
|
6522
|
+
const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile');
|
|
6523
|
+
|
|
6524
|
+
plus.runtime.openDocument(getRealPath$1(filePath), undefined, successCallback, errorCallback);
|
|
6209
6525
|
}
|
|
6210
6526
|
|
|
6211
6527
|
const CHOOSE_LOCATION_PATH = '_www/__uniappchooselocation.html';
|
|
@@ -6408,8 +6724,10 @@ var serviceContext = (function () {
|
|
|
6408
6724
|
function getLocation$1 ({
|
|
6409
6725
|
type = 'wgs84',
|
|
6410
6726
|
geocode = false,
|
|
6411
|
-
altitude = false
|
|
6727
|
+
altitude = false,
|
|
6728
|
+
highAccuracyExpireTime
|
|
6412
6729
|
} = {}, callbackId) {
|
|
6730
|
+
const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation');
|
|
6413
6731
|
plus.geolocation.getCurrentPosition(
|
|
6414
6732
|
position => {
|
|
6415
6733
|
getLocationSuccess(type, position, callbackId);
|
|
@@ -6420,13 +6738,11 @@ var serviceContext = (function () {
|
|
|
6420
6738
|
getLocationSuccess(type, e, callbackId);
|
|
6421
6739
|
return
|
|
6422
6740
|
}
|
|
6423
|
-
|
|
6424
|
-
invoke$1(callbackId, {
|
|
6425
|
-
errMsg: 'getLocation:fail ' + e.message
|
|
6426
|
-
});
|
|
6741
|
+
errorCallback(e);
|
|
6427
6742
|
}, {
|
|
6428
6743
|
geocode: geocode,
|
|
6429
|
-
enableHighAccuracy: altitude
|
|
6744
|
+
enableHighAccuracy: altitude,
|
|
6745
|
+
timeout: highAccuracyExpireTime
|
|
6430
6746
|
}
|
|
6431
6747
|
);
|
|
6432
6748
|
}
|
|
@@ -6625,64 +6941,32 @@ var serviceContext = (function () {
|
|
|
6625
6941
|
})
|
|
6626
6942
|
}
|
|
6627
6943
|
|
|
6628
|
-
function compressImage$1 (tempFilePath) {
|
|
6629
|
-
const dstPath = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`;
|
|
6630
|
-
return new Promise((resolve, reject) => {
|
|
6631
|
-
plus.nativeUI.showWaiting();
|
|
6632
|
-
plus.zip.compressImage({
|
|
6633
|
-
src: tempFilePath,
|
|
6634
|
-
dst: dstPath,
|
|
6635
|
-
overwrite: true
|
|
6636
|
-
}, () => {
|
|
6637
|
-
plus.nativeUI.closeWaiting();
|
|
6638
|
-
resolve(dstPath);
|
|
6639
|
-
}, (error) => {
|
|
6640
|
-
plus.nativeUI.closeWaiting();
|
|
6641
|
-
reject(error);
|
|
6642
|
-
});
|
|
6643
|
-
})
|
|
6644
|
-
}
|
|
6645
|
-
|
|
6646
6944
|
function chooseImage$1 ({
|
|
6647
6945
|
count,
|
|
6648
6946
|
sizeType,
|
|
6649
|
-
sourceType
|
|
6947
|
+
sourceType,
|
|
6948
|
+
crop
|
|
6650
6949
|
} = {}, callbackId) {
|
|
6651
6950
|
const errorCallback = warpPlusErrorCallback(callbackId, 'chooseImage', 'cancel');
|
|
6652
6951
|
|
|
6653
6952
|
function successCallback (paths) {
|
|
6654
6953
|
const tempFiles = [];
|
|
6655
6954
|
const tempFilePaths = [];
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
return getFileInfo$2(path)
|
|
6669
|
-
})
|
|
6670
|
-
}
|
|
6671
|
-
return fileInfo
|
|
6672
|
-
}).then(({ size }) => {
|
|
6673
|
-
tempFilePaths.push(path);
|
|
6674
|
-
tempFiles.push({
|
|
6675
|
-
path,
|
|
6676
|
-
size
|
|
6955
|
+
Promise.all(paths.map((path) => getFileInfo$2(path)))
|
|
6956
|
+
.then((filesInfo) => {
|
|
6957
|
+
filesInfo.forEach((file, index) => {
|
|
6958
|
+
const path = paths[index];
|
|
6959
|
+
tempFilePaths.push(path);
|
|
6960
|
+
tempFiles.push({ path, size: file.size });
|
|
6961
|
+
});
|
|
6962
|
+
|
|
6963
|
+
invoke$1(callbackId, {
|
|
6964
|
+
errMsg: 'chooseImage:ok',
|
|
6965
|
+
tempFilePaths,
|
|
6966
|
+
tempFiles
|
|
6677
6967
|
});
|
|
6678
6968
|
})
|
|
6679
|
-
|
|
6680
|
-
invoke$1(callbackId, {
|
|
6681
|
-
errMsg: 'chooseImage:ok',
|
|
6682
|
-
tempFilePaths,
|
|
6683
|
-
tempFiles
|
|
6684
|
-
});
|
|
6685
|
-
}).catch(errorCallback);
|
|
6969
|
+
.catch(errorCallback);
|
|
6686
6970
|
}
|
|
6687
6971
|
|
|
6688
6972
|
function openCamera () {
|
|
@@ -6690,7 +6974,9 @@ var serviceContext = (function () {
|
|
|
6690
6974
|
camera.captureImage(path => successCallback([path]),
|
|
6691
6975
|
errorCallback, {
|
|
6692
6976
|
filename: TEMP_PATH + '/camera/',
|
|
6693
|
-
resolution: 'high'
|
|
6977
|
+
resolution: 'high',
|
|
6978
|
+
crop,
|
|
6979
|
+
sizeType
|
|
6694
6980
|
});
|
|
6695
6981
|
}
|
|
6696
6982
|
|
|
@@ -6700,7 +6986,9 @@ var serviceContext = (function () {
|
|
|
6700
6986
|
multiple: true,
|
|
6701
6987
|
system: false,
|
|
6702
6988
|
filename: TEMP_PATH + '/gallery/',
|
|
6703
|
-
permissionAlert: true
|
|
6989
|
+
permissionAlert: true,
|
|
6990
|
+
crop,
|
|
6991
|
+
sizeType
|
|
6704
6992
|
});
|
|
6705
6993
|
}
|
|
6706
6994
|
|
|
@@ -6744,38 +7032,20 @@ var serviceContext = (function () {
|
|
|
6744
7032
|
const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel');
|
|
6745
7033
|
|
|
6746
7034
|
function successCallback (tempFilePath = '') {
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
plus.io.getVideoInfo({
|
|
6762
|
-
filePath: tempFilePath,
|
|
6763
|
-
success (videoInfo) {
|
|
6764
|
-
const result = {
|
|
6765
|
-
errMsg: 'chooseVideo:ok',
|
|
6766
|
-
tempFilePath: tempFilePath
|
|
6767
|
-
};
|
|
6768
|
-
result.size = videoInfo.size;
|
|
6769
|
-
result.duration = videoInfo.duration;
|
|
6770
|
-
result.width = videoInfo.width;
|
|
6771
|
-
result.height = videoInfo.height;
|
|
6772
|
-
invoke$1(callbackId, result);
|
|
6773
|
-
},
|
|
6774
|
-
errorCallback
|
|
6775
|
-
});
|
|
6776
|
-
}, error => {
|
|
6777
|
-
plus.nativeUI.closeWaiting();
|
|
6778
|
-
errorCallback(error);
|
|
7035
|
+
plus.io.getVideoInfo({
|
|
7036
|
+
filePath: tempFilePath,
|
|
7037
|
+
success (videoInfo) {
|
|
7038
|
+
const result = {
|
|
7039
|
+
errMsg: 'chooseVideo:ok',
|
|
7040
|
+
tempFilePath: tempFilePath
|
|
7041
|
+
};
|
|
7042
|
+
result.size = videoInfo.size;
|
|
7043
|
+
result.duration = videoInfo.duration;
|
|
7044
|
+
result.width = videoInfo.width;
|
|
7045
|
+
result.height = videoInfo.height;
|
|
7046
|
+
invoke$1(callbackId, result);
|
|
7047
|
+
},
|
|
7048
|
+
fail: errorCallback
|
|
6779
7049
|
});
|
|
6780
7050
|
}
|
|
6781
7051
|
|
|
@@ -6787,7 +7057,8 @@ var serviceContext = (function () {
|
|
|
6787
7057
|
multiple: true,
|
|
6788
7058
|
maximum: 1,
|
|
6789
7059
|
filename: TEMP_PATH + '/gallery/',
|
|
6790
|
-
permissionAlert: true
|
|
7060
|
+
permissionAlert: true,
|
|
7061
|
+
videoCompress: compressed
|
|
6791
7062
|
});
|
|
6792
7063
|
}
|
|
6793
7064
|
|
|
@@ -6796,7 +7067,8 @@ var serviceContext = (function () {
|
|
|
6796
7067
|
plusCamera.startVideoCapture(successCallback, errorCallback, {
|
|
6797
7068
|
index: camera === 'front' ? 2 : 1,
|
|
6798
7069
|
videoMaximumDuration: maxDuration,
|
|
6799
|
-
filename: TEMP_PATH + '/camera/'
|
|
7070
|
+
filename: TEMP_PATH + '/camera/',
|
|
7071
|
+
videoCompress: compressed
|
|
6800
7072
|
});
|
|
6801
7073
|
}
|
|
6802
7074
|
|
|
@@ -6831,7 +7103,7 @@ var serviceContext = (function () {
|
|
|
6831
7103
|
});
|
|
6832
7104
|
}
|
|
6833
7105
|
|
|
6834
|
-
function compressImage$
|
|
7106
|
+
function compressImage$1 (options, callbackId) {
|
|
6835
7107
|
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`;
|
|
6836
7108
|
const errorCallback = warpPlusErrorCallback(callbackId, 'compressImage');
|
|
6837
7109
|
plus.zip.compressImage(Object.assign({}, options, {
|
|
@@ -6845,11 +7117,11 @@ var serviceContext = (function () {
|
|
|
6845
7117
|
}
|
|
6846
7118
|
|
|
6847
7119
|
function compressVideo$1 (options, callbackId) {
|
|
6848
|
-
const
|
|
7120
|
+
const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`;
|
|
6849
7121
|
const successCallback = warpPlusSuccessCallback(callbackId, 'compressVideo');
|
|
6850
7122
|
const errorCallback = warpPlusErrorCallback(callbackId, 'compressVideo');
|
|
6851
7123
|
plus.zip.compressVideo(Object.assign({}, options, {
|
|
6852
|
-
|
|
7124
|
+
filename
|
|
6853
7125
|
}), successCallback, errorCallback);
|
|
6854
7126
|
}
|
|
6855
7127
|
|
|
@@ -6863,11 +7135,14 @@ var serviceContext = (function () {
|
|
|
6863
7135
|
return options
|
|
6864
7136
|
}, data => {
|
|
6865
7137
|
return {
|
|
7138
|
+
orientation: data.orientation,
|
|
7139
|
+
type: data.type,
|
|
6866
7140
|
duration: data.duration,
|
|
6867
|
-
|
|
7141
|
+
size: data.size / 1024,
|
|
6868
7142
|
height: data.height,
|
|
6869
7143
|
width: data.width,
|
|
6870
|
-
|
|
7144
|
+
fps: data.fps || 30,
|
|
7145
|
+
bitrate: data.bitrate
|
|
6871
7146
|
}
|
|
6872
7147
|
});
|
|
6873
7148
|
|
|
@@ -7162,6 +7437,7 @@ var serviceContext = (function () {
|
|
|
7162
7437
|
responseType,
|
|
7163
7438
|
sslVerify = true,
|
|
7164
7439
|
firstIpv4 = false,
|
|
7440
|
+
tls,
|
|
7165
7441
|
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000
|
|
7166
7442
|
} = {}) {
|
|
7167
7443
|
const stream = requireNativePlugin('stream');
|
|
@@ -7215,7 +7491,8 @@ var serviceContext = (function () {
|
|
|
7215
7491
|
timeout: timeout || 6e5,
|
|
7216
7492
|
// 配置和weex模块内相反
|
|
7217
7493
|
sslVerify: !sslVerify,
|
|
7218
|
-
firstIpv4: firstIpv4
|
|
7494
|
+
firstIpv4: firstIpv4,
|
|
7495
|
+
tls
|
|
7219
7496
|
};
|
|
7220
7497
|
if (method !== 'GET') {
|
|
7221
7498
|
options.body = typeof data === 'string' ? data : JSON.stringify(data);
|
|
@@ -7301,6 +7578,26 @@ var serviceContext = (function () {
|
|
|
7301
7578
|
return {
|
|
7302
7579
|
errMsg: 'operateRequestTask:fail'
|
|
7303
7580
|
}
|
|
7581
|
+
}
|
|
7582
|
+
|
|
7583
|
+
function configMTLS$1 ({ certificates }, callbackId) {
|
|
7584
|
+
const stream = requireNativePlugin('stream');
|
|
7585
|
+
stream.configMTLS(certificates, ({ type, code, message }) => {
|
|
7586
|
+
switch (type) {
|
|
7587
|
+
case 'success':
|
|
7588
|
+
invoke$1(callbackId, {
|
|
7589
|
+
errMsg: 'configMTLS:ok',
|
|
7590
|
+
code
|
|
7591
|
+
});
|
|
7592
|
+
break
|
|
7593
|
+
case 'fail':
|
|
7594
|
+
invoke$1(callbackId, {
|
|
7595
|
+
errMsg: 'configMTLS:fail ' + message,
|
|
7596
|
+
code
|
|
7597
|
+
});
|
|
7598
|
+
break
|
|
7599
|
+
}
|
|
7600
|
+
});
|
|
7304
7601
|
}
|
|
7305
7602
|
|
|
7306
7603
|
const socketTasks = {};
|
|
@@ -7468,7 +7765,7 @@ var serviceContext = (function () {
|
|
|
7468
7765
|
}
|
|
7469
7766
|
if (files && files.length) {
|
|
7470
7767
|
files.forEach(file => {
|
|
7471
|
-
uploader.addFile(getRealPath$1(file.uri), {
|
|
7768
|
+
uploader.addFile(getRealPath$1(file.uri || file.filePath), {
|
|
7472
7769
|
key: file.name || 'file'
|
|
7473
7770
|
});
|
|
7474
7771
|
});
|
|
@@ -7595,6 +7892,8 @@ var serviceContext = (function () {
|
|
|
7595
7892
|
}
|
|
7596
7893
|
}
|
|
7597
7894
|
|
|
7895
|
+
let univerifyManager;
|
|
7896
|
+
|
|
7598
7897
|
function getService (provider) {
|
|
7599
7898
|
return new Promise((resolve, reject) => {
|
|
7600
7899
|
plus.oauth.getServices(services => {
|
|
@@ -7607,20 +7906,36 @@ var serviceContext = (function () {
|
|
|
7607
7906
|
/**
|
|
7608
7907
|
* 微信登录
|
|
7609
7908
|
*/
|
|
7610
|
-
function login (params, callbackId) {
|
|
7909
|
+
function login (params, callbackId, plus = true) {
|
|
7611
7910
|
const provider = params.provider || 'weixin';
|
|
7612
|
-
const errorCallback =
|
|
7911
|
+
const errorCallback = warpErrorCallback(callbackId, 'login', plus);
|
|
7912
|
+
const authOptions = provider === 'apple'
|
|
7913
|
+
? { scope: 'email' }
|
|
7914
|
+
: params.univerifyStyle
|
|
7915
|
+
? { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) }
|
|
7916
|
+
: {};
|
|
7917
|
+
const _invoke = plus ? invoke$1 : callback.invoke;
|
|
7613
7918
|
|
|
7614
7919
|
getService(provider).then(service => {
|
|
7615
7920
|
function login () {
|
|
7921
|
+
if (params.onlyAuthorize && provider === 'weixin') {
|
|
7922
|
+
service.authorize(({ code }) => {
|
|
7923
|
+
_invoke(callbackId, {
|
|
7924
|
+
code,
|
|
7925
|
+
authResult: '',
|
|
7926
|
+
errMsg: 'login:ok'
|
|
7927
|
+
});
|
|
7928
|
+
}, errorCallback);
|
|
7929
|
+
return
|
|
7930
|
+
}
|
|
7616
7931
|
service.login(res => {
|
|
7617
7932
|
const authResult = res.target.authResult;
|
|
7618
|
-
|
|
7933
|
+
_invoke(callbackId, {
|
|
7619
7934
|
code: authResult.code,
|
|
7620
7935
|
authResult: authResult,
|
|
7621
7936
|
errMsg: 'login:ok'
|
|
7622
7937
|
});
|
|
7623
|
-
}, errorCallback,
|
|
7938
|
+
}, errorCallback, authOptions);
|
|
7624
7939
|
}
|
|
7625
7940
|
// 先注销再登录
|
|
7626
7941
|
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
|
|
@@ -7688,6 +8003,12 @@ var serviceContext = (function () {
|
|
|
7688
8003
|
});
|
|
7689
8004
|
});
|
|
7690
8005
|
}
|
|
8006
|
+
/**
|
|
8007
|
+
* 获取用户信息-兼容
|
|
8008
|
+
*/
|
|
8009
|
+
function getUserProfile (params, callbackId) {
|
|
8010
|
+
return getUserInfo(params, callbackId)
|
|
8011
|
+
}
|
|
7691
8012
|
|
|
7692
8013
|
/**
|
|
7693
8014
|
* 获取用户信息
|
|
@@ -7704,14 +8025,121 @@ var serviceContext = (function () {
|
|
|
7704
8025
|
}
|
|
7705
8026
|
}
|
|
7706
8027
|
|
|
7707
|
-
function preLogin$1 (params, callbackId) {
|
|
7708
|
-
const successCallback =
|
|
7709
|
-
const errorCallback =
|
|
8028
|
+
function preLogin$1 (params, callbackId, plus) {
|
|
8029
|
+
const successCallback = warpSuccessCallback(callbackId, 'preLogin', plus);
|
|
8030
|
+
const errorCallback = warpErrorCallback(callbackId, 'preLogin', plus);
|
|
7710
8031
|
getService(params.provider).then(service => service.preLogin(successCallback, errorCallback)).catch(errorCallback);
|
|
7711
8032
|
}
|
|
7712
8033
|
|
|
7713
8034
|
function closeAuthView () {
|
|
7714
|
-
getService('univerify').then(service => service.closeAuthView())
|
|
8035
|
+
return getService('univerify').then(service => service.closeAuthView())
|
|
8036
|
+
}
|
|
8037
|
+
|
|
8038
|
+
function getCheckBoxState (params, callbackId, plus) {
|
|
8039
|
+
const successCallback = warpSuccessCallback(callbackId, 'getCheckBoxState', plus);
|
|
8040
|
+
const errorCallback = warpErrorCallback(callbackId, 'getCheckBoxState', plus);
|
|
8041
|
+
try {
|
|
8042
|
+
getService('univerify').then(service => {
|
|
8043
|
+
const state = service.getCheckBoxState();
|
|
8044
|
+
successCallback({ state });
|
|
8045
|
+
});
|
|
8046
|
+
} catch (error) {
|
|
8047
|
+
errorCallback(error);
|
|
8048
|
+
}
|
|
8049
|
+
}
|
|
8050
|
+
|
|
8051
|
+
/**
|
|
8052
|
+
* 一键登录自定义登陆按钮点击处理
|
|
8053
|
+
*/
|
|
8054
|
+
function univerifyButtonsClickHandling (univerifyStyle, errorCallback) {
|
|
8055
|
+
if (isPlainObject(univerifyStyle) && isPlainObject(univerifyStyle.buttons) && toRawType(univerifyStyle.buttons.list) === 'Array') {
|
|
8056
|
+
univerifyStyle.buttons.list.forEach((button, index) => {
|
|
8057
|
+
univerifyStyle.buttons.list[index].onclick = function () {
|
|
8058
|
+
const res = {
|
|
8059
|
+
code: '30008',
|
|
8060
|
+
message: '用户点击了自定义按钮',
|
|
8061
|
+
index,
|
|
8062
|
+
provider: button.provider
|
|
8063
|
+
};
|
|
8064
|
+
isPlainObject(univerifyManager)
|
|
8065
|
+
? univerifyManager._triggerUniverifyButtonsClick(res)
|
|
8066
|
+
: closeAuthView().then(() => {
|
|
8067
|
+
errorCallback(res);
|
|
8068
|
+
});
|
|
8069
|
+
};
|
|
8070
|
+
});
|
|
8071
|
+
}
|
|
8072
|
+
return univerifyStyle
|
|
8073
|
+
}
|
|
8074
|
+
|
|
8075
|
+
class UniverifyManager {
|
|
8076
|
+
constructor () {
|
|
8077
|
+
this.provider = 'univerify';
|
|
8078
|
+
this.eventName = 'api.univerifyButtonsClick';
|
|
8079
|
+
}
|
|
8080
|
+
|
|
8081
|
+
close () {
|
|
8082
|
+
closeAuthView();
|
|
8083
|
+
}
|
|
8084
|
+
|
|
8085
|
+
login (options) {
|
|
8086
|
+
this._warp((data, callbackId) => login(data, callbackId, false), this._getOptions(options));
|
|
8087
|
+
}
|
|
8088
|
+
|
|
8089
|
+
getCheckBoxState (options) {
|
|
8090
|
+
this._warp((_, callbackId) => getCheckBoxState(_, callbackId, false), options);
|
|
8091
|
+
}
|
|
8092
|
+
|
|
8093
|
+
preLogin (options) {
|
|
8094
|
+
this._warp((data, callbackId) => preLogin$1(data, callbackId, false), this._getOptions(options));
|
|
8095
|
+
}
|
|
8096
|
+
|
|
8097
|
+
onButtonsClick (callback) {
|
|
8098
|
+
UniServiceJSBridge.on(this.eventName, callback);
|
|
8099
|
+
}
|
|
8100
|
+
|
|
8101
|
+
offButtonsClick (callback) {
|
|
8102
|
+
UniServiceJSBridge.off(this.eventName, callback);
|
|
8103
|
+
}
|
|
8104
|
+
|
|
8105
|
+
_triggerUniverifyButtonsClick (res) {
|
|
8106
|
+
UniServiceJSBridge.emit(this.eventName, res);
|
|
8107
|
+
}
|
|
8108
|
+
|
|
8109
|
+
_warp (fn, options) {
|
|
8110
|
+
return callback.warp(fn)(this._getOptions(options))
|
|
8111
|
+
}
|
|
8112
|
+
|
|
8113
|
+
_getOptions (options = {}) {
|
|
8114
|
+
return Object.assign({}, options, { provider: this.provider })
|
|
8115
|
+
}
|
|
8116
|
+
}
|
|
8117
|
+
|
|
8118
|
+
function getUniverifyManager () {
|
|
8119
|
+
return univerifyManager || (univerifyManager = new UniverifyManager())
|
|
8120
|
+
}
|
|
8121
|
+
|
|
8122
|
+
function warpSuccessCallback (callbackId, name, plus = true) {
|
|
8123
|
+
return plus
|
|
8124
|
+
? warpPlusSuccessCallback(callbackId, name)
|
|
8125
|
+
: (options) => {
|
|
8126
|
+
callback.invoke(callbackId, Object.assign({}, options, {
|
|
8127
|
+
errMsg: `${name}:ok`
|
|
8128
|
+
}));
|
|
8129
|
+
}
|
|
8130
|
+
}
|
|
8131
|
+
|
|
8132
|
+
function warpErrorCallback (callbackId, name, plus = true) {
|
|
8133
|
+
return plus
|
|
8134
|
+
? warpPlusErrorCallback(callbackId, name)
|
|
8135
|
+
: (error) => {
|
|
8136
|
+
const { code = 0, message: errorMessage } = error;
|
|
8137
|
+
callback.invoke(callbackId, {
|
|
8138
|
+
errMsg: `${name}:fail ${errorMessage || ''}`,
|
|
8139
|
+
errCode: code,
|
|
8140
|
+
code
|
|
8141
|
+
});
|
|
8142
|
+
}
|
|
7715
8143
|
}
|
|
7716
8144
|
|
|
7717
8145
|
function requestPayment (params, callbackId) {
|
|
@@ -8284,20 +8712,18 @@ var serviceContext = (function () {
|
|
|
8284
8712
|
return titleNView
|
|
8285
8713
|
}
|
|
8286
8714
|
|
|
8287
|
-
function parseTitleNView (routeOptions) {
|
|
8715
|
+
function parseTitleNView (id, routeOptions) {
|
|
8288
8716
|
const windowOptions = routeOptions.window;
|
|
8289
8717
|
const titleNView = windowOptions.titleNView;
|
|
8290
|
-
routeOptions.meta.statusBarStyle =
|
|
8291
|
-
|
|
8718
|
+
routeOptions.meta.statusBarStyle =
|
|
8719
|
+
windowOptions.navigationBarTextStyle === 'black' ? 'dark' : 'light';
|
|
8720
|
+
if (
|
|
8721
|
+
// 无头
|
|
8292
8722
|
titleNView === false ||
|
|
8293
8723
|
titleNView === 'false' ||
|
|
8294
|
-
(
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
) || (
|
|
8298
|
-
windowOptions.transparentTitle === 'always' &&
|
|
8299
|
-
!isPlainObject(titleNView)
|
|
8300
|
-
)
|
|
8724
|
+
(windowOptions.navigationStyle === 'custom' &&
|
|
8725
|
+
!isPlainObject(titleNView)) ||
|
|
8726
|
+
(windowOptions.transparentTitle === 'always' && !isPlainObject(titleNView))
|
|
8301
8727
|
) {
|
|
8302
8728
|
return false
|
|
8303
8729
|
}
|
|
@@ -8310,30 +8736,76 @@ var serviceContext = (function () {
|
|
|
8310
8736
|
always: 'float'
|
|
8311
8737
|
};
|
|
8312
8738
|
|
|
8313
|
-
const navigationBarBackgroundColor =
|
|
8739
|
+
const navigationBarBackgroundColor =
|
|
8740
|
+
windowOptions.navigationBarBackgroundColor;
|
|
8314
8741
|
const ret = {
|
|
8315
8742
|
autoBackButton: !routeOptions.meta.isQuit,
|
|
8316
|
-
titleText:
|
|
8317
|
-
|
|
8743
|
+
titleText:
|
|
8744
|
+
titleImage === '' ? windowOptions.navigationBarTitleText || '' : '',
|
|
8745
|
+
titleColor:
|
|
8746
|
+
windowOptions.navigationBarTextStyle === 'black' ? '#000000' : '#ffffff',
|
|
8318
8747
|
type: titleNViewTypeList[transparentTitle],
|
|
8319
|
-
backgroundColor:
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8748
|
+
backgroundColor:
|
|
8749
|
+
/^#[a-z0-9]{6}$/i.test(navigationBarBackgroundColor) ||
|
|
8750
|
+
navigationBarBackgroundColor === 'transparent'
|
|
8751
|
+
? navigationBarBackgroundColor
|
|
8752
|
+
: '#f7f7f7',
|
|
8753
|
+
tags:
|
|
8754
|
+
titleImage === ''
|
|
8755
|
+
? []
|
|
8756
|
+
: [
|
|
8757
|
+
{
|
|
8758
|
+
tag: 'img',
|
|
8759
|
+
src: titleImage,
|
|
8760
|
+
position: {
|
|
8761
|
+
left: 'auto',
|
|
8762
|
+
top: 'auto',
|
|
8763
|
+
width: 'auto',
|
|
8764
|
+
height: '26px'
|
|
8765
|
+
}
|
|
8766
|
+
}
|
|
8767
|
+
]
|
|
8330
8768
|
};
|
|
8331
8769
|
|
|
8332
8770
|
if (isPlainObject(titleNView)) {
|
|
8333
|
-
return
|
|
8771
|
+
return initTitleNViewI18n(
|
|
8772
|
+
id,
|
|
8773
|
+
Object.assign(ret, parseTitleNViewButtons(titleNView))
|
|
8774
|
+
)
|
|
8334
8775
|
}
|
|
8776
|
+
return initTitleNViewI18n(id, ret)
|
|
8777
|
+
}
|
|
8335
8778
|
|
|
8336
|
-
|
|
8779
|
+
function initTitleNViewI18n (id, titleNView) {
|
|
8780
|
+
const i18nResult = initNavigationBarI18n(titleNView);
|
|
8781
|
+
if (!i18nResult) {
|
|
8782
|
+
return titleNView
|
|
8783
|
+
}
|
|
8784
|
+
const [titleTextI18n, searchInputPlaceholderI18n] = i18nResult;
|
|
8785
|
+
if (titleTextI18n || searchInputPlaceholderI18n) {
|
|
8786
|
+
uni.onLocaleChange(() => {
|
|
8787
|
+
const webview = plus.webview.getWebviewById(id + '');
|
|
8788
|
+
if (!webview) {
|
|
8789
|
+
return
|
|
8790
|
+
}
|
|
8791
|
+
const newTitleNView = {};
|
|
8792
|
+
if (titleTextI18n) {
|
|
8793
|
+
newTitleNView.titleText = titleNView.titleText;
|
|
8794
|
+
}
|
|
8795
|
+
if (searchInputPlaceholderI18n) {
|
|
8796
|
+
newTitleNView.searchInput = {
|
|
8797
|
+
placeholder: titleNView.searchInput.placeholder
|
|
8798
|
+
};
|
|
8799
|
+
}
|
|
8800
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8801
|
+
console.log('[uni-app] updateWebview', webview.id, newTitleNView);
|
|
8802
|
+
}
|
|
8803
|
+
webview.setStyle({
|
|
8804
|
+
titleNView: newTitleNView
|
|
8805
|
+
});
|
|
8806
|
+
});
|
|
8807
|
+
}
|
|
8808
|
+
return titleNView
|
|
8337
8809
|
}
|
|
8338
8810
|
|
|
8339
8811
|
function parsePullToRefresh (routeOptions) {
|
|
@@ -8424,10 +8896,12 @@ var serviceContext = (function () {
|
|
|
8424
8896
|
};
|
|
8425
8897
|
|
|
8426
8898
|
// 合并
|
|
8427
|
-
routeOptions.window = parseStyleUnit(
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8899
|
+
routeOptions.window = parseStyleUnit(
|
|
8900
|
+
Object.assign(
|
|
8901
|
+
JSON.parse(JSON.stringify(__uniConfig.window || {})),
|
|
8902
|
+
routeOptions.window || {}
|
|
8903
|
+
)
|
|
8904
|
+
);
|
|
8431
8905
|
|
|
8432
8906
|
Object.keys(routeOptions.window).forEach(name => {
|
|
8433
8907
|
if (WEBVIEW_STYLE_BLACKLIST.indexOf(name) === -1) {
|
|
@@ -8436,7 +8910,10 @@ var serviceContext = (function () {
|
|
|
8436
8910
|
});
|
|
8437
8911
|
|
|
8438
8912
|
const backgroundColor = routeOptions.window.backgroundColor;
|
|
8439
|
-
if (
|
|
8913
|
+
if (
|
|
8914
|
+
/^#[a-z0-9]{6}$/i.test(backgroundColor) ||
|
|
8915
|
+
backgroundColor === 'transparent'
|
|
8916
|
+
) {
|
|
8440
8917
|
if (!webviewStyle.background) {
|
|
8441
8918
|
webviewStyle.background = backgroundColor;
|
|
8442
8919
|
}
|
|
@@ -8445,7 +8922,7 @@ var serviceContext = (function () {
|
|
|
8445
8922
|
}
|
|
8446
8923
|
}
|
|
8447
8924
|
|
|
8448
|
-
const titleNView = parseTitleNView(routeOptions);
|
|
8925
|
+
const titleNView = parseTitleNView(id, routeOptions);
|
|
8449
8926
|
if (titleNView) {
|
|
8450
8927
|
if (
|
|
8451
8928
|
id === 1 &&
|
|
@@ -8470,7 +8947,8 @@ var serviceContext = (function () {
|
|
|
8470
8947
|
delete webviewStyle.popGesture;
|
|
8471
8948
|
}
|
|
8472
8949
|
|
|
8473
|
-
if (routeOptions.meta.isQuit) {
|
|
8950
|
+
if (routeOptions.meta.isQuit) {
|
|
8951
|
+
// 退出
|
|
8474
8952
|
webviewStyle.popGesture = plus.os.name === 'iOS' ? 'appback' : 'none';
|
|
8475
8953
|
}
|
|
8476
8954
|
|
|
@@ -8834,7 +9312,7 @@ var serviceContext = (function () {
|
|
|
8834
9312
|
|
|
8835
9313
|
function createPreloadWebview () {
|
|
8836
9314
|
if (!preloadWebview || preloadWebview.__uniapp_route) { // 不存在,或已被使用
|
|
8837
|
-
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id$1++));
|
|
9315
|
+
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id$1++), { contentAdjust: false });
|
|
8838
9316
|
if (process.env.NODE_ENV !== 'production') {
|
|
8839
9317
|
console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`);
|
|
8840
9318
|
}
|
|
@@ -9252,6 +9730,7 @@ var serviceContext = (function () {
|
|
|
9252
9730
|
const entryRoute = '/' + entryPagePath;
|
|
9253
9731
|
const routeOptions = __uniRoutes.find(route => route.path === entryRoute);
|
|
9254
9732
|
if (!routeOptions) {
|
|
9733
|
+
console.error(`[uni-app] ${entryPagePath} not found...`);
|
|
9255
9734
|
return
|
|
9256
9735
|
}
|
|
9257
9736
|
|
|
@@ -10004,7 +10483,7 @@ var serviceContext = (function () {
|
|
|
10004
10483
|
let currentSize = 0;
|
|
10005
10484
|
for (let index = 0; index < length; index++) {
|
|
10006
10485
|
const key = plus.storage.key(index);
|
|
10007
|
-
if (key !== STORAGE_KEYS && key.indexOf(STORAGE_DATA_TYPE) + STORAGE_DATA_TYPE.length !== key.length) {
|
|
10486
|
+
if (key !== STORAGE_KEYS && (key.indexOf(STORAGE_DATA_TYPE) < 0 || key.indexOf(STORAGE_DATA_TYPE) + STORAGE_DATA_TYPE.length !== key.length)) {
|
|
10008
10487
|
const value = plus.storage.getItem(key);
|
|
10009
10488
|
currentSize += key.length + value.length;
|
|
10010
10489
|
keys.push(key);
|
|
@@ -10158,7 +10637,7 @@ var serviceContext = (function () {
|
|
|
10158
10637
|
});
|
|
10159
10638
|
toast = true;
|
|
10160
10639
|
} else {
|
|
10161
|
-
if (icon && !~['success', 'loading', 'none'].indexOf(icon)) {
|
|
10640
|
+
if (icon && !~['success', 'loading', 'error', 'none'].indexOf(icon)) {
|
|
10162
10641
|
icon = 'success';
|
|
10163
10642
|
}
|
|
10164
10643
|
const waitingOptions = {
|
|
@@ -10185,11 +10664,11 @@ var serviceContext = (function () {
|
|
|
10185
10664
|
interval: duration
|
|
10186
10665
|
};
|
|
10187
10666
|
} else {
|
|
10188
|
-
if (
|
|
10667
|
+
if (['success', 'error'].indexOf(icon) !== -1) {
|
|
10189
10668
|
waitingOptions.loading = {
|
|
10190
10669
|
display: 'block',
|
|
10191
10670
|
height: '55px',
|
|
10192
|
-
icon: '__uniappsuccess.png',
|
|
10671
|
+
icon: icon === 'success' ? '__uniappsuccess.png' : '__uniapperror.png',
|
|
10193
10672
|
interval: duration
|
|
10194
10673
|
};
|
|
10195
10674
|
}
|
|
@@ -10236,24 +10715,34 @@ var serviceContext = (function () {
|
|
|
10236
10715
|
cancelText,
|
|
10237
10716
|
cancelColor,
|
|
10238
10717
|
confirmText,
|
|
10239
|
-
confirmColor
|
|
10718
|
+
confirmColor,
|
|
10719
|
+
editable = false,
|
|
10720
|
+
placeholderText = ''
|
|
10240
10721
|
} = {}, callbackId) {
|
|
10722
|
+
const buttons = showCancel ? [cancelText, confirmText] : [confirmText];
|
|
10723
|
+
const tip = editable ? placeholderText : buttons;
|
|
10724
|
+
|
|
10241
10725
|
content = content || ' ';
|
|
10242
|
-
plus.nativeUI
|
|
10726
|
+
plus.nativeUI[editable ? 'prompt' : 'confirm'](content, (e) => {
|
|
10243
10727
|
if (showCancel) {
|
|
10244
|
-
|
|
10728
|
+
const isConfirm = e.index === 1;
|
|
10729
|
+
const res = {
|
|
10245
10730
|
errMsg: 'showModal:ok',
|
|
10246
|
-
confirm:
|
|
10731
|
+
confirm: isConfirm,
|
|
10247
10732
|
cancel: e.index === 0 || e.index === -1
|
|
10248
|
-
}
|
|
10733
|
+
};
|
|
10734
|
+
isConfirm && editable && (res.content = e.value);
|
|
10735
|
+
invoke$1(callbackId, res);
|
|
10249
10736
|
} else {
|
|
10250
|
-
|
|
10737
|
+
const res = {
|
|
10251
10738
|
errMsg: 'showModal:ok',
|
|
10252
10739
|
confirm: e.index === 0,
|
|
10253
10740
|
cancel: false
|
|
10254
|
-
}
|
|
10741
|
+
};
|
|
10742
|
+
editable && (res.content = e.value);
|
|
10743
|
+
invoke$1(callbackId, res);
|
|
10255
10744
|
}
|
|
10256
|
-
}, title,
|
|
10745
|
+
}, title, tip, buttons);
|
|
10257
10746
|
}
|
|
10258
10747
|
function showActionSheet$1 ({
|
|
10259
10748
|
itemList = [],
|
|
@@ -10347,9 +10836,10 @@ var serviceContext = (function () {
|
|
|
10347
10836
|
text,
|
|
10348
10837
|
iconPath,
|
|
10349
10838
|
selectedIconPath,
|
|
10350
|
-
pagePath
|
|
10839
|
+
pagePath,
|
|
10840
|
+
visible
|
|
10351
10841
|
}) {
|
|
10352
|
-
tabBar$1.setTabBarItem(index, text, iconPath, selectedIconPath);
|
|
10842
|
+
tabBar$1.setTabBarItem(index, text, iconPath, selectedIconPath, visible);
|
|
10353
10843
|
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath);
|
|
10354
10844
|
if (route) {
|
|
10355
10845
|
const meta = route.meta;
|
|
@@ -10553,8 +11043,7 @@ var serviceContext = (function () {
|
|
|
10553
11043
|
callbackId,
|
|
10554
11044
|
data
|
|
10555
11045
|
}, pageId) => {
|
|
10556
|
-
|
|
10557
|
-
getAdData(adpid, width, count, (res) => {
|
|
11046
|
+
getAdData(data, (res) => {
|
|
10558
11047
|
operateAdView(pageId, callbackId, 'success', res);
|
|
10559
11048
|
}, (err) => {
|
|
10560
11049
|
operateAdView(pageId, callbackId, 'fail', err);
|
|
@@ -10563,7 +11052,8 @@ var serviceContext = (function () {
|
|
|
10563
11052
|
|
|
10564
11053
|
const _adDataCache = {};
|
|
10565
11054
|
|
|
10566
|
-
function getAdData (
|
|
11055
|
+
function getAdData (data, onsuccess, onerror) {
|
|
11056
|
+
const { adpid, width } = data;
|
|
10567
11057
|
const key = adpid + '-' + width;
|
|
10568
11058
|
const adDataList = _adDataCache[key];
|
|
10569
11059
|
if (adDataList && adDataList.length > 0) {
|
|
@@ -10572,11 +11062,7 @@ var serviceContext = (function () {
|
|
|
10572
11062
|
}
|
|
10573
11063
|
|
|
10574
11064
|
plus.ad.getAds(
|
|
10575
|
-
|
|
10576
|
-
adpid,
|
|
10577
|
-
count,
|
|
10578
|
-
width
|
|
10579
|
-
},
|
|
11065
|
+
data,
|
|
10580
11066
|
(res) => {
|
|
10581
11067
|
const list = res.ads;
|
|
10582
11068
|
onsuccess(list.splice(0, 1)[0]);
|
|
@@ -10617,6 +11103,7 @@ var serviceContext = (function () {
|
|
|
10617
11103
|
|
|
10618
11104
|
this._preload = options.preload !== undefined ? options.preload : true;
|
|
10619
11105
|
this._isLoad = false;
|
|
11106
|
+
this._isLoading = false;
|
|
10620
11107
|
this._adError = '';
|
|
10621
11108
|
this._loadPromiseResolve = null;
|
|
10622
11109
|
this._loadPromiseReject = null;
|
|
@@ -10625,6 +11112,7 @@ var serviceContext = (function () {
|
|
|
10625
11112
|
const rewardAd = this._rewardAd = plus.ad.createRewardedVideoAd(options);
|
|
10626
11113
|
rewardAd.onLoad((e) => {
|
|
10627
11114
|
this._isLoad = true;
|
|
11115
|
+
this._isLoading = false;
|
|
10628
11116
|
this._lastLoadTime = Date.now();
|
|
10629
11117
|
this._dispatchEvent('load', {});
|
|
10630
11118
|
|
|
@@ -10634,6 +11122,8 @@ var serviceContext = (function () {
|
|
|
10634
11122
|
}
|
|
10635
11123
|
});
|
|
10636
11124
|
rewardAd.onClose((e) => {
|
|
11125
|
+
this._isLoad = false;
|
|
11126
|
+
this._isLoading = false;
|
|
10637
11127
|
if (this._preload) {
|
|
10638
11128
|
this._loadAd();
|
|
10639
11129
|
}
|
|
@@ -10643,6 +11133,7 @@ var serviceContext = (function () {
|
|
|
10643
11133
|
this._dispatchEvent('verify', { isValid: e.isValid });
|
|
10644
11134
|
});
|
|
10645
11135
|
rewardAd.onError((e) => {
|
|
11136
|
+
this._isLoading = false;
|
|
10646
11137
|
const { code, message } = e;
|
|
10647
11138
|
const data = { code: code, errMsg: message };
|
|
10648
11139
|
this._adError = message;
|
|
@@ -10671,18 +11162,25 @@ var serviceContext = (function () {
|
|
|
10671
11162
|
|
|
10672
11163
|
load () {
|
|
10673
11164
|
return new Promise((resolve, reject) => {
|
|
11165
|
+
this._loadPromiseResolve = resolve;
|
|
11166
|
+
this._loadPromiseReject = reject;
|
|
11167
|
+
if (this._isLoading) {
|
|
11168
|
+
return
|
|
11169
|
+
}
|
|
10674
11170
|
if (this._isLoad) {
|
|
10675
11171
|
resolve();
|
|
10676
11172
|
return
|
|
10677
11173
|
}
|
|
10678
|
-
this._loadPromiseResolve = resolve;
|
|
10679
|
-
this._loadPromiseReject = reject;
|
|
10680
11174
|
this._loadAd();
|
|
10681
11175
|
})
|
|
10682
11176
|
}
|
|
10683
11177
|
|
|
10684
11178
|
show () {
|
|
10685
11179
|
return new Promise((resolve, reject) => {
|
|
11180
|
+
if (this._isLoading) {
|
|
11181
|
+
return
|
|
11182
|
+
}
|
|
11183
|
+
|
|
10686
11184
|
const provider = this.getProvider();
|
|
10687
11185
|
if (provider === ProviderType.CSJ && this.isExpired) {
|
|
10688
11186
|
this._isLoad = false;
|
|
@@ -10711,6 +11209,7 @@ var serviceContext = (function () {
|
|
|
10711
11209
|
|
|
10712
11210
|
_loadAd () {
|
|
10713
11211
|
this._isLoad = false;
|
|
11212
|
+
this._isLoading = true;
|
|
10714
11213
|
this._rewardAd.load();
|
|
10715
11214
|
}
|
|
10716
11215
|
|
|
@@ -10727,15 +11226,22 @@ var serviceContext = (function () {
|
|
|
10727
11226
|
return new RewardedVideoAd(options)
|
|
10728
11227
|
}
|
|
10729
11228
|
|
|
11229
|
+
const eventTypes = {
|
|
11230
|
+
load: 'load',
|
|
11231
|
+
close: 'close',
|
|
11232
|
+
error: 'error',
|
|
11233
|
+
adClicked: 'adClicked'
|
|
11234
|
+
};
|
|
11235
|
+
|
|
10730
11236
|
const eventNames$1 = [
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
11237
|
+
eventTypes.load,
|
|
11238
|
+
eventTypes.close,
|
|
11239
|
+
eventTypes.error,
|
|
11240
|
+
eventTypes.adClicked
|
|
10735
11241
|
];
|
|
10736
11242
|
|
|
10737
|
-
class
|
|
10738
|
-
constructor (options
|
|
11243
|
+
class AdBase {
|
|
11244
|
+
constructor (adInstance, options) {
|
|
10739
11245
|
const _callbacks = this._callbacks = {};
|
|
10740
11246
|
eventNames$1.forEach(item => {
|
|
10741
11247
|
_callbacks[item] = [];
|
|
@@ -10745,82 +11251,126 @@ var serviceContext = (function () {
|
|
|
10745
11251
|
};
|
|
10746
11252
|
});
|
|
10747
11253
|
|
|
10748
|
-
this.
|
|
11254
|
+
this._preload = options.preload !== undefined ? options.preload : false;
|
|
11255
|
+
|
|
11256
|
+
this._isLoaded = false;
|
|
11257
|
+
this._isLoading = false;
|
|
10749
11258
|
this._adError = '';
|
|
10750
11259
|
this._loadPromiseResolve = null;
|
|
10751
11260
|
this._loadPromiseReject = null;
|
|
10752
|
-
this.
|
|
11261
|
+
this._showPromiseResolve = null;
|
|
11262
|
+
this._showPromiseReject = null;
|
|
10753
11263
|
|
|
10754
|
-
const ad = this._ad =
|
|
11264
|
+
const ad = this._ad = adInstance;
|
|
10755
11265
|
ad.onLoad((e) => {
|
|
10756
|
-
this.
|
|
10757
|
-
this.
|
|
10758
|
-
this._dispatchEvent('load', {});
|
|
11266
|
+
this._isLoaded = true;
|
|
11267
|
+
this._isLoading = false;
|
|
10759
11268
|
|
|
10760
11269
|
if (this._loadPromiseResolve != null) {
|
|
10761
11270
|
this._loadPromiseResolve();
|
|
10762
11271
|
this._loadPromiseResolve = null;
|
|
10763
11272
|
}
|
|
11273
|
+
if (this._showPromiseResolve != null) {
|
|
11274
|
+
this._showPromiseResolve();
|
|
11275
|
+
this._showPromiseResolve = null;
|
|
11276
|
+
this._showAd();
|
|
11277
|
+
}
|
|
11278
|
+
|
|
11279
|
+
this._dispatchEvent(eventTypes.load, {});
|
|
10764
11280
|
});
|
|
10765
11281
|
ad.onClose((e) => {
|
|
10766
|
-
this.
|
|
10767
|
-
this.
|
|
11282
|
+
this._isLoaded = false;
|
|
11283
|
+
this._isLoading = false;
|
|
11284
|
+
this._dispatchEvent(eventTypes.close, { isEnded: e.isEnded });
|
|
11285
|
+
|
|
11286
|
+
if (this._preload === true) {
|
|
11287
|
+
this._loadAd();
|
|
11288
|
+
}
|
|
10768
11289
|
});
|
|
10769
11290
|
ad.onError((e) => {
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
}
|
|
10776
|
-
|
|
11291
|
+
this._isLoading = false;
|
|
11292
|
+
|
|
11293
|
+
const data = {
|
|
11294
|
+
code: e.code,
|
|
11295
|
+
errMsg: e.message
|
|
11296
|
+
};
|
|
11297
|
+
|
|
11298
|
+
this._adError = data;
|
|
11299
|
+
|
|
11300
|
+
this._dispatchEvent(eventTypes.error, data);
|
|
11301
|
+
|
|
11302
|
+
const error = new Error(JSON.stringify(this._adError));
|
|
11303
|
+
error.code = e.code;
|
|
11304
|
+
error.errMsg = e.message;
|
|
10777
11305
|
|
|
10778
11306
|
if (this._loadPromiseReject != null) {
|
|
10779
|
-
this._loadPromiseReject(
|
|
11307
|
+
this._loadPromiseReject(error);
|
|
10780
11308
|
this._loadPromiseReject = null;
|
|
10781
11309
|
}
|
|
11310
|
+
|
|
11311
|
+
if (this._showPromiseReject != null) {
|
|
11312
|
+
this._showPromiseReject(error);
|
|
11313
|
+
this._showPromiseReject = null;
|
|
11314
|
+
}
|
|
10782
11315
|
});
|
|
10783
|
-
ad.onAdClicked((e) => {
|
|
10784
|
-
this._dispatchEvent(
|
|
11316
|
+
ad.onAdClicked && ad.onAdClicked((e) => {
|
|
11317
|
+
this._dispatchEvent(eventTypes.adClicked, {});
|
|
10785
11318
|
});
|
|
10786
11319
|
}
|
|
10787
11320
|
|
|
10788
11321
|
load () {
|
|
10789
11322
|
return new Promise((resolve, reject) => {
|
|
10790
|
-
if (this._isLoad) {
|
|
10791
|
-
resolve();
|
|
10792
|
-
return
|
|
10793
|
-
}
|
|
10794
11323
|
this._loadPromiseResolve = resolve;
|
|
10795
11324
|
this._loadPromiseReject = reject;
|
|
10796
|
-
this.
|
|
11325
|
+
if (this._isLoading) {
|
|
11326
|
+
return
|
|
11327
|
+
}
|
|
11328
|
+
|
|
11329
|
+
if (this._isLoaded) {
|
|
11330
|
+
resolve();
|
|
11331
|
+
} else {
|
|
11332
|
+
this._loadAd();
|
|
11333
|
+
}
|
|
10797
11334
|
})
|
|
10798
11335
|
}
|
|
10799
11336
|
|
|
10800
11337
|
show () {
|
|
10801
11338
|
return new Promise((resolve, reject) => {
|
|
10802
|
-
|
|
10803
|
-
|
|
11339
|
+
this._showPromiseResolve = resolve;
|
|
11340
|
+
this._showPromiseReject = reject;
|
|
11341
|
+
|
|
11342
|
+
if (this._isLoading) {
|
|
11343
|
+
return
|
|
11344
|
+
}
|
|
11345
|
+
|
|
11346
|
+
if (this._isLoaded) {
|
|
11347
|
+
this._showAd();
|
|
10804
11348
|
resolve();
|
|
10805
11349
|
} else {
|
|
10806
|
-
|
|
11350
|
+
this._loadAd();
|
|
10807
11351
|
}
|
|
10808
11352
|
})
|
|
10809
11353
|
}
|
|
10810
11354
|
|
|
10811
|
-
getProvider () {
|
|
10812
|
-
return this._ad.getProvider()
|
|
10813
|
-
}
|
|
10814
|
-
|
|
10815
11355
|
destroy () {
|
|
10816
11356
|
this._ad.destroy();
|
|
10817
11357
|
}
|
|
10818
11358
|
|
|
11359
|
+
getProvider () {
|
|
11360
|
+
return this._ad.getProvider()
|
|
11361
|
+
}
|
|
11362
|
+
|
|
10819
11363
|
_loadAd () {
|
|
10820
|
-
this.
|
|
11364
|
+
this._adError = '';
|
|
11365
|
+
this._isLoaded = false;
|
|
11366
|
+
this._isLoading = true;
|
|
10821
11367
|
this._ad.load();
|
|
10822
11368
|
}
|
|
10823
11369
|
|
|
11370
|
+
_showAd () {
|
|
11371
|
+
this._ad.show();
|
|
11372
|
+
}
|
|
11373
|
+
|
|
10824
11374
|
_dispatchEvent (name, data) {
|
|
10825
11375
|
this._callbacks[name].forEach(callback => {
|
|
10826
11376
|
if (typeof callback === 'function') {
|
|
@@ -10830,10 +11380,277 @@ var serviceContext = (function () {
|
|
|
10830
11380
|
}
|
|
10831
11381
|
}
|
|
10832
11382
|
|
|
11383
|
+
class FullScreenVideoAd extends AdBase {
|
|
11384
|
+
constructor (options = {}) {
|
|
11385
|
+
super(plus.ad.createFullScreenVideoAd(options), options);
|
|
11386
|
+
}
|
|
11387
|
+
}
|
|
11388
|
+
|
|
10833
11389
|
function createFullScreenVideoAd (options) {
|
|
10834
11390
|
return new FullScreenVideoAd(options)
|
|
10835
11391
|
}
|
|
10836
11392
|
|
|
11393
|
+
class InterstitialAd extends AdBase {
|
|
11394
|
+
constructor (options = {}) {
|
|
11395
|
+
super(plus.ad.createInterstitialAd(options), options);
|
|
11396
|
+
|
|
11397
|
+
this._loadAd();
|
|
11398
|
+
}
|
|
11399
|
+
}
|
|
11400
|
+
|
|
11401
|
+
function createInterstitialAd (options) {
|
|
11402
|
+
return new InterstitialAd(options)
|
|
11403
|
+
}
|
|
11404
|
+
|
|
11405
|
+
const sdkCache = {};
|
|
11406
|
+
const sdkQueue = {};
|
|
11407
|
+
|
|
11408
|
+
function initSDK (options) {
|
|
11409
|
+
const provider = options.provider;
|
|
11410
|
+
if (!sdkCache[provider]) {
|
|
11411
|
+
sdkCache[provider] = {};
|
|
11412
|
+
}
|
|
11413
|
+
if (typeof sdkCache[provider].instance === 'object') {
|
|
11414
|
+
options.success(sdkCache[provider].instance);
|
|
11415
|
+
return
|
|
11416
|
+
}
|
|
11417
|
+
|
|
11418
|
+
if (!sdkQueue[provider]) {
|
|
11419
|
+
sdkQueue[provider] = [];
|
|
11420
|
+
}
|
|
11421
|
+
sdkQueue[provider].push(options);
|
|
11422
|
+
|
|
11423
|
+
if (sdkCache[provider].loading === true) {
|
|
11424
|
+
options.__plugin = sdkCache[provider].plugin;
|
|
11425
|
+
return
|
|
11426
|
+
}
|
|
11427
|
+
sdkCache[provider].loading = true;
|
|
11428
|
+
const plugin = requireNativePlugin(provider) || {};
|
|
11429
|
+
const initFunction = plugin.init || plugin.initSDK;
|
|
11430
|
+
if (!initFunction) {
|
|
11431
|
+
sdkQueue[provider].forEach((item) => {
|
|
11432
|
+
item.fail({
|
|
11433
|
+
code: -1,
|
|
11434
|
+
message: 'provider [' + provider + '] invalid'
|
|
11435
|
+
});
|
|
11436
|
+
});
|
|
11437
|
+
sdkQueue[provider].length = 0;
|
|
11438
|
+
sdkCache[provider].loading = false;
|
|
11439
|
+
return
|
|
11440
|
+
}
|
|
11441
|
+
sdkCache[provider].plugin = plugin;
|
|
11442
|
+
options.__plugin = plugin;
|
|
11443
|
+
initFunction((res) => {
|
|
11444
|
+
const code = res.code;
|
|
11445
|
+
const isSuccess = (provider === 'BXM-AD') ? (code === 0 || code === 1) : (code === 0);
|
|
11446
|
+
if (isSuccess) {
|
|
11447
|
+
sdkCache[provider].instance = plugin;
|
|
11448
|
+
} else {
|
|
11449
|
+
sdkCache[provider].loading = false;
|
|
11450
|
+
}
|
|
11451
|
+
|
|
11452
|
+
sdkQueue[provider].forEach((item) => {
|
|
11453
|
+
if (isSuccess) {
|
|
11454
|
+
item.success(item.__plugin);
|
|
11455
|
+
} else {
|
|
11456
|
+
item.fail(res);
|
|
11457
|
+
}
|
|
11458
|
+
});
|
|
11459
|
+
sdkQueue[provider].length = 0;
|
|
11460
|
+
});
|
|
11461
|
+
}
|
|
11462
|
+
|
|
11463
|
+
class InteractiveAd {
|
|
11464
|
+
constructor (options) {
|
|
11465
|
+
const _callbacks = this._callbacks = {};
|
|
11466
|
+
eventNames$1.forEach(item => {
|
|
11467
|
+
_callbacks[item] = [];
|
|
11468
|
+
const name = item[0].toUpperCase() + item.substr(1);
|
|
11469
|
+
this[`on${name}`] = function (callback) {
|
|
11470
|
+
_callbacks[item].push(callback);
|
|
11471
|
+
};
|
|
11472
|
+
});
|
|
11473
|
+
|
|
11474
|
+
this._ad = null;
|
|
11475
|
+
this._adError = '';
|
|
11476
|
+
this._adpid = options.adpid;
|
|
11477
|
+
this._provider = options.provider;
|
|
11478
|
+
this._userData = options.userData || {};
|
|
11479
|
+
this._isLoaded = false;
|
|
11480
|
+
this._isLoading = false;
|
|
11481
|
+
this._loadPromiseResolve = null;
|
|
11482
|
+
this._loadPromiseReject = null;
|
|
11483
|
+
this._showPromiseResolve = null;
|
|
11484
|
+
this._showPromiseReject = null;
|
|
11485
|
+
|
|
11486
|
+
setTimeout(() => {
|
|
11487
|
+
this._init();
|
|
11488
|
+
});
|
|
11489
|
+
}
|
|
11490
|
+
|
|
11491
|
+
_init () {
|
|
11492
|
+
this._adError = '';
|
|
11493
|
+
initSDK({
|
|
11494
|
+
provider: this._provider,
|
|
11495
|
+
success: (res) => {
|
|
11496
|
+
this._ad = res;
|
|
11497
|
+
if (this._userData) {
|
|
11498
|
+
this.bindUserData(this._userData);
|
|
11499
|
+
}
|
|
11500
|
+
this._loadAd();
|
|
11501
|
+
},
|
|
11502
|
+
fail: (err) => {
|
|
11503
|
+
this._adError = err;
|
|
11504
|
+
this._dispatchEvent(eventTypes.error, err);
|
|
11505
|
+
}
|
|
11506
|
+
});
|
|
11507
|
+
}
|
|
11508
|
+
|
|
11509
|
+
getProvider () {
|
|
11510
|
+
return this._provider
|
|
11511
|
+
}
|
|
11512
|
+
|
|
11513
|
+
load () {
|
|
11514
|
+
return new Promise((resolve, reject) => {
|
|
11515
|
+
this._loadPromiseResolve = resolve;
|
|
11516
|
+
this._loadPromiseReject = reject;
|
|
11517
|
+
if (this._isLoading) {
|
|
11518
|
+
return
|
|
11519
|
+
}
|
|
11520
|
+
|
|
11521
|
+
if (this._adError) {
|
|
11522
|
+
this._init();
|
|
11523
|
+
return
|
|
11524
|
+
}
|
|
11525
|
+
|
|
11526
|
+
if (this._isLoaded) {
|
|
11527
|
+
resolve();
|
|
11528
|
+
} else {
|
|
11529
|
+
this._loadAd();
|
|
11530
|
+
}
|
|
11531
|
+
})
|
|
11532
|
+
}
|
|
11533
|
+
|
|
11534
|
+
show () {
|
|
11535
|
+
return new Promise((resolve, reject) => {
|
|
11536
|
+
this._showPromiseResolve = resolve;
|
|
11537
|
+
this._showPromiseReject = reject;
|
|
11538
|
+
|
|
11539
|
+
if (this._isLoading) {
|
|
11540
|
+
return
|
|
11541
|
+
}
|
|
11542
|
+
|
|
11543
|
+
if (this._adError) {
|
|
11544
|
+
this._init();
|
|
11545
|
+
return
|
|
11546
|
+
}
|
|
11547
|
+
|
|
11548
|
+
if (this._isLoaded) {
|
|
11549
|
+
this._showAd();
|
|
11550
|
+
resolve();
|
|
11551
|
+
} else {
|
|
11552
|
+
this._loadAd();
|
|
11553
|
+
}
|
|
11554
|
+
})
|
|
11555
|
+
}
|
|
11556
|
+
|
|
11557
|
+
destroy () {
|
|
11558
|
+
if (this._ad !== null && this._ad.destroy) {
|
|
11559
|
+
this._ad.destroy({
|
|
11560
|
+
adpid: this._adpid
|
|
11561
|
+
});
|
|
11562
|
+
}
|
|
11563
|
+
}
|
|
11564
|
+
|
|
11565
|
+
bindUserData (data) {
|
|
11566
|
+
if (this._ad !== null && this._ad.bindUserData) {
|
|
11567
|
+
this._ad.bindUserData(data);
|
|
11568
|
+
}
|
|
11569
|
+
}
|
|
11570
|
+
|
|
11571
|
+
_loadAd () {
|
|
11572
|
+
if (this._ad !== null) {
|
|
11573
|
+
if (this._isLoading === true) {
|
|
11574
|
+
return
|
|
11575
|
+
}
|
|
11576
|
+
this._isLoading = true;
|
|
11577
|
+
|
|
11578
|
+
this._ad.loadData({
|
|
11579
|
+
adpid: this._adpid,
|
|
11580
|
+
...this._userData
|
|
11581
|
+
}, (res) => {
|
|
11582
|
+
this._isLoaded = true;
|
|
11583
|
+
this._isLoading = false;
|
|
11584
|
+
|
|
11585
|
+
if (this._loadPromiseResolve != null) {
|
|
11586
|
+
this._loadPromiseResolve();
|
|
11587
|
+
this._loadPromiseResolve = null;
|
|
11588
|
+
}
|
|
11589
|
+
if (this._showPromiseResolve != null) {
|
|
11590
|
+
this._showPromiseResolve();
|
|
11591
|
+
this._showPromiseResolve = null;
|
|
11592
|
+
this._showAd();
|
|
11593
|
+
}
|
|
11594
|
+
|
|
11595
|
+
this._dispatchEvent(eventTypes.load, res);
|
|
11596
|
+
}, (err) => {
|
|
11597
|
+
this._isLoading = false;
|
|
11598
|
+
|
|
11599
|
+
if (this._showPromiseReject != null) {
|
|
11600
|
+
this._showPromiseReject(this._createError(err));
|
|
11601
|
+
this._showPromiseReject = null;
|
|
11602
|
+
}
|
|
11603
|
+
|
|
11604
|
+
this._dispatchEvent(eventTypes.error, err);
|
|
11605
|
+
});
|
|
11606
|
+
}
|
|
11607
|
+
}
|
|
11608
|
+
|
|
11609
|
+
_showAd () {
|
|
11610
|
+
if (this._ad !== null && this._isLoaded === true) {
|
|
11611
|
+
this._ad.show({
|
|
11612
|
+
adpid: this._adpid
|
|
11613
|
+
}, (res) => {
|
|
11614
|
+
this._isLoaded = false;
|
|
11615
|
+
}, (err) => {
|
|
11616
|
+
this._isLoaded = false;
|
|
11617
|
+
|
|
11618
|
+
if (this._showPromiseReject != null) {
|
|
11619
|
+
this._showPromiseReject(this._createError(err));
|
|
11620
|
+
this._showPromiseReject = null;
|
|
11621
|
+
}
|
|
11622
|
+
|
|
11623
|
+
this._dispatchEvent(eventTypes.error, err);
|
|
11624
|
+
});
|
|
11625
|
+
}
|
|
11626
|
+
}
|
|
11627
|
+
|
|
11628
|
+
_createError (err) {
|
|
11629
|
+
const error = new Error(JSON.stringify(err));
|
|
11630
|
+
error.code = err.code;
|
|
11631
|
+
error.errMsg = err.message;
|
|
11632
|
+
return error
|
|
11633
|
+
}
|
|
11634
|
+
|
|
11635
|
+
_dispatchEvent (name, data) {
|
|
11636
|
+
this._callbacks[name].forEach(callback => {
|
|
11637
|
+
if (typeof callback === 'function') {
|
|
11638
|
+
callback(data || {});
|
|
11639
|
+
}
|
|
11640
|
+
});
|
|
11641
|
+
}
|
|
11642
|
+
}
|
|
11643
|
+
|
|
11644
|
+
function createInteractiveAd (options) {
|
|
11645
|
+
if (!options.provider) {
|
|
11646
|
+
return new Error('provider invalid')
|
|
11647
|
+
}
|
|
11648
|
+
if (!options.adpid) {
|
|
11649
|
+
return new Error('adpid invalid')
|
|
11650
|
+
}
|
|
11651
|
+
return new InteractiveAd(options)
|
|
11652
|
+
}
|
|
11653
|
+
|
|
10837
11654
|
var api = /*#__PURE__*/Object.freeze({
|
|
10838
11655
|
__proto__: null,
|
|
10839
11656
|
startPullDownRefresh: startPullDownRefresh,
|
|
@@ -10920,7 +11737,7 @@ var serviceContext = (function () {
|
|
|
10920
11737
|
stopVoice: stopVoice,
|
|
10921
11738
|
chooseImage: chooseImage$1,
|
|
10922
11739
|
chooseVideo: chooseVideo$1,
|
|
10923
|
-
compressImage: compressImage$
|
|
11740
|
+
compressImage: compressImage$1,
|
|
10924
11741
|
compressVideo: compressVideo$1,
|
|
10925
11742
|
getImageInfo: getImageInfo$1,
|
|
10926
11743
|
getVideoInfo: getVideoInfo$1,
|
|
@@ -10933,6 +11750,7 @@ var serviceContext = (function () {
|
|
|
10933
11750
|
createRequestTaskById: createRequestTaskById,
|
|
10934
11751
|
createRequestTask: createRequestTask,
|
|
10935
11752
|
operateRequestTask: operateRequestTask,
|
|
11753
|
+
configMTLS: configMTLS$1,
|
|
10936
11754
|
createSocketTask: createSocketTask,
|
|
10937
11755
|
operateSocketTask: operateSocketTask,
|
|
10938
11756
|
operateUploadTask: operateUploadTask,
|
|
@@ -10940,9 +11758,12 @@ var serviceContext = (function () {
|
|
|
10940
11758
|
getProvider: getProvider$1,
|
|
10941
11759
|
login: login,
|
|
10942
11760
|
getUserInfo: getUserInfo,
|
|
11761
|
+
getUserProfile: getUserProfile,
|
|
10943
11762
|
operateWXData: operateWXData,
|
|
10944
11763
|
preLogin: preLogin$1,
|
|
10945
11764
|
closeAuthView: closeAuthView,
|
|
11765
|
+
getCheckBoxState: getCheckBoxState,
|
|
11766
|
+
getUniverifyManager: getUniverifyManager,
|
|
10946
11767
|
requestPayment: requestPayment,
|
|
10947
11768
|
subscribePush: subscribePush,
|
|
10948
11769
|
unsubscribePush: unsubscribePush,
|
|
@@ -10995,7 +11816,9 @@ var serviceContext = (function () {
|
|
|
10995
11816
|
showTabBar: showTabBar$2,
|
|
10996
11817
|
requestComponentInfo: requestComponentInfo$2,
|
|
10997
11818
|
createRewardedVideoAd: createRewardedVideoAd,
|
|
10998
|
-
createFullScreenVideoAd: createFullScreenVideoAd
|
|
11819
|
+
createFullScreenVideoAd: createFullScreenVideoAd,
|
|
11820
|
+
createInterstitialAd: createInterstitialAd,
|
|
11821
|
+
createInteractiveAd: createInteractiveAd
|
|
10999
11822
|
});
|
|
11000
11823
|
|
|
11001
11824
|
var platformApi = Object.assign(Object.create(null), api, eventApis);
|
|
@@ -18204,8 +19027,9 @@ var serviceContext = (function () {
|
|
|
18204
19027
|
}
|
|
18205
19028
|
|
|
18206
19029
|
function Pattern (image, repetition) {
|
|
18207
|
-
this.
|
|
18208
|
-
this.
|
|
19030
|
+
this.type = 'pattern';
|
|
19031
|
+
this.data = image;
|
|
19032
|
+
this.colorStop = repetition;
|
|
18209
19033
|
}
|
|
18210
19034
|
|
|
18211
19035
|
class CanvasGradient {
|
|
@@ -18915,6 +19739,13 @@ var serviceContext = (function () {
|
|
|
18915
19739
|
constructor (id, pageVm) {
|
|
18916
19740
|
this.id = id;
|
|
18917
19741
|
this.pageVm = pageVm;
|
|
19742
|
+
}
|
|
19743
|
+
|
|
19744
|
+
on (name, callback) {
|
|
19745
|
+
operateMapPlayer$3(this.id, this.pageVm, 'on', {
|
|
19746
|
+
name,
|
|
19747
|
+
callback
|
|
19748
|
+
});
|
|
18918
19749
|
}
|
|
18919
19750
|
}
|
|
18920
19751
|
|
|
@@ -18922,7 +19753,7 @@ var serviceContext = (function () {
|
|
|
18922
19753
|
{
|
|
18923
19754
|
return plus.maps.getMapById(this.pageVm.$page.id + '-map-' + this.id)
|
|
18924
19755
|
}
|
|
18925
|
-
};
|
|
19756
|
+
};
|
|
18926
19757
|
|
|
18927
19758
|
methods.forEach(function (method) {
|
|
18928
19759
|
MapContext.prototype[method] = callback.warp(function (options, callbackId) {
|
|
@@ -20376,6 +21207,51 @@ var serviceContext = (function () {
|
|
|
20376
21207
|
loadFontFace: loadFontFace$1
|
|
20377
21208
|
});
|
|
20378
21209
|
|
|
21210
|
+
function getLocale$1 () {
|
|
21211
|
+
// 优先使用 $locale
|
|
21212
|
+
const app = getApp({
|
|
21213
|
+
allowDefault: true
|
|
21214
|
+
});
|
|
21215
|
+
if (app && app.$vm) {
|
|
21216
|
+
return app.$vm.$locale
|
|
21217
|
+
}
|
|
21218
|
+
return i18n.getLocale()
|
|
21219
|
+
}
|
|
21220
|
+
|
|
21221
|
+
function setLocale (locale) {
|
|
21222
|
+
const oldLocale = getApp().$vm.$locale;
|
|
21223
|
+
if (oldLocale !== locale) {
|
|
21224
|
+
getApp().$vm.$locale = locale;
|
|
21225
|
+
{
|
|
21226
|
+
const pages = getCurrentPages();
|
|
21227
|
+
pages.forEach((page) => {
|
|
21228
|
+
UniServiceJSBridge.publishHandler(
|
|
21229
|
+
'setLocale',
|
|
21230
|
+
locale,
|
|
21231
|
+
page.$page.id
|
|
21232
|
+
);
|
|
21233
|
+
});
|
|
21234
|
+
weex.requireModule('plus').setLanguage(locale);
|
|
21235
|
+
}
|
|
21236
|
+
callbacks$a.forEach(callbackId => {
|
|
21237
|
+
invoke$1(callbackId, { locale });
|
|
21238
|
+
});
|
|
21239
|
+
return true
|
|
21240
|
+
}
|
|
21241
|
+
return false
|
|
21242
|
+
}
|
|
21243
|
+
const callbacks$a = [];
|
|
21244
|
+
function onLocaleChange (callbackId) {
|
|
21245
|
+
callbacks$a.push(callbackId);
|
|
21246
|
+
}
|
|
21247
|
+
|
|
21248
|
+
var require_context_module_1_27 = /*#__PURE__*/Object.freeze({
|
|
21249
|
+
__proto__: null,
|
|
21250
|
+
getLocale: getLocale$1,
|
|
21251
|
+
setLocale: setLocale,
|
|
21252
|
+
onLocaleChange: onLocaleChange
|
|
21253
|
+
});
|
|
21254
|
+
|
|
20379
21255
|
function pageScrollTo$1 (args) {
|
|
20380
21256
|
const pages = getCurrentPages();
|
|
20381
21257
|
if (pages.length) {
|
|
@@ -20384,7 +21260,7 @@ var serviceContext = (function () {
|
|
|
20384
21260
|
return {}
|
|
20385
21261
|
}
|
|
20386
21262
|
|
|
20387
|
-
var
|
|
21263
|
+
var require_context_module_1_28 = /*#__PURE__*/Object.freeze({
|
|
20388
21264
|
__proto__: null,
|
|
20389
21265
|
pageScrollTo: pageScrollTo$1
|
|
20390
21266
|
});
|
|
@@ -20397,7 +21273,7 @@ var serviceContext = (function () {
|
|
|
20397
21273
|
return {}
|
|
20398
21274
|
}
|
|
20399
21275
|
|
|
20400
|
-
var
|
|
21276
|
+
var require_context_module_1_29 = /*#__PURE__*/Object.freeze({
|
|
20401
21277
|
__proto__: null,
|
|
20402
21278
|
setPageMeta: setPageMeta$1
|
|
20403
21279
|
});
|
|
@@ -20422,19 +21298,19 @@ var serviceContext = (function () {
|
|
|
20422
21298
|
|
|
20423
21299
|
const hideTabBarRedDot$1 = removeTabBarBadge$1;
|
|
20424
21300
|
|
|
20425
|
-
const callbacks$
|
|
21301
|
+
const callbacks$b = [];
|
|
20426
21302
|
|
|
20427
21303
|
onMethod('onTabBarMidButtonTap', res => {
|
|
20428
|
-
callbacks$
|
|
21304
|
+
callbacks$b.forEach(callbackId => {
|
|
20429
21305
|
invoke$1(callbackId, res);
|
|
20430
21306
|
});
|
|
20431
21307
|
});
|
|
20432
21308
|
|
|
20433
21309
|
function onTabBarMidButtonTap (callbackId) {
|
|
20434
|
-
callbacks$
|
|
21310
|
+
callbacks$b.push(callbackId);
|
|
20435
21311
|
}
|
|
20436
21312
|
|
|
20437
|
-
var
|
|
21313
|
+
var require_context_module_1_30 = /*#__PURE__*/Object.freeze({
|
|
20438
21314
|
__proto__: null,
|
|
20439
21315
|
removeTabBarBadge: removeTabBarBadge$1,
|
|
20440
21316
|
showTabBarRedDot: showTabBarRedDot$1,
|
|
@@ -20442,23 +21318,23 @@ var serviceContext = (function () {
|
|
|
20442
21318
|
onTabBarMidButtonTap: onTabBarMidButtonTap
|
|
20443
21319
|
});
|
|
20444
21320
|
|
|
20445
|
-
const callbacks$
|
|
21321
|
+
const callbacks$c = [];
|
|
20446
21322
|
onMethod('onViewDidResize', res => {
|
|
20447
|
-
callbacks$
|
|
21323
|
+
callbacks$c.forEach(callbackId => {
|
|
20448
21324
|
invoke$1(callbackId, res);
|
|
20449
21325
|
});
|
|
20450
21326
|
});
|
|
20451
21327
|
|
|
20452
21328
|
function onWindowResize (callbackId) {
|
|
20453
|
-
callbacks$
|
|
21329
|
+
callbacks$c.push(callbackId);
|
|
20454
21330
|
}
|
|
20455
21331
|
|
|
20456
21332
|
function offWindowResize (callbackId) {
|
|
20457
21333
|
// 此处和微信平台一致查询不到去掉最后一个
|
|
20458
|
-
callbacks$
|
|
21334
|
+
callbacks$c.splice(callbacks$c.indexOf(callbackId), 1);
|
|
20459
21335
|
}
|
|
20460
21336
|
|
|
20461
|
-
var
|
|
21337
|
+
var require_context_module_1_31 = /*#__PURE__*/Object.freeze({
|
|
20462
21338
|
__proto__: null,
|
|
20463
21339
|
onWindowResize: onWindowResize,
|
|
20464
21340
|
offWindowResize: offWindowResize
|
|
@@ -20496,10 +21372,11 @@ var serviceContext = (function () {
|
|
|
20496
21372
|
'./ui/create-media-query-observer.js': require_context_module_1_24,
|
|
20497
21373
|
'./ui/create-selector-query.js': require_context_module_1_25,
|
|
20498
21374
|
'./ui/load-font-face.js': require_context_module_1_26,
|
|
20499
|
-
'./ui/
|
|
20500
|
-
'./ui/
|
|
20501
|
-
'./ui/
|
|
20502
|
-
'./ui/
|
|
21375
|
+
'./ui/locale.js': require_context_module_1_27,
|
|
21376
|
+
'./ui/page-scroll-to.js': require_context_module_1_28,
|
|
21377
|
+
'./ui/set-page-meta.js': require_context_module_1_29,
|
|
21378
|
+
'./ui/tab-bar.js': require_context_module_1_30,
|
|
21379
|
+
'./ui/window.js': require_context_module_1_31,
|
|
20503
21380
|
|
|
20504
21381
|
};
|
|
20505
21382
|
var req = function req(key) {
|
|
@@ -20538,6 +21415,9 @@ var serviceContext = (function () {
|
|
|
20538
21415
|
}
|
|
20539
21416
|
const evalJSCode =
|
|
20540
21417
|
`typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${eventType}",${args},__PAGE_ID__)`;
|
|
21418
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
21419
|
+
console.log(`UNIAPP[publishHandler]:[${+new Date()}]`, 'length', evalJSCode.length);
|
|
21420
|
+
}
|
|
20541
21421
|
pageIds.forEach(id => {
|
|
20542
21422
|
const webview = plus.webview.getWebviewById(String(id));
|
|
20543
21423
|
webview && webview.evalJS(evalJSCode.replace('__PAGE_ID__', id));
|
|
@@ -20992,10 +21872,15 @@ var serviceContext = (function () {
|
|
|
20992
21872
|
});
|
|
20993
21873
|
});
|
|
20994
21874
|
|
|
21875
|
+
let keyboardHeightChange = 0;
|
|
20995
21876
|
plus.globalEvent.addEventListener('KeyboardHeightChange', function (event) {
|
|
20996
|
-
|
|
20997
|
-
|
|
20998
|
-
|
|
21877
|
+
// 安卓设备首次获取高度为 0
|
|
21878
|
+
if (keyboardHeightChange !== event.height) {
|
|
21879
|
+
keyboardHeightChange = event.height;
|
|
21880
|
+
publish('onKeyboardHeightChange', {
|
|
21881
|
+
height: keyboardHeightChange
|
|
21882
|
+
});
|
|
21883
|
+
}
|
|
20999
21884
|
});
|
|
21000
21885
|
|
|
21001
21886
|
globalEvent.addEventListener('uistylechange', function (event) {
|
|
@@ -21041,6 +21926,12 @@ var serviceContext = (function () {
|
|
|
21041
21926
|
|
|
21042
21927
|
callAppHook(appVm, 'onLaunch', args);
|
|
21043
21928
|
callAppHook(appVm, 'onShow', args);
|
|
21929
|
+
// https://tower.im/teams/226535/todos/16905/
|
|
21930
|
+
const getAppState = weex.requireModule('plus').getAppState;
|
|
21931
|
+
const appState = getAppState && Number(getAppState());
|
|
21932
|
+
if (appState === 2) {
|
|
21933
|
+
callAppHook(appVm, 'onHide', args);
|
|
21934
|
+
}
|
|
21044
21935
|
}
|
|
21045
21936
|
|
|
21046
21937
|
function initTabBar () {
|
|
@@ -21101,12 +21992,13 @@ var serviceContext = (function () {
|
|
|
21101
21992
|
});
|
|
21102
21993
|
}
|
|
21103
21994
|
|
|
21104
|
-
function registerApp (appVm) {
|
|
21995
|
+
function registerApp (appVm, Vue) {
|
|
21105
21996
|
if (process.env.NODE_ENV !== 'production') {
|
|
21106
21997
|
console.log('[uni-app] registerApp');
|
|
21107
21998
|
}
|
|
21108
21999
|
appCtx = appVm;
|
|
21109
22000
|
appCtx.$vm = appVm;
|
|
22001
|
+
initAppLocale(Vue, appVm);
|
|
21110
22002
|
|
|
21111
22003
|
Object.assign(appCtx, defaultApp); // 拷贝默认实现
|
|
21112
22004
|
|
|
@@ -21933,7 +22825,7 @@ var serviceContext = (function () {
|
|
|
21933
22825
|
|
|
21934
22826
|
return {
|
|
21935
22827
|
version: VD_SYNC_VERSION,
|
|
21936
|
-
locale: plus.
|
|
22828
|
+
locale: weex.requireModule('plus').getLanguage(),
|
|
21937
22829
|
disableScroll,
|
|
21938
22830
|
onPageScroll,
|
|
21939
22831
|
onPageReachBottom,
|
|
@@ -22010,6 +22902,8 @@ var serviceContext = (function () {
|
|
|
22010
22902
|
|
|
22011
22903
|
initPolyfill(Vue);
|
|
22012
22904
|
|
|
22905
|
+
uniIdMixin(Vue);
|
|
22906
|
+
|
|
22013
22907
|
Vue.prototype.getOpenerEventChannel = function () {
|
|
22014
22908
|
if (!this.$root.$scope.eventChannel) {
|
|
22015
22909
|
this.$root.$scope.eventChannel = new EventChannel();
|
|
@@ -22045,12 +22939,12 @@ var serviceContext = (function () {
|
|
|
22045
22939
|
console.log('[uni-app] launchApp');
|
|
22046
22940
|
}
|
|
22047
22941
|
plus.updateConfigInfo && plus.updateConfigInfo();
|
|
22048
|
-
registerApp(this);
|
|
22942
|
+
registerApp(this, Vue);
|
|
22049
22943
|
oldMount.call(this, el, hydrating);
|
|
22050
22944
|
});
|
|
22051
22945
|
return
|
|
22052
22946
|
}
|
|
22053
|
-
registerApp(this);
|
|
22947
|
+
registerApp(this, Vue);
|
|
22054
22948
|
}
|
|
22055
22949
|
return oldMount.call(this, el, hydrating)
|
|
22056
22950
|
};
|
|
@@ -22075,6 +22969,8 @@ var serviceContext = (function () {
|
|
|
22075
22969
|
}
|
|
22076
22970
|
};
|
|
22077
22971
|
|
|
22972
|
+
initI18n();
|
|
22973
|
+
|
|
22078
22974
|
// 挂靠在uni上,暂不做全局导出
|
|
22079
22975
|
uni$1.__$wx__ = wx;
|
|
22080
22976
|
|
|
@@ -22089,7 +22985,8 @@ var serviceContext = (function () {
|
|
|
22089
22985
|
__registerPage: registerPage,
|
|
22090
22986
|
uni: uni$1,
|
|
22091
22987
|
getApp: getApp$1,
|
|
22092
|
-
getCurrentPages: getCurrentPages$1
|
|
22988
|
+
getCurrentPages: getCurrentPages$1,
|
|
22989
|
+
EventChannel
|
|
22093
22990
|
};
|
|
22094
22991
|
|
|
22095
22992
|
return index$1;
|