不知道改什么了

This commit is contained in:
田岩
2025-07-23 19:50:42 +08:00
parent 41015eb0d7
commit c7c20f5406
76 changed files with 1057 additions and 152 deletions
@@ -0,0 +1,7 @@
## 1.0.22023-06-21
1. 优化customStyle属性
## 1.0.12023-05-16
1. 优化组件依赖,修改后无需全局引入,组件导入即可使用
2. 优化部分功能
## 1.0.02023-05-10
uv-load-more 加载更多
@@ -0,0 +1,95 @@
export default {
props: {
// 组件状态,loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
status: {
type: String,
default: 'loadmore'
},
// 组件背景色
bgColor: {
type: String,
default: 'transparent'
},
// 是否显示加载中的图标
icon: {
type: Boolean,
default: true
},
// 字体大小
fontSize: {
type: [String, Number],
default: 14
},
// 图标大小
iconSize: {
type: [String, Number],
default: 16
},
// 字体颜色
color: {
type: String,
default: '#606266'
},
// 加载中状态的图标,spinner-花朵状图标,circle-圆圈状,semicircle-半圆
loadingIcon: {
type: String,
default: 'spinner'
},
// 加载前的提示语
loadmoreText: {
type: String,
default: '加载更多'
},
// 加载中提示语
loadingText: {
type: String,
default: '正在加载...'
},
// 没有更多的提示语
nomoreText: {
type: String,
default: '没有更多了'
},
// 在“没有更多”状态下,是否显示粗点
isDot: {
type: Boolean,
default: false
},
// 加载中图标的颜色
iconColor: {
type: String,
default: '#b7b7b7'
},
// 上边距
marginTop: {
type: [String, Number],
default: 10
},
// 下边距
marginBottom: {
type: [String, Number],
default: 10
},
// 高度,单位px
height: {
type: [String, Number],
default: 'auto'
},
// 是否显示左边分割线
line: {
type: Boolean,
default: false
},
// 线条颜色
lineColor: {
type: String,
default: '#E6E8EB'
},
// 是否虚线,true-虚线,false-实线
dashed: {
type: Boolean,
default: false
},
...uni.$uv?.props?.loadmore
}
}
@@ -0,0 +1,152 @@
<template>
<view
class="uv-loadmore"
:style="[{
backgroundColor: bgColor,
marginBottom: $uv.addUnit(marginBottom),
marginTop: $uv.addUnit(marginTop),
height: $uv.addUnit(height),
},
$uv.addStyle(customStyle)]"
>
<uv-line
length="140rpx"
:color="lineColor"
:hairline="false"
:dashed="dashed"
v-if="line"
></uv-line>
<!-- 加载中和没有更多的状态才显示两边的横线 -->
<view
:class="status == 'loadmore' || status == 'nomore' ? 'uv-more' : ''"
class="uv-loadmore__content"
>
<view
class="uv-loadmore__content__icon-wrap"
v-if="status === 'loading' && icon"
>
<uv-loading-icon
:color="iconColor"
:size="iconSize"
:mode="loadingIcon"
></uv-loading-icon>
</view>
<!-- 如果没有更多的状态下显示内容为dot粗点加载特定样式 -->
<text
class="uv-line-1"
:style="[loadTextStyle]"
:class="[(status == 'nomore' && isDot == true) ? 'uv-loadmore__content__dot-text' : 'uv-loadmore__content__text']"
@tap="loadMore"
>{{ showText }}</text>
</view>
<uv-line
length="140rpx"
:color="lineColor"
:hairline="false"
:dashed="dashed"
v-if="line"
></uv-line>
</view>
</template>
<script>
import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
import props from './props.js';
/**
* loadmore 加载更多
* @description 此组件一般用于标识页面底部加载数据时的状态。
* @tutorial https://www.uvui.cn/components/loadMore.html
* @property {String} status 组件状态(默认 'loadmore'
* @property {String} bgColor 组件背景颜色,在页面是非白色时会用到(默认 'transparent'
* @property {Boolean} icon 加载中时是否显示图标(默认 true )
* @property {String | Number} fontSize 字体大小(默认 14
* @property {String | Number} iconSize 图标大小(默认 17
* @property {String} color 字体颜色(默认 '#606266'
* @property {String} loadingIcon 加载图标(默认 'circle'
* @property {String} loadmoreText 加载前的提示语(默认 '加载更多'
* @property {String} loadingText 加载中提示语(默认 '正在加载...'
* @property {String} nomoreText 没有更多的提示语(默认 '没有更多了'
* @property {Boolean} isDot 到上一个相邻元素的距离 (默认 false )
* @property {String} iconColor 加载中图标的颜色 (默认 '#b7b7b7'
* @property {String} lineColor 线条颜色(默认 #E6E8EB
* @property {String | Number} marginTop 上边距 (默认 10
* @property {String | Number} marginBottom 下边距 (默认 10
* @property {String | Number} height 高度,单位px (默认 'auto'
* @property {Boolean} line 是否显示左边分割线 (默认 false )
* @property {Boolean} dashed // 是否虚线,true-虚线,false-实线 (默认 false
* @event {Function} loadmore status为loadmore时,点击组件会发出此事件
* @example <uv-loadmore :status="status" icon-type="iconType" load-text="loadText" />
*/
export default {
name: "uv-loadmore",
mixins: [mpMixin, mixin,props],
data() {
return {
// 粗点
dotText: "●"
}
},
computed: {
// 加载的文字显示的样式
loadTextStyle() {
return {
color: this.color,
fontSize: this.$uv.addUnit(this.fontSize),
lineHeight: this.$uv.addUnit(this.fontSize),
backgroundColor: this.bgColor,
}
},
// 显示的提示文字
showText() {
let text = '';
if (this.status == 'loadmore') text = this.loadmoreText
else if (this.status == 'loading') text = this.loadingText
else if (this.status == 'nomore' && this.isDot) text = this.dotText;
else text = this.nomoreText;
return text;
}
},
methods: {
loadMore() {
// 只有在“加载更多”的状态下才发送点击事件,内容不满一屏时无法触发底部上拉事件,所以需要点击来触发
if (this.status == 'loadmore') this.$emit('loadmore');
}
}
}
</script>
<style lang="scss" scoped>
$show-lines: 1;
@import '@/uni_modules/uv-ui-tools/libs/css/variable.scss';
@import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
@import '@/uni_modules/uv-ui-tools/libs/css/color.scss';
.uv-loadmore {
@include flex(row);
align-items: center;
justify-content: center;
flex: 1;
&__content {
margin: 0 15px;
@include flex(row);
align-items: center;
justify-content: center;
&__icon-wrap {
margin-right: 8px;
}
&__text {
font-size: 14px;
color: $uv-content-color;
}
&__dot-text {
font-size: 15px;
color: $uv-tips-color;
}
}
}
</style>
+89
View File
@@ -0,0 +1,89 @@
{
"id": "uv-load-more",
"displayName": "uv-load-more 加载更多 全面兼容小程序、nvue、vue2、vue3等多端",
"version": "1.0.2",
"description": "uv-load-more 此组件一般用于标识页面底部加载数据时的状态,共有三种状态:加载前、加载中、加载后。",
"keywords": [
"uv-load-more",
"uvui",
"uv-ui",
"more",
"加载更多"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"uv-ui-tools",
"uv-line",
"uv-loading-icon"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
## LoadMore 加载更多
> **组件名:uv-load-more**
此组件一般用于标识页面底部加载数据时的状态,共有三种状态:加载前、加载中、加载后。
### <a href="https://www.uvui.cn/components/loadMore.html" target="_blank">查看文档</a>
### [完整示例项目下载 | 关注更多组件](https://ext.dcloud.net.cn/plugin?name=uv-ui)
#### 如使用过程中有任何问题,或者您对uv-ui有一些好的建议,欢迎加入 uv-ui 交流群:<a href="https://ext.dcloud.net.cn/plugin?id=12287" target="_blank">uv-ui</a>、<a href="https://www.uvui.cn/components/addQQGroup.html" target="_blank">官方QQ群</a>
+11
View File
@@ -0,0 +1,11 @@
## 1.0.42023-12-20
1. 优化
## 1.0.32023-10-13
1. unmounted兼容vue3
## 1.0.22023-08-27
1. 优化
## 1.0.12023-05-16
1. 优化组件依赖,修改后无需全局引入,组件导入即可使用
2. 优化部分功能
## 1.0.02023-05-10
uv-sticky 吸顶
@@ -0,0 +1,41 @@
export default {
props: {
// 吸顶容器到顶部某个距离的时候,进行吸顶,在H5平台,NavigationBar为44px
offsetTop: {
type: [String, Number],
default: 0
},
// 自定义导航栏的高度
customNavHeight: {
type: [String, Number],
// #ifdef H5
// H5端的导航栏属于“自定义”导航栏的范畴,因为它是非原生的,与普通元素一致
default: 44,
// #endif
// #ifndef H5
default: 0
// #endif
},
// 是否禁用吸顶功能
disabled: {
type: Boolean,
default: false
},
// 吸顶区域的背景颜色
bgColor: {
type: String,
default: 'transparent'
},
// z-index值
zIndex: {
type: [String, Number],
default: ''
},
// 列表中的索引值
index: {
type: [String, Number],
default: ''
},
...uni.$uv?.props?.sticky
}
}
@@ -0,0 +1,223 @@
<template>
<view
class="uv-sticky"
:id="elId"
:style="[style]"
>
<view
:style="[stickyContent]"
class="uv-sticky__content"
>
<slot />
</view>
</view>
</template>
<script>
import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
import props from './props.js';
/**
* sticky 吸顶
* @description 该组件与CSS中position: sticky属性实现的效果一致,当组件达到预设的到顶部距离时, 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。
* @tutorial https://www.uvui.cn/components/sticky.html
* @property {String Number} offsetTop 吸顶时与顶部的距离,单位px(默认 0 )
* @property {String Number} customNavHeight 自定义导航栏的高度 (h5 默认44 其他默认 0 )
* @property {Boolean} disabled 是否开启吸顶功能 (默认 false )
* @property {String} bgColor 组件背景颜色(默认 '#ffffff'
* @property {String Number} zIndex 吸顶时的z-index值
* @property {String Number} index 自定义标识,用于区分是哪一个组件
* @property {Object} customStyle 组件的样式,对象形式
* @example <uv-sticky offsetTop="200"><view>塞下秋来风景异,衡阳雁去无留意</view></uv-sticky>
*/
export default {
name: 'uv-sticky',
mixins: [mpMixin, mixin, props],
data() {
return {
cssSticky: false, // 是否使用css的sticky实现
stickyTop: 0, // 吸顶的top值,因为可能受自定义导航栏影响,最终的吸顶值非offsetTop值
elId: '',
left: 0, // js模式时,吸顶的内容因为处于postition: fixed模式,为了和原来保持一致的样式,需要记录并重新设置它的left,heightwidth属性
width: 'auto',
height: 'auto',
fixed: false, // js模式时,是否处于吸顶模式
}
},
computed: {
style() {
const style = {}
if(!this.disabled) {
if (this.cssSticky) {
style.position = 'sticky'
style.zIndex = this.uZindex
style.top = this.$uv.addUnit(this.stickyTop)
} else {
style.height = this.fixed ? this.height + 'px' : 'auto'
}
} else {
// 无需吸顶时,设置会默认的relative(nvue)和非nvue的static静态模式即可
// #ifdef APP-NVUE
style.position = 'relative'
// #endif
// #ifndef APP-NVUE
style.position = 'static'
// #endif
}
style.backgroundColor = this.bgColor
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
},
// 吸顶内容的样式
stickyContent() {
const style = {}
if (!this.cssSticky) {
style.position = this.fixed ? 'fixed' : 'static'
style.top = this.stickyTop + 'px'
style.left = this.left + 'px'
style.width = this.width == 'auto' ? 'auto' : this.width + 'px'
style.zIndex = this.uZindex
}
return style
},
uZindex() {
return this.zIndex ? this.zIndex : 970
}
},
created() {
this.elId = this.$uv.guid();
},
mounted() {
this.init()
},
methods: {
init() {
this.getStickyTop()
// 判断使用的模式
this.checkSupportCssSticky()
// 如果不支持css sticky,则使用js方案,此方案性能比不上css方案
if (!this.cssSticky) {
!this.disabled && this.initObserveContent()
}
},
initObserveContent() {
// 获取吸顶内容的高度,用于在js吸顶模式时,给父元素一个填充高度,防止"塌陷"
this.$uvGetRect('#' + this.elId).then((res) => {
this.height = res.height
this.left = res.left
this.width = res.width
this.$nextTick(() => {
this.observeContent()
})
})
},
observeContent() {
// 先断掉之前的观察
this.disconnectObserver('contentObserver')
const contentObserver = uni.createIntersectionObserver({
// 检测的区间范围
thresholds: [0.95, 0.98, 1]
})
// 到屏幕顶部的高度时触发
contentObserver.relativeToViewport({
top: -this.stickyTop
})
// 绑定观察的元素
contentObserver.observe(`#${this.elId}`, res => {
this.setFixed(res.boundingClientRect.top)
})
this.contentObserver = contentObserver
},
setFixed(top) {
// 判断是否出于吸顶条件范围
const fixed = top <= this.stickyTop
this.fixed = fixed
},
disconnectObserver(observerName) {
// 断掉观察,释放资源
const observer = this[observerName]
observer && observer.disconnect()
},
getStickyTop() {
this.stickyTop = this.$uv.getPx(this.offsetTop) + this.$uv.getPx(this.customNavHeight)
},
async checkSupportCssSticky() {
// #ifdef H5
// H5,一般都是现代浏览器,是支持css sticky的,这里使用创建元素嗅探的形式判断
if (this.checkCssStickyForH5()) {
this.cssSticky = true
}
// #endif
// 如果安卓版本高于8.0,依然认为是支持css sticky的(因为安卓7在某些机型,可能不支持sticky)
if (this.$uv.os() === 'android' && Number(this.$uv.sys().system) > 8) {
this.cssSticky = true
}
// APP-Vue和微信平台,通过computedStyle判断是否支持css sticky
// #ifdef APP-VUE || MP-WEIXIN
this.cssSticky = await this.checkComputedStyle()
// #endif
// ios上,从ios6开始,都是支持css sticky的
if (this.$uv.os() === 'ios') {
this.cssSticky = true
}
// nvue,是支持css sticky的
// #ifdef APP-NVUE
this.cssSticky = true
// #endif
},
// 在APP和微信小程序上,通过uni.createSelectorQuery可以判断是否支持css sticky
checkComputedStyle() {
// 方法内进行判断,避免在其他平台生成无用代码
// #ifdef APP-VUE || MP-WEIXIN
return new Promise(resolve => {
uni.createSelectorQuery().in(this).select('.uv-sticky').fields({
computedStyle: ["position"]
}).exec(e => {
resolve('sticky' === e[0].position)
})
})
// #endif
},
// H5通过创建元素的形式嗅探是否支持css sticky
// 判断浏览器是否支持sticky属性
checkCssStickyForH5() {
// 方法内进行判断,避免在其他平台生成无用代码
// #ifdef H5
const vendorList = ['', '-webkit-', '-ms-', '-moz-', '-o-'],
vendorListLength = vendorList.length,
stickyElement = document.createElement('div')
for (let i = 0; i < vendorListLength; i++) {
stickyElement.style.position = vendorList[i] + 'sticky'
if (stickyElement.style.position !== '') {
return true
}
}
return false;
// #endif
}
},
// #ifdef VUE2
beforeDestroy() {
this.disconnectObserver('contentObserver')
},
// #endif
// #ifdef VUE3
unmounted() {
this.disconnectObserver('contentObserver')
}
// #endif
}
</script>
<style lang="scss" scoped>
@import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
.uv-sticky {
/* #ifdef APP-VUE || MP-WEIXIN */
// 此处默认写sticky属性,是为了给微信和APP通过uni.createSelectorQuery查询是否支持css sticky使用
position: sticky;
/* #endif */
}
</style>
+87
View File
@@ -0,0 +1,87 @@
{
"id": "uv-sticky",
"displayName": "uv-sticky 吸顶 全面兼容小程序、nvue、vue2、vue3等多端",
"version": "1.0.4",
"description": "吸顶组件与CSS中position: sticky属性实现的效果一致,当组件达到预设的到顶部距离时, 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。",
"keywords": [
"uv-sticky",
"uvui",
"uv-ui",
"sticky",
"吸顶"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"uv-ui-tools"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
## Sticky 吸顶
> **组件名:uv-sticky**
该组件与CSS中position: sticky属性实现的效果一致,当组件达到预设的到顶部距离时, 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。
### <a href="https://www.uvui.cn/components/sticky.html" target="_blank">查看文档</a>
### [完整示例项目下载 | 关注更多组件](https://ext.dcloud.net.cn/plugin?name=uv-ui)
#### 如使用过程中有任何问题,或者您对uv-ui有一些好的建议,欢迎加入 uv-ui 交流群:<a href="https://ext.dcloud.net.cn/plugin?id=12287" target="_blank">uv-ui</a>、<a href="https://www.uvui.cn/components/addQQGroup.html" target="_blank">官方QQ群</a>