提交 ddac6c4a 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-mp-qq/dist/index.js
#	packages/uni-mp-weixin/dist/index.js
......@@ -1665,7 +1665,7 @@ const customizeRE = /:/g;
const customize = cached((str) => {
return camelize(str.replace(customizeRE, '-'))
});
});
const isComponent2 = my.canIUse('component2');
......@@ -2022,8 +2022,14 @@ function parseComponent (vueComponentOptions) {
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
initVm.call(this, VueComponent);
didMount () {
if (my.dd) { // 钉钉小程序底层基础库有 bug,组件嵌套使用时,在 didMount 中无法及时调用 props 中的方法
setTimeout(() => {
initVm.call(this, VueComponent);
}, 4);
} else {
initVm.call(this, VueComponent);
}
initSpecialMethods(this);
......
......@@ -1507,23 +1507,29 @@ function parseComponent (vueOptions) {
const componentOptions = parseBaseComponent(vueOptions, {
isPage,
initRelation
});
});
// 关于百度小程序新生命周期(2.0)的说明(组件作为页面时):
// lifetimes:attached --> methods:onShow --> methods:onLoad --> methods:onReady
// 这里在新生命周期强制将onShow挪到onLoad之后触发,另外一处修改在page-parser.js
const oldAttached = componentOptions.lifetimes.attached;
componentOptions.lifetimes.attached = function attached () {
oldAttached.call(this);
if (isPage.call(this)) { // 百度 onLoad 在 attached 之前触发
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this.pageinstance.$vm = this.$vm;
if (hasOwn(this.pageinstance, '_$args')) {
this.$vm.$mp.query = this.pageinstance._$args;
this.$vm.__call_hook('onLoad', this.pageinstance._$args);
this.$vm.__call_hook('onLoad', this.pageinstance._$args);
this.$vm.__call_hook('onShow');
delete this.pageinstance._$args;
}
// TODO 3.105.17以下基础库内百度 Component 作为页面时,methods 中的 onShow 不触发
!newLifecycle && this.$vm.__call_hook('onShow');
} else {
// 百度小程序组件不触发methods内的onReady
if (this.$vm) {
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted');
}
}
};
......@@ -1590,13 +1596,21 @@ function parsePage (vuePageOptions) {
initRelation
});
const newLifecycle = swan.canIUse('lifecycle-2-0');
// 纠正百度小程序新生命周期(2.0)methods:onShow在methods:onLoad之前触发的问题
if (newLifecycle) {
delete pageOptions.methods.onShow;
}
pageOptions.methods.onLoad = function onLoad (args) {
// 百度 onLoad 在 attached 之前触发,先存储 args, 在 attached 里边触发 onLoad
if (this.$vm) {
this.$vm.$mp.query = args;
this.$vm.__call_hook('onLoad', args);
} else {
this.pageinstance._$args = args;
if (this.$vm) {
this.$vm.$mp.query = args;
this.$vm.__call_hook('onLoad', args);
this.$vm.__call_hook('onShow');
} else {
this.pageinstance._$args = args;
}
};
......
......@@ -1214,6 +1214,11 @@ function parseBaseApp (vm, {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm;
......@@ -1339,6 +1344,13 @@ function parseBaseComponent (vueComponentOptions, {
addGlobalClass: true
};
{
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']);
}
}
const componentOptions = {
options,
data: initData(vueOptions, Vue.prototype),
......
......@@ -1281,7 +1281,7 @@ function parseBaseComponent (vueComponentOptions, {
};
{
// 微信multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']);
}
......
......@@ -11,7 +11,7 @@
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "",
"libVersion": "2.9.2",
"appid": "touristappid",
"projectname": "",
"condition": {
......
......@@ -6,11 +6,13 @@ export function getApp () {
return appVm
}
export function getCurrentPages (isAll = false) {
export function getCurrentPages (isAll = false, ignoreError = false) {
const pages = []
const app = getApp()
if (!app) {
console.error('app is not ready')
if (ignoreError) {
console.error('app is not ready')
}
return []
}
const childrenVm = app.$children[0]
......@@ -62,4 +64,4 @@ export default function createApp (vm, routes) {
// initEvents(appVm)
initRouterGuard(appVm, routes)
}
}
......@@ -58,6 +58,9 @@ export function pageScrollTo ({
// bodyStyle.webkitTransform = `translateY(${documentElement.scrollTop}px) translateZ(0)`
}
let testReachBottomTimer
let lastScrollHeight = 0
export function createScrollListener (pageId, {
enablePageScroll,
enablePageReachBottom,
......@@ -72,14 +75,16 @@ export function createScrollListener (pageId, {
function isReachBottom () {
const {
clientHeight,
scrollHeight
} = document.documentElement
// 部分浏览器窗口高度变化后document.documentelement.clientheight不会变化,采用window.innerHeight
const windowHeight = window.innerHeight
const scrollY = window.scrollY
let isBottom = scrollY > 0 && scrollHeight > clientHeight && (scrollY + clientHeight + onReachBottomDistance) >=
scrollHeight
if (isBottom && !hasReachBottom) {
let isBottom = scrollY > 0 && scrollHeight > windowHeight && (scrollY + windowHeight + onReachBottomDistance) >= scrollHeight
// 兼容部分浏览器滚动时scroll事件不触发
const heightChanged = Math.abs(scrollHeight - lastScrollHeight) > onReachBottomDistance
if (isBottom && (!hasReachBottom || heightChanged)) {
lastScrollHeight = scrollHeight
hasReachBottom = true
return true
}
......@@ -108,18 +113,28 @@ export function createScrollListener (pageId, {
scrollTop
})
}
if (enablePageReachBottom && onReachBottom && isReachBottom()) {
publishHandler('onReachBottom', {}, pageId)
onReachBottom = false
setTimeout(function () {
onReachBottom = true
}, 350)
function testReachBottom () {
if (isReachBottom()) {
publishHandler('onReachBottom', {}, pageId)
onReachBottom = false
setTimeout(function () {
onReachBottom = true
}, 350)
return true
}
}
if (enablePageReachBottom && onReachBottom) {
if (testReachBottom()) {
} else {
// 解决部分浏览器滚动中js获取窗口高度不准确导致的问题
testReachBottomTimer = setTimeout(testReachBottom, 300)
}
}
ticking = false
}
return function onScroll () {
clearTimeout(testReachBottomTimer)
if (!ticking) {
requestAnimationFrame(trigger)
}
......
......@@ -118,13 +118,19 @@ export function showPage ({
animationType: 'pop-in',
animationDuration: 200,
uniNView: {
path: `/${url}.js?from=${getPageId()}&runtime=${runtime}&data=${encodeURIComponent(JSON.stringify(data))}`,
path: `${(typeof process === 'object' && process.env && process.env.VUE_APP_TEMPLATE_PATH) || ''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
viewport: plus_.screen.resolutionWidth
}
}
style = Object.assign(defaultStyle, style)
const page = plus_.webview.create('', pageId, style)
const page = plus_.webview.create('', pageId, style, {
extras: {
from: getPageId(),
runtime: runtime,
data
}
})
page.addEventListener('close', onClose)
addEventListener(pageId, message => {
if (typeof onMessage === 'function') {
......@@ -136,4 +142,4 @@ export function showPage ({
})
page.show(style.animationType, style.animationDuration)
return new Page(page)
}
}
......@@ -8,7 +8,8 @@ import {
} from './parser/webview-style-parser'
import {
publish
publish,
setStatusBarStyle
} from '../../bridge'
let id = 2
......@@ -75,6 +76,29 @@ export function initWebview (webview, routeOptions) {
emit('onResize', res, parseInt(webview.id))
})
webview.addEventListener('popGesture', e => {
if (e.type === 'start') {
// 设置下一个页面的 statusBarStyle
const pages = getCurrentPages()
const page = pages[pages.length - 2]
const statusBarStyle = page && page.$page.meta.statusBarStyle
statusBarStyle && setStatusBarStyle(statusBarStyle)
} else if (e.type === 'end' && !e.result) {
// 拖拽未完成,设置为当前状态栏前景色
setStatusBarStyle()
} else if (e.type === 'end' && e.result) {
const pages = getCurrentPages()
const page = pages[pages.length - 1]
page && page.$remove()
setStatusBarStyle()
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateBack'
})
}
})
// TODO 应该结束之前未完成的下拉刷新
on(webview.id + '.startPullDownRefresh', () => {
webview.beginPullToRefresh()
......@@ -85,4 +109,4 @@ export function initWebview (webview, routeOptions) {
})
return webview
}
}
......@@ -84,7 +84,7 @@ export function getSystemInfoSync () {
const {
top: windowTop,
bottom: windowBottom
} = getWindowOffset()
} = getWindowOffset(false, true)
windowHeight -= windowTop
windowHeight -= windowBottom
......
import getRealPath from 'uni-platform/helpers/get-real-path'
function _getServiceAddress () {
return window.location.protocol + '//' + window.location.host
}
......@@ -11,7 +9,7 @@ export function getImageInfo ({
invokeCallbackHandler: invoke
} = UniServiceJSBridge
const img = new Image()
const realPath = getRealPath(src)
const realPath = src
img.onload = function () {
invoke(callbackId, {
errMsg: 'getImageInfo:ok',
......@@ -26,4 +24,4 @@ export function getImageInfo ({
})
}
img.src = src
}
}
......@@ -68,6 +68,9 @@ class SocketTask {
const data = options.data
const ws = this._webSocket
try {
if (ws.readyState !== ws.OPEN) {
throw new Error('SocketTask.readyState is not OPEN')
}
ws.send(data)
this._callback(options, 'sendSocketMessage:ok')
} catch (error) {
......@@ -118,11 +121,11 @@ class SocketTask {
}
}
}
eventNames.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1)
SocketTask.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback)
}
eventNames.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1)
SocketTask.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback)
}
})
/**
* 创建一个 WebSocket 连接
......
......@@ -281,6 +281,7 @@ export default {
this.$watch('mode', this._setValue)
},
beforeDestroy () {
this.$refs.picker.remove()
this.$dispatch('Form', 'uni-form-group-update', {
type: 'remove',
vm: this
......
......@@ -91,8 +91,14 @@ export default function parseComponent (vueComponentOptions) {
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
initVm.call(this, VueComponent)
didMount () {
if (my.dd) { // 钉钉小程序底层基础库有 bug,组件嵌套使用时,在 didMount 中无法及时调用 props 中的方法
setTimeout(() => {
initVm.call(this, VueComponent)
}, 4)
} else {
initVm.call(this, VueComponent)
}
initSpecialMethods(this)
......
......@@ -14,7 +14,7 @@ const customizeRE = /:/g
const customize = cached((str) => {
return camelize(str.replace(customizeRE, '-'))
})
})
export const isComponent2 = my.canIUse('component2')
......
......@@ -15,23 +15,23 @@ export default function parseComponent (vueOptions) {
const componentOptions = parseBaseComponent(vueOptions, {
isPage,
initRelation
})
})
// 关于百度小程序新生命周期(2.0)的说明(组件作为页面时):
// lifetimes:attached --> methods:onShow --> methods:onLoad --> methods:onReady
// 这里在新生命周期强制将onShow挪到onLoad之后触发,另外一处修改在page-parser.js
const oldAttached = componentOptions.lifetimes.attached
componentOptions.lifetimes.attached = function attached () {
oldAttached.call(this)
if (isPage.call(this)) { // 百度 onLoad 在 attached 之前触发
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this.pageinstance.$vm = this.$vm
if (hasOwn(this.pageinstance, '_$args')) {
this.$vm.$mp.query = this.pageinstance._$args
this.$vm.__call_hook('onLoad', this.pageinstance._$args)
this.$vm.__call_hook('onLoad', this.pageinstance._$args)
this.$vm.__call_hook('onShow')
delete this.pageinstance._$args
}
// TODO 3.105.17以下基础库内百度 Component 作为页面时,methods 中的 onShow 不触发
!newLifecycle && this.$vm.__call_hook('onShow')
} else {
// 百度小程序组件不触发methods内的onReady
if (this.$vm) {
......
import {
isPage,
isPage,
initRelation
} from './util'
......@@ -25,13 +25,21 @@ export default function parsePage (vuePageOptions) {
initRelation
})
const newLifecycle = swan.canIUse('lifecycle-2-0')
// 纠正百度小程序新生命周期(2.0)methods:onShow在methods:onLoad之前触发的问题
if (newLifecycle) {
delete pageOptions.methods.onShow
}
pageOptions.methods.onLoad = function onLoad (args) {
// 百度 onLoad 在 attached 之前触发,先存储 args, 在 attached 里边触发 onLoad
if (this.$vm) {
this.$vm.$mp.query = args
this.$vm.__call_hook('onLoad', args)
} else {
this.pageinstance._$args = args
if (this.$vm) {
this.$vm.$mp.query = args
this.$vm.__call_hook('onLoad', args)
this.$vm.__call_hook('onShow')
} else {
this.pageinstance._$args = args
}
}
......@@ -41,4 +49,4 @@ export default function parsePage (vuePageOptions) {
}
return pageOptions
}
}
......@@ -52,7 +52,7 @@ export default function parseBaseApp (vm, {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
if (__PLATFORM__ === 'mp-weixin') {
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq') {
if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上')
}
......
......@@ -26,8 +26,8 @@ export default function parseBaseComponent (vueComponentOptions, {
addGlobalClass: true
}
if (__PLATFORM__ === 'mp-weixin') {
// 微信multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq') {
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options'])
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册