提交 1b7bd565 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-h5/dist/index.umd.min.js
...@@ -4037,7 +4037,6 @@ var serviceContext = (function () { ...@@ -4037,7 +4037,6 @@ var serviceContext = (function () {
var onBluetoothAdapterStateChange; var onBluetoothAdapterStateChange;
var onBluetoothDeviceFound; var onBluetoothDeviceFound;
var onBLEConnectionStateChange; var onBLEConnectionStateChange;
var onBLEConnectionStateChanged;
var onBLECharacteristicValueChange; var onBLECharacteristicValueChange;
function openBluetoothAdapter (data, callbackId) { function openBluetoothAdapter (data, callbackId) {
...@@ -4072,7 +4071,6 @@ var serviceContext = (function () { ...@@ -4072,7 +4071,6 @@ var serviceContext = (function () {
function createBLEConnection (data, callbackId) { function createBLEConnection (data, callbackId) {
onBLEConnectionStateChange = onBLEConnectionStateChange || bluetoothOn('onBLEConnectionStateChange'); onBLEConnectionStateChange = onBLEConnectionStateChange || bluetoothOn('onBLEConnectionStateChange');
onBLEConnectionStateChanged = onBLEConnectionStateChanged || bluetoothOn('onBLEConnectionStateChanged');
bluetoothExec('createBLEConnection', callbackId, data); bluetoothExec('createBLEConnection', callbackId, data);
} }
...@@ -5925,7 +5923,8 @@ var serviceContext = (function () { ...@@ -5925,7 +5923,8 @@ var serviceContext = (function () {
const camera = plus.camera.getCamera(); const camera = plus.camera.getCamera();
camera.captureImage(e => invokeChooseImage(callbackId, 'ok', sizeType, [e]), camera.captureImage(e => invokeChooseImage(callbackId, 'ok', sizeType, [e]),
e => invokeChooseImage(callbackId, 'fail', 1), { e => invokeChooseImage(callbackId, 'fail', 1), {
filename: TEMP_PATH + '/camera/' filename: TEMP_PATH + '/camera/',
resolution: 'high'
}); });
}; };
const openAlbum = function (callbackId, sizeType, count) { const openAlbum = function (callbackId, sizeType, count) {
...@@ -13016,6 +13015,17 @@ var serviceContext = (function () { ...@@ -13016,6 +13015,17 @@ var serviceContext = (function () {
}; };
} }
/**
* mpvue event
*/
function wrapperMPEvent (event) {
event.mp = Object.assign({
'@warning': 'mp is deprecated'
}, event);
event._processed = true;
return event
}
const isAndroid = plus.os.name.toLowerCase() === 'android'; const isAndroid = plus.os.name.toLowerCase() === 'android';
const FOCUS_TIMEOUT = isAndroid ? 300 : 700; const FOCUS_TIMEOUT = isAndroid ? 300 : 700;
const HIDE_TIMEOUT = isAndroid ? 800 : 300; const HIDE_TIMEOUT = isAndroid ? 800 : 300;
...@@ -13105,10 +13115,7 @@ var serviceContext = (function () { ...@@ -13105,10 +13115,7 @@ var serviceContext = (function () {
parseTargets(event); parseTargets(event);
event.preventDefault = noop; event.preventDefault = noop;
event.stopPropagation = noop; event.stopPropagation = noop;
event.mp = event; return wrapperMPEvent(event)
return Object.assign({
mp: event // mpvue
}, event)
} }
const handleVdData = { const handleVdData = {
......
...@@ -92,7 +92,7 @@ module.exports = { ...@@ -92,7 +92,7 @@ module.exports = {
return uniPluginOptions.vue || '@dcloudio/vue-cli-plugin-uni/packages/mp-vue' return uniPluginOptions.vue || '@dcloudio/vue-cli-plugin-uni/packages/mp-vue'
}, },
getPlatformCssVars () { getPlatformCssVars () {
return uniPluginOptions.cssVars return uniPluginOptions.cssVars || {}
}, },
getPlatformCssnano () { getPlatformCssnano () {
return { return {
...@@ -134,4 +134,4 @@ module.exports = { ...@@ -134,4 +134,4 @@ module.exports = {
] ]
} }
} }
} }
...@@ -236,6 +236,14 @@ const v3 = { ...@@ -236,6 +236,14 @@ const v3 = {
} }
if (isAppView) { if (isAppView) {
if (process.env.UNI_USING_V3_SCOPED) {
webpackConfig.module
.rule('vue')
.use('uniapp-app-style-scoped')
.loader(path.resolve(__dirname,
'../../packages/webpack-uni-app-loader/view/style'))
}
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
require('../h5/cssnano-options')(webpackConfig) require('../h5/cssnano-options')(webpackConfig)
} }
......
...@@ -26,6 +26,8 @@ global.uniPlugin.validate.forEach(validate => { ...@@ -26,6 +26,8 @@ global.uniPlugin.validate.forEach(validate => {
process.UNI_MANIFEST = manifestJsonObj process.UNI_MANIFEST = manifestJsonObj
process.env.UNI_USING_V3_SCOPED = true
process.UNI_CLOUD = false process.UNI_CLOUD = false
process.UNI_CLOUD_TCB = false process.UNI_CLOUD_TCB = false
process.UNI_CLOUD_ALIYUN = false process.UNI_CLOUD_ALIYUN = false
...@@ -408,6 +410,10 @@ global.uniPlugin.configureEnv.forEach(configureEnv => { ...@@ -408,6 +410,10 @@ global.uniPlugin.configureEnv.forEach(configureEnv => {
configureEnv() configureEnv()
}) })
if (process.env.UNI_PLATFORM.startsWith('mp-')) {
console.log('小程序各家浏览器内核及自定义组件实现机制存在差异,可能存在样式布局兼容问题,参考:https://uniapp.dcloud.io/matter?id=mp')
}
runByHBuilderX && console.log('正在编译中...') runByHBuilderX && console.log('正在编译中...')
module.exports = { module.exports = {
......
...@@ -7,11 +7,12 @@ const splitRE = /\r?\n/g; ...@@ -7,11 +7,12 @@ const splitRE = /\r?\n/g;
const emptyRE = /^(?:\/\/)?\s*$/; const emptyRE = /^(?:\/\/)?\s*$/;
function parse(options) { function parse(options) {
const { source, filename = '', compiler, compilerParseOptions = { pad: 'line' }, sourceRoot = '', needMap = true } = options; const { source, filename = '', compiler, compilerParseOptions = { pad: 'line' }, sourceRoot = '', needMap = true } = options;
const cacheKey = hash(filename + source); // fixed by xxxxxx (添加isAppNVue标记,防止nvue与vue引用相同组件时,走了相同的cache)
const cacheKey = hash(String(options.isAppNVue) + filename + source);
let output = cache.get(cacheKey); let output = cache.get(cacheKey);
if (output) if (output)
return output; return output;
// fixed by xxxxxx // fixed by xxxxxx
output = require('./parseCustomBlocks')(compiler.parseComponent(source, compilerParseOptions), options); output = require('./parseCustomBlocks')(compiler.parseComponent(source, compilerParseOptions), options);
if (needMap) { if (needMap) {
if (output.script && !output.script.src) { if (output.script && !output.script.src) {
......
const path = require('path')
const loaderUtils = require('loader-utils')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const AppPath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, 'App.vue'))
module.exports = function(content) {
this.cacheable && this.cacheable()
if (this.resourceQuery) {
const params = loaderUtils.parseQuery(this.resourceQuery)
if (params.mpType === 'page') {
return content
}
}
if (normalizePath(this.resourcePath) === AppPath) {
return content
}
if (content.indexOf('platform="mp-weixin"') !== -1) {
return content
}
return content.replace(/(<style\b[^><]*)>/ig, '$1 scoped>')
}
...@@ -3,7 +3,7 @@ function generatePageCode (pages, pageOptions) { ...@@ -3,7 +3,7 @@ function generatePageCode (pages, pageOptions) {
if (pageOptions[pagePath].nvue) { if (pageOptions[pagePath].nvue) {
return '' return ''
} }
return `__definePage('${pagePath}',function(){return Vue.extend(require('${pagePath}.vue').default)})` return `__definePage('${pagePath}',function(){return Vue.extend(require('${pagePath}.vue?mpType=page').default)})`
}).join('\n') }).join('\n')
} }
......
...@@ -6,10 +6,11 @@ import { ...@@ -6,10 +6,11 @@ import {
* mpvue event * mpvue event
*/ */
export function wrapperMPEvent (event) { export function wrapperMPEvent (event) {
return Object.assign({ event.mp = Object.assign({
mp: event, '@warning': 'mp is deprecated'
_processed: true
}, event) }, event)
event._processed = true
return event
} }
/** /**
* app-plus titleNView * app-plus titleNView
...@@ -48,4 +49,4 @@ export function mergeTitleNView (navigationBar, titleNView) { ...@@ -48,4 +49,4 @@ export function mergeTitleNView (navigationBar, titleNView) {
} }
} }
return navigationBar return navigationBar
} }
<template> <template>
<uni-canvas <uni-canvas
:canvas-id="canvasId" :canvas-id="canvasId"
:disable-scroll="disableScroll" :disable-scroll="disableScroll"
v-on="_listeners" v-on="_listeners"
> >
<canvas <canvas
ref="canvas" ref="canvas"
width="300" width="300"
height="150" height="150"
/> />
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;"> <div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;">
<slot /> <slot />
</div> </div>
<v-uni-resize-sensor <v-uni-resize-sensor
ref="sensor" ref="sensor"
@resize="_resize" @resize="_resize"
/> />
</uni-canvas> </uni-canvas>
</template> </template>
...@@ -279,37 +279,37 @@ export default { ...@@ -279,37 +279,37 @@ export default {
} }
}, },
preloadImage: function (actions) { preloadImage: function (actions) {
var sefl = this var self = this
actions.forEach(function (action) { actions.forEach(function (action) {
var method = action.method var method = action.method
var data = action.data var data = action.data
var src = '' var src = ''
if (method === 'drawImage') { if (method === 'drawImage') {
src = data[0] src = data[0]
src = sefl.$getRealPath(src) src = self.$getRealPath(src)
data[0] = src data[0] = src
} else if (method === 'setFillStyle' && data[0] === 'pattern') { } else if (method === 'setFillStyle' && data[0] === 'pattern') {
src = data[1] src = data[1]
src = sefl.$getRealPath(src) src = self.$getRealPath(src)
data[1] = src data[1] = src
} }
if (src && !sefl._images[src]) { if (src && !self._images[src]) {
loadImage() loadImage()
} }
/** /**
* 加载图像 * 加载图像
*/ */
function loadImage () { function loadImage () {
sefl._images[src] = new Image() self._images[src] = new Image()
sefl._images[src].onload = function () { self._images[src].onload = function () {
sefl._images[src].ready = true self._images[src].ready = true
} }
/** /**
* 从Blob加载 * 从Blob加载
* @param {Blob} blob * @param {Blob} blob
*/ */
function loadBlob (blob) { function loadBlob (blob) {
sefl._images[src].src = (window.URL || window.webkitURL).createObjectURL(blob) self._images[src].src = (window.URL || window.webkitURL).createObjectURL(blob)
} }
/** /**
* 从本地文件加载 * 从本地文件加载
...@@ -318,7 +318,7 @@ export default { ...@@ -318,7 +318,7 @@ export default {
function loadFile (path) { function loadFile (path) {
var bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now()) var bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now())
bitmap.load(path, function () { bitmap.load(path, function () {
sefl._images[src].src = bitmap.toBase64Data() self._images[src].src = bitmap.toBase64Data()
bitmap.clear() bitmap.clear()
}, function () { }, function () {
bitmap.clear() bitmap.clear()
...@@ -337,7 +337,7 @@ export default { ...@@ -337,7 +337,7 @@ export default {
if (status === 200) { if (status === 200) {
loadFile(d.filename) loadFile(d.filename)
} else { } else {
sefl._images[src].src = src self._images[src].src = src
} }
}).start() }).start()
} }
...@@ -350,20 +350,20 @@ export default { ...@@ -350,20 +350,20 @@ export default {
} }
} }
xhr.onerror = window.plus ? plusDownload : function () { xhr.onerror = window.plus ? plusDownload : function () {
sefl._images[src].src = src self._images[src].src = src
} }
xhr.send() xhr.send()
} }
if (window.plus && (!window.webkit || !window.webkit.messageHandlers)) { if (window.plus && (!window.webkit || !window.webkit.messageHandlers)) {
sefl._images[src].src = src self._images[src].src = src
} else { } else {
// 解决 PLUS-APP(wkwebview)以及 H5 图像跨域问题(H5图像响应头需包含access-control-allow-origin) // 解决 PLUS-APP(wkwebview)以及 H5 图像跨域问题(H5图像响应头需包含access-control-allow-origin)
if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !== if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !==
0) { 0) {
loadFile(src) loadFile(src)
} else if (/^data:.*,.*/.test(src)) { } else if (/^data:.*,.*/.test(src)) {
sefl._images[src].src = src self._images[src].src = src
} else { } else {
loadUrl(src) loadUrl(src)
} }
...@@ -449,7 +449,7 @@ export default { ...@@ -449,7 +449,7 @@ export default {
}, this.$page.id) }, this.$page.id)
return return
} }
if (!callbackId) { if (!callbackId) {
// fix [...]展开TypedArray在低版本手机报错的问题,使用Array.prototype.slice // fix [...]展开TypedArray在低版本手机报错的问题,使用Array.prototype.slice
return { return {
data: Array.prototype.slice.call(imgData.data), data: Array.prototype.slice.call(imgData.data),
......
export default function (Quill) { export default function (Quill) {
const Image = Quill.import('formats/image') const Image = Quill.import('formats/image')
const ATTRIBUTES = [
'alt',
'height',
'width',
'data-custom',
'class',
'data-local'
]
Image.sanitize = url => url Image.sanitize = url => url
Image.formats = function formats (domNode) {
return ATTRIBUTES.reduce(function (formats, attribute) {
if (domNode.hasAttribute(attribute)) {
formats[attribute] = domNode.getAttribute(attribute)
}
return formats
}, {})
}
const format = Image.prototype.format
Image.prototype.format = function (name, value) {
if (ATTRIBUTES.indexOf(name) > -1) {
if (value) {
this.domNode.setAttribute(name, value)
} else {
this.domNode.removeAttribute(name)
}
} else {
format.call(this, name, value)
}
}
} }
...@@ -142,9 +142,15 @@ export default { ...@@ -142,9 +142,15 @@ export default {
case 'insertImage': case 'insertImage':
{ {
range = quill.getSelection(true) range = quill.getSelection(true)
const { src = '', alt = '', data = {} } = options const { src = '', alt = '', width = '', height = '', extClass = '', data = {} } = options
quill.insertEmbed(range.index, 'image', this.$getRealPath(src), Quill.sources.USER) const path = this.$getRealPath(src)
quill.insertEmbed(range.index, 'image', path, Quill.sources.USER)
const local = /^(file|blob):/.test(path) ? path : false
quill.formatText(range.index, 1, 'data-local', local)
quill.formatText(range.index, 1, 'alt', alt) quill.formatText(range.index, 1, 'alt', alt)
quill.formatText(range.index, 1, 'width', width)
quill.formatText(range.index, 1, 'height', height)
quill.formatText(range.index, 1, 'class', extClass)
quill.formatText(range.index, 1, 'data-custom', Object.keys(data).map(key => `${key}=${data[key]}`).join('&')) quill.formatText(range.index, 1, 'data-custom', Object.keys(data).map(key => `${key}=${data[key]}`).join('&'))
quill.setSelection(range.index + 1, Quill.sources.SILENT) quill.setSelection(range.index + 1, Quill.sources.SILENT)
} }
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<uni-image v-on="$listeners"> <uni-image v-on="$listeners">
<div <div
ref="content" ref="content"
:style="modeStyle" :style="modeStyle"
/> />
<img :src="realImagePath"> <img :src="realImagePath">
<v-uni-resize-sensor <v-uni-resize-sensor
v-if="mode === 'widthFix'" v-if="mode === 'widthFix'"
ref="sensor" ref="sensor"
@resize="_resize" @resize="_resize"
/> />
</uni-image> </uni-image>
</template> </template>
...@@ -34,8 +34,7 @@ export default { ...@@ -34,8 +34,7 @@ export default {
return { return {
originalWidth: 0, originalWidth: 0,
originalHeight: 0, originalHeight: 0,
availHeight: '', availHeight: ''
sizeFixed: false
} }
}, },
computed: { computed: {
...@@ -43,7 +42,7 @@ export default { ...@@ -43,7 +42,7 @@ export default {
return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0 return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0
}, },
realImagePath () { realImagePath () {
return this.src && this.$getRealPath(this.src) return this.$getRealPath(this.src)
}, },
modeStyle () { modeStyle () {
let size = 'auto' let size = 'auto'
...@@ -106,7 +105,6 @@ export default { ...@@ -106,7 +105,6 @@ export default {
mode (newValue, oldValue) { mode (newValue, oldValue) {
if (oldValue === 'widthFix') { if (oldValue === 'widthFix') {
this.$el.style.height = this.availHeight this.$el.style.height = this.availHeight
this.sizeFixed = false
} }
if (newValue === 'widthFix' && this.ratio) { if (newValue === 'widthFix' && this.ratio) {
this._fixSize() this._fixSize()
...@@ -123,7 +121,7 @@ export default { ...@@ -123,7 +121,7 @@ export default {
}, },
methods: { methods: {
_resize () { _resize () {
if (this.mode === 'widthFix' && !this.sizeFixed) { if (this.mode === 'widthFix') {
this._fixSize() this._fixSize()
} }
}, },
...@@ -136,7 +134,6 @@ export default { ...@@ -136,7 +134,6 @@ export default {
height = Math.round(height / 2) * 2 height = Math.round(height / 2) * 2
} }
this.$el.style.height = height + 'px' this.$el.style.height = height + 'px'
this.sizeFixed = true
} }
}, },
_setContentImage () { _setContentImage () {
......
<template> <template>
<uni-input <uni-input
@change.stop @change.stop
v-on="$listeners" v-on="$listeners"
> >
<div <div
ref="wrapper" ref="wrapper"
class="uni-input-wrapper" class="uni-input-wrapper"
> >
<div <div
...@@ -97,7 +97,7 @@ export default { ...@@ -97,7 +97,7 @@ export default {
}, },
data () { data () {
return { return {
inputValue: this.value + '', inputValue: this._getValueString(this.value),
composing: false, composing: false,
wrapperHeight: 0, wrapperHeight: 0,
cachedValue: '' cachedValue: ''
...@@ -133,7 +133,7 @@ export default { ...@@ -133,7 +133,7 @@ export default {
value && this._focusInput() value && this._focusInput()
}, },
value (value) { value (value) {
this.inputValue = value + '' this.inputValue = this._getValueString(value)
}, },
inputValue (value) { inputValue (value) {
this.$emit('update:value', value) this.$emit('update:value', value)
...@@ -255,6 +255,9 @@ export default { ...@@ -255,6 +255,9 @@ export default {
value: this.inputValue, value: this.inputValue,
key: this.name key: this.name
} : {} } : {}
},
_getValueString (value) {
return value === null ? '' : String(value)
} }
} }
} }
...@@ -295,7 +298,7 @@ uni-input[hidden] { ...@@ -295,7 +298,7 @@ uni-input[hidden] {
} }
.uni-input-placeholder, .uni-input-placeholder,
.uni-input-input{ .uni-input-input {
width: 100%; width: 100%;
} }
......
<script> <script>
import { import {
disableScrollBounce disableScrollBounce,
deepClone
} from 'uni-shared' } from 'uni-shared'
function calc (e) { function calc (e) {
...@@ -56,9 +57,9 @@ export default { ...@@ -56,9 +57,9 @@ export default {
} }
return get(target) return get(target)
}, },
_touchstart (t) { _touchstart (t) {
disableScrollBounce({ disableScrollBounce({
disable: true disable: true
}) })
var i = t.touches var i = t.touches
if (i) { if (i) {
...@@ -94,9 +95,9 @@ export default { ...@@ -94,9 +95,9 @@ export default {
} }
} }
}, },
_touchend (e) { _touchend (e) {
disableScrollBounce({ disableScrollBounce({
disable: false disable: false
}) })
var t = e.touches var t = e.touches
if (!(t && t.length)) { if (!(t && t.length)) {
...@@ -142,8 +143,9 @@ export default { ...@@ -142,8 +143,9 @@ export default {
}, },
render (createElement) { render (createElement) {
var items = [] var items = []
if (this.$slots.default) { const $slots = this.$slots.default && deepClone(this.$slots.default, createElement)
this.$slots.default.forEach(vnode => { if ($slots) {
$slots.forEach(vnode => {
if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-movable-view') { if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-movable-view') {
items.push(vnode) items.push(vnode)
} }
...@@ -163,7 +165,7 @@ export default { ...@@ -163,7 +165,7 @@ export default {
on: { on: {
resize: this._resize resize: this._resize
} }
}), this.$slots.default]) }), $slots])
} }
} }
</script> </script>
...@@ -178,4 +180,4 @@ export default { ...@@ -178,4 +180,4 @@ export default {
uni-movable-area[hidden] { uni-movable-area[hidden] {
display: none; display: none;
} }
</style> </style>
<script> <script>
import { deepClone } from 'uni-shared'
export default { export default {
name: 'PickerView', name: 'PickerView',
props: { props: {
...@@ -93,7 +95,7 @@ export default { ...@@ -93,7 +95,7 @@ export default {
render (createElement) { render (createElement) {
var items = [] var items = []
if (this.$slots.default) { if (this.$slots.default) {
this.$slots.default.forEach(vnode => { deepClone(this.$slots.default, createElement).forEach(vnode => {
if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-picker-view-column') { if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-picker-view-column') {
items.push(vnode) items.push(vnode)
} }
......
<script> <script>
import touchtrack from 'uni-mixins/touchtrack' import touchtrack from 'uni-mixins/touchtrack'
import { deepClone } from 'uni-shared'
function deepClone (vnodes, createElement) {
function cloneVNode (vnode) {
var clonedChildren = vnode.children && vnode.children.map(cloneVNode)
var cloned = createElement(vnode.tag, vnode.data, clonedChildren)
cloned.text = vnode.text
cloned.isComment = vnode.isComment
cloned.componentOptions = vnode.componentOptions
cloned.elm = vnode.elm
cloned.context = vnode.context
cloned.ns = vnode.ns
cloned.isStatic = vnode.isStatic
cloned.key = vnode.key
return cloned
}
return vnodes.map(cloneVNode)
}
export default { export default {
name: 'Swiper', name: 'Swiper',
......
...@@ -119,7 +119,7 @@ export default { ...@@ -119,7 +119,7 @@ export default {
}, },
data () { data () {
return { return {
valueSync: String(this.value), valueSync: this._getValueString(this.value),
valueComposition: '', valueComposition: '',
composition: false, composition: false,
focusSync: this.focus, focusSync: this.focus,
...@@ -152,7 +152,7 @@ export default { ...@@ -152,7 +152,7 @@ export default {
}, },
watch: { watch: {
value (val) { value (val) {
this.valueSync = String(val) this.valueSync = this._getValueString(val)
}, },
valueSync (val) { valueSync (val) {
if (val !== this._oldValue) { if (val !== this._oldValue) {
...@@ -296,6 +296,9 @@ export default { ...@@ -296,6 +296,9 @@ export default {
}, },
_resetFormData () { _resetFormData () {
this.valueSync = '' this.valueSync = ''
},
_getValueString (value) {
return value === null ? '' : String(value)
} }
} }
} }
......
...@@ -6,10 +6,10 @@ import { ...@@ -6,10 +6,10 @@ import {
export default { export default {
methods: { methods: {
$getRealPath (src) { $getRealPath (src) {
return getRealPath(src) return src ? getRealPath(src) : src
}, },
$trigger (name, $event, detail) { $trigger (name, $event, detail) {
this.$emit(name, processEvent.call(this, name, $event, detail, this.$el, this.$el)) this.$emit(name, processEvent.call(this, name, $event, detail, this.$el, this.$el))
} }
} }
} }
...@@ -107,6 +107,10 @@ export default { ...@@ -107,6 +107,10 @@ export default {
UniViewJSBridge.unsubscribe('hideKeyboard', this.hideKeyboardTemp) UniViewJSBridge.unsubscribe('hideKeyboard', this.hideKeyboardTemp)
document.removeEventListener('click', iosHideKeyboard, false) document.removeEventListener('click', iosHideKeyboard, false)
this.resetSoftinputNavBar() this.resetSoftinputNavBar()
// 修复ios端显示与点击位置错位的Bug by:wyq
if (document.body.scrollIntoView) {
document.body.scrollIntoView()
}
} }
} }
} }
...@@ -97,7 +97,8 @@ const openCamera = function (callbackId, sizeType) { ...@@ -97,7 +97,8 @@ const openCamera = function (callbackId, sizeType) {
const camera = plus.camera.getCamera() const camera = plus.camera.getCamera()
camera.captureImage(e => invokeChooseImage(callbackId, 'ok', sizeType, [e]), camera.captureImage(e => invokeChooseImage(callbackId, 'ok', sizeType, [e]),
e => invokeChooseImage(callbackId, 'fail', 1), { e => invokeChooseImage(callbackId, 'fail', 1), {
filename: TEMP_PATH + '/camera/' filename: TEMP_PATH + '/camera/',
resolution: 'high'
}) })
} }
const openAlbum = function (callbackId, sizeType, count) { const openAlbum = function (callbackId, sizeType, count) {
......
...@@ -168,7 +168,7 @@ export function showActionSheet ({ ...@@ -168,7 +168,7 @@ export function showActionSheet ({
} }
if (plus.os.name === 'iOS') { if (plus.os.name === 'iOS') {
options.cancel = '取消' options.cancel = ''
} }
plus.nativeUI.actionSheet(Object.assign(options, { popover }), (e) => { plus.nativeUI.actionSheet(Object.assign(options, { popover }), (e) => {
......
...@@ -3,6 +3,10 @@ import { ...@@ -3,6 +3,10 @@ import {
noop noop
} from 'uni-shared' } from 'uni-shared'
import {
wrapperMPEvent
} from 'uni-helpers/patch'
import { import {
VD_SYNC, VD_SYNC,
UI_EVENT, UI_EVENT,
...@@ -55,10 +59,7 @@ function wrapperEvent (event) { ...@@ -55,10 +59,7 @@ function wrapperEvent (event) {
parseTargets(event) parseTargets(event)
event.preventDefault = noop event.preventDefault = noop
event.stopPropagation = noop event.stopPropagation = noop
event.mp = event return wrapperMPEvent(event)
return Object.assign({
mp: event // mpvue
}, event)
} }
const handleVdData = { const handleVdData = {
......
...@@ -166,7 +166,7 @@ export default { ...@@ -166,7 +166,7 @@ export default {
this.map && this.map[val ? 'hide' : 'show']() this.map && this.map[val ? 'hide' : 'show']()
}, },
scale (val) { scale (val) {
this.map && this.map.setZoom(val) this.map && this.map.setZoom(parseInt(val))
}, },
latitude (val) { latitude (val) {
this.map && this.map.setStyles({ this.map && this.map.setStyles({
...@@ -197,7 +197,7 @@ export default { ...@@ -197,7 +197,7 @@ export default {
map.__markers__ = {} map.__markers__ = {}
map.__lines__ = [] map.__lines__ = []
map.__circles__ = [] map.__circles__ = []
map.setZoom(this.scale) map.setZoom(parseInt(this.scale))
plus.webview.currentWebview().append(map) plus.webview.currentWebview().append(map)
if (this.hidden) { if (this.hidden) {
map.hide() map.hide()
...@@ -238,11 +238,12 @@ export default { ...@@ -238,11 +238,12 @@ export default {
}) })
}, },
getCenterLocation ({ callbackId }) { getCenterLocation ({ callbackId }) {
const center = this.map.getCenter() this.map.getCurrentCenter((state, point) => {
this._publishHandler(callbackId, { this._publishHandler(callbackId, {
longitude: center.longitude, longitude: point.longitude,
latitude: center.latitude, latitude: point.latitude,
errMsg: 'getCenterLocation:ok' errMsg: 'getCenterLocation:ok'
})
}) })
}, },
getRegion ({ callbackId }) { getRegion ({ callbackId }) {
...@@ -319,11 +320,18 @@ export default { ...@@ -319,11 +320,18 @@ export default {
nativeMap.__markers__[id + ''] = nativeMarker nativeMap.__markers__[id + ''] = nativeMarker
}) })
}, },
_clearMarkers () {
const map = this.map
const data = map.__markers__
for (const key in data) {
map.removeOverlay(data[key])
}
map.__markers__ = {}
},
_addMarkers (markers, clear) { _addMarkers (markers, clear) {
if (this.map) { if (this.map) {
if (clear) { if (clear) {
this.map.clearOverlays() this._clearMarkers()
this.map.__markers__ = {}
} }
markers.forEach(marker => { markers.forEach(marker => {
this._addMarker(this.map, marker) this._addMarker(this.map, marker)
......
...@@ -127,7 +127,7 @@ function getData (id, name) { ...@@ -127,7 +127,7 @@ function getData (id, name) {
try { try {
return this.$r[id][name] return this.$r[id][name]
} catch (e) { } catch (e) {
console.error(this.$options.__file + `:[${this._$id}]$r[${id}][${name}] is undefined`) // console.error(this.$options.__file + `:[${this._$id}]$r[${id}][${name}] is undefined`)
} }
} }
/** /**
...@@ -143,7 +143,7 @@ function getChangeData (id, name) { ...@@ -143,7 +143,7 @@ function getChangeData (id, name) {
this.$set(this.wxsProps, wxsPropName, value) this.$set(this.wxsProps, wxsPropName, value)
return value return value
} catch (e) { } catch (e) {
console.error(this.$options.__file + `:[${this._$id}]$r[${id}][${name}] is undefined`) // console.error(this.$options.__file + `:[${this._$id}]$r[${id}][${name}] is undefined`)
} }
} }
......
...@@ -55,7 +55,7 @@ export function chooseImage ({ ...@@ -55,7 +55,7 @@ export function chooseImage ({
for (let i = 0; i < fileCount; i++) { for (let i = 0; i < fileCount; i++) {
const file = event.target.files[i] const file = event.target.files[i]
let filePath let filePath
Object.defineProperty(file, 'filePath', { Object.defineProperty(file, 'path', {
get () { get () {
filePath = filePath || fileToUrl(file) filePath = filePath || fileToUrl(file)
return filePath return filePath
......
...@@ -95,43 +95,61 @@ export function debounce (fn, delay) { ...@@ -95,43 +95,61 @@ export function debounce (fn, delay) {
export function kebabCase (string) { export function kebabCase (string) {
return string.replace(/[A-Z]/g, str => '-' + str.toLowerCase()) return string.replace(/[A-Z]/g, str => '-' + str.toLowerCase())
} }
/** /**
* Check if two values are loosely equal - that is, * Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape? * if they are plain objects, do they have the same shape?
*/ */
export function looseEqual (a, b) { export function looseEqual (a, b) {
if (a === b) return true if (a === b) return true
const isObjectA = isObject(a) const isObjectA = isObject(a)
const isObjectB = isObject(b) const isObjectB = isObject(b)
if (isObjectA && isObjectB) { if (isObjectA && isObjectB) {
try { try {
const isArrayA = Array.isArray(a) const isArrayA = Array.isArray(a)
const isArrayB = Array.isArray(b) const isArrayB = Array.isArray(b)
if (isArrayA && isArrayB) { if (isArrayA && isArrayB) {
return a.length === b.length && a.every((e, i) => { return a.length === b.length && a.every((e, i) => {
return looseEqual(e, b[i]) return looseEqual(e, b[i])
}) })
} else if (a instanceof Date && b instanceof Date) { } else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime() return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) { } else if (!isArrayA && !isArrayB) {
const keysA = Object.keys(a) const keysA = Object.keys(a)
const keysB = Object.keys(b) const keysB = Object.keys(b)
return keysA.length === keysB.length && keysA.every(key => { return keysA.length === keysB.length && keysA.every(key => {
return looseEqual(a[key], b[key]) return looseEqual(a[key], b[key])
}) })
} else { } else {
/* istanbul ignore next */ /* istanbul ignore next */
return false return false
} }
} catch (e) { } catch (e) {
/* istanbul ignore next */ /* istanbul ignore next */
return false return false
} }
} else if (!isObjectA && !isObjectB) { } else if (!isObjectA && !isObjectB) {
return String(a) === String(b) return String(a) === String(b)
} else { } else {
return false return false
} }
} }
export function deepClone (vnodes, createElement) {
function cloneVNode (vnode) {
var clonedChildren = vnode.children && vnode.children.map(cloneVNode)
var cloned = createElement(vnode.tag, vnode.data, clonedChildren)
cloned.text = vnode.text
cloned.isComment = vnode.isComment
cloned.componentOptions = vnode.componentOptions
cloned.elm = vnode.elm
cloned.context = vnode.context
cloned.ns = vnode.ns
cloned.isStatic = vnode.isStatic
cloned.key = vnode.key
return cloned
}
return vnodes.map(cloneVNode)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册