Commit 7d463c81 authored by wlxuqu's avatar wlxuqu

1. 【新增】新增$u.sys用于获取设备的信息,相当于uni.getSystemInfoSync()的效果

2. 【新增】新增$u.os用于返回平台名称,结果为小写的"ios"或者"android"
3. 【新增】popup和mask新增hover-stop-propagation属性,阻止父节点出现点击状态
4. 【新增】layout组件的col新增text-align属性,用于控制内部的水平对齐方式
5. 【新增】upload新增limit-type参数,用于控制允许选择的图片后缀
6. 【新增】input组件新增selection-start和selection-end参数
7. 【新增】number-box组件新增只能属于正整数的positive-integer参数
8. 【新增】picker、select和keyboard组件新增cancel-text和confirm-text参数
9. 【新增】tabs组件新增item-width参数,用于控制标签的宽度,超出用过省略号表示,默认auto
10. 【新增】avatar头像新增性别和等级展示角标
11. 【新增】sticky新增unfixed取消吸顶事件
12. 【新增】action-sheet组件新增disabled属性,用于禁止某些条目的可选性
13. 【新增】最新版hx2.8.2中,waterfall组件支持支付宝小程序
14. 【新增】button组件返回的click事件中新增返回事件源参数
15. 【新增】icon组件新增用于控制图标的width和height参数,以及控制垂直方向偏移的top参数
16. 【优化】调整navbar的返回图标为nav-back,大小调整为44
17. 【优化】重构section组件,类名使用BEM规范,左侧竖线使用字体图标,新增控制竖线颜色的line-color参数
18. 【修复】改正radio和checkbox组件的label-disabled判断不严格的问题
19. 【修复】修复popup组件关闭时触发两次close事件的问题
20. 【修复】修复slider滑块组件block-color参数无效的问题
21. 【修复】修复http请求中拦截器中返回false报错的问题,优化响应拦截器返回false报找不到catch()的问题
22. 【修复】修复layout的col子组件text-align参数无效的问题
23. 【修复】修复image组件的error-icon和loadingicon参数传图片地址时无效的问题
24. 【修复】修复number-box动态设置输入值不生效的问题
parent 788462b0
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name" : "uView", "name" : "uView",
"appid" : "__UNI__60F4B81", "appid" : "__UNI__60F4B81",
"description" : "多平台快速开发的UI框架", "description" : "多平台快速开发的UI框架",
"versionName" : "1.5.5", "versionName" : "1.5.6",
"versionCode" : "100", "versionCode" : "100",
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
......
...@@ -828,22 +828,22 @@ ...@@ -828,22 +828,22 @@
"backgroundColor": "#FFFFFF", "backgroundColor": "#FFFFFF",
"borderStyle": "black", "borderStyle": "black",
"list": [{ "list": [{
"pagePath": "pages/example/components", "pagePath": "pages/example/components"
"iconPath": "static/uview/example/component.png", // "iconPath": "static/uview/example/component.png",
"selectedIconPath": "static/uview/example/component_select.png", // "selectedIconPath": "static/uview/example/component_select.png",
"text": "组件" // "text": "组件"
}, },
{ {
"pagePath": "pages/example/js", "pagePath": "pages/example/js"
"iconPath": "static/uview/example/js.png", // "iconPath": "static/uview/example/js.png",
"selectedIconPath": "static/uview/example/js_select.png", // "selectedIconPath": "static/uview/example/js_select.png",
"text": "工具" // "text": "工具"
}, },
{ {
"pagePath": "pages/example/template", "pagePath": "pages/example/template"
"iconPath": "static/uview/example/template.png", // "iconPath": "static/uview/example/template.png",
"selectedIconPath": "static/uview/example/template_select.png", // "selectedIconPath": "static/uview/example/template_select.png",
"text": "模板" // "text": "模板"
} }
] ]
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
</u-cell-group> </u-cell-group>
</view> </view>
<u-gap height="70"></u-gap> <u-gap height="70"></u-gap>
<u-tabbar :list="vuex_tabbar" :mid-button="true"></u-tabbar>
</view> </view>
</template> </template>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
</u-cell-group> </u-cell-group>
</view> </view>
<u-gap height="70"></u-gap> <u-gap height="70"></u-gap>
<u-tabbar :list="vuex_tabbar" :mid-button="true"></u-tabbar>
</view> </view>
</template> </template>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
</u-cell-group> </u-cell-group>
</view> </view>
<u-gap height="70"></u-gap> <u-gap height="70"></u-gap>
<u-tabbar :list="vuex_tabbar" :mid-button="true"></u-tabbar>
</view> </view>
</template> </template>
......
static/uview/example/js.png

