提交 6a4fff34 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -27,6 +27,12 @@ export default {
loadnext: {
type: [Boolean, String],
default: false
},
urlCallback: {
type: Object,
default () {
return {}
}
}
},
data () {
......@@ -58,7 +64,31 @@ export default {
show () {
this.errorMessage = null
this._ad = this.selectComponent('.uniad-plugin')
this._ad.show()
if (this._hasCallback()) {
const userCryptoManager = wx.getUserCryptoManager()
userCryptoManager.getLatestUserKey({
success: ({
encryptKey,
iv,
version,
expireTime
}) => {
this._ad.show({
userId: this.urlCallback.userId || '',
extra: this.urlCallback.extra || '',
encryptKey,
iv,
version,
expireTime
})
},
fail: (err) => {
this._dispatchEvent(EventType.Error, err)
}
})
} else {
this._ad.show()
}
},
_onclick () {
......@@ -80,6 +110,11 @@ export default {
return result
},
_hasCallback () {
return false
// return (typeof this.urlCallback === 'object' && Object.keys(this.urlCallback).length > 0)
},
_onmpload (e) {
this.loading = false
this._dispatchEvent(EventType.Load, {})
......@@ -87,6 +122,31 @@ export default {
_onmpclose (e) {
this._dispatchEvent(EventType.Close, e.detail)
if (e.detail.adsdata) {
const adv = e.detail.adv
const adsdata = e.detail.adsdata
const version = e.detail.version
/* eslint-disable no-undef */
uniCloud.callFunction({
name: 'uniAdCallback',
data: {
adv: adv,
adsdata: adsdata,
version: version
},
secretType: 'both',
success: (res) => {
},
fail: (err) => {
this._dispatchEvent(EventType.Error, err)
}
})
delete e.detail.adv
delete e.detail.adsdata
delete e.detail.version
}
},
_onmperror (e) {
......
......@@ -13,6 +13,12 @@ const {
getTemplatePath
} = require('@dcloudio/uni-cli-shared')
const fileLoader = require('@dcloudio/uni-cli-shared/lib/file-loader')
const {
compileI18nJsonStr
} = require('@dcloudio/uni-i18n')
const {
initI18nOptions
} = require('@dcloudio/uni-cli-shared/lib/i18n')
const WebpackAppPlusNVuePlugin = process.env.UNI_USING_V3
? require('../packages/webpack-app-plus-plugin')
: require('../packages/webpack-app-plus-nvue-plugin')
......@@ -226,11 +232,25 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
}]
// 自动化测试时,不启用androidPrivacy.json
if (!process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
if (fs.existsSync(androidPrivacyPath)) {
const fileName = 'androidPrivacy.json'
const context = path.resolve(process.env.UNI_INPUT_DIR)
if (fs.existsSync(path.join(context, fileName))) {
patterns.push({
from: androidPrivacyPath,
to: 'androidPrivacy.json'
from: fileName,
context,
to: fileName,
transform (content) {
const options = initI18nOptions(
process.env.UNI_PLATFORM,
process.env.UNI_INPUT_DIR,
false,
true
)
if (!options) {
return content
}
return compileI18nJsonStr(content.toString(), options)
}
})
}
}
......
......@@ -92,16 +92,14 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
})
// 自动化测试时,不启用androidPrivacy.json
if (process.env.UNI_PLATFORM === 'app-plus' && !process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
const from = 'android*.json'
const fileName = 'androidPrivacy.json'
const context = path.resolve(process.env.UNI_INPUT_DIR)
const options = {
from,
context,
to: `[name]${CopyWebpackPluginVersion > 5 ? '' : '.'}[ext]`,
noErrorOnMissing: true,
transform (content, path) {
if (path.endsWith(fileName)) {
if (fs.existsSync(path.join(context, fileName))) {
copyOptions.push({
from: fileName,
context,
to: fileName,
transform (content) {
const options = initI18nOptions(
process.env.UNI_PLATFORM,
process.env.UNI_INPUT_DIR,
......@@ -113,22 +111,7 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
}
return compileI18nJsonStr(content.toString(), options)
}
return content
}
}
// copy-webpack-plugin/glob-parent 存在 Bug,例如:/test/dir(1
const globParent = require(require.resolve('glob-parent', { paths: [require.resolve('copy-webpack-plugin')] }))
const parent = globParent(path.join(context, from))
let canNotWatch
if (parent !== context) {
options.from = fileName
if (!fs.existsSync(path.join(context, fileName))) {
canNotWatch = true
// console.warn(`invalid path: ${context}, can not watch ${fileName}`)
}
}
if (!canNotWatch) {
copyOptions.push(options)
})
}
}
return copyOptions
......
......@@ -4,8 +4,8 @@ module.exports = function (appJson) {
}
if (!appJson.plugins['uni-ad']) {
appJson.plugins['uni-ad'] = {
version: '1.1.0',
provider: 'wx999bf02c8e05dfc9'
version: '1.0.0',
provider: 'wxf72d316417b6767f'
}
}
if (!appJson.plugins['coral-adv']) {
......
......@@ -142,7 +142,7 @@ export function initData (vueOptions, context) {
try {
// 对 data 格式化
data = JSON.parse(JSON.stringify(data))
} catch (e) {}
} catch (e) { }
}
if (!isPlainObject(data)) {
......@@ -332,7 +332,7 @@ function wrapper (event) {
// TODO 又得兼容 mpvue 的 mp 对象
try {
event.mp = JSON.parse(JSON.stringify(event))
} catch (e) {}
} catch (e) { }
event.stopPropagation = noop
event.preventDefault = noop
......@@ -413,7 +413,7 @@ function getExtraValue (vm, dataPathsArray) {
return context
}
function processEventExtra (vm, extra, event) {
function processEventExtra (vm, extra, event, __args__) {
const extraObj = {}
if (Array.isArray(extra) && extra.length) {
......@@ -436,11 +436,7 @@ function processEventExtra (vm, extra, event) {
if (dataPath === '$event') { // $event
extraObj['$' + index] = event
} else if (dataPath === 'arguments') {
if (event.detail && event.detail.__args__) {
extraObj['$' + index] = event.detail.__args__
} else {
extraObj['$' + index] = [event]
}
extraObj['$' + index] = event.detail ? event.detail.__args__ || __args__ : __args__
} else if (dataPath.indexOf('$event.') === 0) { // $event.target.value
extraObj['$' + index] = vm.__get_value(dataPath.replace('$event.', ''), event)
} else {
......@@ -467,6 +463,12 @@ function getObjByArray (arr) {
function processEventArgs (vm, event, args = [], extra = [], isCustom, methodName) {
let isCustomMPEvent = false // wxcomponent 组件,传递原始 event 对象
// fixed 用户直接触发 mpInstance.triggerEvent
const __args__ = isPlainObject(event.detail)
? event.detail.__args__ || [event.detail]
: [event.detail]
if (isCustom) { // 自定义事件
isCustomMPEvent = event.currentTarget &&
event.currentTarget.dataset &&
......@@ -475,11 +477,11 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
if (isCustomMPEvent) {
return [event]
}
return event.detail.__args__ || event.detail
return __args__
}
}
const extraObj = processEventExtra(vm, extra, event)
const extraObj = processEventExtra(vm, extra, event, __args__)
const ret = []
args.forEach(arg => {
......@@ -488,7 +490,7 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
ret.push(event.target.value)
} else {
if (isCustom && !isCustomMPEvent) {
ret.push(event.detail.__args__[0])
ret.push(__args__[0])
} else { // wxcomponent 组件或内置组件
ret.push(event)
}
......
......@@ -92,6 +92,7 @@ class SelectorQuery {
this._page = page
this._queue = []
this._queueCb = []
this._nodesRef = null
}
exec (callback) {
......@@ -110,6 +111,8 @@ class SelectorQuery {
})
isFn(callback) && callback.call(this, res)
})
return this._nodesRef
}
['in'] (component) {
......@@ -119,15 +122,15 @@ class SelectorQuery {
}
select (selector) {
return new NodesRef(this, this._component, selector, true)
return (this._nodesRef = new NodesRef(this, this._component, selector, true))
}
selectAll (selector) {
return new NodesRef(this, this._component, selector, false)
return (this._nodesRef = new NodesRef(this, this._component, selector, false))
}
selectViewport () {
return new NodesRef(this, 0, '', true)
return (this._nodesRef = new NodesRef(this, 0, '', true))
}
_push (selector, component, single, fields, callback) {
......
......@@ -26,8 +26,8 @@ export function setClipboardData ({
textarea.style.zIndex = '-9999'
document.body.appendChild(textarea)
textarea.value = data
textarea.focus()
textarea.select()
textarea.setSelectionRange(0, textarea.value.length)
const result = document.execCommand('Copy', false, null)
textarea.blur()
if (result) {
......
......@@ -3,13 +3,17 @@
:id="id"
ref="mapContainer"
v-on="$listeners"
@touchend="handleAMapClick"
>
<map-marker
v-for="item in markers"
:key="item.id"
v-bind="item"
/>
<map-control
v-for="(item, index) in controls"
:key="item.id || index"
v-bind="item"
/>
<map-polygon
v-for="item in polygons"
:key="JSON.stringify(item.points)"
......@@ -18,6 +22,7 @@
<div
ref="map"
style="width: 100%; height: 100%; position: relative; overflow: hidden"
@click.stop
/>
<div
style="
......@@ -46,6 +51,7 @@ import {
} from './maps'
import mapMarker from './map-marker'
import mapControl from './map-control'
import mapPolygon from './map-polygon'
import { ICON_PATH_ORIGIN, IS_AMAP } from '../../../helpers/location'
......@@ -80,6 +86,7 @@ export default {
name: 'Map',
components: {
mapMarker,
mapControl,
mapPolygon
},
mixins: [subscriber],
......@@ -160,8 +167,7 @@ export default {
isMapReady: false,
isBoundsReady: false,
polylineSync: [],
circlesSync: [],
controlsSync: []
circlesSync: []
}
},
watch: {
......@@ -186,11 +192,6 @@ export default {
this.createCircles()
})
},
controls () {
this.mapReady(() => {
this.createControls()
})
},
includePoints () {
this.mapReady(() => {
this.fitBounds(this.includePoints)
......@@ -223,20 +224,9 @@ export default {
beforeDestroy () {
this.removePolyline()
this.removeCircles()
this.removeControls()
this.removeLocation()
},
methods: {
handleAMapClick (e) {
if (IS_AMAP) {
// The mobile terminal prevent not map click event trigger map click
if (e.target.nodeName !== 'CANVAS') {
return
}
const { pageX, pageY } = e.changedTouches[0]
this.$trigger('tap', { x: pageX, y: pageY }, {})
}
},
_handleSubscribe ({
type,
data = {}
......@@ -409,6 +399,9 @@ export default {
this.isBoundsReady = true
this.$emit('boundsready')
})
maps.event.addListener(map, 'click', (e) => {
this.$trigger('click', {}, {})
})
maps.event.addListener(map, 'dragstart', () => {
this.$trigger('regionchange', {}, {
type: 'begin',
......@@ -453,9 +446,6 @@ export default {
if (this.circles && Array.isArray(this.circles) && this.circles.length) {
this.createCircles()
}
if (this.controls && Array.isArray(this.controls) && this.controls.length) {
this.createControls()
}
if (this.showLocation) {
this.createLocation()
}
......@@ -597,61 +587,6 @@ export default {
})
circles.splice(0, circles.length)
},
createControls () {
const maps = this._maps
var _self = this
var map = this._map
var controls = this.controlsSync
this.removeControls()
this.controls.forEach(option => {
var position = option.position || {}
var control = document.createElement('div')
var img = new Image()
control.appendChild(img)
var style = control.style
style.position = 'absolute'
style.width = 0
style.height = 0
style.top = 0
style.left = 0
style.zIndex = 999
img.onload = () => {
if (option.position.width) {
img.width = option.position.width
}
if (option.position.height) {
img.height = option.position.height
}
var style = img.style
style.position = 'absolute'
style.left = (position.left || 0) + 'px'
style.top = (position.top || 0) + 'px'
style.maxWidth = 'initial'
}
img.src = this.$getRealPath(option.iconPath)
img.onclick = function ($event) {
if (option.clickable) {
_self.$trigger('controltap', $event, {
controlId: option.id
})
}
$event.stopPropagation()
}
if (IS_AMAP) {
this.$refs.mapContainer.appendChild(control)
} else {
map.controls[maps.ControlPosition.TOP_LEFT].push(control)
}
controls.push(control)
})
},
removeControls () {
var controls = this.controlsSync
controls.forEach(control => {
control.remove()
})
controls.splice(0, controls.length)
},
createLocation () {
const maps = this._maps
const map = this._map
......
import getRealPath from 'uni-platform/helpers/get-real-path'
export default {
props: {
id: {
type: [Number, String],
default: ''
},
position: {
type: Object,
require: true
},
iconPath: {
type: String,
require: true
},
clickable: {
type: Boolean,
default: false
}
},
data () {
return {
control: null
}
},
watch: {
props: function () {
this.updateControl()
}
},
mounted () {
this.$parent.mapReady(() => {
this.addControl()
})
},
beforeDestroy () {
this.removeControl()
},
methods: {
addControl () {
this.control = document.createElement('div')
const style = this.control.style
style.position = 'absolute'
style.width = 0
style.height = 0
style.top = 0
style.left = 0
style.zIndex = 999
const img = new Image()
img.src = getRealPath(this.iconPath)
img.onload = () => {
if (this.position.width) {
img.width = this.position.width
}
if (this.position.height) {
img.height = this.position.height
}
const style = img.style
style.position = 'absolute'
style.left = (this.position.left || 0) + 'px'
style.top = (this.position.top || 0) + 'px'
style.maxWidth = 'initial'
this.control.appendChild(img)
this.$parent.$el.appendChild(this.control)
}
img.onclick = ($event) => {
if (this.clickable) {
this.$parent.$trigger('controltap', $event, {
controlId: this.id
})
}
$event.stopPropagation()
}
},
updateControl () {
this.removeControl()
this.addControl()
},
removeControl () {
if (this.control) {
this.control.remove()
}
}
},
render () {
return null
}
}
......@@ -129,12 +129,6 @@ export default {
}
event.stopPropagation()
})
// 处理 google H5移动端 maker 点击触发 map 点击问题
maps.event.addListener(marker, 'mousedown', (e) => {
if (e.domEvent) {
e.domEvent.stopPropagation()
}
})
}
},
updateMarker (option) {
......@@ -301,6 +295,11 @@ export default {
$event.stopPropagation()
$event.preventDefault()
}
// The mobile terminal prevent google map callout click trigger map click
if (getMapInfo().type === MapType.GOOGLE) {
callout.div.onpointerdown = (e) => { e.stopPropagation() }
callout.div.ontouchstart = (e) => { e.stopPropagation() }
}
}
}
} else {
......
......@@ -15,7 +15,17 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
// 事件名统一转驼峰格式,仅处理:当前组件为 vue 组件、当前组件为 vue 组件子组件
if (this.$vm || (this.dataset && this.dataset.comType)) {
event = customize(event)
} else if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq') {
// 针对微信/QQ小程序单独补充驼峰格式事件,以兼容历史项目
const newEvent = customize(event)
if (newEvent !== event) {
oldTriggerEvent.apply(this, [newEvent, ...args])
}
}
return oldTriggerEvent.apply(this, [event, ...args])
}
try {
// 京东小程序 triggerEvent 为只读
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册