提交 6934b710 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -108,7 +108,8 @@
"my": true,
"swan": true,
"tt": true,
"qh": true,
"qh": true,
"qa": true,
"weex": true,
"__id__": true,
"__uniConfig": true,
......
......@@ -97,7 +97,7 @@ const plugins = [
new WebpackAppPlusNVuePlugin()
]
const excludeModuleReg = /node_modules(?!(\/|\\).*(weex).*)/
// const excludeModuleReg = /node_modules(?!(\/|\\).*(weex).*)/
const rules = [{
test: path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
......@@ -119,10 +119,10 @@ const rules = [{
}
},
jsPreprocessorLoader
],
exclude (modulePath) {
return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1
}
]
// exclude (modulePath) { // nvue js均提供babel,否则还得提供transpileDependencies配置
// return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1
// }
},
{
test: [/\.nvue(\?[^?]+)?$/, /\.vue(\?[^?]+)?$/],
......
......@@ -3,6 +3,12 @@ const path = require('path')
const mkdirp = require('mkdirp')
const loaderUtils = require('loader-utils')
const hasOwnProperty = Object.prototype.hasOwnProperty
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
process.UNI_CLOUD = false
process.UNI_CLOUD_TCB = false
process.UNI_CLOUD_ALIYUN = false
......@@ -124,7 +130,7 @@ process.UNI_STAT_CONFIG = {
// 默认启用 自定义组件模式
// if (isInHBuilderXAlpha) {
let usingComponentsAbsent = false
if (!platformOptions.hasOwnProperty('usingComponents')) {
if (!hasOwn(platformOptions, 'usingComponents')) {
usingComponentsAbsent = true
}
platformOptions.usingComponents = true
......@@ -173,12 +179,15 @@ if (process.env.UNI_PLATFORM === 'app-plus') {
isNVueCompiler = false
}
if (
platformOptions.compilerVersion === '3' ||
platformOptions.compilerVersion === 3
!hasOwn(platformOptions, 'compilerVersion') || // 默认v3
(
platformOptions.compilerVersion === '3' ||
platformOptions.compilerVersion === 3
)
) {
delete process.env.UNI_USING_CACHE
if (platformOptions.renderer === 'native') {
process.env.UNI_USING_V3_NATIVE = true
process.env.UNI_USING_V3_NATIVE = true
} else {
process.env.UNI_USING_V3 = true
platformOptions.usingComponents = true
......@@ -269,7 +278,8 @@ const needWarning = !platformOptions.usingComponents || usingComponentsAbsent
let hasNVue = false
// 输出编译器版本等信息
if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
console.log('当前nvue编译模式' + (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + '' + (isNVueCompiler ? 'uni-app' : 'weex') +
console.log('当前nvue编译模式' + (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + '' + (isNVueCompiler ? 'uni-app'
: 'weex') +
' 。编译模式差异见:https://ask.dcloud.net.cn/article/36074')
} else if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'quickapp') {
try {
......
......@@ -92,7 +92,7 @@ function getStylesCode(loaderContext) {
'app-vue'
)
}
return stylesCode.replace(/main\.js/g, 'App.vue')
return stylesCode.replace(/main\.[jt]s/g, 'App.vue')
}
module.exports = function(source, map) {
......
......@@ -42,7 +42,8 @@ var isReady=false;var onReadyCallbacks=[];
var __uniConfig = ${JSON.stringify(appJson, null)};
var __uniRoutes = ${JSON.stringify(__uniRoutes)};
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,window:void 0}}}});
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,window:void 0,global:void 0}}}});
`
}
}
}
......@@ -18,17 +18,13 @@ UniServiceJSBridge.subscribe('onMapMethodCallback', ({
callback.invoke(callbackId, data)
})
const methods = ['getCenterLocation', 'getScale', 'getRegion', 'includePoints', 'translateMarker']
const methods = ['getCenterLocation', 'moveToLocation', 'getScale', 'getRegion', 'includePoints', 'translateMarker']
export class MapContext {
constructor (id, pageVm) {
this.id = id
this.pageVm = pageVm
}
moveToLocation () {
operateMapPlayer(this.id, this.pageVm, 'moveToLocation')
}
}
MapContext.prototype.$getAppMap = function () {
......
......@@ -44,7 +44,10 @@ export default {
methods: {
initKeyboard (el) {
el.addEventListener('focus', () => {
UniViewJSBridge.subscribe('hideKeyboard', hideKeyboard)
this.hideKeyboardTemp = function () {
hideKeyboard()
}
UniViewJSBridge.subscribe('hideKeyboard', this.hideKeyboardTemp)
document.addEventListener('click', iosHideKeyboard, false)
this.setSoftinputNavBar()
this.setSoftinputTemporary()
......@@ -101,7 +104,7 @@ export default {
}
},
onKeyboardHide () {
UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard)
UniViewJSBridge.unsubscribe('hideKeyboard', this.hideKeyboardTemp)
document.removeEventListener('click', iosHideKeyboard, false)
this.resetSoftinputNavBar()
}
......
......@@ -2,17 +2,14 @@
const eventNames = [
'load',
'close',
'verify',
'error'
]
const ERROR_CODE_LIST = [-5001, -5002, -5003, -5004, -5005, -5006]
class RewardedVideoAd {
constructor (adpid) {
this._options = {
adpid: adpid
}
constructor (options = {}) {
const _callbacks = this._callbacks = {}
eventNames.forEach(item => {
_callbacks[item] = []
......@@ -26,7 +23,7 @@ class RewardedVideoAd {
this._adError = ''
this._loadPromiseResolve = null
this._loadPromiseReject = null
const rewardAd = this._rewardAd = plus.ad.createRewardedVideoAd(this._options)
const rewardAd = this._rewardAd = plus.ad.createRewardedVideoAd(options)
rewardAd.onLoad((e) => {
this._isLoad = true
this._dispatchEvent('load', {})
......@@ -39,6 +36,9 @@ class RewardedVideoAd {
this._loadAd()
this._dispatchEvent('close', { isEnded: e.isEnded })
})
rewardAd.onVerify((e) => {
this._dispatchEvent('verify', { isValid: e.isValid })
})
rewardAd.onError((e) => {
const { code, message } = e
const data = { code: code, errMsg: message }
......@@ -72,6 +72,12 @@ class RewardedVideoAd {
}
})
}
getProvider () {
return this._rewardAd.getProvider()
}
destroy () {
this._rewardAd.destroy()
}
_loadAd () {
this._isLoad = false
this._rewardAd.load()
......@@ -85,8 +91,6 @@ class RewardedVideoAd {
}
}
export function createRewardedVideoAd ({
adpid = ''
} = {}) {
return new RewardedVideoAd(adpid)
export function createRewardedVideoAd (options) {
return new RewardedVideoAd(options)
}
import {
invoke
} from '../../bridge'
import {
showPage
} from '../page.js'
export function openLocation (data) {
export function openLocation (data, callbackId) {
showPage({
url: '__uniappopenlocation',
data,
style: {
titleNView: {
type: 'transparent'
}
},
popGesture: 'close',
backButtonAutoControl: 'close'
},
onClose () {
invoke(callbackId, {
errMsg: 'openLocation:fail cancel'
})
}
})
return {
......
......@@ -5,7 +5,7 @@ function onMessage (pageId, arg) {
return
}
if (!page.$page.meta.isNVue) {
const target = page.$vm._$vd.elements.find(target => target.tagName === 'web-view' && target.events['message'])
const target = page.$vm._$vd.elements.find(target => target.type === 'web-view' && target.events['message'])
if (!target) {
return
}
......
......@@ -229,8 +229,11 @@ export default {
}
this.map && this[type](data)
},
moveToLocation (data) {
this.map.setCenter(new plus.maps.Point(this.longitude, this.latitude))
moveToLocation ({ callbackId, longitude, latitude }) {
this.map.setCenter(new plus.maps.Point(longitude || this.longitude, latitude || this.latitude))
this._publishHandler(callbackId, {
errMsg: 'moveToLocation:ok'
})
},
getCenterLocation ({ callbackId }) {
const center = this.map.getCenter()
......
......@@ -4,10 +4,17 @@ const SCHEME_RE = /^([a-z-]+:)?\/\//i
const DATA_RE = /^data:.*,.*/
function addBase (filePath) {
if (__uniConfig.router.base) {
return __uniConfig.router.base + filePath
const base = __uniConfig.router.base
if (!base) {
return filePath
}
return filePath
if (base !== '/') {
// 部分地址已经带了base(如被webpack处理过的资源自动带了publicPath)
if (('/' + filePath).indexOf(base) === 0) {
return '/' + filePath
}
}
return base + filePath
}
export default function getRealPath (filePath) {
......
......@@ -348,10 +348,12 @@ export default {
})
})
break
case 'moveToLocation':
var locationPosition = this._locationPosition
case 'moveToLocation':
const { latitude, longitude } = data
var locationPosition = (latitude && longitude) ? new maps.LatLng(latitude, longitude) : this._locationPosition
if (locationPosition) {
this._map.setCenter(locationPosition)
this._map.setCenter(locationPosition)
callback({})
}
break
case 'translateMarker':
......
......@@ -353,7 +353,9 @@ export default {
}
const length = this.valueSync.length = Math.max(val.length, this.range.length)
for (let index = 0; index < length; index++) {
this.valueSync.splice(index, 1, Number(val[index]) || Number(this.valueSync[index]) || 0)
const val0 = Number(val[index])
const val1 = Number(this.valueSync[index])
this.valueSync.splice(index, 1, isNaN(val0) ? (isNaN(val1) ? 0 : val1) : val0)
}
break
case mode.TIME:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册