3.14 KB | W: | H:

static/uview/example/js.png

4.14 KB | W: | H:

static/uview/example/js.png
static/uview/example/js.png
static/uview/example/js.png
static/uview/example/js.png
  • 2-up
  • Swipe
  • Onion skin
static/uview/example/js_select.png

2.2 KB | W: | H:

static/uview/example/js_select.png

4.18 KB | W: | H:

static/uview/example/js_select.png
static/uview/example/js_select.png
static/uview/example/js_select.png
static/uview/example/js_select.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -36,6 +36,27 @@ const store = new Vuex.Store({ ...@@ -36,6 +36,27 @@ const store = new Vuex.Store({
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式 // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_version: '1.0.1', vuex_version: '1.0.1',
vuex_demo: '绛紫', vuex_demo: '绛紫',
// 自定义tabbar数据
vuex_tabbar: [{
iconPath: "/static/uview/example/component.png",
selectedIconPath: "/static/uview/example/component_select.png",
text: '组件',
pagePath: '/pages/example/components'
},
{
iconPath: "/static/uview/example/js.png",
selectedIconPath: "/static/uview/example/js_select.png",
text: '工具',
midButton: true,
pagePath: '/pages/example/js'
},
{
iconPath: "/static/uview/example/template.png",
selectedIconPath: "/static/uview/example/template_select.png",
text: '模板',
pagePath: '/pages/example/template'
}
]
}, },
mutations: { mutations: {
$uStore(state, payload) { $uStore(state, payload) {
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
<slot /> <slot />
<view class="u-tooltip" v-if="tooltip"> <view class="u-tooltip" v-if="tooltip">
<view class="u-tooltip-item u-tooltip-cancel" hover-class="u-tooltip-cancel-hover" @tap="onCancel"> <view class="u-tooltip-item u-tooltip-cancel" hover-class="u-tooltip-cancel-hover" @tap="onCancel">
{{cancelBtn ? '取消' : ''}} {{cancelBtn ? cancelText : ''}}
</view> </view>
<view v-if="showTips" class="u-tooltip-item u-tooltip-tips"> <view v-if="showTips" class="u-tooltip-item u-tooltip-tips">
{{tips ? tips : mode == 'number' ? '数字键盘' : mode == 'card' ? '身份证键盘' : '车牌号键盘'}} {{tips ? tips : mode == 'number' ? '数字键盘' : mode == 'card' ? '身份证键盘' : '车牌号键盘'}}
</view> </view>
<view v-if="confirmBtn" @tap="onConfirm" class="u-tooltip-item u-tooltips-submit" hover-class="u-tooltips-submit-hover"> <view v-if="confirmBtn" @tap="onConfirm" class="u-tooltip-item u-tooltips-submit" hover-class="u-tooltips-submit-hover">
{{confirmBtn ? '完成' : ''}} {{confirmBtn ? confirmText : ''}}
</view> </view>
</view> </view>
<block v-if="mode == 'number' || mode == 'card'"> <block v-if="mode == 'number' || mode == 'card'">
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
* @property {Boolean} cancel-btn 是否显示工具条左边的"取消"按钮(默认true) * @property {Boolean} cancel-btn 是否显示工具条左边的"取消"按钮(默认true)
* @property {Boolean} confirm-btn 是否显示工具条右边的"完成"按钮(默认true) * @property {Boolean} confirm-btn 是否显示工具条右边的"完成"按钮(默认true)
* @property {Boolean} mask 是否显示遮罩(默认true) * @property {Boolean} mask 是否显示遮罩(默认true)
* @property {String} confirm-text 确认按钮的文字
* @property {String} cancel-text 取消按钮的文字
* @property {Number String} z-index 弹出键盘的z-index值(默认1075) * @property {Number String} z-index 弹出键盘的z-index值(默认1075)
* @property {Boolean} random 是否打乱键盘按键的顺序(默认false) * @property {Boolean} random 是否打乱键盘按键的顺序(默认false)
* @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false) * @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
...@@ -111,6 +113,16 @@ ...@@ -111,6 +113,16 @@
zIndex: { zIndex: {
type: [Number, String], type: [Number, String],
default: '' default: ''
},
// 取消按钮的文字
cancelText: {
type: String,
default: '取消'
},
// 确认按钮的文字
confirmText: {
type: String,
default: '确认'
} }
}, },
data() { data() {
......
<template> <template>
<view> <view>
<u-popup :zoom="zoom" <u-popup :zoom="zoom" mode="center" :popup="false" :z-index="uZIndex" v-model="value" :length="width"
mode="center" :popup="false" :mask-close-able="maskCloseAble" :border-radius="borderRadius" @close="popupClose" :negative-top="negativeTop">
:z-index="uZIndex" v-model="value"
:length="width" :mask-close-able="maskCloseAble"
:border-radius="borderRadius"
@close="popupClose"
:negative-top="negativeTop"
>
<view class="u-model"> <view class="u-model">
<view v-if="showTitle" class="u-model-title u-line-1" :style="[titleStyle]">{{ title }}</view> <view v-if="showTitle" class="u-model__title u-line-1" :style="[titleStyle]">{{ title }}</view>
<view class="u-model-content"> <view class="u-model__content">
<view :style="[contentStyle]" v-if="$slots.default"> <view :style="[contentStyle]" v-if="$slots.default">
<slot /> <slot />
</view> </view>
<view v-else class="u-model-content-message" :style="[contentStyle]">{{ content }}</view> <view v-else class="u-model__content__message" :style="[contentStyle]">{{ content }}</view>
</view> </view>
<view class="u-model-footer u-border-top" v-if="showCancelButton || showConfirmButton"> <view class="u-model__footer u-border-top" v-if="showCancelButton || showConfirmButton">
<view <view v-if="showCancelButton" :hover-stay-time="100" hover-class="u-model__btn--hover" class="u-model__footer__button"
v-if="showCancelButton" :style="[cancelBtnStyle]" @tap="cancel">
:hover-stay-time="100"
hover-class="btn-hover"
class="u-model-footer-button"
type="default"
:style="[cancelBtnStyle]"
@tap="cancel"
>
{{cancelText}} {{cancelText}}
</view> </view>
<view <view v-if="showConfirmButton" :hover-stay-time="100" :hover-class="asyncClose ? 'none' : 'u-model__btn--hover'"
v-if="showConfirmButton" class="u-model__footer__button hairline-left" :style="[confirmBtnStyle]" @tap="confirm">
:hover-stay-time="100"
:hover-class="asyncClose ? 'none' : 'btn-hover'"
class="u-model-footer-button hairline-left"
:style="[confirmBtnStyle]"
@tap="confirm"
>
<u-loading mode="circle" :color="confirmColor" v-if="loading"></u-loading> <u-loading mode="circle" :color="confirmColor" v-if="loading"></u-loading>
<block v-else> <block v-else>
{{confirmText}} {{confirmText}}
...@@ -48,248 +29,252 @@ ...@@ -48,248 +29,252 @@
</template> </template>
<script> <script>
/** /**
* modal 模态框 * modal 模态框
* @description 弹出模态框,常用于消息提示、消息确认、在当前页面内完成特定的交互操作 * @description 弹出模态框,常用于消息提示、消息确认、在当前页面内完成特定的交互操作
* @tutorial https://www.uviewui.com/components/modal.html * @tutorial https://www.uviewui.com/components/modal.html
* @property {Boolean} value 是否显示模态框 * @property {Boolean} value 是否显示模态框
* @property {String | Number} z-index 层级 * @property {String | Number} z-index 层级
* @property {String} title 模态框标题(默认"提示") * @property {String} title 模态框标题(默认"提示")
* @property {String | Number} width 模态框宽度(默认600) * @property {String | Number} width 模态框宽度(默认600)
* @property {String} content 模态框内容(默认"内容") * @property {String} content 模态框内容(默认"内容")
* @property {Boolean} show-title 是否显示标题(默认true) * @property {Boolean} show-title 是否显示标题(默认true)
* @property {Boolean} async-close 是否异步关闭,只对确定按钮有效(默认false) * @property {Boolean} async-close 是否异步关闭,只对确定按钮有效(默认false)
* @property {Boolean} show-confirm-button 是否显示确认按钮(默认true) * @property {Boolean} show-confirm-button 是否显示确认按钮(默认true)
* @property {Stringr | Number} negative-top modal往上偏移的值 * @property {Stringr | Number} negative-top modal往上偏移的值
* @property {Boolean} show-cancel-button 是否显示取消按钮(默认false) * @property {Boolean} show-cancel-button 是否显示取消按钮(默认false)
* @property {Boolean} mask-close-able 是否允许点击遮罩关闭modal(默认false) * @property {Boolean} mask-close-able 是否允许点击遮罩关闭modal(默认false)
* @property {String} confirm-text 确认按钮的文字内容(默认"确认") * @property {String} confirm-text 确认按钮的文字内容(默认"确认")
* @property {String} cancel-text 取消按钮的文字内容(默认"取消") * @property {String} cancel-text 取消按钮的文字内容(默认"取消")
* @property {String} cancel-color 取消按钮的颜色(默认"#606266") * @property {String} cancel-color 取消按钮的颜色(默认"#606266")
* @property {String} confirm-color 确认按钮的文字内容(默认"#2979ff") * @property {String} confirm-color 确认按钮的文字内容(默认"#2979ff")
* @property {String | Number} border-radius 模态框圆角值,单位rpx(默认16) * @property {String | Number} border-radius 模态框圆角值,单位rpx(默认16)
* @property {Object} title-style 自定义标题样式,对象形式 * @property {Object} title-style 自定义标题样式,对象形式
* @property {Object} content-style 自定义内容样式,对象形式 * @property {Object} content-style 自定义内容样式,对象形式
* @property {Object} cancel-style 自定义取消按钮样式,对象形式 * @property {Object} cancel-style 自定义取消按钮样式,对象形式
* @property {Object} confirm-style 自定义确认按钮样式,对象形式 * @property {Object} confirm-style 自定义确认按钮样式,对象形式
* @property {Boolean} zoom 是否开启缩放模式(默认true) * @property {Boolean} zoom 是否开启缩放模式(默认true)
* @event {Function} confirm 确认按钮被点击 * @event {Function} confirm 确认按钮被点击
* @event {Function} cancel 取消按钮被点击 * @event {Function} cancel 取消按钮被点击
* @example <u-modal :src="title" :content="content"></u-modal> * @example <u-modal :src="title" :content="content"></u-modal>
*/ */
export default { export default {
name: 'u-modal', name: 'u-modal',
props: { props: {
// 是否显示Modal // 是否显示Modal
value: { value: {
type: Boolean, type: Boolean,
default: false default: false
}, },
// 层级z-index // 层级z-index
zIndex: { zIndex: {
type: [Number, String], type: [Number, String],
default: '' default: ''
}, },
// 标题 // 标题
title: { title: {
type: [String], type: [String],
default: '提示' default: '提示'
}, },
// 弹窗宽度,可以是数值(rpx),百分比,auto等 // 弹窗宽度,可以是数值(rpx),百分比,auto等
width: { width: {
type: [Number, String], type: [Number, String],
default: 600 default: 600
}, },
// 弹窗内容 // 弹窗内容
content: { content: {
type: String, type: String,
default: '内容' default: '内容'
}, },
// 是否显示标题 // 是否显示标题
showTitle: { showTitle: {
type: Boolean, type: Boolean,
default: true default: true
}, },
// 是否显示确认按钮 // 是否显示确认按钮
showConfirmButton: { showConfirmButton: {
type: Boolean, type: Boolean,
default: true default: true
}, },
// 是否显示取消按钮 // 是否显示取消按钮
showCancelButton: { showCancelButton: {
type: Boolean, type: Boolean,
default: false default: false
}, },
// 确认文案 // 确认文案
confirmText: { confirmText: {
type: String, type: String,
default: '确认' default: '确认'
}, },
// 取消文案 // 取消文案
cancelText: { cancelText: {
type: String, type: String,
default: '取消' default: '取消'
}, },
// 确认按钮颜色 // 确认按钮颜色
confirmColor: { confirmColor: {
type: String, type: String,
default: '#2979ff' default: '#2979ff'
}, },
// 取消文字颜色 // 取消文字颜色
cancelColor: { cancelColor: {
type: String, type: String,
default: '#606266' default: '#606266'
}, },
// 圆角值 // 圆角值
borderRadius: { borderRadius: {
type: [Number, String], type: [Number, String],
default: 16 default: 16
}, },
// 标题的样式 // 标题的样式
titleStyle: { titleStyle: {
type: Object, type: Object,
default() { default () {
return {} return {}
}
},
// 内容的样式
contentStyle: {
type: Object,
default () {
return {}
}
},
// 取消按钮的样式
cancelStyle: {
type: Object,
default () {
return {}
}
},
// 确定按钮的样式
confirmStyle: {
type: Object,
default () {
return {}
}
},
// 是否开启缩放效果
zoom: {
type: Boolean,
default: true
},
// 是否异步关闭,只对确定按钮有效
asyncClose: {
type: Boolean,
default: false
},
// 是否允许点击遮罩关闭modal
maskCloseAble: {
type: Boolean,
default: false
},
// 给一个负的margin-top,往上偏移,避免和键盘重合的情况
negativeTop: {
type: [String, Number],
default: 0
} }
}, },
// 内容的样式 data() {
contentStyle: { return {
type: Object, loading: false, // 确认按钮是否正在加载中
default() {
return {}
} }
}, },
// 取消按钮的样式 computed: {
cancelStyle: { cancelBtnStyle() {
type: Object, return Object.assign({
default() { color: this.cancelColor
return {} }, this.cancelStyle);
},
confirmBtnStyle() {
return Object.assign({
color: this.confirmColor
}, this.confirmStyle);
},
uZIndex() {
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
} }
}, },
// 确定按钮的样式 watch: {
confirmStyle: { // 如果是异步关闭时,外部修改v-model的值为false时,重置内部的loading状态
type: Object, // 避免下次打开的时候,状态混乱
default() { value(n) {
return {} if (n === true) this.loading = false;
} }
}, },
// 是否开启缩放效果 methods: {
zoom: { confirm() {
type: Boolean, // 异步关闭
default: true if (this.asyncClose) {
}, this.loading = true;
// 是否异步关闭,只对确定按钮有效 } else {
asyncClose: { this.$emit('input', false);
type: Boolean, }
default: false this.$emit('confirm');
}, },
// 是否允许点击遮罩关闭modal cancel() {
maskCloseAble: { this.$emit('cancel');
type: Boolean,
default: false
},
// 给一个负的margin-top,往上偏移,避免和键盘重合的情况
negativeTop: {
type: [String, Number],
default: 0
}
},
data() {
return {
loading: false, // 确认按钮是否正在加载中
}
},
computed: {
cancelBtnStyle() {
return Object.assign({color: this.cancelColor}, this.cancelStyle);
},
confirmBtnStyle() {
return Object.assign({color: this.confirmColor}, this.confirmStyle);
},
uZIndex() {
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
}
},
watch: {
// 如果是异步关闭时,外部修改v-model的值为false时,重置内部的loading状态
// 避免下次打开的时候,状态混乱
value(n) {
if(n === true) this.loading = false;
}
},
methods: {
confirm() {
// 异步关闭
if(this.asyncClose) {
this.loading = true;
} else {
this.$emit('input', false); this.$emit('input', false);
} // 目前popup弹窗关闭有一个延时操作,此处做一个延时
this.$emit('confirm'); // 避免确认按钮文字变成了"确定"字样,modal还没消失,造成视觉不好的效果
}, setTimeout(() => {
cancel() { this.loading = false;
this.$emit('cancel'); }, 300);
this.$emit('input', false); },
// 目前popup弹窗关闭有一个延时操作,此处做一个延时 // 点击遮罩关闭modal,设置v-model的值为false,否则无法第二次弹起modal
// 避免确认按钮文字变成了"确定"字样,modal还没消失,造成视觉不好的效果 popupClose() {
setTimeout(() => { this.$emit('input', false);
},
// 清除加载中的状态
clearLoading() {
this.loading = false; this.loading = false;
}, 300); }
},
// 点击遮罩关闭modal,设置v-model的值为false,否则无法第二次弹起modal
popupClose() {
this.$emit('input', false);
},
// 清除加载中的状态
clearLoading() {
this.loading = false;
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../libs/css/style.components.scss"; @import "../../libs/css/style.components.scss";
.btn-hover { .u-model {
background-color: rgb(230, 230, 230); height: auto;
} overflow: hidden;
font-size: 32rpx;
background-color: #fff;
.u-model { &__btn--hover {
height: auto; background-color: rgb(230, 230, 230);
overflow: hidden; }
font-size: 32rpx;
background-color: #fff;
&-title {
padding-top: 48rpx;
font-weight: 500;
text-align: center;
color: $u-main-color;
}
&-content { &__title {
&-message { padding-top: 48rpx;
padding: 48rpx; font-weight: 500;
font-size: 30rpx;
text-align: center; text-align: center;
color: $u-content-color; color: $u-main-color;
} }
}
&-footer { &__content {
display: flex; &__message {
padding: 48rpx;
font-size: 30rpx;
text-align: center;
color: $u-content-color;
}
}
&-button { &__footer {
flex: 1; display: flex;
height: 100rpx;
line-height: 100rpx; &__button {
font-size: 32rpx; flex: 1;
box-sizing: border-box; height: 100rpx;
cursor: pointer; line-height: 100rpx;
text-align: center; font-size: 32rpx;
border-radius: 4rpx; box-sizing: border-box;
cursor: pointer;
text-align: center;
border-radius: 4rpx;
}
} }
} }
}
</style> </style>
...@@ -14,10 +14,11 @@ ...@@ -14,10 +14,11 @@
<view :class="[ <view :class="[
midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button' midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button'
]"> ]">
<u-icon <u-icon
:size="midButton && item.midButton ? midButtonSize : iconSize" :size="midButton && item.midButton ? midButtonSize : iconSize"
:name="index == value ? item.selectedIconPath : item.iconPath" :name="elIconPath(index)"
:color="index == value ? activeColor : inactiveColor" img-mode="scaleToFill"
:color="elColor(index)"
:custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'" :custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'"
></u-icon> ></u-icon>
<u-badge :count="item.count" :is-dot="item.isDot" <u-badge :count="item.count" :is-dot="item.isDot"
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
></u-badge> ></u-badge>
</view> </view>
<view class="u-tabbar__content__item__text" :style="{ <view class="u-tabbar__content__item__text" :style="{
color: index == value ? activeColor : inactiveColor color: elColor(index)
}"> }">
<text class="u-line-1">{{item.text}}</text> <text class="u-line-1">{{item.text}}</text>
</view> </view>
...@@ -34,7 +35,8 @@ ...@@ -34,7 +35,8 @@
<view v-if="midButton" class="u-tabbar__content__circle__border" :class="{ <view v-if="midButton" class="u-tabbar__content__circle__border" :class="{
'u-border': borderTop, 'u-border': borderTop,
}" :style="{ }" :style="{
backgroundColor: bgColor backgroundColor: bgColor,
left: midButtonLeft
}"> }">
</view> </view>
</view> </view>
...@@ -110,12 +112,64 @@ ...@@ -110,12 +112,64 @@
type: Boolean, type: Boolean,
default: true default: true
}, },
// 是否隐藏原生tabbar
hideTabBar: {
type: Boolean,
default: true
},
}, },
data() { data() {
return { return {
// 由于安卓太菜了,通过css居中凸起按钮的外层元素有误差,故通过js计算将其其中
midButtonLeft: '50%',
pageUrl: '', // 当前
}
},
created() {
// 是否隐藏原生tabbar
if(this.borderTop) uni.hideTabBar();
// 获取引入了u-tabbar页面的路由地址,该地址没有路径前面的"/"
let pages = getCurrentPages();
// 页面栈中的最后一个即为项为当前页面,route属性为页面路径
this.pageUrl = pages[pages.length - 1].route;
},
computed: {
elIconPath() {
return (index) => {
// 历遍u-tabbar的每一项item时,判断是否传入了pagePath参数,如果传入了
// 和data中的pageUrl参数对比,如果相等,即可判断当前的item对应当前的tabbar页面,设置高亮图标
// 采用这个方法,可以无需使用v-model绑定的value值
let pagePath = this.list[index].pagePath;
// 如果定义了pagePath属性,意味着使用系统自带tabbar方案,否则使用一个页面用几个组件模拟tabbar页面的方案
// 这两个方案对处理tabbar item的激活与否方式不一样
if(pagePath) {
if(pagePath == this.pageUrl || pagePath == '/' + this.pageUrl) {
return this.list[index].selectedIconPath;
} else {
return this.list[index].iconPath;
}
} else {
// 普通方案中,索引等于v-model值时,即为激活项
return index == this.value ? this.list[index].selectedIconPath : this.list[index].iconPath
}
}
},
elColor() {
return (index) => {
// 判断方法同理于elIconPath
let pagePath = this.list[index].pagePath;
if(pagePath) {
if(pagePath == this.pageUrl || pagePath == '/' + this.pageUrl) return this.activeColor;
else return this.inactiveColor;
} else {
return index == this.value ? this.activeColor : this.inactiveColor;
}
}
} }
}, },
mounted() {
this.midButton && this.getMidButtonLeft();
},
methods: { methods: {
async clickHandler(index) { async clickHandler(index) {
if(this.beforeSwitch && typeof(this.beforeSwitch) === 'function') { if(this.beforeSwitch && typeof(this.beforeSwitch) === 'function') {
...@@ -141,7 +195,16 @@ ...@@ -141,7 +195,16 @@
switchTab(index) { switchTab(index) {
// 发出事件和修改v-model绑定的值 // 发出事件和修改v-model绑定的值
this.$emit('change', index); this.$emit('change', index);
this.$emit('input', index); // 如果有配置pagePath属性,使用uni.switchTab进行跳转
if(this.list[index].pagePath) {
uni.switchTab({
url: this.list[index].pagePath
})
} else {
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
this.$emit('input', index);
}
}, },
// 计算角标的right值 // 计算角标的right值
getOffsetRight(count, isDot) { getOffsetRight(count, isDot) {
...@@ -153,6 +216,12 @@ ...@@ -153,6 +216,12 @@
} else { } else {
return -30; return -30;
} }
},
// 获取凸起按钮外层元素的left值,让其水平居中
getMidButtonLeft() {
let windowWidth = this.$u.sys.windowWidth;
// 由于安卓中css计算left: 50%的结果不准确,故用js计算
this.midButtonLeft = (windowWidth / 2) + 'px';
} }
} }
} }
...@@ -181,12 +250,14 @@ ...@@ -181,12 +250,14 @@
width: 110rpx; width: 110rpx;
height: 110rpx; height: 110rpx;
top: -48rpx; top: -48rpx;
left: 50%;
transform: translateX(-50%);
position: absolute; position: absolute;
z-index: 4; z-index: 4;
background-color: #ffffff; background-color: #ffffff;
// 由于安卓的无能,导致只有3个tabbar item时,此css计算方式有误差
// 故使用js计算的形式来定位,此处不注释,是因为js计算有延后,避免出现位置闪动
left: 50%;
transform: translateX(-50%);
&:after { &:after {
border-radius: 100px; border-radius: 100px;
} }
......
// 此版本发布于2020-07-23 // 此版本发布于2020-07-28
let version = '1.5.5'; let version = '1.5.6';
export default { export default {
v: version, v: version,
......
{ {
"name": "uview-ui", "name": "uview-ui",
"version": "1.5.5", "version": "1.5.6",
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水", "description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"main": "index.js", "main": "index.js",
"keywords": ["uview", "uView", "uni-app", "uni-app ui", "uniapp", "uviewui", "uview ui", "uviewUI", "uViewui", "uViewUI", "uView UI", "uni ui", "uni UI", "uniapp ui", "ui", "UI框架", "uniapp ui框架", "uniapp UI"], "keywords": ["uview", "uView", "uni-app", "uni-app ui", "uniapp", "uviewui", "uview ui", "uviewUI", "uViewui", "uViewUI", "uView UI", "uni ui", "uni UI", "uniapp ui", "ui", "UI框架", "uniapp ui框架", "uniapp UI"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment