@dcloudio/uni-mp-alipay 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/index.js +384 -118
- package/dist/uni.api.esm.js +645 -270
- package/dist/uni.mp.esm.js +501 -172
- package/lib/uni.config.js +12 -1
- package/package.json +2 -2
package/dist/uni.mp.esm.js
CHANGED
|
@@ -1,4 +1,296 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPlainObject, isArray, extend, hyphenate, isObject, hasOwn, toNumber, capitalize, isFunction, NOOP, EMPTY_OBJ, camelize } from '@vue/shared';
|
|
2
|
+
import { onUnmounted, injectHook, ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
const encode = encodeURIComponent;
|
|
5
|
+
function stringifyQuery(obj, encodeStr = encode) {
|
|
6
|
+
const res = obj
|
|
7
|
+
? Object.keys(obj)
|
|
8
|
+
.map((key) => {
|
|
9
|
+
let val = obj[key];
|
|
10
|
+
if (typeof val === undefined || val === null) {
|
|
11
|
+
val = '';
|
|
12
|
+
}
|
|
13
|
+
else if (isPlainObject(val)) {
|
|
14
|
+
val = JSON.stringify(val);
|
|
15
|
+
}
|
|
16
|
+
return encodeStr(key) + '=' + encodeStr(val);
|
|
17
|
+
})
|
|
18
|
+
.filter((x) => x.length > 0)
|
|
19
|
+
.join('&')
|
|
20
|
+
: null;
|
|
21
|
+
return res ? `?${res}` : '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function cache(fn) {
|
|
25
|
+
const cache = Object.create(null);
|
|
26
|
+
return (str) => {
|
|
27
|
+
const hit = cache[str];
|
|
28
|
+
return hit || (cache[str] = fn(str));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const invokeArrayFns = (fns, arg) => {
|
|
32
|
+
let ret;
|
|
33
|
+
for (let i = 0; i < fns.length; i++) {
|
|
34
|
+
ret = fns[i](arg);
|
|
35
|
+
}
|
|
36
|
+
return ret;
|
|
37
|
+
};
|
|
38
|
+
// lifecycle
|
|
39
|
+
// App and Page
|
|
40
|
+
const ON_SHOW = 'onShow';
|
|
41
|
+
const ON_HIDE = 'onHide';
|
|
42
|
+
//App
|
|
43
|
+
const ON_LAUNCH = 'onLaunch';
|
|
44
|
+
const ON_ERROR = 'onError';
|
|
45
|
+
const ON_THEME_CHANGE = 'onThemeChange';
|
|
46
|
+
const ON_PAGE_NOT_FOUND = 'onPageNotFound';
|
|
47
|
+
const ON_UNHANDLE_REJECTION = 'onUnhandledRejection';
|
|
48
|
+
//Page
|
|
49
|
+
const ON_LOAD = 'onLoad';
|
|
50
|
+
const ON_READY = 'onReady';
|
|
51
|
+
const ON_UNLOAD = 'onUnload';
|
|
52
|
+
const ON_RESIZE = 'onResize';
|
|
53
|
+
const ON_BACK_PRESS = 'onBackPress';
|
|
54
|
+
const ON_TAB_ITEM_TAP = 'onTabItemTap';
|
|
55
|
+
const ON_REACH_BOTTOM = 'onReachBottom';
|
|
56
|
+
const ON_PULL_DOWN_REFRESH = 'onPullDownRefresh';
|
|
57
|
+
const ON_ADD_TO_FAVORITES = 'onAddToFavorites';
|
|
58
|
+
const ON_SHARE_APP_MESSAGE = 'onShareAppMessage';
|
|
59
|
+
|
|
60
|
+
class EventChannel {
|
|
61
|
+
constructor(id, events) {
|
|
62
|
+
this.id = id;
|
|
63
|
+
this.listener = {};
|
|
64
|
+
this.emitCache = {};
|
|
65
|
+
if (events) {
|
|
66
|
+
Object.keys(events).forEach((name) => {
|
|
67
|
+
this.on(name, events[name]);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
emit(eventName, ...args) {
|
|
72
|
+
const fns = this.listener[eventName];
|
|
73
|
+
if (!fns) {
|
|
74
|
+
return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args);
|
|
75
|
+
}
|
|
76
|
+
fns.forEach((opt) => {
|
|
77
|
+
opt.fn.apply(opt.fn, args);
|
|
78
|
+
});
|
|
79
|
+
this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
|
|
80
|
+
}
|
|
81
|
+
on(eventName, fn) {
|
|
82
|
+
this._addListener(eventName, 'on', fn);
|
|
83
|
+
this._clearCache(eventName);
|
|
84
|
+
}
|
|
85
|
+
once(eventName, fn) {
|
|
86
|
+
this._addListener(eventName, 'once', fn);
|
|
87
|
+
this._clearCache(eventName);
|
|
88
|
+
}
|
|
89
|
+
off(eventName, fn) {
|
|
90
|
+
const fns = this.listener[eventName];
|
|
91
|
+
if (!fns) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (fn) {
|
|
95
|
+
for (let i = 0; i < fns.length;) {
|
|
96
|
+
if (fns[i].fn === fn) {
|
|
97
|
+
fns.splice(i, 1);
|
|
98
|
+
i--;
|
|
99
|
+
}
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
delete this.listener[eventName];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_clearCache(eventName) {
|
|
108
|
+
const cacheArgs = this.emitCache[eventName];
|
|
109
|
+
if (cacheArgs) {
|
|
110
|
+
for (; cacheArgs.length > 0;) {
|
|
111
|
+
this.emit.apply(this, [eventName, ...cacheArgs.shift()]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_addListener(eventName, type, fn) {
|
|
116
|
+
(this.listener[eventName] || (this.listener[eventName] = [])).push({
|
|
117
|
+
fn,
|
|
118
|
+
type,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const eventChannels = {};
|
|
124
|
+
const eventChannelStack = [];
|
|
125
|
+
function getEventChannel(id) {
|
|
126
|
+
if (id) {
|
|
127
|
+
const eventChannel = eventChannels[id];
|
|
128
|
+
delete eventChannels[id];
|
|
129
|
+
return eventChannel;
|
|
130
|
+
}
|
|
131
|
+
return eventChannelStack.shift();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function initVueIds(vueIds, mpInstance) {
|
|
135
|
+
if (!vueIds) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const ids = vueIds.split(',');
|
|
139
|
+
const len = ids.length;
|
|
140
|
+
if (len === 1) {
|
|
141
|
+
mpInstance._$vueId = ids[0];
|
|
142
|
+
}
|
|
143
|
+
else if (len === 2) {
|
|
144
|
+
mpInstance._$vueId = ids[0];
|
|
145
|
+
mpInstance._$vuePid = ids[1];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
149
|
+
if (!isArray(wxsCallMethods)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
wxsCallMethods.forEach((callMethod) => {
|
|
153
|
+
methods[callMethod] = function (args) {
|
|
154
|
+
return this.$vm[callMethod](args);
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function findVmByVueId(instance, vuePid) {
|
|
159
|
+
// 标准 vue3 中 没有 $children,定制了内核
|
|
160
|
+
const $children = instance.$children;
|
|
161
|
+
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
|
|
162
|
+
for (let i = $children.length - 1; i >= 0; i--) {
|
|
163
|
+
const childVm = $children[i];
|
|
164
|
+
if (childVm.$scope._$vueId === vuePid) {
|
|
165
|
+
return childVm;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// 反向递归查找
|
|
169
|
+
let parentVm;
|
|
170
|
+
for (let i = $children.length - 1; i >= 0; i--) {
|
|
171
|
+
parentVm = findVmByVueId($children[i], vuePid);
|
|
172
|
+
if (parentVm) {
|
|
173
|
+
return parentVm;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function getTarget(obj, path) {
|
|
178
|
+
const parts = path.split('.');
|
|
179
|
+
let key = parts[0];
|
|
180
|
+
if (key.indexOf('__$n') === 0) {
|
|
181
|
+
//number index
|
|
182
|
+
key = parseInt(key.replace('__$n', ''));
|
|
183
|
+
}
|
|
184
|
+
if (!obj) {
|
|
185
|
+
obj = {};
|
|
186
|
+
}
|
|
187
|
+
if (parts.length === 1) {
|
|
188
|
+
return obj[key];
|
|
189
|
+
}
|
|
190
|
+
return getTarget(obj[key], parts.slice(1).join('.'));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function getValue(dataPath, target) {
|
|
194
|
+
return getTarget(target || this, dataPath);
|
|
195
|
+
}
|
|
196
|
+
function getClass(dynamicClass, staticClass) {
|
|
197
|
+
return renderClass(staticClass, dynamicClass);
|
|
198
|
+
}
|
|
199
|
+
function getStyle(dynamicStyle, staticStyle) {
|
|
200
|
+
if (!dynamicStyle && !staticStyle) {
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
var dynamicStyleObj = normalizeStyleBinding(dynamicStyle);
|
|
204
|
+
var styleObj = staticStyle
|
|
205
|
+
? extend(staticStyle, dynamicStyleObj)
|
|
206
|
+
: dynamicStyleObj;
|
|
207
|
+
return Object.keys(styleObj)
|
|
208
|
+
.map(function (name) {
|
|
209
|
+
return hyphenate(name) + ':' + styleObj[name];
|
|
210
|
+
})
|
|
211
|
+
.join(';');
|
|
212
|
+
}
|
|
213
|
+
function toObject(arr) {
|
|
214
|
+
var res = {};
|
|
215
|
+
for (var i = 0; i < arr.length; i++) {
|
|
216
|
+
if (arr[i]) {
|
|
217
|
+
extend(res, arr[i]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return res;
|
|
221
|
+
}
|
|
222
|
+
function normalizeStyleBinding(bindingStyle) {
|
|
223
|
+
if (Array.isArray(bindingStyle)) {
|
|
224
|
+
return toObject(bindingStyle);
|
|
225
|
+
}
|
|
226
|
+
if (typeof bindingStyle === 'string') {
|
|
227
|
+
return parseStyleText(bindingStyle);
|
|
228
|
+
}
|
|
229
|
+
return bindingStyle;
|
|
230
|
+
}
|
|
231
|
+
var parseStyleText = cache(function parseStyleText(cssText) {
|
|
232
|
+
var res = {};
|
|
233
|
+
var listDelimiter = /;(?![^(]*\))/g;
|
|
234
|
+
var propertyDelimiter = /:(.+)/;
|
|
235
|
+
cssText.split(listDelimiter).forEach(function (item) {
|
|
236
|
+
if (item) {
|
|
237
|
+
var tmp = item.split(propertyDelimiter);
|
|
238
|
+
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return res;
|
|
242
|
+
});
|
|
243
|
+
function isDef(v) {
|
|
244
|
+
return v !== undefined && v !== null;
|
|
245
|
+
}
|
|
246
|
+
function renderClass(staticClass, dynamicClass) {
|
|
247
|
+
if (isDef(staticClass) || isDef(dynamicClass)) {
|
|
248
|
+
return concat(staticClass, stringifyClass(dynamicClass));
|
|
249
|
+
}
|
|
250
|
+
/* istanbul ignore next */
|
|
251
|
+
return '';
|
|
252
|
+
}
|
|
253
|
+
function concat(a, b) {
|
|
254
|
+
return a ? (b ? a + ' ' + b : a) : b || '';
|
|
255
|
+
}
|
|
256
|
+
function stringifyClass(value) {
|
|
257
|
+
if (Array.isArray(value)) {
|
|
258
|
+
return stringifyArray(value);
|
|
259
|
+
}
|
|
260
|
+
if (isObject(value)) {
|
|
261
|
+
return stringifyObject(value);
|
|
262
|
+
}
|
|
263
|
+
if (typeof value === 'string') {
|
|
264
|
+
return value;
|
|
265
|
+
}
|
|
266
|
+
/* istanbul ignore next */
|
|
267
|
+
return '';
|
|
268
|
+
}
|
|
269
|
+
function stringifyArray(value) {
|
|
270
|
+
var res = '';
|
|
271
|
+
var stringified;
|
|
272
|
+
for (var i = 0, l = value.length; i < l; i++) {
|
|
273
|
+
if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
|
|
274
|
+
if (res) {
|
|
275
|
+
res += ' ';
|
|
276
|
+
}
|
|
277
|
+
res += stringified;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return res;
|
|
281
|
+
}
|
|
282
|
+
function stringifyObject(value) {
|
|
283
|
+
var res = '';
|
|
284
|
+
for (var key in value) {
|
|
285
|
+
if (value[key]) {
|
|
286
|
+
if (res) {
|
|
287
|
+
res += ' ';
|
|
288
|
+
}
|
|
289
|
+
res += key;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return res;
|
|
293
|
+
}
|
|
2
294
|
|
|
3
295
|
function setModel(target, key, value, modifiers) {
|
|
4
296
|
if (isArray(modifiers)) {
|
|
@@ -50,7 +342,7 @@ const MP_METHODS = [
|
|
|
50
342
|
'createSelectorQuery',
|
|
51
343
|
'createIntersectionObserver',
|
|
52
344
|
'selectAllComponents',
|
|
53
|
-
'selectComponent'
|
|
345
|
+
'selectComponent',
|
|
54
346
|
];
|
|
55
347
|
function createEmitFn(oldEmit, ctx) {
|
|
56
348
|
return function emit(event, ...args) {
|
|
@@ -85,16 +377,27 @@ function initBaseInstance(instance, options) {
|
|
|
85
377
|
Object.defineProperty(instance, 'slots', {
|
|
86
378
|
get() {
|
|
87
379
|
return this.$scope && this.$scope.props.$slots;
|
|
88
|
-
}
|
|
380
|
+
},
|
|
89
381
|
});
|
|
90
382
|
}
|
|
383
|
+
ctx.getOpenerEventChannel = function () {
|
|
384
|
+
if (!this.__eventChannel__) {
|
|
385
|
+
this.__eventChannel__ = new EventChannel();
|
|
386
|
+
}
|
|
387
|
+
return this.__eventChannel__;
|
|
388
|
+
};
|
|
389
|
+
ctx.$hasHook = hasHook;
|
|
390
|
+
ctx.$callHook = callHook;
|
|
91
391
|
// $emit
|
|
92
392
|
instance.emit = createEmitFn(instance.emit, ctx);
|
|
93
393
|
}
|
|
94
394
|
function initComponentInstance(instance, options) {
|
|
95
395
|
initBaseInstance(instance, options);
|
|
396
|
+
{
|
|
397
|
+
initScopedSlotsParams(instance);
|
|
398
|
+
}
|
|
96
399
|
const ctx = instance.ctx;
|
|
97
|
-
MP_METHODS.forEach(method => {
|
|
400
|
+
MP_METHODS.forEach((method) => {
|
|
98
401
|
ctx[method] = function (...args) {
|
|
99
402
|
const mpInstance = ctx.$scope;
|
|
100
403
|
if (mpInstance && mpInstance[method]) {
|
|
@@ -110,36 +413,105 @@ function initComponentInstance(instance, options) {
|
|
|
110
413
|
ctx.__set_sync = setSync;
|
|
111
414
|
ctx.__get_orig = getOrig;
|
|
112
415
|
// TODO
|
|
113
|
-
|
|
416
|
+
ctx.__get_value = getValue;
|
|
417
|
+
ctx.__get_class = getClass;
|
|
418
|
+
ctx.__get_style = getStyle;
|
|
114
419
|
ctx.__map = map;
|
|
115
420
|
}
|
|
116
421
|
function initMocks(instance, mpInstance, mocks) {
|
|
117
422
|
const ctx = instance.ctx;
|
|
118
|
-
mocks.forEach(mock => {
|
|
423
|
+
mocks.forEach((mock) => {
|
|
119
424
|
if (hasOwn(mpInstance, mock)) {
|
|
120
425
|
ctx[mock] = mpInstance[mock];
|
|
121
426
|
}
|
|
122
427
|
});
|
|
428
|
+
}
|
|
429
|
+
function hasHook(name) {
|
|
430
|
+
const hooks = this.$[name];
|
|
431
|
+
if (hooks && hooks.length) {
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
function callHook(name, args) {
|
|
437
|
+
if (name === 'mounted') {
|
|
438
|
+
callHook.call(this, 'bm'); // beforeMount
|
|
439
|
+
this.$.isMounted = true;
|
|
440
|
+
name = 'm';
|
|
441
|
+
}
|
|
442
|
+
else if (name === 'onLoad' && args && args.__id__) {
|
|
443
|
+
this.__eventChannel__ = getEventChannel(args.__id__);
|
|
444
|
+
delete args.__id__;
|
|
445
|
+
}
|
|
446
|
+
const hooks = this.$[name];
|
|
447
|
+
return hooks && invokeArrayFns(hooks, args);
|
|
448
|
+
}
|
|
449
|
+
const center = {};
|
|
450
|
+
const parents = {};
|
|
451
|
+
function initScopedSlotsParams(instance) {
|
|
452
|
+
const ctx = instance.ctx;
|
|
453
|
+
ctx.$hasScopedSlotsParams = function (vueId) {
|
|
454
|
+
const has = center[vueId];
|
|
455
|
+
if (!has) {
|
|
456
|
+
parents[vueId] = this;
|
|
457
|
+
onUnmounted(() => {
|
|
458
|
+
delete parents[vueId];
|
|
459
|
+
}, instance);
|
|
460
|
+
}
|
|
461
|
+
return has;
|
|
462
|
+
};
|
|
463
|
+
ctx.$getScopedSlotsParams = function (vueId, name, key) {
|
|
464
|
+
const data = center[vueId];
|
|
465
|
+
if (data) {
|
|
466
|
+
const object = data[name] || {};
|
|
467
|
+
return key ? object[key] : object;
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
parents[vueId] = this;
|
|
471
|
+
onUnmounted(() => {
|
|
472
|
+
delete parents[vueId];
|
|
473
|
+
}, instance);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
ctx.$setScopedSlotsParams = function (name, value) {
|
|
477
|
+
const vueIds = instance.attrs.vueId;
|
|
478
|
+
if (vueIds) {
|
|
479
|
+
const vueId = vueIds.split(',')[0];
|
|
480
|
+
const object = (center[vueId] = center[vueId] || {});
|
|
481
|
+
object[name] = value;
|
|
482
|
+
if (parents[vueId]) {
|
|
483
|
+
parents[vueId].$forceUpdate();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
onUnmounted(function () {
|
|
488
|
+
const propsData = instance.attrs;
|
|
489
|
+
const vueId = propsData && propsData.vueId;
|
|
490
|
+
if (vueId) {
|
|
491
|
+
delete center[vueId];
|
|
492
|
+
delete parents[vueId];
|
|
493
|
+
}
|
|
494
|
+
}, instance);
|
|
123
495
|
}
|
|
124
496
|
|
|
125
497
|
const PAGE_HOOKS = [
|
|
126
|
-
|
|
127
|
-
|
|
498
|
+
ON_LOAD,
|
|
499
|
+
ON_SHOW,
|
|
500
|
+
ON_HIDE,
|
|
501
|
+
ON_UNLOAD,
|
|
502
|
+
ON_RESIZE,
|
|
503
|
+
ON_TAB_ITEM_TAP,
|
|
504
|
+
ON_REACH_BOTTOM,
|
|
505
|
+
ON_PULL_DOWN_REFRESH,
|
|
506
|
+
ON_ADD_TO_FAVORITES,
|
|
128
507
|
// 'onReady', // lifetimes.ready
|
|
129
|
-
'onHide',
|
|
130
|
-
'onUnload',
|
|
131
|
-
'onResize',
|
|
132
508
|
// 'onPageScroll', // 影响性能,开发者手动注册
|
|
133
|
-
'onTabItemTap',
|
|
134
|
-
'onReachBottom',
|
|
135
|
-
'onPullDownRefresh',
|
|
136
509
|
// 'onShareTimeline', // 右上角菜单,开发者手动注册
|
|
137
|
-
'onAddToFavorites'
|
|
138
510
|
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
|
|
139
511
|
];
|
|
140
512
|
function findHooks(vueOptions, hooks = new Set()) {
|
|
141
513
|
if (vueOptions) {
|
|
142
|
-
Object.keys(vueOptions).forEach(name => {
|
|
514
|
+
Object.keys(vueOptions).forEach((name) => {
|
|
143
515
|
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
|
|
144
516
|
hooks.add(name);
|
|
145
517
|
}
|
|
@@ -147,7 +519,7 @@ function findHooks(vueOptions, hooks = new Set()) {
|
|
|
147
519
|
if (__VUE_OPTIONS_API__) {
|
|
148
520
|
const { extends: extendsOptions, mixins } = vueOptions;
|
|
149
521
|
if (mixins) {
|
|
150
|
-
mixins.forEach(mixin => findHooks(mixin, hooks));
|
|
522
|
+
mixins.forEach((mixin) => findHooks(mixin, hooks));
|
|
151
523
|
}
|
|
152
524
|
if (extendsOptions) {
|
|
153
525
|
findHooks(extendsOptions, hooks);
|
|
@@ -163,22 +535,32 @@ function initHook(mpOptions, hook, excludes) {
|
|
|
163
535
|
};
|
|
164
536
|
}
|
|
165
537
|
}
|
|
166
|
-
const EXCLUDE_HOOKS = [
|
|
538
|
+
const EXCLUDE_HOOKS = [ON_READY];
|
|
167
539
|
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
|
|
168
|
-
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
|
|
540
|
+
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
|
|
169
541
|
}
|
|
170
542
|
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
|
|
171
|
-
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
|
|
543
|
+
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
my.appLaunchHooks = [];
|
|
547
|
+
function injectAppLaunchHooks(appInstance) {
|
|
548
|
+
my.appLaunchHooks.forEach((hook) => {
|
|
549
|
+
injectHook(ON_LAUNCH, hook, appInstance);
|
|
550
|
+
});
|
|
172
551
|
}
|
|
173
552
|
|
|
174
553
|
const HOOKS = [
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
554
|
+
ON_SHOW,
|
|
555
|
+
ON_HIDE,
|
|
556
|
+
ON_ERROR,
|
|
557
|
+
ON_THEME_CHANGE,
|
|
558
|
+
ON_PAGE_NOT_FOUND,
|
|
559
|
+
ON_UNHANDLE_REJECTION,
|
|
181
560
|
];
|
|
561
|
+
{
|
|
562
|
+
HOOKS.push(ON_SHARE_APP_MESSAGE);
|
|
563
|
+
}
|
|
182
564
|
function parseApp(instance, parseAppOptions) {
|
|
183
565
|
const internalInstance = instance.$;
|
|
184
566
|
const appOptions = {
|
|
@@ -193,12 +575,14 @@ function parseApp(instance, parseAppOptions) {
|
|
|
193
575
|
initBaseInstance(internalInstance, {
|
|
194
576
|
mpType: 'app',
|
|
195
577
|
mpInstance: this,
|
|
196
|
-
slots: []
|
|
578
|
+
slots: [],
|
|
197
579
|
});
|
|
580
|
+
injectAppLaunchHooks(internalInstance);
|
|
198
581
|
ctx.globalData = this.globalData;
|
|
199
|
-
instance.$callHook(
|
|
200
|
-
}
|
|
582
|
+
instance.$callHook(ON_LAUNCH, extend({ app: this }, options));
|
|
583
|
+
},
|
|
201
584
|
};
|
|
585
|
+
initLocale(instance);
|
|
202
586
|
const vueOptions = instance.$.type;
|
|
203
587
|
initHooks(appOptions, HOOKS);
|
|
204
588
|
initUnknownHooks(appOptions, vueOptions);
|
|
@@ -215,70 +599,17 @@ function initCreateApp(parseAppOptions) {
|
|
|
215
599
|
return function createApp(vm) {
|
|
216
600
|
return App(parseApp(vm, parseAppOptions));
|
|
217
601
|
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const encode = encodeURIComponent;
|
|
221
|
-
function stringifyQuery(obj, encodeStr = encode) {
|
|
222
|
-
const res = obj
|
|
223
|
-
? Object.keys(obj)
|
|
224
|
-
.map(key => {
|
|
225
|
-
let val = obj[key];
|
|
226
|
-
if (typeof val === undefined || val === null) {
|
|
227
|
-
val = '';
|
|
228
|
-
}
|
|
229
|
-
else if (isPlainObject(val)) {
|
|
230
|
-
val = JSON.stringify(val);
|
|
231
|
-
}
|
|
232
|
-
return encodeStr(key) + '=' + encodeStr(val);
|
|
233
|
-
})
|
|
234
|
-
.filter(x => x.length > 0)
|
|
235
|
-
.join('&')
|
|
236
|
-
: null;
|
|
237
|
-
return res ? `?${res}` : '';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function initVueIds(vueIds, mpInstance) {
|
|
241
|
-
if (!vueIds) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const ids = vueIds.split(',');
|
|
245
|
-
const len = ids.length;
|
|
246
|
-
if (len === 1) {
|
|
247
|
-
mpInstance._$vueId = ids[0];
|
|
248
|
-
}
|
|
249
|
-
else if (len === 2) {
|
|
250
|
-
mpInstance._$vueId = ids[0];
|
|
251
|
-
mpInstance._$vuePid = ids[1];
|
|
252
|
-
}
|
|
253
602
|
}
|
|
254
|
-
function
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
603
|
+
function initLocale(appVm) {
|
|
604
|
+
const locale = ref(my.getSystemInfoSync().language || 'zh-Hans');
|
|
605
|
+
Object.defineProperty(appVm, '$locale', {
|
|
606
|
+
get() {
|
|
607
|
+
return locale.value;
|
|
608
|
+
},
|
|
609
|
+
set(v) {
|
|
610
|
+
locale.value = v;
|
|
611
|
+
},
|
|
262
612
|
});
|
|
263
|
-
}
|
|
264
|
-
function findVmByVueId(instance, vuePid) {
|
|
265
|
-
// TODO vue3 中 没有 $children
|
|
266
|
-
const $children = instance.$children;
|
|
267
|
-
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
|
|
268
|
-
for (let i = $children.length - 1; i >= 0; i--) {
|
|
269
|
-
const childVm = $children[i];
|
|
270
|
-
if (childVm.$scope._$vueId === vuePid) {
|
|
271
|
-
return childVm;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
// 反向递归查找
|
|
275
|
-
let parentVm;
|
|
276
|
-
for (let i = $children.length - 1; i >= 0; i--) {
|
|
277
|
-
parentVm = findVmByVueId($children[i], vuePid);
|
|
278
|
-
if (parentVm) {
|
|
279
|
-
return parentVm;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
613
|
}
|
|
283
614
|
|
|
284
615
|
const PROP_TYPES = [String, Number, Boolean, Object, Array, null];
|
|
@@ -294,7 +625,7 @@ function initDefaultProps(isBehavior = false) {
|
|
|
294
625
|
if (!isBehavior) {
|
|
295
626
|
properties.vueId = {
|
|
296
627
|
type: String,
|
|
297
|
-
value: ''
|
|
628
|
+
value: '',
|
|
298
629
|
};
|
|
299
630
|
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
|
|
300
631
|
properties.vueSlots = {
|
|
@@ -306,9 +637,9 @@ function initDefaultProps(isBehavior = false) {
|
|
|
306
637
|
$slots[slotName] = true;
|
|
307
638
|
});
|
|
308
639
|
this.setData({
|
|
309
|
-
$slots
|
|
640
|
+
$slots,
|
|
310
641
|
});
|
|
311
|
-
}
|
|
642
|
+
},
|
|
312
643
|
};
|
|
313
644
|
}
|
|
314
645
|
return properties;
|
|
@@ -321,14 +652,14 @@ function createProperty(key, prop) {
|
|
|
321
652
|
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
|
|
322
653
|
const properties = initDefaultProps(isBehavior);
|
|
323
654
|
if (isArray(rawProps)) {
|
|
324
|
-
rawProps.forEach(key => {
|
|
655
|
+
rawProps.forEach((key) => {
|
|
325
656
|
properties[key] = createProperty(key, {
|
|
326
|
-
type: null
|
|
657
|
+
type: null,
|
|
327
658
|
});
|
|
328
659
|
});
|
|
329
660
|
}
|
|
330
661
|
else if (isPlainObject(rawProps)) {
|
|
331
|
-
Object.keys(rawProps).forEach(key => {
|
|
662
|
+
Object.keys(rawProps).forEach((key) => {
|
|
332
663
|
const opts = rawProps[key];
|
|
333
664
|
if (isPlainObject(opts)) {
|
|
334
665
|
// title:{type:String,default:''}
|
|
@@ -340,14 +671,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
|
|
|
340
671
|
opts.type = parsePropType(key, type);
|
|
341
672
|
properties[key] = createProperty(key, {
|
|
342
673
|
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
|
|
343
|
-
value
|
|
674
|
+
value,
|
|
344
675
|
});
|
|
345
676
|
}
|
|
346
677
|
else {
|
|
347
678
|
// content:String
|
|
348
679
|
const type = parsePropType(key, opts);
|
|
349
680
|
properties[key] = createProperty(key, {
|
|
350
|
-
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
|
|
681
|
+
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
|
|
351
682
|
});
|
|
352
683
|
}
|
|
353
684
|
});
|
|
@@ -359,8 +690,7 @@ function initData(vueOptions) {
|
|
|
359
690
|
let data = vueOptions.data || {};
|
|
360
691
|
if (typeof data === 'function') {
|
|
361
692
|
try {
|
|
362
|
-
const appConfig = getApp().$vm.$.appContext
|
|
363
|
-
.config;
|
|
693
|
+
const appConfig = getApp().$vm.$.appContext.config;
|
|
364
694
|
data = data.call(appConfig.globalProperties);
|
|
365
695
|
}
|
|
366
696
|
catch (e) {
|
|
@@ -391,7 +721,7 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
391
721
|
}
|
|
392
722
|
const behaviors = [];
|
|
393
723
|
if (isArray(vueBehaviors)) {
|
|
394
|
-
vueBehaviors.forEach(behavior => {
|
|
724
|
+
vueBehaviors.forEach((behavior) => {
|
|
395
725
|
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
|
|
396
726
|
if (behavior === 'uni://form-field') {
|
|
397
727
|
if (isArray(vueProps)) {
|
|
@@ -401,24 +731,24 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
401
731
|
else {
|
|
402
732
|
vueProps.name = {
|
|
403
733
|
type: String,
|
|
404
|
-
default: ''
|
|
734
|
+
default: '',
|
|
405
735
|
};
|
|
406
736
|
vueProps.value = {
|
|
407
737
|
type: [String, Number, Boolean, Array, Object, Date],
|
|
408
|
-
default: ''
|
|
738
|
+
default: '',
|
|
409
739
|
};
|
|
410
740
|
}
|
|
411
741
|
}
|
|
412
742
|
});
|
|
413
743
|
}
|
|
414
|
-
if (
|
|
744
|
+
if (vueExtends && vueExtends.props) {
|
|
415
745
|
const behavior = {};
|
|
416
746
|
initProps(behavior, vueExtends.props, true);
|
|
417
747
|
behaviors.push(initBehavior(behavior));
|
|
418
748
|
}
|
|
419
749
|
if (isArray(vueMixins)) {
|
|
420
|
-
vueMixins.forEach(vueMixin => {
|
|
421
|
-
if (
|
|
750
|
+
vueMixins.forEach((vueMixin) => {
|
|
751
|
+
if (vueMixin.props) {
|
|
422
752
|
const behavior = {};
|
|
423
753
|
initProps(behavior, vueMixin.props, true);
|
|
424
754
|
behaviors.push(initBehavior(behavior));
|
|
@@ -428,21 +758,9 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
428
758
|
return behaviors;
|
|
429
759
|
}
|
|
430
760
|
|
|
431
|
-
function getValue(obj, path) {
|
|
432
|
-
const parts = path.split('.');
|
|
433
|
-
let key = parts[0];
|
|
434
|
-
if (key.indexOf('__$n') === 0) {
|
|
435
|
-
//number index
|
|
436
|
-
key = parseInt(key.replace('__$n', ''));
|
|
437
|
-
}
|
|
438
|
-
if (parts.length === 1) {
|
|
439
|
-
return obj[key];
|
|
440
|
-
}
|
|
441
|
-
return getValue(obj[key], parts.slice(1).join('.'));
|
|
442
|
-
}
|
|
443
761
|
function getExtraValue(instance, dataPathsArray) {
|
|
444
762
|
let context = instance;
|
|
445
|
-
dataPathsArray.forEach(dataPathArray => {
|
|
763
|
+
dataPathsArray.forEach((dataPathArray) => {
|
|
446
764
|
const dataPath = dataPathArray[0];
|
|
447
765
|
const value = dataPathArray[2];
|
|
448
766
|
if (dataPath || typeof value !== 'undefined') {
|
|
@@ -461,7 +779,7 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
461
779
|
vFor = dataPath.substr(3);
|
|
462
780
|
}
|
|
463
781
|
else {
|
|
464
|
-
vFor =
|
|
782
|
+
vFor = getTarget(context, dataPath);
|
|
465
783
|
}
|
|
466
784
|
}
|
|
467
785
|
if (Number.isInteger(vFor)) {
|
|
@@ -472,13 +790,13 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
472
790
|
}
|
|
473
791
|
else {
|
|
474
792
|
if (isArray(vFor)) {
|
|
475
|
-
context = vFor.find(vForItem => {
|
|
476
|
-
return
|
|
793
|
+
context = vFor.find((vForItem) => {
|
|
794
|
+
return getTarget(vForItem, propPath) === value;
|
|
477
795
|
});
|
|
478
796
|
}
|
|
479
797
|
else if (isPlainObject(vFor)) {
|
|
480
|
-
context = Object.keys(vFor).find(vForKey => {
|
|
481
|
-
return
|
|
798
|
+
context = Object.keys(vFor).find((vForKey) => {
|
|
799
|
+
return getTarget(vFor[vForKey], propPath) === value;
|
|
482
800
|
});
|
|
483
801
|
}
|
|
484
802
|
else {
|
|
@@ -486,7 +804,7 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
486
804
|
}
|
|
487
805
|
}
|
|
488
806
|
if (valuePath) {
|
|
489
|
-
context =
|
|
807
|
+
context = getTarget(context, valuePath);
|
|
490
808
|
}
|
|
491
809
|
}
|
|
492
810
|
});
|
|
@@ -527,10 +845,10 @@ function processEventExtra(instance, extra, event) {
|
|
|
527
845
|
}
|
|
528
846
|
else if (dataPath.indexOf('$event.') === 0) {
|
|
529
847
|
// $event.target.value
|
|
530
|
-
extraObj['$' + index] =
|
|
848
|
+
extraObj['$' + index] = getTarget(event, dataPath.replace('$event.', ''));
|
|
531
849
|
}
|
|
532
850
|
else {
|
|
533
|
-
extraObj['$' + index] =
|
|
851
|
+
extraObj['$' + index] = getTarget(instance, dataPath);
|
|
534
852
|
}
|
|
535
853
|
}
|
|
536
854
|
}
|
|
@@ -567,7 +885,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
|
|
|
567
885
|
}
|
|
568
886
|
const extraObj = processEventExtra(instance, extra, event);
|
|
569
887
|
const ret = [];
|
|
570
|
-
args.forEach(arg => {
|
|
888
|
+
args.forEach((arg) => {
|
|
571
889
|
if (arg === '$event') {
|
|
572
890
|
if (methodName === '__set_model' && !isCustom) {
|
|
573
891
|
// input v-model value
|
|
@@ -609,7 +927,7 @@ function wrapper(event) {
|
|
|
609
927
|
event.detail.markerId = event.markerId;
|
|
610
928
|
}
|
|
611
929
|
if (isPlainObject(event.detail)) {
|
|
612
|
-
event.target =
|
|
930
|
+
event.target = extend({}, event.target, event.detail);
|
|
613
931
|
}
|
|
614
932
|
return event;
|
|
615
933
|
}
|
|
@@ -667,7 +985,14 @@ function handleEvent(event) {
|
|
|
667
985
|
}
|
|
668
986
|
handler.once = true;
|
|
669
987
|
}
|
|
670
|
-
|
|
988
|
+
let params = processEventArgs(this.$vm, event, eventArray[1], eventArray[2], isCustom, methodName);
|
|
989
|
+
params = Array.isArray(params) ? params : [];
|
|
990
|
+
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
|
|
991
|
+
if (/=\s*\S+\.eventParams\s*\|\|\s*\S+\[['"]event-params['"]\]/.test(handler.toString())) {
|
|
992
|
+
// eslint-disable-next-line no-sparse-arrays
|
|
993
|
+
params = params.concat([, , , , , , , , , , event]);
|
|
994
|
+
}
|
|
995
|
+
ret.push(handler.apply(handlerCtx, params));
|
|
671
996
|
}
|
|
672
997
|
});
|
|
673
998
|
}
|
|
@@ -719,7 +1044,7 @@ function onAliGetAuthorize(method, $event) {
|
|
|
719
1044
|
$event.type = 'getphonenumber';
|
|
720
1045
|
$event.detail.errMsg = 'getPhoneNumber:fail';
|
|
721
1046
|
this[method]($event);
|
|
722
|
-
}
|
|
1047
|
+
},
|
|
723
1048
|
});
|
|
724
1049
|
}
|
|
725
1050
|
function parse(appOptions) {
|
|
@@ -738,11 +1063,11 @@ function parse(appOptions) {
|
|
|
738
1063
|
}
|
|
739
1064
|
|
|
740
1065
|
var parseAppOptions = /*#__PURE__*/Object.freeze({
|
|
741
|
-
|
|
742
|
-
|
|
1066
|
+
__proto__: null,
|
|
1067
|
+
parse: parse
|
|
743
1068
|
});
|
|
744
1069
|
|
|
745
|
-
function handleLink(event) {
|
|
1070
|
+
function handleLink$1(event) {
|
|
746
1071
|
// detail 是微信,value 是百度(dipatch)
|
|
747
1072
|
const detail = (event.detail ||
|
|
748
1073
|
event.value);
|
|
@@ -815,11 +1140,11 @@ function customize(str) {
|
|
|
815
1140
|
}
|
|
816
1141
|
function initBehavior({ properties }) {
|
|
817
1142
|
const props = {};
|
|
818
|
-
Object.keys(properties).forEach(key => {
|
|
1143
|
+
Object.keys(properties).forEach((key) => {
|
|
819
1144
|
props[key] = properties[key].value;
|
|
820
1145
|
});
|
|
821
1146
|
return {
|
|
822
|
-
props
|
|
1147
|
+
props,
|
|
823
1148
|
};
|
|
824
1149
|
}
|
|
825
1150
|
function initRelation(mpInstance, detail) {
|
|
@@ -859,10 +1184,10 @@ function initChildVues(mpInstance) {
|
|
|
859
1184
|
}
|
|
860
1185
|
const childVues = mpInstance._$childVues;
|
|
861
1186
|
if (childVues) {
|
|
862
|
-
childVues.forEach(relationOptions => {
|
|
1187
|
+
childVues.forEach((relationOptions) => {
|
|
863
1188
|
// 父子关系
|
|
864
|
-
handleLink.call(mpInstance, {
|
|
865
|
-
detail: relationOptions
|
|
1189
|
+
handleLink$1.call(mpInstance, {
|
|
1190
|
+
detail: relationOptions,
|
|
866
1191
|
});
|
|
867
1192
|
const { mpInstance: childMPInstance, createComponent } = relationOptions;
|
|
868
1193
|
childMPInstance.$vm = createComponent(relationOptions.parent);
|
|
@@ -872,7 +1197,7 @@ function initChildVues(mpInstance) {
|
|
|
872
1197
|
}
|
|
873
1198
|
initChildVues(childMPInstance);
|
|
874
1199
|
childMPInstance.$vm.$callHook('mounted');
|
|
875
|
-
childMPInstance.$vm.$callHook(
|
|
1200
|
+
childMPInstance.$vm.$callHook(ON_READY);
|
|
876
1201
|
});
|
|
877
1202
|
}
|
|
878
1203
|
delete mpInstance._$childVues;
|
|
@@ -904,14 +1229,14 @@ function triggerEvent(type, detail) {
|
|
|
904
1229
|
const eventOpts = this.props['data-event-opts'];
|
|
905
1230
|
const target = {
|
|
906
1231
|
dataset: {
|
|
907
|
-
eventOpts
|
|
908
|
-
}
|
|
1232
|
+
eventOpts,
|
|
1233
|
+
},
|
|
909
1234
|
};
|
|
910
1235
|
handler({
|
|
911
1236
|
type: customize(type),
|
|
912
1237
|
target,
|
|
913
1238
|
currentTarget: target,
|
|
914
|
-
detail
|
|
1239
|
+
detail,
|
|
915
1240
|
});
|
|
916
1241
|
}
|
|
917
1242
|
const IGNORES = ['$slots', '$scopedSlots'];
|
|
@@ -922,7 +1247,7 @@ function createObserver(isDidUpdate = false) {
|
|
|
922
1247
|
if (equal(prevProps, nextProps)) {
|
|
923
1248
|
return;
|
|
924
1249
|
}
|
|
925
|
-
Object.keys(prevProps).forEach(name => {
|
|
1250
|
+
Object.keys(prevProps).forEach((name) => {
|
|
926
1251
|
if (IGNORES.indexOf(name) === -1) {
|
|
927
1252
|
const prevValue = prevProps[name];
|
|
928
1253
|
const nextValue = nextProps[name];
|
|
@@ -935,19 +1260,19 @@ function createObserver(isDidUpdate = false) {
|
|
|
935
1260
|
});
|
|
936
1261
|
};
|
|
937
1262
|
}
|
|
938
|
-
const handleLink
|
|
1263
|
+
const handleLink = (function () {
|
|
939
1264
|
if (isComponent2) {
|
|
940
|
-
return function handleLink
|
|
941
|
-
return handleLink.call(this, {
|
|
942
|
-
detail
|
|
1265
|
+
return function handleLink(detail) {
|
|
1266
|
+
return handleLink$1.call(this, {
|
|
1267
|
+
detail,
|
|
943
1268
|
});
|
|
944
1269
|
};
|
|
945
1270
|
}
|
|
946
|
-
return function handleLink
|
|
1271
|
+
return function handleLink(detail) {
|
|
947
1272
|
if (this.$vm && this.$vm.$.isMounted) {
|
|
948
1273
|
// 父已初始化
|
|
949
|
-
return handleLink.call(this, {
|
|
950
|
-
detail
|
|
1274
|
+
return handleLink$1.call(this, {
|
|
1275
|
+
detail,
|
|
951
1276
|
});
|
|
952
1277
|
}
|
|
953
1278
|
(this._$childVues || (this._$childVues = [])).unshift(detail);
|
|
@@ -956,7 +1281,7 @@ const handleLink$1 = (function () {
|
|
|
956
1281
|
function createVueComponent(mpType, mpInstance, vueOptions, parent) {
|
|
957
1282
|
return $createComponent({
|
|
958
1283
|
type: vueOptions,
|
|
959
|
-
props: mpInstance.props
|
|
1284
|
+
props: mpInstance.props,
|
|
960
1285
|
}, {
|
|
961
1286
|
mpType,
|
|
962
1287
|
mpInstance,
|
|
@@ -964,43 +1289,43 @@ function createVueComponent(mpType, mpInstance, vueOptions, parent) {
|
|
|
964
1289
|
onBeforeSetup(instance, options) {
|
|
965
1290
|
initMocks(instance, mpInstance, mocks);
|
|
966
1291
|
initComponentInstance(instance, options);
|
|
967
|
-
}
|
|
1292
|
+
},
|
|
968
1293
|
});
|
|
969
1294
|
}
|
|
970
1295
|
|
|
971
|
-
function createPage(vueOptions) {
|
|
1296
|
+
function createPage$1(vueOptions) {
|
|
972
1297
|
vueOptions = vueOptions.default || vueOptions;
|
|
973
1298
|
const pageOptions = {
|
|
974
1299
|
onLoad(query) {
|
|
975
1300
|
this.options = query;
|
|
976
1301
|
this.$page = {
|
|
977
|
-
fullPath: '/' + this.route + stringifyQuery(query)
|
|
1302
|
+
fullPath: '/' + this.route + stringifyQuery(query),
|
|
978
1303
|
};
|
|
979
1304
|
// 初始化 vue 实例
|
|
980
1305
|
this.$vm = createVueComponent('page', this, vueOptions);
|
|
981
1306
|
initSpecialMethods(this);
|
|
982
|
-
this.$vm.$callHook(
|
|
1307
|
+
this.$vm.$callHook(ON_LOAD, query);
|
|
983
1308
|
},
|
|
984
1309
|
onReady() {
|
|
985
1310
|
initChildVues(this);
|
|
986
1311
|
this.$vm.$callHook('mounted');
|
|
987
|
-
this.$vm.$callHook(
|
|
1312
|
+
this.$vm.$callHook(ON_READY);
|
|
988
1313
|
},
|
|
989
1314
|
onUnload() {
|
|
990
1315
|
if (this.$vm) {
|
|
991
|
-
this.$vm.$callHook(
|
|
1316
|
+
this.$vm.$callHook(ON_UNLOAD);
|
|
992
1317
|
$destroyComponent(this.$vm);
|
|
993
1318
|
}
|
|
994
1319
|
},
|
|
995
1320
|
events: {
|
|
996
1321
|
// 支付宝小程序有些页面事件只能放在events下
|
|
997
1322
|
onBack() {
|
|
998
|
-
this.$vm.$callHook(
|
|
999
|
-
}
|
|
1323
|
+
this.$vm.$callHook(ON_BACK_PRESS);
|
|
1324
|
+
},
|
|
1000
1325
|
},
|
|
1001
1326
|
__r: handleRef,
|
|
1002
1327
|
__e: handleEvent,
|
|
1003
|
-
__l: handleLink
|
|
1328
|
+
__l: handleLink,
|
|
1004
1329
|
};
|
|
1005
1330
|
if (__VUE_OPTIONS_API__) {
|
|
1006
1331
|
pageOptions.data = initData(vueOptions);
|
|
@@ -1013,14 +1338,14 @@ function createPage(vueOptions) {
|
|
|
1013
1338
|
|
|
1014
1339
|
function initComponentProps(rawProps) {
|
|
1015
1340
|
const propertiesOptions = {
|
|
1016
|
-
properties: {}
|
|
1341
|
+
properties: {},
|
|
1017
1342
|
};
|
|
1018
1343
|
initProps(propertiesOptions, rawProps, false);
|
|
1019
1344
|
const properties = propertiesOptions.properties;
|
|
1020
1345
|
const props = {
|
|
1021
|
-
onVueInit: function () { }
|
|
1346
|
+
onVueInit: function () { },
|
|
1022
1347
|
};
|
|
1023
|
-
Object.keys(properties).forEach(key => {
|
|
1348
|
+
Object.keys(properties).forEach((key) => {
|
|
1024
1349
|
if (key !== 'vueSlots') {
|
|
1025
1350
|
props[key] = properties[key].value;
|
|
1026
1351
|
}
|
|
@@ -1036,7 +1361,7 @@ function initVm(mpInstance, createComponent) {
|
|
|
1036
1361
|
const relationOptions = {
|
|
1037
1362
|
vuePid: mpInstance._$vuePid,
|
|
1038
1363
|
mpInstance,
|
|
1039
|
-
createComponent
|
|
1364
|
+
createComponent,
|
|
1040
1365
|
};
|
|
1041
1366
|
if (isComponent2) {
|
|
1042
1367
|
// 处理父子关系
|
|
@@ -1057,7 +1382,7 @@ function initVm(mpInstance, createComponent) {
|
|
|
1057
1382
|
}
|
|
1058
1383
|
}
|
|
1059
1384
|
}
|
|
1060
|
-
function createComponent(vueOptions) {
|
|
1385
|
+
function createComponent$1(vueOptions) {
|
|
1061
1386
|
vueOptions = vueOptions.default || vueOptions;
|
|
1062
1387
|
const mpComponentOptions = {
|
|
1063
1388
|
props: initComponentProps(vueOptions.props),
|
|
@@ -1085,9 +1410,9 @@ function createComponent(vueOptions) {
|
|
|
1085
1410
|
methods: {
|
|
1086
1411
|
__r: handleRef,
|
|
1087
1412
|
__e: handleEvent,
|
|
1088
|
-
__l: handleLink
|
|
1089
|
-
triggerEvent
|
|
1090
|
-
}
|
|
1413
|
+
__l: handleLink,
|
|
1414
|
+
triggerEvent,
|
|
1415
|
+
},
|
|
1091
1416
|
};
|
|
1092
1417
|
if (__VUE_OPTIONS_API__) {
|
|
1093
1418
|
mpComponentOptions.data = initData(vueOptions);
|
|
@@ -1108,6 +1433,10 @@ function createComponent(vueOptions) {
|
|
|
1108
1433
|
return Component(mpComponentOptions);
|
|
1109
1434
|
}
|
|
1110
1435
|
|
|
1111
|
-
const createApp = initCreateApp(parseAppOptions);
|
|
1436
|
+
const createApp = initCreateApp(parseAppOptions);
|
|
1437
|
+
my.EventChannel = EventChannel;
|
|
1438
|
+
my.createApp = createApp;
|
|
1439
|
+
my.createPage = createPage;
|
|
1440
|
+
my.createComponent = createComponent;
|
|
1112
1441
|
|
|
1113
|
-
export { createApp, createComponent, createPage };
|
|
1442
|
+
export { createApp, createComponent$1 as createComponent, createPage$1 as createPage };
|