uview-pro 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +6 -0
- package/components/u-action-sheet/u-action-sheet.vue +205 -0
- package/components/u-alert-tips/u-alert-tips.vue +241 -0
- package/components/u-avatar/u-avatar.vue +220 -0
- package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
- package/components/u-avatar-cropper/weCropper.d.ts +54 -0
- package/components/u-avatar-cropper/weCropper.js +1267 -0
- package/components/u-avatar-cropper/weCropper.ts +1254 -0
- package/components/u-back-top/u-back-top.vue +156 -0
- package/components/u-badge/u-badge.vue +189 -0
- package/components/u-button/u-button.vue +562 -0
- package/components/u-calendar/u-calendar.vue +725 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
- package/components/u-card/u-card.vue +240 -0
- package/components/u-cell-group/u-cell-group.vue +56 -0
- package/components/u-cell-item/u-cell-item.vue +245 -0
- package/components/u-checkbox/u-checkbox.vue +310 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
- package/components/u-circle-progress/u-circle-progress.vue +210 -0
- package/components/u-col/u-col.vue +135 -0
- package/components/u-collapse/u-collapse.vue +82 -0
- package/components/u-collapse-item/u-collapse-item.vue +190 -0
- package/components/u-column-notice/u-column-notice.vue +264 -0
- package/components/u-count-down/u-count-down.vue +333 -0
- package/components/u-count-to/u-count-to.vue +297 -0
- package/components/u-divider/u-divider.vue +141 -0
- package/components/u-dropdown/u-dropdown.vue +311 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
- package/components/u-empty/u-empty.vue +111 -0
- package/components/u-field/u-field.vue +469 -0
- package/components/u-form/u-form.vue +162 -0
- package/components/u-form-item/u-form-item.vue +476 -0
- package/components/u-full-screen/u-full-screen.vue +80 -0
- package/components/u-gap/u-gap.vue +48 -0
- package/components/u-grid/u-grid.vue +101 -0
- package/components/u-grid-item/u-grid-item.vue +136 -0
- package/components/u-icon/u-icon.vue +389 -0
- package/components/u-image/types.ts +48 -0
- package/components/u-image/u-image.vue +218 -0
- package/components/u-index-anchor/u-index-anchor.vue +101 -0
- package/components/u-index-list/u-index-list.vue +376 -0
- package/components/u-input/u-input.vue +462 -0
- package/components/u-keyboard/u-keyboard.vue +188 -0
- package/components/u-lazy-load/u-lazy-load.vue +288 -0
- package/components/u-line/u-line.vue +71 -0
- package/components/u-line-progress/u-line-progress.vue +128 -0
- package/components/u-link/u-link.vue +87 -0
- package/components/u-loading/u-loading.vue +111 -0
- package/components/u-loadmore/u-loadmore.vue +205 -0
- package/components/u-mask/u-mask.vue +137 -0
- package/components/u-message-input/u-message-input.vue +315 -0
- package/components/u-modal/u-modal.vue +284 -0
- package/components/u-navbar/u-navbar.vue +314 -0
- package/components/u-no-network/image.ts +2 -0
- package/components/u-no-network/u-no-network.vue +311 -0
- package/components/u-notice-bar/u-notice-bar.vue +274 -0
- package/components/u-number-box/u-number-box.vue +344 -0
- package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
- package/components/u-parse/libs/CssHandler.js +100 -0
- package/components/u-parse/libs/MpHtmlParser.js +580 -0
- package/components/u-parse/libs/config.js +80 -0
- package/components/u-parse/libs/handler.wxs +22 -0
- package/components/u-parse/libs/trees.vue +505 -0
- package/components/u-parse/u-parse.vue +645 -0
- package/components/u-picker/u-picker.vue +808 -0
- package/components/u-popup/u-popup.vue +404 -0
- package/components/u-radio/u-radio.vue +272 -0
- package/components/u-radio-group/u-radio-group.vue +116 -0
- package/components/u-rate/u-rate.vue +349 -0
- package/components/u-read-more/u-read-more.vue +199 -0
- package/components/u-row/u-row.vue +95 -0
- package/components/u-row-notice/u-row-notice.vue +273 -0
- package/components/u-search/u-search.vue +298 -0
- package/components/u-section/u-section.vue +175 -0
- package/components/u-select/u-select.vue +387 -0
- package/components/u-skeleton/u-skeleton.vue +230 -0
- package/components/u-slider/u-slider.vue +293 -0
- package/components/u-steps/u-steps.vue +200 -0
- package/components/u-sticky/u-sticky.vue +189 -0
- package/components/u-subsection/u-subsection.vue +388 -0
- package/components/u-swipe-action/u-swipe-action.vue +289 -0
- package/components/u-swiper/u-swiper.vue +305 -0
- package/components/u-switch/u-switch.vue +146 -0
- package/components/u-tabbar/u-tabbar.vue +347 -0
- package/components/u-table/u-table.vue +104 -0
- package/components/u-tabs/u-tabs.vue +322 -0
- package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
- package/components/u-tag/u-tag.vue +270 -0
- package/components/u-td/u-td.vue +76 -0
- package/components/u-th/u-th.vue +70 -0
- package/components/u-time-line/u-time-line.vue +39 -0
- package/components/u-time-line-item/u-time-line-item.vue +88 -0
- package/components/u-toast/types.ts +4 -0
- package/components/u-toast/u-toast.vue +238 -0
- package/components/u-top-tips/u-top-tips.vue +118 -0
- package/components/u-tr/u-tr.vue +24 -0
- package/components/u-upload/u-upload.vue +600 -0
- package/components/u-verification-code/u-verification-code.vue +194 -0
- package/components/u-waterfall/u-waterfall.vue +186 -0
- package/iconfont.css +910 -0
- package/index.scss +23 -0
- package/index.ts +166 -0
- package/libs/config/config.ts +26 -0
- package/libs/config/zIndex.ts +37 -0
- package/libs/css/color.scss +155 -0
- package/libs/css/common.scss +176 -0
- package/libs/css/style.components.scss +7 -0
- package/libs/css/style.h5.scss +8 -0
- package/libs/css/style.mp.scss +72 -0
- package/libs/css/style.nvue.scss +3 -0
- package/libs/css/style.vue.scss +175 -0
- package/libs/function/$parent.ts +22 -0
- package/libs/function/addUnit.ts +13 -0
- package/libs/function/color.ts +37 -0
- package/libs/function/colorGradient.ts +123 -0
- package/libs/function/debounce.ts +28 -0
- package/libs/function/deepClone.ts +39 -0
- package/libs/function/deepMerge.ts +34 -0
- package/libs/function/getParent.ts +59 -0
- package/libs/function/getRect.ts +26 -0
- package/libs/function/guid.ts +42 -0
- package/libs/function/md5.ts +397 -0
- package/libs/function/parent.ts +21 -0
- package/libs/function/queryParams.ts +60 -0
- package/libs/function/random.ts +16 -0
- package/libs/function/randomArray.ts +11 -0
- package/libs/function/route.ts +118 -0
- package/libs/function/sys.ts +15 -0
- package/libs/function/test.ts +229 -0
- package/libs/function/throttle.ts +31 -0
- package/libs/function/timeFormat.ts +54 -0
- package/libs/function/timeFrom.ts +48 -0
- package/libs/function/toast.ts +14 -0
- package/libs/function/trim.ts +21 -0
- package/libs/function/type2icon.ts +36 -0
- package/libs/hooks/useEmitter.ts +77 -0
- package/libs/hooks/useParent.ts +29 -0
- package/libs/request/index.ts +237 -0
- package/libs/store/index.ts +88 -0
- package/libs/util/area.ts +1 -0
- package/libs/util/async-validator.js +1356 -0
- package/libs/util/city.ts +1 -0
- package/libs/util/emitter.ts +112 -0
- package/libs/util/mitt.ts +118 -0
- package/libs/util/parent.ts +20 -0
- package/libs/util/province.ts +1 -0
- package/package.json +98 -0
- package/readme.md +165 -0
- package/theme.scss +38 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="props.show" class="u-tabbar" @touchmove.stop.prevent="() => {}">
|
|
3
|
+
<view
|
|
4
|
+
class="u-tabbar__content safe-area-inset-bottom"
|
|
5
|
+
:style="{ height: $u.addUnit(props.height), backgroundColor: props.bgColor }"
|
|
6
|
+
:class="{ 'u-border-top': props.borderTop }"
|
|
7
|
+
>
|
|
8
|
+
<view
|
|
9
|
+
class="u-tabbar__content__item"
|
|
10
|
+
v-for="(item, index) in props.list"
|
|
11
|
+
:key="index"
|
|
12
|
+
:class="{ 'u-tabbar__content__circle': props.midButton && item.midButton }"
|
|
13
|
+
@tap.stop="clickHandler(index)"
|
|
14
|
+
:style="{ backgroundColor: props.bgColor }"
|
|
15
|
+
>
|
|
16
|
+
<view :class="[props.midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button']">
|
|
17
|
+
<u-icon
|
|
18
|
+
:size="props.midButton && item.midButton ? props.midButtonSize : props.iconSize"
|
|
19
|
+
:name="elIconPath(index)"
|
|
20
|
+
img-mode="scaleToFill"
|
|
21
|
+
:color="elColor(index)"
|
|
22
|
+
:custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'"
|
|
23
|
+
></u-icon>
|
|
24
|
+
<u-badge :count="item.count" :is-dot="item.isDot" v-if="item.count || item.isDot" :offset="[-2, getOffsetRight(item.count, item.isDot)]"></u-badge>
|
|
25
|
+
</view>
|
|
26
|
+
<view class="u-tabbar__content__item__text" :style="{ color: elColor(index) }">
|
|
27
|
+
<text class="u-line-1">{{ item.text }}</text>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
<view
|
|
31
|
+
v-if="props.midButton"
|
|
32
|
+
class="u-tabbar__content__circle__border"
|
|
33
|
+
:class="{ 'u-border': props.borderTop }"
|
|
34
|
+
:style="{ backgroundColor: props.bgColor, left: midButtonLeft }"
|
|
35
|
+
></view>
|
|
36
|
+
</view>
|
|
37
|
+
<!-- 这里加上一个48rpx的高度,是为了增高有凸起按钮时的防塌陷高度(也即按钮凸出来部分的高度) -->
|
|
38
|
+
<view class="u-fixed-placeholder safe-area-inset-bottom" :style="{ height: `calc(${$u.addUnit(props.height)} + ${props.midButton ? 48 : 0}rpx)` }"></view>
|
|
39
|
+
</view>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { ref, computed, onMounted, getCurrentInstance } from 'vue';
|
|
44
|
+
import { $u } from '../..';
|
|
45
|
+
|
|
46
|
+
defineOptions({ name: 'u-tabbar' });
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* u-tabbar 底部导航栏
|
|
50
|
+
* @property {Boolean} show 显示与否
|
|
51
|
+
* @property {String|Number} value 通过v-model绑定current值
|
|
52
|
+
* @property {String} bgColor 整个tabbar的背景颜色
|
|
53
|
+
* @property {String|Number} height tabbar的高度,默认50px,单位任意,如果为数值,则为rpx单位
|
|
54
|
+
* @property {String|Number} iconSize 非凸起图标的大小,单位任意,数值默认rpx
|
|
55
|
+
* @property {String|Number} midButtonSize 凸起的图标的大小,单位任意,数值默认rpx
|
|
56
|
+
* @property {String} activeColor 激活时的演示,包括字体图标,提示文字等的演示
|
|
57
|
+
* @property {String} inactiveColor 未激活时的颜色
|
|
58
|
+
* @property {Boolean} midButton 是否显示中部的凸起按钮
|
|
59
|
+
* @property {Array} list 配置参数
|
|
60
|
+
* @property {Function} beforeSwitch 切换前的回调
|
|
61
|
+
* @property {Boolean} borderTop 是否显示顶部的横线
|
|
62
|
+
* @property {Boolean} hideTabBar 是否隐藏原生tabbar
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
const props = defineProps({
|
|
66
|
+
/** 显示与否 */
|
|
67
|
+
show: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true
|
|
70
|
+
},
|
|
71
|
+
/** 通过v-model绑定current值 */
|
|
72
|
+
modelValue: {
|
|
73
|
+
type: [String, Number],
|
|
74
|
+
default: 0
|
|
75
|
+
},
|
|
76
|
+
/** 整个tabbar的背景颜色 */
|
|
77
|
+
bgColor: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: '#ffffff'
|
|
80
|
+
},
|
|
81
|
+
/** tabbar的高度,默认50px,单位任意,如果为数值,则为rpx单位 */
|
|
82
|
+
height: {
|
|
83
|
+
type: [String, Number],
|
|
84
|
+
default: '50px'
|
|
85
|
+
},
|
|
86
|
+
/** 非凸起图标的大小,单位任意,数值默认rpx */
|
|
87
|
+
iconSize: {
|
|
88
|
+
type: [String, Number],
|
|
89
|
+
default: 40
|
|
90
|
+
},
|
|
91
|
+
/** 凸起的图标的大小,单位任意,数值默认rpx */
|
|
92
|
+
midButtonSize: {
|
|
93
|
+
type: [String, Number],
|
|
94
|
+
default: 90
|
|
95
|
+
},
|
|
96
|
+
/** 激活时的演示,包括字体图标,提示文字等的演示 */
|
|
97
|
+
activeColor: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: '#303133'
|
|
100
|
+
},
|
|
101
|
+
/** 未激活时的颜色 */
|
|
102
|
+
inactiveColor: {
|
|
103
|
+
type: String,
|
|
104
|
+
default: '#606266'
|
|
105
|
+
},
|
|
106
|
+
/** 是否显示中部的凸起按钮 */
|
|
107
|
+
midButton: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: false
|
|
110
|
+
},
|
|
111
|
+
/** 配置参数 */
|
|
112
|
+
list: {
|
|
113
|
+
type: Array as () => any[],
|
|
114
|
+
default: () => []
|
|
115
|
+
},
|
|
116
|
+
/** 切换前的回调 */
|
|
117
|
+
beforeSwitch: {
|
|
118
|
+
type: Function,
|
|
119
|
+
default: null
|
|
120
|
+
},
|
|
121
|
+
/** 是否显示顶部的横线 */
|
|
122
|
+
borderTop: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: true
|
|
125
|
+
},
|
|
126
|
+
/** 是否隐藏原生tabbar */
|
|
127
|
+
hideTabBar: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: true
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const emit = defineEmits<{ (e: 'change', index: number): void; (e: 'update:modelValue', index: number): void }>();
|
|
134
|
+
|
|
135
|
+
// 由于安卓太菜了,通过css居中凸起按钮的外层元素有误差,故通过js计算将其居中
|
|
136
|
+
const midButtonLeft = ref('50%');
|
|
137
|
+
const pageUrl = ref(''); // 当前页面URL
|
|
138
|
+
|
|
139
|
+
onMounted(() => {
|
|
140
|
+
// 是否隐藏原生tabbar
|
|
141
|
+
// 注意:如果当前页面不是tabbar页面,浏览器控制台会报错:{errMsg: 'hideTabBar:fail not TabBar page'}
|
|
142
|
+
if (props.hideTabBar) uni.hideTabBar();
|
|
143
|
+
// 获取引入了u-tabbar页面的路由地址,该地址没有路径前面的"/"
|
|
144
|
+
const pages = getCurrentPages();
|
|
145
|
+
// 页面栈中的最后一个即为项为当前页面,route属性为页面路径
|
|
146
|
+
pageUrl.value = pages[pages.length - 1].route as string;
|
|
147
|
+
if (props.midButton) getMidButtonLeft();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 计算当前item的icon路径
|
|
152
|
+
*/
|
|
153
|
+
const elIconPath = computed<(index: number) => string>(() => {
|
|
154
|
+
return (index: number) => {
|
|
155
|
+
// 历遍u-tabbar的每一项item时,判断是否传入了pagePath参数,如果传入了
|
|
156
|
+
// 和data中的pageUrl参数对比,如果相等,即可判断当前的item对应当前的tabbar页面,设置高亮图标
|
|
157
|
+
// 采用这个方法,可以无需使用v-model绑定的value值
|
|
158
|
+
const pagePath = props.list[index]?.pagePath;
|
|
159
|
+
// 如果定义了pagePath属性,意味着使用系统自带tabbar方案,否则使用一个页面用几个组件模拟tabbar页面的方案
|
|
160
|
+
// 这两个方案对处理tabbar item的激活与否方式不一样
|
|
161
|
+
if (pagePath) {
|
|
162
|
+
if (pagePath === pageUrl.value || pagePath === '/' + pageUrl.value) {
|
|
163
|
+
return props.list[index].selectedIconPath;
|
|
164
|
+
} else {
|
|
165
|
+
return props.list[index].iconPath;
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
// 普通方案中,索引等于v-model值时,即为激活项
|
|
169
|
+
return index == props.modelValue ? props.list[index].selectedIconPath : props.list[index].iconPath;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 计算当前item的颜色
|
|
176
|
+
*/
|
|
177
|
+
const elColor = computed<(index: number) => string>(() => {
|
|
178
|
+
return (index: number) => {
|
|
179
|
+
// 判断方法同理于elIconPath
|
|
180
|
+
const pagePath = props.list[index]?.pagePath;
|
|
181
|
+
if (pagePath) {
|
|
182
|
+
if (pagePath === pageUrl.value || pagePath === '/' + pageUrl.value) return props.activeColor;
|
|
183
|
+
else return props.inactiveColor;
|
|
184
|
+
} else {
|
|
185
|
+
return index == props.modelValue ? props.activeColor : props.inactiveColor;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 点击tabbar item
|
|
192
|
+
*/
|
|
193
|
+
async function clickHandler(index: number) {
|
|
194
|
+
if (props.beforeSwitch && typeof props.beforeSwitch === 'function') {
|
|
195
|
+
// 执行回调,同时传入索引当作参数
|
|
196
|
+
// 在微信,支付宝等环境(H5正常),会导致父组件定义的customBack()函数体中的this变成子组件的this
|
|
197
|
+
// 通过bind()方法,绑定父组件的this,让this.customBack()的this为父组件的上下文
|
|
198
|
+
// let beforeSwitch = props.beforeSwitch.bind($u.$parent.call(getCurrentInstance()?.proxy))(index);
|
|
199
|
+
// 或许有问题
|
|
200
|
+
let beforeSwitch = props.beforeSwitch(index);
|
|
201
|
+
// 判断是否返回了promise
|
|
202
|
+
if (!!beforeSwitch && typeof beforeSwitch.then === 'function') {
|
|
203
|
+
await beforeSwitch
|
|
204
|
+
.then(() => {
|
|
205
|
+
// promise返回成功,
|
|
206
|
+
switchTab(index);
|
|
207
|
+
})
|
|
208
|
+
.catch(() => {});
|
|
209
|
+
} else if (beforeSwitch === true) {
|
|
210
|
+
// 如果返回true
|
|
211
|
+
switchTab(index);
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
switchTab(index);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 切换tab
|
|
220
|
+
*/
|
|
221
|
+
function switchTab(index: number) {
|
|
222
|
+
// 发出事件和修改v-model绑定的值
|
|
223
|
+
emit('change', index);
|
|
224
|
+
// 如果有配置pagePath属性,使用uni.switchTab进行跳转
|
|
225
|
+
if (props.list[index]?.pagePath) {
|
|
226
|
+
uni.switchTab({ url: props.list[index].pagePath });
|
|
227
|
+
} else {
|
|
228
|
+
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
|
|
229
|
+
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
|
|
230
|
+
emit('update:modelValue', index);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* 计算角标的right值
|
|
236
|
+
*/
|
|
237
|
+
function getOffsetRight(count: number, isDot: boolean): number {
|
|
238
|
+
// 点类型,count大于9(两位数),分别设置不同的right值,避免位置太挤
|
|
239
|
+
if (isDot) {
|
|
240
|
+
return -20;
|
|
241
|
+
} else if (count > 9) {
|
|
242
|
+
return -40;
|
|
243
|
+
} else {
|
|
244
|
+
return -30;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 获取凸起按钮外层元素的left值,让其水平居中
|
|
250
|
+
*/
|
|
251
|
+
function getMidButtonLeft() {
|
|
252
|
+
const windowWidth = $u.sys().windowWidth;
|
|
253
|
+
// 由于安卓中css计算left: 50%的结果不准确,故用js计算
|
|
254
|
+
midButtonLeft.value = windowWidth / 2 + 'px';
|
|
255
|
+
}
|
|
256
|
+
</script>
|
|
257
|
+
|
|
258
|
+
<style scoped lang="scss">
|
|
259
|
+
@import '../../libs/css/style.components.scss';
|
|
260
|
+
.u-fixed-placeholder {
|
|
261
|
+
/* #ifndef APP-NVUE */
|
|
262
|
+
box-sizing: content-box;
|
|
263
|
+
/* #endif */
|
|
264
|
+
}
|
|
265
|
+
.u-tabbar {
|
|
266
|
+
&__content {
|
|
267
|
+
@include vue-flex;
|
|
268
|
+
align-items: center;
|
|
269
|
+
position: relative;
|
|
270
|
+
position: fixed;
|
|
271
|
+
bottom: 0;
|
|
272
|
+
left: 0;
|
|
273
|
+
width: 100%;
|
|
274
|
+
z-index: 998;
|
|
275
|
+
/* #ifndef APP-NVUE */
|
|
276
|
+
box-sizing: content-box;
|
|
277
|
+
/* #endif */
|
|
278
|
+
&__circle__border {
|
|
279
|
+
border-radius: 100%;
|
|
280
|
+
width: 110rpx;
|
|
281
|
+
height: 110rpx;
|
|
282
|
+
top: -48rpx;
|
|
283
|
+
position: absolute;
|
|
284
|
+
z-index: 4;
|
|
285
|
+
background-color: #ffffff;
|
|
286
|
+
// 由于安卓的无能,导致只有3个tabbar item时,此css计算方式有误差
|
|
287
|
+
// 故使用js计算的形式来定位,此处不注释,是因为js计算有延后,避免出现位置闪动
|
|
288
|
+
left: 50%;
|
|
289
|
+
transform: translateX(-50%);
|
|
290
|
+
&:after {
|
|
291
|
+
border-radius: 100px;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
&__item {
|
|
295
|
+
flex: 1;
|
|
296
|
+
justify-content: center;
|
|
297
|
+
height: 100%;
|
|
298
|
+
padding: 12rpx 0;
|
|
299
|
+
@include vue-flex;
|
|
300
|
+
flex-direction: column;
|
|
301
|
+
align-items: center;
|
|
302
|
+
position: relative;
|
|
303
|
+
&__button {
|
|
304
|
+
position: absolute;
|
|
305
|
+
top: 14rpx;
|
|
306
|
+
left: 50%;
|
|
307
|
+
transform: translateX(-50%);
|
|
308
|
+
}
|
|
309
|
+
&__text {
|
|
310
|
+
color: $u-content-color;
|
|
311
|
+
font-size: 26rpx;
|
|
312
|
+
line-height: 28rpx;
|
|
313
|
+
position: absolute;
|
|
314
|
+
bottom: 14rpx;
|
|
315
|
+
left: 50%;
|
|
316
|
+
transform: translateX(-50%);
|
|
317
|
+
width: 100%;
|
|
318
|
+
text-align: center;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
&__circle {
|
|
322
|
+
position: relative;
|
|
323
|
+
@include vue-flex;
|
|
324
|
+
flex-direction: column;
|
|
325
|
+
justify-content: space-between;
|
|
326
|
+
z-index: 10;
|
|
327
|
+
/* #ifndef APP-NVUE */
|
|
328
|
+
height: calc(100% - 1px);
|
|
329
|
+
/* #endif */
|
|
330
|
+
&__button {
|
|
331
|
+
width: 90rpx;
|
|
332
|
+
height: 90rpx;
|
|
333
|
+
border-radius: 100%;
|
|
334
|
+
@include vue-flex;
|
|
335
|
+
justify-content: center;
|
|
336
|
+
align-items: center;
|
|
337
|
+
position: absolute;
|
|
338
|
+
background-color: #ffffff;
|
|
339
|
+
top: -40rpx;
|
|
340
|
+
left: 50%;
|
|
341
|
+
z-index: 6;
|
|
342
|
+
transform: translateX(-50%);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-table" :style="tableStyle">
|
|
3
|
+
<slot />
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
|
|
10
|
+
defineOptions({ name: 'u-table' });
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* table 表格
|
|
14
|
+
* @description 表格组件一般用于展示大量结构化数据的场景
|
|
15
|
+
* @tutorial https://www.uviewui.com/components/table.html
|
|
16
|
+
* @property {String} border-color 表格边框的颜色(默认#e4e7ed)
|
|
17
|
+
* @property {String} bg-color 表格的背景颜色(默认#ffffff)
|
|
18
|
+
* @property {String} align 单元格的内容对齐方式,作用类似css的text-align(默认center)
|
|
19
|
+
* @property {String} padding 单元格的内边距,同css的padding写法(默认10rpx 0)
|
|
20
|
+
* @property {String | Number} font-size 单元格字体大小,单位rpx(默认28)
|
|
21
|
+
* @property {String} color 单元格字体颜色(默认#606266)
|
|
22
|
+
* @property {Object} th-style th单元格的样式,对象形式(将th所需参数放在table组件,是为了避免每一个th组件要写一遍)
|
|
23
|
+
* @event {Function} click 点击组件时触发
|
|
24
|
+
* @event {Function} close 点击关闭按钮时触发
|
|
25
|
+
* @example <u-table></u-table>
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const props = defineProps({
|
|
29
|
+
/**
|
|
30
|
+
* 表格边框的颜色
|
|
31
|
+
*/
|
|
32
|
+
borderColor: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: '#e4e7ed'
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* 单元格的内容对齐方式
|
|
38
|
+
*/
|
|
39
|
+
align: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: 'center'
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* td的内边距
|
|
45
|
+
*/
|
|
46
|
+
padding: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: '10rpx 6rpx'
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* 字体大小
|
|
52
|
+
*/
|
|
53
|
+
fontSize: {
|
|
54
|
+
type: [String, Number],
|
|
55
|
+
default: 28
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* 字体颜色
|
|
59
|
+
*/
|
|
60
|
+
color: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: '#606266'
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* th的自定义样式
|
|
66
|
+
*/
|
|
67
|
+
thStyle: {
|
|
68
|
+
type: Object as () => Record<string, any>,
|
|
69
|
+
default: () => ({})
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* table的背景颜色
|
|
73
|
+
*/
|
|
74
|
+
bgColor: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: '#ffffff'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 计算表格样式
|
|
82
|
+
*/
|
|
83
|
+
const tableStyle = computed(() => {
|
|
84
|
+
const style: Record<string, any> = {};
|
|
85
|
+
style.borderLeft = `solid 1px ${props.borderColor}`;
|
|
86
|
+
style.borderTop = `solid 1px ${props.borderColor}`;
|
|
87
|
+
style.backgroundColor = props.bgColor;
|
|
88
|
+
return style;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
defineExpose({
|
|
92
|
+
props,
|
|
93
|
+
tableStyle
|
|
94
|
+
});
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style lang="scss" scoped>
|
|
98
|
+
@import '../../libs/css/style.components.scss';
|
|
99
|
+
|
|
100
|
+
.u-table {
|
|
101
|
+
width: 100%;
|
|
102
|
+
box-sizing: border-box;
|
|
103
|
+
}
|
|
104
|
+
</style>
|