提交 39bd6ad6 编写于 作者: L lixu

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

...@@ -27,6 +27,12 @@ export default { ...@@ -27,6 +27,12 @@ export default {
loadnext: { loadnext: {
type: [Boolean, String], type: [Boolean, String],
default: false default: false
},
urlCallback: {
type: Object,
default () {
return {}
}
} }
}, },
data () { data () {
...@@ -58,7 +64,31 @@ export default { ...@@ -58,7 +64,31 @@ export default {
show () { show () {
this.errorMessage = null this.errorMessage = null
this._ad = this.selectComponent('.uniad-plugin') 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 () { _onclick () {
...@@ -80,6 +110,11 @@ export default { ...@@ -80,6 +110,11 @@ export default {
return result return result
}, },
_hasCallback () {
return false
// return (typeof this.urlCallback === 'object' && Object.keys(this.urlCallback).length > 0)
},
_onmpload (e) { _onmpload (e) {
this.loading = false this.loading = false
this._dispatchEvent(EventType.Load, {}) this._dispatchEvent(EventType.Load, {})
...@@ -87,6 +122,31 @@ export default { ...@@ -87,6 +122,31 @@ export default {
_onmpclose (e) { _onmpclose (e) {
this._dispatchEvent(EventType.Close, e.detail) 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) { _onmperror (e) {
......
...@@ -4,8 +4,8 @@ module.exports = function (appJson) { ...@@ -4,8 +4,8 @@ module.exports = function (appJson) {
} }
if (!appJson.plugins['uni-ad']) { if (!appJson.plugins['uni-ad']) {
appJson.plugins['uni-ad'] = { appJson.plugins['uni-ad'] = {
version: '1.1.0', version: '1.0.0',
provider: 'wx999bf02c8e05dfc9' provider: 'wxf72d316417b6767f'
} }
} }
if (!appJson.plugins['coral-adv']) { if (!appJson.plugins['coral-adv']) {
......
...@@ -142,7 +142,7 @@ export function initData (vueOptions, context) { ...@@ -142,7 +142,7 @@ export function initData (vueOptions, context) {
try { try {
// 对 data 格式化 // 对 data 格式化
data = JSON.parse(JSON.stringify(data)) data = JSON.parse(JSON.stringify(data))
} catch (e) {} } catch (e) { }
} }
if (!isPlainObject(data)) { if (!isPlainObject(data)) {
...@@ -332,7 +332,7 @@ function wrapper (event) { ...@@ -332,7 +332,7 @@ function wrapper (event) {
// TODO 又得兼容 mpvue 的 mp 对象 // TODO 又得兼容 mpvue 的 mp 对象
try { try {
event.mp = JSON.parse(JSON.stringify(event)) event.mp = JSON.parse(JSON.stringify(event))
} catch (e) {} } catch (e) { }
event.stopPropagation = noop event.stopPropagation = noop
event.preventDefault = noop event.preventDefault = noop
...@@ -413,7 +413,7 @@ function getExtraValue (vm, dataPathsArray) { ...@@ -413,7 +413,7 @@ function getExtraValue (vm, dataPathsArray) {
return context return context
} }
function processEventExtra (vm, extra, event) { function processEventExtra (vm, extra, event, __args__) {
const extraObj = {} const extraObj = {}
if (Array.isArray(extra) && extra.length) { if (Array.isArray(extra) && extra.length) {
...@@ -436,11 +436,7 @@ function processEventExtra (vm, extra, event) { ...@@ -436,11 +436,7 @@ function processEventExtra (vm, extra, event) {
if (dataPath === '$event') { // $event if (dataPath === '$event') { // $event
extraObj['$' + index] = event extraObj['$' + index] = event
} else if (dataPath === 'arguments') { } else if (dataPath === 'arguments') {
if (event.detail && event.detail.__args__) { extraObj['$' + index] = event.detail ? event.detail.__args__ || __args__ : __args__
extraObj['$' + index] = event.detail.__args__
} else {
extraObj['$' + index] = [event]
}
} else if (dataPath.indexOf('$event.') === 0) { // $event.target.value } else if (dataPath.indexOf('$event.') === 0) { // $event.target.value
extraObj['$' + index] = vm.__get_value(dataPath.replace('$event.', ''), event) extraObj['$' + index] = vm.__get_value(dataPath.replace('$event.', ''), event)
} else { } else {
...@@ -467,6 +463,12 @@ function getObjByArray (arr) { ...@@ -467,6 +463,12 @@ function getObjByArray (arr) {
function processEventArgs (vm, event, args = [], extra = [], isCustom, methodName) { function processEventArgs (vm, event, args = [], extra = [], isCustom, methodName) {
let isCustomMPEvent = false // wxcomponent 组件,传递原始 event 对象 let isCustomMPEvent = false // wxcomponent 组件,传递原始 event 对象
// fixed 用户直接触发 mpInstance.triggerEvent
const __args__ = isPlainObject(event.detail)
? event.detail.__args__ || [event.detail]
: [event.detail]
if (isCustom) { // 自定义事件 if (isCustom) { // 自定义事件
isCustomMPEvent = event.currentTarget && isCustomMPEvent = event.currentTarget &&
event.currentTarget.dataset && event.currentTarget.dataset &&
...@@ -475,11 +477,11 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam ...@@ -475,11 +477,11 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
if (isCustomMPEvent) { if (isCustomMPEvent) {
return [event] 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 = [] const ret = []
args.forEach(arg => { args.forEach(arg => {
...@@ -488,7 +490,7 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam ...@@ -488,7 +490,7 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
ret.push(event.target.value) ret.push(event.target.value)
} else { } else {
if (isCustom && !isCustomMPEvent) { if (isCustom && !isCustomMPEvent) {
ret.push(event.detail.__args__[0]) ret.push(__args__[0])
} else { // wxcomponent 组件或内置组件 } else { // wxcomponent 组件或内置组件
ret.push(event) ret.push(event)
} }
......
...@@ -92,6 +92,7 @@ class SelectorQuery { ...@@ -92,6 +92,7 @@ class SelectorQuery {
this._page = page this._page = page
this._queue = [] this._queue = []
this._queueCb = [] this._queueCb = []
this._nodesRef = null
} }
exec (callback) { exec (callback) {
...@@ -110,6 +111,8 @@ class SelectorQuery { ...@@ -110,6 +111,8 @@ class SelectorQuery {
}) })
isFn(callback) && callback.call(this, res) isFn(callback) && callback.call(this, res)
}) })
return this._nodesRef
} }
['in'] (component) { ['in'] (component) {
...@@ -119,15 +122,15 @@ class SelectorQuery { ...@@ -119,15 +122,15 @@ class SelectorQuery {
} }
select (selector) { select (selector) {
return new NodesRef(this, this._component, selector, true) return (this._nodesRef = new NodesRef(this, this._component, selector, true))
} }
selectAll (selector) { selectAll (selector) {
return new NodesRef(this, this._component, selector, false) return (this._nodesRef = new NodesRef(this, this._component, selector, false))
} }
selectViewport () { selectViewport () {
return new NodesRef(this, 0, '', true) return (this._nodesRef = new NodesRef(this, 0, '', true))
} }
_push (selector, component, single, fields, callback) { _push (selector, component, single, fields, callback) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册