提交 c7c506eb 编写于 作者: X xzs02

Merge branch 'dev'

......@@ -89,14 +89,14 @@ function checkDeviceWidth () {
platform,
pixelRatio,
windowWidth
} = uni.getSystemInfoSync();
} = my.getSystemInfoSync(); // runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px (number, newDeviceWidth) {
function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -406,6 +406,18 @@ const protocols = { // 需要做转换的 API 列表
args: {
orderInfo: 'orderStr'
}
},
getBLEDeviceServices: {
returnValue (result) {
result.services.forEach((item) => {
item.uuid = item.serviceId;
});
}
},
makePhoneCall: {
args: {
phoneNumber: 'number'
}
}
};
......@@ -578,10 +590,10 @@ var api = /*#__PURE__*/Object.freeze({
removeStorageSync: removeStorageSync
});
let uni$1 = {};
let uni = {};
if (typeof Proxy !== 'undefined') {
uni$1 = new Proxy({}, {
uni = new Proxy({}, {
get (target, name) {
if (name === 'upx2px') {
return upx2px
......@@ -602,27 +614,27 @@ if (typeof Proxy !== 'undefined') {
}
});
} else {
uni$1.upx2px = upx2px;
uni.upx2px = upx2px;
Object.keys(todoApis).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(api).forEach(name => {
uni$1[name] = promisify(name, api[name]);
uni[name] = promisify(name, api[name]);
});
Object.keys(my).forEach(name => {
if (hasOwn(my, name) || hasOwn(protocols, name)) {
uni$1[name] = promisify(name, wrapper(name, my[name]));
uni[name] = promisify(name, wrapper(name, my[name]));
}
});
}
var uni$2 = uni$1;
var uni$1 = uni;
export default uni$2;
export default uni$1;
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.5",
"version": "0.0.6",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
......
......@@ -89,14 +89,14 @@ function checkDeviceWidth () {
platform,
pixelRatio,
windowWidth
} = uni.getSystemInfoSync();
} = swan.getSystemInfoSync(); // uni=>swan runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px (number, newDeviceWidth) {
function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -332,10 +332,10 @@ var api = /*#__PURE__*/Object.freeze({
requestPayment: requestPayment
});
let uni$1 = {};
let uni = {};
if (typeof Proxy !== 'undefined') {
uni$1 = new Proxy({}, {
uni = new Proxy({}, {
get (target, name) {
if (name === 'upx2px') {
return upx2px
......@@ -356,27 +356,27 @@ if (typeof Proxy !== 'undefined') {
}
});
} else {
uni$1.upx2px = upx2px;
uni.upx2px = upx2px;
Object.keys(todoApis).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(api).forEach(name => {
uni$1[name] = promisify(name, api[name]);
uni[name] = promisify(name, api[name]);
});
Object.keys(swan).forEach(name => {
if (hasOwn(swan, name) || hasOwn(protocols, name)) {
uni$1[name] = promisify(name, wrapper(name, swan[name]));
uni[name] = promisify(name, wrapper(name, swan[name]));
}
});
}
var uni$2 = uni$1;
var uni$1 = uni;
export default uni$2;
export default uni$1;
{
"name": "@dcloudio/uni-mp-baidu",
"version": "0.0.4",
"version": "0.0.5",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
......
......@@ -89,14 +89,14 @@ function checkDeviceWidth () {
platform,
pixelRatio,
windowWidth
} = uni.getSystemInfoSync();
} = wx.getSystemInfoSync(); // uni=>wx runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px (number, newDeviceWidth) {
function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -261,10 +261,10 @@ var api = /*#__PURE__*/Object.freeze({
});
let uni$1 = {};
let uni = {};
if (typeof Proxy !== 'undefined') {
uni$1 = new Proxy({}, {
uni = new Proxy({}, {
get (target, name) {
if (name === 'upx2px') {
return upx2px
......@@ -285,27 +285,27 @@ if (typeof Proxy !== 'undefined') {
}
});
} else {
uni$1.upx2px = upx2px;
uni.upx2px = upx2px;
Object.keys(todoApis).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(api).forEach(name => {
uni$1[name] = promisify(name, api[name]);
uni[name] = promisify(name, api[name]);
});
Object.keys(wx).forEach(name => {
if (hasOwn(wx, name) || hasOwn(protocols, name)) {
uni$1[name] = promisify(name, wrapper(name, wx[name]));
uni[name] = promisify(name, wrapper(name, wx[name]));
}
});
}
var uni$2 = uni$1;
var uni$1 = uni;
export default uni$2;
export default uni$1;
{
"name": "@dcloudio/uni-mp-weixin",
"version": "0.0.3",
"version": "0.0.4",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
......
......@@ -8,7 +8,7 @@ import {
import {
upx2px
} from '../service/api/upx2px'
} from './upx2px'
import wrapper from './wrapper'
......
const EPS = 1e-4
const BASE_DEVICE_WIDTH = 750
let isIOS = false
let deviceWidth = 0
let deviceDPR = 0
export function checkDeviceWidth () {
const {
platform,
pixelRatio,
windowWidth
} = __GLOBAL__.getSystemInfoSync() // uni=>__GLOBAL__ runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth
deviceDPR = pixelRatio
isIOS = platform === 'ios'
}
export function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth()
}
number = Number(number)
if (number === 0) {
return 0
}
number = (number / BASE_DEVICE_WIDTH) * (newDeviceWidth || deviceWidth)
number = Math.floor(number + EPS)
if (number === 0) {
if (deviceDPR === 1 || !isIOS) {
return 1
} else {
return 0.5
}
}
return number
}
......@@ -38,7 +38,10 @@ function reLaunch (toName) {
this.keepAliveInclude = []
}
let currentPages = []
function beforeEach (to, from, next, routes) {
currentPages = getCurrentPages(true) // 每次 beforeEach 时获取当前currentPages,因为 afterEach 之后,获取不到上一个 page 了,导致无法调用 onUnload
const fromId = from.params.__id__
const toId = to.params.__id__
if (toId === fromId) { // 相同页面阻止
......@@ -58,12 +61,26 @@ function beforeEach (to, from, next, routes) {
case 'redirectTo':
// 关闭前一个页面
removeKeepAliveInclude.call(this, fromName)
if (from.meta) {
if (from.meta.isQuit) { // 如果 redirectTo 的前一个页面是 quit 类型,则新打开的页面也是 quit
to.meta.isQuit = true
to.meta.isEntry = !!from.meta.isEntry
}
if (from.meta.isTabBar) { // 如果是 tabBar,需要更新系统组件 tabBar 内的 list 数据
to.meta.isTabBar = true
to.meta.tabBarIndex = from.meta.tabBarIndex
const appVm = getApp().$children[0]
appVm.$set(appVm.tabBar.list[to.meta.tabBarIndex], 'pagePath', to.meta.pagePath)
}
}
break
case 'switchTab':
switchTab.call(this, routes)
break
case 'reLaunch':
reLaunch.call(this, toName)
to.meta.isQuit = true // reLaunch后,该页面为 quit 类型
break
default:
// 后退或非 API 访问
......@@ -97,7 +114,7 @@ function afterEach (to, from) {
const fromId = from.params.__id__
const toId = to.params.__id__
const fromVm = getCurrentPages(true).find(pageVm => pageVm.$page.id === fromId)
const fromVm = currentPages.find(pageVm => pageVm.$page.id === fromId) // 使用 beforeEach 时的 pages
switch (to.type) {
case 'navigateTo': // 前一个页面触发 onHide
......@@ -121,10 +138,10 @@ function afterEach (to, from) {
}
if (to.type !== 'reLaunch') { // 因为 reLaunch 会重置 id,故不触发 onShow,switchTab 在 beforeRouteEnter 中触发
// 直接获取所有 pages,getCurrentPages 正常情况下仅返回页面栈内,传 true 则返回所有已存在(主要是 tabBar 页面)
const toVm = getCurrentPages(true).find(pageVm => pageVm.$page.id === toId)
const toVm = getCurrentPages(true).find(pageVm => pageVm.$page.id === toId) // 使用最新的 pages
if (toVm) { // 目标页面若已存在,则触发 onShow
// 延迟执行 onShow,防止与 UniServiceJSBridge.emit('onHidePopup') 冲突。
setTimeout(function () {
setTimeout(function () {
callPageHook(toVm, 'onShow')
}, 0)
}
......
......@@ -71,19 +71,25 @@ function getNodeInfo (el, fields) {
function getNodesInfo (pageVm, component, selector, single, fields) {
const $el = pageVm.$el
if (single) {
const node = $el.querySelector(selector)
const node = $el && ($el.matches(selector) ? $el : $el.querySelector(selector))
if (node) {
return getNodeInfo(node, fields)
}
return null
} else if (!$el) {
return []
} else {
let infos = []
const nodeList = $el.querySelectorAll(selector)
if (nodeList && nodeList.length) {
return ([]).map.call(nodeList, node => {
infos = ([]).map.call(nodeList, node => {
return getNodeInfo(node, fields)
})
}
return []
if ($el.matches(selector)) {
infos.unshift($el)
}
return infos
}
}
......@@ -118,4 +124,4 @@ export default function requestComponentInfo ({
reqId,
res: result
}, pageVm.$page.id)
}
}
......@@ -20,7 +20,8 @@ export function pageScrollTo ({
scrollTop = Math.min(scrollTop, scrollHeight - clientHeight)
if (duration === 0) {
documentElement.scrollTop = scrollTop
// 部分浏览器(比如微信)中 scrollTop 的值需要通过 document.body 来控制
documentElement.scrollTop = document.body.scrollTop = scrollTop
return
}
......
<template>
<uni-canvas>
<uni-canvas
:canvas-id="canvasId"
:disable-scroll="disableScroll"
v-on="$listeners"
@touchmove="_touchmove"
>
<canvas
ref="canvas"
:canvas-id="canvasId"
:disable-scroll="disableScroll"
width="300"
height="150"
@touchmove="_touchmove"
/>
height="150"/>
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;">
<slot/>
</div>
<v-uni-resize-sensor
ref="sensor"
@resize="_resize"/>
......
<template>
<uni-image v-on="$listeners">
<div :style="modeStyle" />
<img :src="realImagePath">
</uni-image>
</template>
<script>
......@@ -32,6 +33,9 @@ export default {
ratio () {
return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0
},
realImagePath () {
return this.$getRealPath(this.src)
},
modeStyle () {
let size = 'auto'
let position = ''
......@@ -149,6 +153,7 @@ export default {
height: 240px;
display: inline-block;
overflow: hidden;
position: relative;
}
uni-image[hidden] {
......@@ -165,6 +170,12 @@ export default {
-webkit-user-select: none;
-moz-user-select: none;
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
}
uni-image>.uni-image-will-change {
......
......@@ -317,6 +317,9 @@ export default {
this._contentTrackViewport = current
} else {
this._updateViewport(current)
if (this.autoplay) {
this._scheduleAutoplay()
}
}
} else {
this._invalid = true
......@@ -360,9 +363,6 @@ export default {
if (this.circularEnabled) {
this._checkCircularLayout(index)
}
if (this.skipHiddenItemLayout) {
this._updateHiddenItemDisplay(index)
}
}
var x = this.vertical ? '0' : 100 * -index * this._viewportMoveRatio + '%'
......@@ -567,7 +567,7 @@ export default {
slidesDots.push(createElement('div', {
class: {
'uni-swiper-dot': true,
'uni-swiper-dot-active': index === this.currentSync
'uni-swiper-dot-active': (index < this.currentSync + this.displayMultipleItemsNumber && index >= this.currentSync) || (index < this.currentSync + this.displayMultipleItemsNumber - this.items.length)
},
style: {
'background': index === this.currentSync ? this.indicatorActiveColor : this.indicatorColor
......
......@@ -40,6 +40,7 @@ export default {
const nodeList = []
this.$slots.default && this.$slots.default.forEach(vnode => {
if (vnode.text) {
// 处理可能出现的多余的转义字符
const nodeText = vnode.text.replace(/\\n/g, '\n')
const texts = nodeText.split('\n')
......@@ -49,13 +50,15 @@ export default {
nodeList.push(createElement('br'))
}
})
} else {
} else if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-text') {
nodeList.push(vnode)
}
})
return createElement('uni-text', {
on: this.$listeners
on: this.$listeners,
attrs: {
selectable: !!this.selectable
}
}, [
createElement('span', {}, nodeList)
])
......@@ -64,6 +67,7 @@ export default {
</script>
<style>
uni-text[selectable] {
cursor: auto;
user-select: text;
-webkit-user-select: text;
}
......
<template>
<uni-view
v-if="hoverClass && hoverClass !== 'none'"
:class="[hovering?hoverClass:'']"
<uni-view
v-if="hoverClass && hoverClass !== 'none'"
:class="[hovering?hoverClass:'']"
@touchstart="_hoverTouchStart"
@touchend="_hoverTouchEnd"
@touchcancel="_hoverTouchCancel"
v-on="$listeners">
<slot />
@touchend="_hoverTouchEnd"
@touchcancel="_hoverTouchCancel"
v-on="$listeners"
>
<slot/>
</uni-view>
<uni-view
v-else
<uni-view
v-else
v-on="$listeners">
<slot />
<slot/>
</uni-view>
</template>
<style>
uni-view {
display: block;
}
uni-view {
display: block;
}
uni-view[hidden] {
display: none;
}
</style>
<script>
......@@ -30,4 +34,4 @@ export default {
'label-click': 'clickHandler'
}
}
</script>
</script>
<template>
<uni-actionsheet @touchmove.prevent>
<transition name="uni-fade">
<div
v-show="visible"
class="uni-mask"
<div
v-show="visible"
class="uni-mask"
@click="_close(-1)" />
</transition>
<div
:class="{'uni-actionsheet_toggle':visible}"
<div
:class="{'uni-actionsheet_toggle':visible}"
class="uni-actionsheet">
<div class="uni-actionsheet__menu">
<div
v-for="(title,index) in itemList"
:key="index"
:style="{color:itemColor}"
class="uni-actionsheet__cell"
<div
v-for="(title,index) in itemList"
:key="index"
:style="{color:itemColor}"
class="uni-actionsheet__cell"
@click="_close(index)">{{ title }}</div>
</div>
<div class="uni-actionsheet__action">
<div
:style="{color:itemColor}"
class="uni-actionsheet__cell"
<div
:style="{color:itemColor}"
class="uni-actionsheet__cell"
@click="_close(-1)">取消</div>
</div>
</div>
......@@ -67,10 +67,13 @@ export default {
z-index: 999;
width: 100%;
background-color: #efeff4;
transition: transform .3s;
visibility: hidden;
transition-property: transform, visibility;
transition-duration: 0.3s, 0.3s;
}
uni-actionsheet .uni-actionsheet.uni-actionsheet_toggle {
visibility: visible;
transform: translate(0, 0);
}
......@@ -78,19 +81,6 @@ export default {
box-sizing: border-box;
}
uni-actionsheet .uni-actionsheet {
position: fixed;
left: 0;
bottom: 0;
transform: translate(0, 100%);
backface-visibility: hidden;
z-index: 999;
width: 100%;
background-color: #efeff4;
transition: transform .3s;
transition: transform 0.3s;
}
uni-actionsheet .uni-actionsheet__menu {
background-color: #fcfcfd;
}
......@@ -127,4 +117,4 @@ export default {
uni-actionsheet .uni-actionsheet__cell:first-child:before {
display: none;
}
</style>
</style>
<template>
<uni-picker @touchmove.prevent>
<transition name="uni-fade">
<div
v-show="visible"
class="uni-mask"
<div
v-show="visible"
class="uni-mask"
@click="_cancel"/>
</transition>
<div
:class="{'uni-picker-toggle':visible}"
<div
:class="{'uni-picker-toggle':visible}"
class="uni-picker">
<div
class="uni-picker-header"
<div
class="uni-picker-header"
@click.stop>
<div
class="uni-picker-action uni-picker-action-cancel"
<div
class="uni-picker-action uni-picker-action-cancel"
@click="_cancel">取消</div>
<div
class="uni-picker-action uni-picker-action-confirm"
<div
class="uni-picker-action uni-picker-action-confirm"
@click="_change">确定</div>
</div>
<v-uni-picker-view
v-if="visible"
:value.sync="valueArray"
<v-uni-picker-view
v-if="visible"
:value.sync="valueArray"
class="uni-picker-content">
<v-uni-picker-view-column
v-for="(range,index0) in rangeArray"
<v-uni-picker-view-column
v-for="(range,index0) in rangeArray"
:key="index0">
<div
v-for="(item,index) in range"
......@@ -173,13 +173,23 @@ export default {
},
startArray () {
var splitStr = this.mode === mode.DATE ? '-' : ':'
return this.start.split(splitStr).map((val, i) => (this.mode === mode.DATE ? this.dateArray : this.timeArray)[i].indexOf(
var array = this.mode === mode.DATE ? this.dateArray : this.timeArray
var val = this.start.split(splitStr).map((val, i) => array[i].indexOf(
val))
if (val.indexOf(-1) >= 0) {
val = array.map(() => 0)
}
return val
},
endArray () {
var splitStr = this.mode === mode.DATE ? '-' : ':'
return this.end.split(splitStr).map((val, i) => (this.mode === mode.DATE ? this.dateArray : this.timeArray)[i].indexOf(
var array = this.mode === mode.DATE ? this.dateArray : this.timeArray
var val = this.end.split(splitStr).map((val, i) => array[i].indexOf(
val))
if (val.indexOf(-1) >= 0) {
val = array.map((val) => val.length - 1)
}
return val
},
units () {
switch (this.mode) {
......@@ -347,22 +357,6 @@ uni-picker {
box-sizing: border-box;
}
uni-picker .uni-picker {
position: fixed;
left: 0;
bottom: 0;
transform: translate(0, 100%);
backface-visibility: hidden;
z-index: 999;
width: 100%;
background-color: #efeff4;
transition: transform 0.3s;
}
uni-picker .uni-picker.uni-picker-toggle {
transform: translate(0, 0);
}
uni-picker .uni-picker * {
box-sizing: border-box;
}
......@@ -376,8 +370,14 @@ uni-picker .uni-picker {
z-index: 999;
width: 100%;
background-color: #efeff4;
transition: transform 0.3s;
transition: transform 0.3s;
visibility: hidden;
transition-property: transform,visibility;
transition-duration: 0.3s, 0.3s;
}
uni-picker .uni-picker.uni-picker-toggle {
visibility: visible;
transform: translate(0, 0);
}
uni-picker .uni-picker-content {
......
......@@ -116,7 +116,7 @@ uni-tabbar .uni-tabbar-border {
uni-tabbar .uni-tabbar__reddot {
position: absolute;
top: 6px;
left: 100%;
left: 16px;
width: 12px;
height: 12px;
display: inline-block;
......
......@@ -22,11 +22,11 @@
</uni-page>
</template>
<style>
uni-page {
display: block;
width: 100%;
height: 100%;
}
uni-page {
display: block;
width: 100%;
height: 100%;
}
</style>
<script>
import {
......@@ -137,7 +137,7 @@ export default {
data () {
const navigationBar = mergeTitleNView({
loading: false,
backButton: !this.isQuit,
backButton: !this.isQuit && !this.$route.meta.isQuit, // redirectTo,reLaunch时可能动态修改 meta.isQuit
backgroundColor: this.navigationBarBackgroundColor,
textColor: this.navigationBarTextStyle === 'black' ? '#000' : '#fff',
titleText: this.navigationBarTitleText,
......
<template>
<uni-audio
:id="id"
:class="{controls:controls}"
:src="src"
:loop="loop"
:controls="controls"
:poster="poster"
:name="name"
:author="author"
class="uni-audio"
v-on="$listeners">
<audio
ref="audio"
:loop="loop"
v-on="$listeners"
>
<audio
ref="audio"
:loop="loop"
style="display:none;"/>
<div class="uni-audio-default">
<div
:style="'background-image: url('+$getRealPath(poster)+');'"
<div
:style="'background-image: url('+$getRealPath(poster)+');'"
class="uni-audio-left">
<div
:class="{play:!playing,pause:playing}"
class="uni-audio-button"
<div
:class="{play:!playing,pause:playing}"
class="uni-audio-button"
@click="trigger"/>
</div>
<div class="uni-audio-right">
<div
class="uni-audio-time"
v-text="currentTime"/>
<div class="uni-audio-time">{{ currentTime }}</div>
<div class="uni-audio-info">
<div
class="uni-audio-name"
v-text="name"/>
<div
class="uni-audio-author"
v-text="author"/>
<div class="uni-audio-name">{{ name }}</div>
<div class="uni-audio-author">{{ author }}</div>
</div>
</div>
</div>
......@@ -167,14 +160,18 @@ export default {
</script>
<style>
.uni-audio {
uni-audio {
display: none;
}
.uni-audio.controls {
uni-audio[controls] {
display: inline-block;
}
uni-audio[hidden] {
display: none;
}
.uni-audio-default {
max-width: 100%;
min-width: 302px;
......
<template>
<uni-cover-image
:src="src"
v-on="$listeners">
<div
class="uni-cover-image">
<img
v-if="src"
:src="$getRealPath(src)"
@load="_load"
@error="_error">
</div>
</uni-cover-image>
</template>
<script>
export default {
name: 'CoverImage',
props: {
src: {
type: String,
default: ''
}
},
methods: {
_load ($event) {
this.$trigger('load', $event)
},
_error ($event) {
this.$trigger('error', $event)
}
}
}
</script>
<style>
uni-cover-image {
display: block;
line-height: 1.2;
overflow: hidden;
height: 100%;
width: 100%;
}
uni-cover-image img {
width: 100%;
height: 100%;
}
uni-cover-image[hidden] {
display: none;
}
uni-cover-image .uni-cover-image {
width: 100%;
height: 100%;
text-overflow: inherit;
overflow: inherit;
white-space: nowrap;
-webkit-align-items: inherit;
align-items: inherit;
-webkit-justify-content: inherit;
justify-content: inherit;
-webkit-flex-direction: inherit;
flex-direction: inherit;
font-size: 0;
display: inherit;
}
</style>
<template>
<uni-cover-view/>
<uni-cover-view
:scroll-top="scrollTop"
v-on="$listeners">
<div
ref="content"
class="uni-cover-view">
<slot/>
</div>
</uni-cover-view>
</template>
<script>
export default {
name: 'CoverView'
name: 'CoverView',
props: {
scrollTop: {
type: [String, Number],
default: 0
}
},
watch: {
scrollTop (val) {
this.setScrollTop(val)
}
},
mounted () {
this.setScrollTop(this.scrollTop)
},
methods: {
setScrollTop (val) {
var content = this.$refs.content
if (getComputedStyle(content).overflowY === 'scroll') {
content.scrollTop = this._upx2pxNum(val)
}
},
_upx2pxNum (val) {
if (/\d+[ur]px$/i.test(val)) {
val.replace(/\d+[ur]px$/i, text => {
return uni.upx2px(parseFloat(text))
})
}
return parseFloat(val) || 0
}
}
}
</script>
<style>
uni-cover-view {
display: block;
line-height: 1.2;
overflow: hidden;
white-space: nowrap;
}
uni-cover-view[hidden] {
display: none;
}
uni-cover-view .uni-cover-view {
width: 100%;
height: 100%;
text-overflow: inherit;
overflow: hidden;
white-space: inherit;
-webkit-align-items: inherit;
align-items: inherit;
-webkit-justify-content: inherit;
justify-content: inherit;
-webkit-flex-direction: inherit;
flex-direction: inherit;
-webkit-flex-wrap: inherit;
flex-wrap: inherit;
display: inherit;
overflow: inherit;
}
</style>
<template>
<uni-video
:id="id"
class="uni-video"
v-on="$listeners">
<!-- 视频容器 -->
<div
ref="container"
:class="{'uni-video-type-fullscreen':fullscreen,'uni-video-type-rotate-left':rotateType==='left','uni-video-type-rotate-right':rotateType==='right'}"
......@@ -13,7 +11,6 @@
@touchstart="touchstart($event)"
@touchend="touchend($event)"
@touchmove="touchmove($event)">
<!-- 视频 -->
<video
ref="video"
:style="{opacity:!start?0.8:1,objectFit:objectFit}"
......@@ -27,7 +24,6 @@
x5-video-player-type="h5"
x5-video-player-fullscreen="false"
x5-video-orientation="landscape|portrait" />
<!-- 控制条 -->
<div
v-show="controlsShow"
class="uni-video-bar uni-video-bar-full"
......@@ -68,13 +64,11 @@
class="uni-video-fullscreen"
@click.stop="triggerFullscreen" />
</div>
<!-- 弹幕 -->
<div
v-show="start&&enableDanmuSync"
ref="danmu"
style="z-index: 0;"
class="uni-video-danmu" />
<!-- 封面 -->
<div
v-if="!start"
class="uni-video-cover"
......@@ -84,7 +78,6 @@
@click.stop="play" />
<p class="uni-video-cover-duration">{{ (duration||durationTime)|getTime }}</p>
</div>
<!-- 提示-音量调整 -->
<div
:class="{'uni-video-toast-volume':gestureType==='volume'}"
class="uni-video-toast">
......@@ -111,14 +104,15 @@
</div>
</div>
</div>
<!-- 提示-进度调整 -->
<div
:class="{'uni-video-toast-progress':gestureType=='progress'}"
class="uni-video-toast">
<div class="uni-video-toast-title">{{ currentTimeNew|getTime }} / {{ durationTime|getTime }}</div>
</div>
</div>
<!-- <div style="position: absolute; top: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none;"></div> -->
<div style="position: absolute; top: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none;">
<slot/>
</div>
</uni-video>
</template>
<script>
......@@ -134,21 +128,9 @@ const passiveOptions = supportsPassive ? {
} : false
const GestureType = {
/**
* 未开始
*/
NONE: 'none',
/**
* 停止
*/
STOP: 'stop',
/**
* 音量
*/
VOLUME: 'volume',
/**
* 进度
*/
PROGRESS: 'progress'
}
......@@ -179,116 +161,68 @@ export default {
type: String,
default: ''
},
/**
* 指定视频时长
*/
duration: {
type: [Number, String],
default: ''
},
/**
* 是否显示默认播放控件
*/
controls: {
type: [Boolean, String],
default: true
},
/**
* 弹幕列表
*/
danmuList: {
type: Array,
default () {
return []
}
},
/**
* 是否显示弹幕按钮
*/
danmuBtn: {
type: [Boolean, String],
default: false
},
/**
* 是否展示弹幕
*/
enableDanmu: {
type: [Boolean, String],
default: false
},
/**
* 是否自动播放
*/
autoplay: {
type: [Boolean, String],
default: false
},
/**
* 是否循环播放
*/
loop: {
type: [Boolean, String],
default: false
},
/**
* 是否静音播放
*/
muted: {
type: [Boolean, String],
default: false
},
/**
* 视频的表现形式
*/
objectFit: {
type: String,
default: 'contain'
},
/**
* 视频封面
*/
poster: {
type: String,
default: ''
},
/**
* 设置全屏时视频的方向,0为竖向,90和-90为横向,默认360为自动
*/
direction: {
type: [String, Number],
default: 360
},
/**
* 视频初始播放位置
*/
initialTime: {
type: [String, Number],
default: 0
},
/**
* 是否显示全屏按钮
*/
showFullscreenBtn: {
type: [Boolean, String],
default: true
},
/**
* 在非全屏模式下,是否开启亮度与音量调节手势
*/
pageGesture: {
type: [Boolean, String],
default: false
},
/**
* 是否开启控制进度的手势
*/
enableProgressGesture: {
type: [Boolean, String],
default: true
},
/**
* 是否显示视频底部控制栏的播放按钮
*/
showPlayBtn: {
type: [Boolean, String],
default: true
......@@ -296,113 +230,38 @@ export default {
},
data () {
return {
/**
* 是否播放开始
*/
start: false,
/**
* 是否正在播放
*/
playing: false,
/**
* 当前播放时长
*/
currentTime: 0,
/**
* 播放总时长
*/
durationTime: 0,
/**
* 进度(0-100)
*/
progress: 0,
/**
* 触摸中
*/
touching: false,
/**
* 是否展示弹幕
*/
enableDanmuSync: Boolean(this.enableDanmu),
/**
* 默认播放控件显示状态
*/
controlsVisible: true,
/**
* 全屏状态
*/
fullscreen: false,
/**
* 播放器宽度
*/
width: '0',
/**
* 播放器高度
*/
height: '0',
/**
* 全屏状态切换中
*/
fullscreenTriggering: false,
/**
* 控制条触摸中
*/
controlsTouching: false,
/**
* 全屏时视频的方向
*/
directionSync: Number(this.direction),
/**
* 触摸起点
*/
touchStartOrigin: {
x: 0,
y: 0
},
/**
* 手势状态(未开始:none、停止:stop、音量:volume、进度:progress)
*/
gestureType: GestureType.NONE,
/**
* 播放进度旧值
*/
currentTimeOld: 0,
/**
* 播放进度新值
*/
currentTimeNew: 0,
/**
* 系统音量旧值
*/
volumeOld: null,
/**
* 系统音量新值
*/
volumeNew: null,
/**
* isIOS: uni.isIOS
*/
isIOS: false,
/**
* 缓冲进度(0-1)
*/
buffered: 0,
/**
* 旋转方向 left:逆时针旋转90度 right:顺时针旋转90度
*/
rotateType: ''
}
},
computed: {
/**
* 显示控制条
*/
controlsShow () {
return this.start && this.controls && this.controlsVisible
},
/**
* 自动隐藏的计时器状态
*/
autoHideContorls () {
return this.controlsShow && this.playing && !this.controlsTouching
},
......@@ -428,12 +287,8 @@ export default {
container.remove()
if (val) {
this.resize()
// uni.enterFullscreen(() => {
// this.resize()
// })
document.body.appendChild(container)
} else {
// uni.leaveFullscreen()
this.$el.appendChild(container)
}
this.$trigger('fullscreenchange', {}, {
......@@ -467,20 +322,11 @@ export default {
},
created () {
this.otherData = {
/**
* 弹幕列表
*/
danmuList: [],
/**
* 弹幕指针
*/
danmuIndex: {
time: 0,
index: -1
},
/**
* 操作栏隐藏倒计时
*/
hideTiming: null
}
var danmuList = this.otherData.danmuList = JSON.parse(JSON.stringify(this.danmuList || []))
......@@ -540,7 +386,6 @@ export default {
video.addEventListener('timeupdate', function ($event) {
var currentTime = self.currentTime = video.currentTime
var duration = video.duration
// 移动弹幕指针
var oldDanmuIndex = otherData.danmuIndex
var danmuIndex = {
time: currentTime,
......@@ -633,7 +478,6 @@ export default {
},
beforeDestroy () {
this.$refs.container.remove()
// uni.leaveFullscreen()
clearTimeout(this.otherData.hideTiming)
},
methods: {
......@@ -671,33 +515,24 @@ export default {
var direction = Math.abs(this.directionSync)
if (direction === 0) {
// 强制竖屏
if (w > h) {
// 设备横屏-逆时针旋转90度
this.rotateType = 'left'
} else {
// 设备竖屏-不旋转
this.rotateType = ''
}
} else if (direction === 90) {
// 强制横屏
if (w > h) {
// 设备横屏-不旋转
this.rotateType = ''
} else {
// 设备竖屏-顺时针旋转90度
this.rotateType = 'right'
}
} else {
// 自动适应
this.rotateType = ''
}
if (!this.rotateType) {
// 无旋转
this.width = w + 'px'
this.height = h + 'px'
} else {
// 旋转90度
this.width = h + 'px'
this.height = w + 'px'
}
......@@ -808,15 +643,12 @@ export default {
if (gestureType === GestureType.PROGRESS) {
this.changeProgress(pageX - origin.x)
} else if (gestureType === GestureType.VOLUME) {
// 横屏时调节,需颠倒方向
this.changeVolume(pageY - origin.y)
}
if (gestureType !== GestureType.NONE) {
return
}
// 横向
if (Math.abs(pageX - origin.x) > Math.abs(pageY - origin.y)) {
// 未开启进度手势
if (!this.enableProgressGesture) {
this.gestureType = GestureType.STOP
return
......@@ -826,13 +658,11 @@ export default {
if (!this.fullscreen) {
stop()
}
} else { // 纵向
// 未开启亮度和音量手势
} else {
if (!this.pageGesture) {
this.gestureType = GestureType.STOP
return
}
// 调节音量
this.gestureType = GestureType.VOLUME
this.volumeOld = this.$refs.video.volume
if (!this.fullscreen) {
......@@ -874,7 +704,6 @@ export default {
this.volumeNew = value
}
},
// 自动隐藏操作栏
autoHideStart () {
this.otherData.hideTiming = setTimeout(() => {
this.controlsVisible = false
......@@ -887,9 +716,7 @@ export default {
otherData.hideTiming = null
}
},
// 获取转换后的屏幕坐标
getScreenXY (dataOrigin) {
// 未全屏或者未旋转返回原始数据
var rotateType = this.rotateType
if (!this.fullscreen || !rotateType) {
return dataOrigin
......@@ -901,11 +728,9 @@ export default {
var pageX
var pageY
if (rotateType === 'left') {
// 向左旋转-逆时针90度
pageX = h - y
pageY = x
} else {
// 向右旋转-顺时针90度
pageX = y
pageY = w - x
}
......@@ -924,7 +749,7 @@ export default {
</script>
<style>
.uni-video {
uni-video {
width: 300px;
height: 225px;
display: inline-block;
......@@ -933,6 +758,10 @@ export default {
position: relative;
}
uni-video[hidden] {
display: none;
}
.uni-video-container {
width: 100%;
height: 100%;
......@@ -971,13 +800,9 @@ export default {
left: 0;
bottom: 0;
width: 100%;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-justify-content: center;
justify-content: center;
-webkit-align-items: center;
align-items: center;
background-color: rgba(1, 1, 1, 0.5);
z-index: 1;
......@@ -1103,15 +928,6 @@ export default {
border-radius: 50%;
}
/* .uni-video-controls > .uni-video-duration {
height: 14.5px;
line-height: 14.5px;
margin-top: 15px;
margin-bottom: 14.5px;
font-size: 12px;
color: #cbcbcb;
} */
.uni-video-danmu-button {
white-space: nowrap;
line-height: 1;
......
<template>
<uni-web-view>
<iframe
:src="realPath"
:src="$getRealPath(src)"
frameborder="0"
width="100%"
height="100%" />
......@@ -15,11 +15,6 @@ export default {
type: String,
default: ''
}
},
data () {
return {
realPath: this.$getRealPath(this.src)
}
}
}
</script>
......
......@@ -287,6 +287,18 @@ const protocols = { // 需要做转换的 API 列表
args: {
orderInfo: 'orderStr'
}
},
getBLEDeviceServices: {
returnValue (result) {
result.services.forEach((item) => {
item.uuid = item.serviceId
})
}
},
makePhoneCall: {
args: {
phoneNumber: 'number'
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册