提交 0fe18d34 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'v3' of https://github.com/dcloudio/uni-app into v3

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,function(){"use strict";function i(e,n){var i={options:{timestamp:+new Date},name:e,arg:n};if(!window.plus)return window.parent.postMessage({type:s,data:i,pageId:""},"*");if(0===d.length){var t=plus.webview.currentWebview();if(!t)throw new Error("plus.webview.currentWebview() is undefined");var a=t.parent(),r="";r=a?a.id:t.id,d.push(r)}var o=JSON.stringify(i);plus.webview.getWebviewById(u)?plus.webview.postMessageToUniNView({type:s,args:{data:i,webviewIds:d}},u):plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat(s,'",').concat(o,",").concat(JSON.stringify(d),");"))}var d=[],u="__uniapp__service",s="WEB_INVOKE_APPSERVICE",n={navigateTo:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("navigateTo",{url:encodeURI(n)})},navigateBack:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).delta;i("navigateBack",{delta:parseInt(n)||1})},switchTab:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("switchTab",{url:encodeURI(n)})},reLaunch:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("reLaunch",{url:encodeURI(n)})},redirectTo:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("redirectTo",{url:encodeURI(n)})},getEnv:function(e){window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(e){i("postMessage",(0<arguments.length&&void 0!==e?e:{}).data||{})}},t=/uni-app/i.test(navigator.userAgent),a=/complete|loaded|interactive/;var r=window.my&&-1<navigator.userAgent.indexOf("AlipayClient");var o=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var w=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var g=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var c=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);for(var e,v=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},m=[function(e){if(t)return window.plus&&a.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),n},function(e){if(c)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(w)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(r){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(o)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(g)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),n}],p=0;p<m.length&&!(e=m[p](v));p++);e=e||{};var f="undefined"!=typeof uni?uni:{};return f.navigateTo?f.miniProgram=e:Object.assign(f,e,{miniProgram:e}),f});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,function(){"use strict";function i(e,n){var i={options:{timestamp:+new Date},name:e,arg:n};if(window.__dcloud_weex_postMessage||window.__dcloud_weex_){if("postMessage"===e){var t={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(t):window.__dcloud_weex_.postMessage(JSON.stringify(t))}var o={type:c,args:{data:i,webviewIds:w}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(o):window.__dcloud_weex_.postMessageToService(JSON.stringify(o))}if(!window.plus)return window.parent.postMessage({type:c,data:i,pageId:""},"*");if(0===w.length){var a=plus.webview.currentWebview();if(!a)throw new Error("plus.webview.currentWebview() is undefined");var d=a.parent(),r="";r=d?d.id:a.id,w.push(r)}if(plus.webview.getWebviewById(u))plus.webview.postMessageToUniNView({type:c,args:{data:i,webviewIds:w}},u);else{var s=JSON.stringify(i);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat(c,'",').concat(s,",").concat(JSON.stringify(w),");"))}}var w=[],u="__uniapp__service",c="WEB_INVOKE_APPSERVICE",n={navigateTo:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("navigateTo",{url:encodeURI(n)})},navigateBack:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).delta;i("navigateBack",{delta:parseInt(n)||1})},switchTab:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("switchTab",{url:encodeURI(n)})},reLaunch:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("reLaunch",{url:encodeURI(n)})},redirectTo:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("redirectTo",{url:encodeURI(n)})},getEnv:function(e){window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(e){i("postMessage",(0<arguments.length&&void 0!==e?e:{}).data||{})}},t=/uni-app/i.test(navigator.userAgent),o=/complete|loaded|interactive/;var a=window.my&&-1<navigator.userAgent.indexOf("AlipayClient");var d=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var r=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var s=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var g=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);for(var e,v=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},p=[function(e){if(t)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&o.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),n},function(e){if(g)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(r)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(a){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(d)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(s)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),n}],l=0;l<p.length&&!(e=p[l](v));l++);e=e||{};var f="undefined"!=typeof uni?uni:{};return f.navigateTo?f.webView=e:Object.assign(f,e,{webView:e}),f});
......@@ -123,7 +123,7 @@ export default {
focusSync: this.focus,
height: 0,
focusChangeSource: '',
isIOS: String(navigator.platform).indexOf('iP') === 0 && String(navigator.vendor).indexOf('Apple') === 0
isIOS: String(navigator.platform).indexOf('iP') === 0 && String(navigator.vendor).indexOf('Apple') === 0 && String(navigator.appVersion).split('OS ')[1].split('_')[0] < 13
}
},
computed: {
......
import {
plusReady
} from 'uni-shared'
function hideKeyboard () {
document.activeElement.blur()
}
......@@ -34,15 +38,6 @@ export default {
this.onKeyboardHide()
},
methods: {
plusReady (callback) {
if (!callback) {
return
}
if (window.plus) {
return callback()
}
document.addEventListener('plusready', callback)
},
initKeyboard (el) {
el.addEventListener('focus', () => {
UniViewJSBridge.subscribe('hideKeyboard', hideKeyboard)
......@@ -52,12 +47,12 @@ export default {
el.addEventListener('blur', this.onKeyboardHide)
},
showSoftKeybord () {
this.plusReady(() => {
plusReady(() => {
plus.key.showSoftKeybord()
})
},
setSoftinputTemporary () {
this.plusReady(() => {
plusReady(() => {
var currentWebview = plus.webview.currentWebview()
var style = currentWebview.getStyle() || {}
if (style.softinputMode === 'adjustResize') {
......
......@@ -11,13 +11,42 @@ const publish = function (method, params) {
name: method,
arg: params
}
if (!window.plus) { // h5
const isNvue = window.__dcloud_weex_postMessage || window.__dcloud_weex_
if (isNvue) { // nvue web-view
if (method === 'postMessage') {
const message = {
data: [params]
}
if (window.__dcloud_weex_postMessage) {
return window.__dcloud_weex_postMessage(message)
} else {
return window.__dcloud_weex_.postMessage(JSON.stringify(message))
}
}
const serviceMessage = {
type: WEB_INVOKE_APPSERVICE,
args: {
data: paramsObj,
webviewIds
}
}
if (window.__dcloud_weex_postMessage) {
window.__dcloud_weex_postMessageToService(serviceMessage)
} else {
window.__dcloud_weex_.postMessageToService(JSON.stringify(serviceMessage))
}
}
if (!window.plus) { // h5 web-view
return window.parent.postMessage({
type: WEB_INVOKE_APPSERVICE,
data: paramsObj,
pageId: ''
}, '*')
}
// app-plus
if (webviewIds.length === 0) {
const currentWebview = plus.webview.currentWebview()
......@@ -34,7 +63,6 @@ const publish = function (method, params) {
}
webviewIds.push(webviewId)
}
const paramsString = JSON.stringify(paramsObj)
if (plus.webview.getWebviewById(UNIAPP_SERVICE_NVUE_ID)) {
plus.webview.postMessageToUniNView({
type: WEB_INVOKE_APPSERVICE,
......@@ -44,6 +72,7 @@ const publish = function (method, params) {
}
}, UNIAPP_SERVICE_NVUE_ID)
} else {
const paramsString = JSON.stringify(paramsObj)
plus.webview.getLaunchWebview().evalJS(
`UniPlusBridge.subscribeHandler("${WEB_INVOKE_APPSERVICE}",${paramsString},${JSON.stringify(webviewIds)});`
)
......
......@@ -8,7 +8,9 @@ export function initWebviewApi (readyCallback) {
if (!isAppPlus) {
return
}
if (window.plus && readyRE.test(document.readyState)) {
if (window.__dcloud_weex_postMessage || window.__dcloud_weex_) { // nvue web-view
document.addEventListener('DOMContentLoaded', readyCallback)
} else if (window.plus && readyRE.test(document.readyState)) {
setTimeout(readyCallback, 0)
} else {
document.addEventListener('plusready', readyCallback)
......
import {
APP_SERVICE_ID
} from '../constants'
function plusReady (callback) {
if (!callback) {
return
}
if (window.plus) {
return callback()
}
document.addEventListener('plusready', callback)
}
import {
plusReady
} from 'uni-shared'
export function publishHandler (event, args = {}) {
plusReady(function () {
......
<template>
<uni-cover-image
:src="src"
:style="imageInfo"
v-on="$listeners">
<div
ref="container"
......@@ -10,6 +11,12 @@
<script>
import native from '../../mixins/native'
import cover from '../../mixins/cover'
import {
plusReady
} from 'uni-shared'
import {
TEMP_PATH
} from '../../../service/api/constants'
export default {
name: 'CoverImage',
......@@ -18,16 +25,80 @@ export default {
src: {
type: String,
default: ''
},
autoSize: {
type: [Boolean, String],
default: false
}
},
data () {
return {
coverType: 'image'
coverType: 'image',
coverContent: '',
imageInfo: {}
}
},
watch: {
src () {
this.loadImage()
}
},
created () {
this.loadImage()
},
beforeDestroy () {
const downloaTask = this.downloaTask
if (downloaTask && downloaTask.state < 4) {
downloaTask.abort()
}
},
methods: {
loadImage () {
this.coverContent = ''
this.imageInfo = this.autoSize ? { width: 0, height: 0 } : {}
const realPath = this.src ? this.$getRealPath(this.src) : ''
if (realPath.indexOf('http://') === 0 || realPath.indexOf('https://') === 0) {
plusReady(() => {
this.downloaTask = plus.downloader.createDownload(realPath, {
filename: TEMP_PATH + '/download/'
}, (task, status) => {
if (status === 200) {
this.getImageInfo(task.filename)
} else {
this.$trigger('error', {}, {
errMsg: 'error'
})
}
}).start()
})
} else if (realPath) {
this.getImageInfo(realPath)
}
},
computed: {
coverContent () {
return this.$getRealPath(this.src)
getImageInfo (src) {
this.coverContent = src
plusReady(() => {
plus.io.getImageInfo({
src,
success: ({ width, height }) => {
if (this.autoSize) {
this.imageInfo = {
width: `${width}px`,
height: `${height}px`
}
if (this._isMounted) {
this._requestPositionUpdate()
}
}
this.$trigger('load', {}, { width, height })
},
fail: () => {
this.$trigger('error', {}, {
errMsg: 'error'
})
}
})
})
}
}
}
......
......@@ -10,6 +10,7 @@
:key="index"
:src="control.iconPath"
:style="control.position"
auto-size
@click="controlclick(control)"/>
<div class="uni-map-slot">
<slot />
......
......@@ -3,3 +3,4 @@ export * from './util'
export * from './color'
export * from './query'
export * from './scroll'
export * from './platform'
export function plusReady (callback) {
if (typeof callback !== 'function') {
return
}
if (window.plus) {
return callback()
}
document.addEventListener('plusready', callback)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册