Commit a5c163a2 authored by wlxuqu's avatar wlxuqu

1. 添加.editorconfig

2. 优化avatar头像组件二次加载图片时无效的问题
3. icon组件的lable新增在左边和上放的参数lebel-pos=left | top
4. image组件图片加载完成时移除背景色,避免png图片能看到底色
5. 优化line线条组件的length参数单位问题
6. 修复由于deepClone导致null结果为{}而导致http的loading无效的问题
parent fad8df8e
[*] [*]
#缩进风格:空格 #缩进风格:空格
indent_style = space indent_style = tab
#缩进大小2 #缩进大小2
indent_size = 4 indent_size = 4
#换行符lf #换行符lf
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name" : "uView", "name" : "uView",
"appid" : "__UNI__60F4B81", "appid" : "__UNI__60F4B81",
"description" : "多平台快速开发的UI框架", "description" : "多平台快速开发的UI框架",
"versionName" : "1.4.0", "versionName" : "1.4.1",
"versionCode" : "100", "versionCode" : "100",
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
......
<template> <template>
<view> <view>
<!-- 底部弹窗 --> <u-icon name="map" label="nihao" label-pos="right"></u-icon>
<u-popup v-model="show" mode="bottom">
<view style="padding-bottom: 60px;">出淤泥而不染,濯清涟而不妖</view>
</u-popup>
<!-- 底部固定栏 -->
<view class="box-1"></view>
<!-- 模态框 -->
<u-modal v-model="show" :zoom="false"></u-modal>
</view> </view>
</template> </template>
......
<template> <template>
<view class="u-avatar" :style="[wrapStyle]" @tap="click"> <view class="u-avatar" :style="[wrapStyle]" @tap="click">
<image @error="loadError" :style="[imgStyle]" class="u-avatar-img" v-if="!text && defaultAvatar" :src="defaultAvatar" :mode="imgMode"></image> <image
@error="loadError"
:style="[imgStyle]"
class="u-avatar-img"
v-if="!text && avatar"
:src="avatar"
:mode="mode"
></image>
<text class="u-line-1" v-else-if="text">{{text}}</text> <text class="u-line-1" v-else-if="text">{{text}}</text>
<slot v-else></slot> <slot v-else></slot>
</view> </view>
...@@ -65,12 +72,19 @@ ...@@ -65,12 +72,19 @@
data() { data() {
return { return {
error: false, error: false,
avatar: this.src, // 头像的地址,因为如果加载错误,需要赋值为默认图片,props值无法修改,所以需要一个中间值
} }
}, },
watch: {
src(n) {
// 用户可能会在头像加载失败时,再次修改头像值,所以需要重新赋值
this.avatar = n;
}
},
computed: { computed: {
wrapStyle() { wrapStyle() {
let style = {}; let style = {};
style.height = this.size == 'large' ? '120rpx' : this.size == 'default' ? style.height = this.size == 'large' ? '120rpx' : this.size == 'default' ?
'90rpx' : this.size == 'mini' ? '70rpx' : this.size + 'rpx'; '90rpx' : this.size == 'mini' ? '70rpx' : this.size + 'rpx';
style.width = style.height; style.width = style.height;
style.flex = `0 0 ${style.height}`; style.flex = `0 0 ${style.height}`;
...@@ -79,21 +93,17 @@ ...@@ -79,21 +93,17 @@
if(this.text) style.padding = `0 6rpx`; if(this.text) style.padding = `0 6rpx`;
return style; return style;
}, },
defaultAvatar() {
if(!this.src) return base64Avatar;
else if(this.src && this.error) return base64Avatar;
else return this.src;
},
imgStyle() { imgStyle() {
let style = {}; let style = {};
style.borderRadius = this.mode == 'circle' ? '500px' : '5px'; style.borderRadius = this.mode == 'circle' ? '500px' : '5px';
return style; return style;
} },
}, },
methods: { methods: {
// 图片加载错误时,显示默认头像 // 图片加载错误时,显示默认头像
loadError() { loadError() {
this.error = true; this.error = true;
this.avatar = base64Avatar;
}, },
click() { click() {
this.$emit('click', this.index); this.$emit('click', this.index);
...@@ -104,7 +114,7 @@ ...@@ -104,7 +114,7 @@
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../libs/css/style.components.scss"; @import "../../libs/css/style.components.scss";
.u-avatar { .u-avatar {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
...@@ -112,9 +122,9 @@ ...@@ -112,9 +122,9 @@
font-size: 28rpx; font-size: 28rpx;
color: $u-content-color; color: $u-content-color;
border-radius: 10px; border-radius: 10px;
overflow: hidden; overflow: hidden;
} }
.u-avatar-img { .u-avatar-img {
width: 100%; width: 100%;
height: 100%; height: 100%;
......
<template> <template>
<view :style="[customStyle]" class="u-icon" @tap="click" :class="[labelPos == 'bottom' ? 'u-flex-col u-row-center' : 'u-flex u-col-center']"> <view :style="[customStyle]" class="u-icon" @tap="click" :class="['u-icon--' + labelPos]">
<image class="u-icon__img" v-if="isImg" :src="name" :mode="imgMode" :style="[imgStyle]"></image> <image class="u-icon__img" v-if="isImg" :src="name" :mode="imgMode" :style="[imgStyle]"></image>
<text v-else class="u-icon__icon" :class="customClass" :style="[iconStyle]" :hover-class="hoverClass" @touchstart="touchstart"></text> <text v-else class="u-icon__icon" :class="customClass" :style="[iconStyle]" :hover-class="hoverClass" @touchstart="touchstart"></text>
<text v-if="label" class="u-icon__label" :style="{ <text v-if="label" class="u-icon__label" :style="{
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
fontSize: labelSize + 'rpx', fontSize: labelSize + 'rpx',
marginLeft: labelPos == 'right' ? marginLeft + 'rpx' : 0, marginLeft: labelPos == 'right' ? marginLeft + 'rpx' : 0,
marginTop: labelPos == 'bottom' ? marginTop + 'rpx' : 0, marginTop: labelPos == 'bottom' ? marginTop + 'rpx' : 0,
marginRight: labelPos == 'left' ? marginRight + 'rpx' : 0,
marginBottom: labelPos == 'top' ? marginBottom + 'rpx' : 0,
}">{{label}}</text> }">{{label}}</text>
</view> </view>
</template> </template>
...@@ -26,6 +28,8 @@ ...@@ -26,6 +28,8 @@
* @property {Object} custom-style icon的样式,对象形式 * @property {Object} custom-style icon的样式,对象形式
* @property {String | Number} margin-left label在右侧时与图标的距离,单位rpx(默认6) * @property {String | Number} margin-left label在右侧时与图标的距离,单位rpx(默认6)
* @property {String | Number} margin-top label在下方时与图标的距离,单位rpx(默认6) * @property {String | Number} margin-top label在下方时与图标的距离,单位rpx(默认6)
* @property {String | Number} margin-bottom label在上方时与图标的距离,单位rpx(默认6)
* @property {String | Number} margin-right label在左侧时与图标的距离,单位rpx(默认6)
* @property {String} label-pos label相对于图标的位置,只能right或bottom(默认right) * @property {String} label-pos label相对于图标的位置,只能right或bottom(默认right)
* @property {String} index 一个用于区分多个图标的值,点击图标时通过click事件传出 * @property {String} index 一个用于区分多个图标的值,点击图标时通过click事件传出
* @property {String} hover-class 图标按下去的样式类,用法同uni的view组件的hover-class参数,详情见官网 * @property {String} hover-class 图标按下去的样式类,用法同uni的view组件的hover-class参数,详情见官网
...@@ -100,6 +104,16 @@ export default { ...@@ -100,6 +104,16 @@ export default {
type: [String, Number], type: [String, Number],
default: '6' default: '6'
}, },
// label与图标的距离(竖向排列)
marginRight: {
type: [String, Number],
default: '6'
},
// label与图标的距离(竖向排列)
marginBottom: {
type: [String, Number],
default: '6'
},
// 图片的mode // 图片的mode
imgMode: { imgMode: {
type: String, type: String,
...@@ -167,32 +181,56 @@ export default { ...@@ -167,32 +181,56 @@ export default {
.u-icon { .u-icon {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
&--left {
flex-direction: row;
align-items: center;
}
&--right {
flex-direction: row-reverse;
align-items: center;
}
&--top {
flex-direction: column-reverse;
justify-content: center;
}
&--bottom {
flex-direction: column;
justify-content: center;
}
&__icon { &__icon {
&--primary { &--primary {
color: $u-type-primary; color: $u-type-primary;
} }
&--success { &--success {
color: $u-type-success; color: $u-type-success;
} }
&--error { &--error {
color: $u-type-error; color: $u-type-error;
} }
&--warning { &--warning {
color: $u-type-warning; color: $u-type-warning;
} }
&--info { &--info {
color: $u-type-info; color: $u-type-info;
} }
} }
&__img { &__img {
height: auto; height: auto;
will-change: transform; will-change: transform;
} }
&__label {
line-height: 1;
}
} }
</style> </style>
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
<view <view
class="u-image" class="u-image"
@tap.stop.prevent="onClick" @tap.stop.prevent="onClick"
:style="[wrapStyle]" :style="[wrapStyle, backgroundStyle]"
> >
<image <image
v-if="!isError" v-if="!isError"
:src="src" :src="src"
:mode="mode" :mode="mode"
@error="onErrorHandler" @error="onErrorHandler"
@load="onLoadHandler" @load="onLoadHandler"
:lazy-load="lazyLoad" :lazy-load="lazyLoad"
class="u-image__image" class="u-image__image"
:style="{ :style="{
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
// 裁剪模式 // 裁剪模式
mode: { mode: {
type: String, type: String,
default: 'widthFix' default: 'aspectFill'
}, },
// 宽度,单位任意 // 宽度,单位任意
width: { width: {
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
// 圆角,单位任意 // 圆角,单位任意
borderRadius: { borderRadius: {
type: [String, Number], type: [String, Number],
default: 10 default: 0
}, },
// 是否懒加载,微信小程序、App、百度小程序、字节跳动小程序 // 是否懒加载,微信小程序、App、百度小程序、字节跳动小程序
lazyLoad: { lazyLoad: {
...@@ -120,6 +120,8 @@ export default { ...@@ -120,6 +120,8 @@ export default {
opacity: 1, opacity: 1,
// 过渡时间,因为props的值无法修改,故需要一个中间值 // 过渡时间,因为props的值无法修改,故需要一个中间值
durationTime: this.duration, durationTime: this.duration,
// 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
backgroundStyle: {}
}; };
}, },
computed: { computed: {
...@@ -153,7 +155,7 @@ export default { ...@@ -153,7 +155,7 @@ export default {
// 图片加载完成,标记loading结束 // 图片加载完成,标记loading结束
onLoadHandler() { onLoadHandler() {
this.loading = false; this.loading = false;
this.error = false; this.isError = false;
this.$emit('load'); this.$emit('load');
// 如果不需要动画效果,就不执行下方代码 // 如果不需要动画效果,就不执行下方代码
if(!this.fade) return ; if(!this.fade) return ;
...@@ -166,6 +168,12 @@ export default { ...@@ -166,6 +168,12 @@ export default {
setTimeout(() => { setTimeout(() => {
this.durationTime = this.duration; this.durationTime = this.duration;
this.opacity = 1; this.opacity = 1;
setTimeout(() => {
// 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
this.backgroundStyle = {
backgroundColor: 'transparent'
};
}, this.durationTime)
}, 50) }, 50)
} }
} }
...@@ -184,7 +192,7 @@ export default { ...@@ -184,7 +192,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
&__loading, &__error { &__loading, &__error {
position: absolute; position: absolute;
top: 0; top: 0;
......
...@@ -59,13 +59,13 @@ ...@@ -59,13 +59,13 @@
// 此处采用兼容分开写,兼容nvue的写法 // 此处采用兼容分开写,兼容nvue的写法
style.borderBottomWidth = '1px'; style.borderBottomWidth = '1px';
style.borderBottomStyle = this.borderStyle; style.borderBottomStyle = this.borderStyle;
style.width = this.length; style.width = this.$u.addUnit(this.length);
if(this.hairLine) style.transform = 'scaleY(0.5)'; if(this.hairLine) style.transform = 'scaleY(0.5)';
} else { } else {
// 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了 // 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了
style.borderLeftWidth = '1px'; style.borderLeftWidth = '1px';
style.borderLeftStyle = this.borderStyle; style.borderLeftStyle = this.borderStyle;
style.height = this.length; style.height = this.$u.addUnit(this.length);
if(this.hairLine) style.transform = 'scaleX(0.5)'; if(this.hairLine) style.transform = 'scaleX(0.5)';
} }
style.borderColor = this.color; style.borderColor = this.color;
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<view class="u-load-more-wrap" :style="{ <view class="u-load-more-wrap" :style="{
backgroundColor: bgColor, backgroundColor: bgColor,
marginBottom: marginBottom + 'rpx', marginBottom: marginBottom + 'rpx',
marginTop: marginTop + 'rpx' marginTop: marginTop + 'rpx',
height: $u.addUnit(height)
}"> }">
<!-- 加载中和没有更多的状态才显示两边的横线 --> <!-- 加载中和没有更多的状态才显示两边的横线 -->
<view :class="status == 'loadmore' || status == 'nomore' ? 'u-more' : ''" class="u-load-more-inner"> <view :class="status == 'loadmore' || status == 'nomore' ? 'u-more' : ''" class="u-load-more-inner">
...@@ -96,6 +97,11 @@ ...@@ -96,6 +97,11 @@
type: [String, Number], type: [String, Number],
default: 0 default: 0
}, },
// 高度,单位rpx
height: {
type: [String, Number],
default: 'auto'
}
}, },
data() { data() {
return { return {
......
...@@ -181,7 +181,6 @@ export default { ...@@ -181,7 +181,6 @@ export default {
visibleSync: false, visibleSync: false,
showDrawer: false, showDrawer: false,
timer: null, timer: null,
style1: {}
}; };
}, },
computed: { computed: {
...@@ -249,7 +248,11 @@ export default { ...@@ -249,7 +248,11 @@ export default {
} }
} }
}, },
methods: { mounted() {
// 组件渲染完成时,检查value是否为true,如果是,弹出popup
this.value && this.open();
},
methods: {
// 判断传入的值,是否带有单位,如果没有,就默认用rpx单位 // 判断传入的值,是否带有单位,如果没有,就默认用rpx单位
getUnitValue(val) { getUnitValue(val) {
if(/(%|px|rpx|auto)$/.test(val)) return val; if(/(%|px|rpx|auto)$/.test(val)) return val;
......
// 此版本发布于2020-06-28 // 此版本发布于2020-06-28
let version = '1.4.0'; let version = '1.4.1';
export default { export default {
v: version, v: version,
......
// 判断arr是否为一个数组,返回一个bool值 // 判断arr是否为一个数组,返回一个bool值
function isArray (arr) { function isArray (arr) {
return Object.prototype.toString.call(arr) === '[object Array]'; return Object.prototype.toString.call(arr) === '[object Array]';
} }
// 深度克隆 // 深度克隆
function deepClone (obj) { function deepClone (obj) {
// 对常见的“非”值,直接返回原来值
if([null, undefined, NaN, false].includes(obj)) return obj;
if(typeof obj !== "object" && typeof obj !== 'function') { if(typeof obj !== "object" && typeof obj !== 'function') {
//原始类型直接返回 //原始类型直接返回
return obj; return obj;
}
var o = isArray(obj) ? [] : {};
for(let i in obj) {
if(obj.hasOwnProperty(i)){
o[i] = typeof obj[i] === "object" ? deepClone(obj[i]) : obj[i];
}
} }
var o = isArray(obj) ? [] : {};
for(let i in obj) {
if(obj.hasOwnProperty(i)){
o[i] = typeof obj[i] === "object" ? deepClone(obj[i]) : obj[i];
}
}
return o; return o;
} }
......
...@@ -32,6 +32,7 @@ class Request { ...@@ -32,6 +32,7 @@ class Request {
uni.hideLoading(); uni.hideLoading();
// 清除定时器,如果请求回来了,就无需loading // 清除定时器,如果请求回来了,就无需loading
clearTimeout(this.config.timer); clearTimeout(this.config.timer);
this.timer = null;
// 判断用户对拦截返回数据的要求,如果originalData为true,返回所有的数据(response)到拦截器,否则只返回response.data // 判断用户对拦截返回数据的要求,如果originalData为true,返回所有的数据(response)到拦截器,否则只返回response.data
if(this.config.originalData) { if(this.config.originalData) {
// 判断是否存在拦截器 // 判断是否存在拦截器
......
{ {
"name": "uview-ui", "name": "uview-ui",
"version": "1.4.0", "version": "1.4.1",
"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