From 86e5187ce2226e80ad2a341d3154453da43855fe Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Sat, 18 May 2019 21:30:34 +0800 Subject: [PATCH] build uni mp-alipay --- packages/uni-mp-alipay/dist/index.js | 66 ++++++++++++------- packages/uni-mp-alipay/package.json | 2 +- src/core/runtime/index.js | 8 +-- src/core/runtime/wrapper/create-component.js | 2 +- .../mp-alipay/runtime/wrapper/page-parser.js | 2 +- 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 1d32ea0624..13dc87310f 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -1283,6 +1283,25 @@ function initRelation$1 (detail) { this.props.onVueInit(detail); } +const SPECIAL_EVENTS = [ + 'formReset', + 'markerTap', + 'calloutTap', + 'controlTap', + 'regionChange' +]; + +function initSpecialEvents (mpMethods, vueMethods) { + if (!vueMethods) { + return + } + SPECIAL_EVENTS.forEach((name) => { + if (vueMethods[name]) { + mpMethods[name] = vueMethods[name]; + } + }); +} + function initChildVues (mpInstance) { // 此时需保证当前 mpInstance 已经存在 $vm if (!mpInstance.$vm) { @@ -1293,7 +1312,7 @@ function initChildVues (mpInstance) { vueOptions, VueComponent, mpInstance: childMPInstance - }) => { + }) => { // 父子关系 handleLink.call(mpInstance, { detail: { @@ -1306,9 +1325,9 @@ function initChildVues (mpInstance) { handleRef.call(vueOptions.parent.$scope, childMPInstance); - childMPInstance.$vm.$mount(); - - initChildVues(childMPInstance); + childMPInstance.$vm.$mount(); + + initChildVues(childMPInstance); childMPInstance.$vm._isMounted = true; childMPInstance.$vm.__call_hook('mounted'); @@ -1462,7 +1481,7 @@ function parsePage (vuePageOptions) { this.$vm.__call_hook('onLoad', args); }, onReady () { - initChildVues(this); + initChildVues(this); this.$vm._isMounted = true; this.$vm.__call_hook('mounted'); this.$vm.__call_hook('onReady'); @@ -1476,11 +1495,9 @@ function parsePage (vuePageOptions) { __l: handleLink$1 }; - initHooks(pageOptions, hooks$1); - - if (vueOptions.methods && vueOptions.methods.formReset) { - pageOptions.formReset = vueOptions.methods.formReset; - } + initHooks(pageOptions, hooks$1); + + initSpecialEvents(pageOptions, vueOptions.methods); return pageOptions } @@ -1517,23 +1534,23 @@ function initVm (VueComponent) { // 触发首次 setData this.$vm.$mount(); - } else { + } else { // 处理父子关系 initRelation$1.call(this, { vuePid: this._$vuePid, vueOptions: options, VueComponent, mpInstance: this - }); + }); - if (options.parent) { // 父组件已经初始化,直接初始化子,否则放到父组件的 didMount 中处理 + if (options.parent) { // 父组件已经初始化,直接初始化子,否则放到父组件的 didMount 中处理 // 初始化 vue 实例 - this.$vm = new VueComponent(options); + this.$vm = new VueComponent(options); handleRef.call(options.parent.$scope, this); // 触发首次 setData - this.$vm.$mount(); - - initChildVues(this); + this.$vm.$mount(); + + initChildVues(this); this.$vm._isMounted = true; this.$vm.__call_hook('mounted'); @@ -1589,15 +1606,14 @@ function parseComponent (vueComponentOptions) { componentOptions.didUpdate = createObserver$1(true); } - if (vueOptions.methods && vueOptions.methods.formReset) { - componentOptions.methods.formReset = vueOptions.methods.formReset; - } + initSpecialEvents(componentOptions.methods, vueOptions.methods); + return componentOptions } function createComponent (vueOptions) { { - return my.createComponent(parseComponent(vueOptions)) + return my.defineComponent(parseComponent(vueOptions)) } } @@ -1660,10 +1676,10 @@ if (typeof Proxy !== 'undefined') { } }); } - -my.createApp = createApp; -my.createPage = createPage; -my.createComponent = createComponent; + +my.createApp = createApp; +my.createPage = createPage; +my.createComponent = createComponent; var uni$1 = uni; diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index 4a79e8e32a..1843fc2999 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-alipay", - "version": "0.0.806", + "version": "0.0.807", "description": "uni-app mp-alipay", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/index.js b/src/core/runtime/index.js index 65b86341ea..c80c2d9af8 100644 --- a/src/core/runtime/index.js +++ b/src/core/runtime/index.js @@ -87,10 +87,10 @@ if (typeof Proxy !== 'undefined') { } }) } - -__GLOBAL__.createApp = createApp -__GLOBAL__.createPage = createPage -__GLOBAL__.createComponent = createComponent + +__GLOBAL__.createApp = createApp +__GLOBAL__.createPage = createPage +__GLOBAL__.createComponent = createComponent export { createApp, diff --git a/src/core/runtime/wrapper/create-component.js b/src/core/runtime/wrapper/create-component.js index a8a274b748..40607261bb 100644 --- a/src/core/runtime/wrapper/create-component.js +++ b/src/core/runtime/wrapper/create-component.js @@ -2,7 +2,7 @@ import parseComponent from 'uni-platform/runtime/wrapper/component-parser' export default function createComponent (vueOptions) { if (__PLATFORM__ === 'mp-alipay') { - return my.createComponent(parseComponent(vueOptions)) + return my.defineComponent(parseComponent(vueOptions)) } else { return Component(parseComponent(vueOptions)) } diff --git a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js index 2483579b85..45c574153e 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js @@ -70,7 +70,7 @@ export default function parsePage (vuePageOptions) { initHooks(pageOptions, hooks) - initSpecialEvents(pageOptions.methods, vueOptions.methods) + initSpecialEvents(pageOptions, vueOptions.methods) return pageOptions } -- GitLab