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.
Files changed (149) hide show
  1. package/changelog.md +6 -0
  2. package/components/u-action-sheet/u-action-sheet.vue +205 -0
  3. package/components/u-alert-tips/u-alert-tips.vue +241 -0
  4. package/components/u-avatar/u-avatar.vue +220 -0
  5. package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
  6. package/components/u-avatar-cropper/weCropper.d.ts +54 -0
  7. package/components/u-avatar-cropper/weCropper.js +1267 -0
  8. package/components/u-avatar-cropper/weCropper.ts +1254 -0
  9. package/components/u-back-top/u-back-top.vue +156 -0
  10. package/components/u-badge/u-badge.vue +189 -0
  11. package/components/u-button/u-button.vue +562 -0
  12. package/components/u-calendar/u-calendar.vue +725 -0
  13. package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
  14. package/components/u-card/u-card.vue +240 -0
  15. package/components/u-cell-group/u-cell-group.vue +56 -0
  16. package/components/u-cell-item/u-cell-item.vue +245 -0
  17. package/components/u-checkbox/u-checkbox.vue +310 -0
  18. package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
  19. package/components/u-circle-progress/u-circle-progress.vue +210 -0
  20. package/components/u-col/u-col.vue +135 -0
  21. package/components/u-collapse/u-collapse.vue +82 -0
  22. package/components/u-collapse-item/u-collapse-item.vue +190 -0
  23. package/components/u-column-notice/u-column-notice.vue +264 -0
  24. package/components/u-count-down/u-count-down.vue +333 -0
  25. package/components/u-count-to/u-count-to.vue +297 -0
  26. package/components/u-divider/u-divider.vue +141 -0
  27. package/components/u-dropdown/u-dropdown.vue +311 -0
  28. package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
  29. package/components/u-empty/u-empty.vue +111 -0
  30. package/components/u-field/u-field.vue +469 -0
  31. package/components/u-form/u-form.vue +162 -0
  32. package/components/u-form-item/u-form-item.vue +476 -0
  33. package/components/u-full-screen/u-full-screen.vue +80 -0
  34. package/components/u-gap/u-gap.vue +48 -0
  35. package/components/u-grid/u-grid.vue +101 -0
  36. package/components/u-grid-item/u-grid-item.vue +136 -0
  37. package/components/u-icon/u-icon.vue +389 -0
  38. package/components/u-image/types.ts +48 -0
  39. package/components/u-image/u-image.vue +218 -0
  40. package/components/u-index-anchor/u-index-anchor.vue +101 -0
  41. package/components/u-index-list/u-index-list.vue +376 -0
  42. package/components/u-input/u-input.vue +462 -0
  43. package/components/u-keyboard/u-keyboard.vue +188 -0
  44. package/components/u-lazy-load/u-lazy-load.vue +288 -0
  45. package/components/u-line/u-line.vue +71 -0
  46. package/components/u-line-progress/u-line-progress.vue +128 -0
  47. package/components/u-link/u-link.vue +87 -0
  48. package/components/u-loading/u-loading.vue +111 -0
  49. package/components/u-loadmore/u-loadmore.vue +205 -0
  50. package/components/u-mask/u-mask.vue +137 -0
  51. package/components/u-message-input/u-message-input.vue +315 -0
  52. package/components/u-modal/u-modal.vue +284 -0
  53. package/components/u-navbar/u-navbar.vue +314 -0
  54. package/components/u-no-network/image.ts +2 -0
  55. package/components/u-no-network/u-no-network.vue +311 -0
  56. package/components/u-notice-bar/u-notice-bar.vue +274 -0
  57. package/components/u-number-box/u-number-box.vue +344 -0
  58. package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
  59. package/components/u-parse/libs/CssHandler.js +100 -0
  60. package/components/u-parse/libs/MpHtmlParser.js +580 -0
  61. package/components/u-parse/libs/config.js +80 -0
  62. package/components/u-parse/libs/handler.wxs +22 -0
  63. package/components/u-parse/libs/trees.vue +505 -0
  64. package/components/u-parse/u-parse.vue +645 -0
  65. package/components/u-picker/u-picker.vue +808 -0
  66. package/components/u-popup/u-popup.vue +404 -0
  67. package/components/u-radio/u-radio.vue +272 -0
  68. package/components/u-radio-group/u-radio-group.vue +116 -0
  69. package/components/u-rate/u-rate.vue +349 -0
  70. package/components/u-read-more/u-read-more.vue +199 -0
  71. package/components/u-row/u-row.vue +95 -0
  72. package/components/u-row-notice/u-row-notice.vue +273 -0
  73. package/components/u-search/u-search.vue +298 -0
  74. package/components/u-section/u-section.vue +175 -0
  75. package/components/u-select/u-select.vue +387 -0
  76. package/components/u-skeleton/u-skeleton.vue +230 -0
  77. package/components/u-slider/u-slider.vue +293 -0
  78. package/components/u-steps/u-steps.vue +200 -0
  79. package/components/u-sticky/u-sticky.vue +189 -0
  80. package/components/u-subsection/u-subsection.vue +388 -0
  81. package/components/u-swipe-action/u-swipe-action.vue +289 -0
  82. package/components/u-swiper/u-swiper.vue +305 -0
  83. package/components/u-switch/u-switch.vue +146 -0
  84. package/components/u-tabbar/u-tabbar.vue +347 -0
  85. package/components/u-table/u-table.vue +104 -0
  86. package/components/u-tabs/u-tabs.vue +322 -0
  87. package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
  88. package/components/u-tag/u-tag.vue +270 -0
  89. package/components/u-td/u-td.vue +76 -0
  90. package/components/u-th/u-th.vue +70 -0
  91. package/components/u-time-line/u-time-line.vue +39 -0
  92. package/components/u-time-line-item/u-time-line-item.vue +88 -0
  93. package/components/u-toast/types.ts +4 -0
  94. package/components/u-toast/u-toast.vue +238 -0
  95. package/components/u-top-tips/u-top-tips.vue +118 -0
  96. package/components/u-tr/u-tr.vue +24 -0
  97. package/components/u-upload/u-upload.vue +600 -0
  98. package/components/u-verification-code/u-verification-code.vue +194 -0
  99. package/components/u-waterfall/u-waterfall.vue +186 -0
  100. package/iconfont.css +910 -0
  101. package/index.scss +23 -0
  102. package/index.ts +166 -0
  103. package/libs/config/config.ts +26 -0
  104. package/libs/config/zIndex.ts +37 -0
  105. package/libs/css/color.scss +155 -0
  106. package/libs/css/common.scss +176 -0
  107. package/libs/css/style.components.scss +7 -0
  108. package/libs/css/style.h5.scss +8 -0
  109. package/libs/css/style.mp.scss +72 -0
  110. package/libs/css/style.nvue.scss +3 -0
  111. package/libs/css/style.vue.scss +175 -0
  112. package/libs/function/$parent.ts +22 -0
  113. package/libs/function/addUnit.ts +13 -0
  114. package/libs/function/color.ts +37 -0
  115. package/libs/function/colorGradient.ts +123 -0
  116. package/libs/function/debounce.ts +28 -0
  117. package/libs/function/deepClone.ts +39 -0
  118. package/libs/function/deepMerge.ts +34 -0
  119. package/libs/function/getParent.ts +59 -0
  120. package/libs/function/getRect.ts +26 -0
  121. package/libs/function/guid.ts +42 -0
  122. package/libs/function/md5.ts +397 -0
  123. package/libs/function/parent.ts +21 -0
  124. package/libs/function/queryParams.ts +60 -0
  125. package/libs/function/random.ts +16 -0
  126. package/libs/function/randomArray.ts +11 -0
  127. package/libs/function/route.ts +118 -0
  128. package/libs/function/sys.ts +15 -0
  129. package/libs/function/test.ts +229 -0
  130. package/libs/function/throttle.ts +31 -0
  131. package/libs/function/timeFormat.ts +54 -0
  132. package/libs/function/timeFrom.ts +48 -0
  133. package/libs/function/toast.ts +14 -0
  134. package/libs/function/trim.ts +21 -0
  135. package/libs/function/type2icon.ts +36 -0
  136. package/libs/hooks/useEmitter.ts +77 -0
  137. package/libs/hooks/useParent.ts +29 -0
  138. package/libs/request/index.ts +237 -0
  139. package/libs/store/index.ts +88 -0
  140. package/libs/util/area.ts +1 -0
  141. package/libs/util/async-validator.js +1356 -0
  142. package/libs/util/city.ts +1 -0
  143. package/libs/util/emitter.ts +112 -0
  144. package/libs/util/mitt.ts +118 -0
  145. package/libs/util/parent.ts +20 -0
  146. package/libs/util/province.ts +1 -0
  147. package/package.json +98 -0
  148. package/readme.md +165 -0
  149. package/theme.scss +38 -0
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <view class="u-td" :style="tdStyle">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ref, onMounted, getCurrentInstance } from 'vue';
9
+ import { $u } from '../..';
10
+
11
+ defineOptions({ name: 'u-td' });
12
+
13
+ /**
14
+ * td td单元格
15
+ * @description 表格组件一般用于展示大量结构化数据的场景(搭配u-table使用)
16
+ * @tutorial https://www.uviewui.com/components/table.html#td-props
17
+ * @property {String | Number} width 单元格宽度百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比,单元格宽度默认为均分tr的长度(默认auto)
18
+ * @example <u-td>二年级</u-td>
19
+ */
20
+
21
+ const props = defineProps({
22
+ /**
23
+ * 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
24
+ */
25
+ width: {
26
+ type: [Number, String],
27
+ default: 'auto'
28
+ }
29
+ });
30
+
31
+ /**
32
+ * 组合式API变量声明
33
+ * 保留所有说明注释
34
+ */
35
+ const tdStyle = ref<Record<string, any>>({}); // 单元格样式
36
+ let parent: any = null; // 父组件实例
37
+
38
+ /**
39
+ * 组件挂载时查找父组件u-table并合并样式
40
+ */
41
+ onMounted(() => {
42
+ // 查找父组件u-table
43
+ const instance = getCurrentInstance();
44
+ if (instance) {
45
+ parent = $u.$parent('u-table');
46
+ if (parent) {
47
+ // 将父组件的相关参数,合并到本组件
48
+ const style: Record<string, any> = {};
49
+ if (props.width !== 'auto') style.flex = `0 0 ${props.width}`;
50
+ style.textAlign = parent.props.align;
51
+ style.fontSize = parent.props.fontSize + 'rpx';
52
+ style.padding = parent.props.padding;
53
+ style.borderBottom = `solid 1px ${parent.props.borderColor}`;
54
+ style.borderRight = `solid 1px ${parent.props.borderColor}`;
55
+ style.color = parent.props.color;
56
+ tdStyle.value = style;
57
+ }
58
+ }
59
+ });
60
+ </script>
61
+
62
+ <style lang="scss" scoped>
63
+ @import '../../libs/css/style.components.scss';
64
+
65
+ .u-td {
66
+ @include vue-flex;
67
+ flex-direction: column;
68
+ flex: 1;
69
+ justify-content: center;
70
+ font-size: 28rpx;
71
+ color: $u-content-color;
72
+ align-self: stretch;
73
+ box-sizing: border-box;
74
+ height: 100%;
75
+ }
76
+ </style>
@@ -0,0 +1,70 @@
1
+ <template>
2
+ <view class="u-th" :style="thStyle">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ref, onMounted, getCurrentInstance } from 'vue';
9
+ import { $u } from '../..';
10
+
11
+ defineOptions({ name: 'u-th' });
12
+
13
+ /**
14
+ * th th单元格
15
+ * @description 表格组件一般用于展示大量结构化数据的场景(搭配u-table使用)
16
+ * @tutorial https://www.uviewui.com/components/table.html#td-props
17
+ * @property {String | Number} width 标题单元格宽度百分比或者具体带单位的值,如30%,200rpx等,一般使用百分比,单元格宽度默认为均分tr的长度
18
+ * @example 暂无示例
19
+ */
20
+
21
+ const props = defineProps({
22
+ /**
23
+ * 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
24
+ */
25
+ width: {
26
+ type: [Number, String],
27
+ default: ''
28
+ }
29
+ });
30
+
31
+ const thStyle = ref<Record<string, any>>({}); // 标题单元格样式
32
+ let parent: any = null; // 父组件实例
33
+
34
+ /**
35
+ * 组件挂载时查找父组件u-table并合并样式
36
+ */
37
+ onMounted(() => {
38
+ // 查找父组件u-table
39
+ const instance = getCurrentInstance();
40
+ if (instance) {
41
+ parent = $u.$parent('u-table');
42
+ if (parent) {
43
+ // 将父组件的相关参数,合并到本组件
44
+ const style: Record<string, any> = {};
45
+ if (props.width) style.flex = `0 0 ${props.width}`;
46
+ style.textAlign = parent.props.align;
47
+ style.padding = parent.props.padding;
48
+ style.borderBottom = `solid 1px ${parent.props.borderColor}`;
49
+ style.borderRight = `solid 1px ${parent.props.borderColor}`;
50
+ Object.assign(style, parent.props.thStyle);
51
+ thStyle.value = style;
52
+ }
53
+ }
54
+ });
55
+ </script>
56
+
57
+ <style lang="scss" scoped>
58
+ @import '../../libs/css/style.components.scss';
59
+
60
+ .u-th {
61
+ @include vue-flex;
62
+ flex-direction: column;
63
+ flex: 1;
64
+ justify-content: center;
65
+ font-size: 28rpx;
66
+ color: $u-main-color;
67
+ font-weight: bold;
68
+ background-color: rgb(245, 246, 248);
69
+ }
70
+ </style>
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <view class="u-time-axis">
3
+ <slot />
4
+ </view>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ defineOptions({ name: 'u-time-line' });
9
+
10
+ /**
11
+ * timeLine 时间轴
12
+ * @description 时间轴组件一般用于物流信息展示,各种跟时间相关的记录等场景。
13
+ * @tutorial https://www.uviewui.com/components/timeLine.html
14
+ * @example <u-time-line></u-time-line>
15
+ */
16
+
17
+ // 当前组件无 props 和方法,仅作为时间轴容器使用
18
+ </script>
19
+
20
+ <style lang="scss" scoped>
21
+ @import '../../libs/css/style.components.scss';
22
+
23
+ .u-time-axis {
24
+ padding-left: 40rpx;
25
+ position: relative;
26
+ }
27
+
28
+ .u-time-axis::before {
29
+ content: ' ';
30
+ position: absolute;
31
+ left: 0;
32
+ top: 12rpx;
33
+ width: 1px;
34
+ bottom: 0;
35
+ border-left: 1px solid #ddd;
36
+ transform-origin: 0 0;
37
+ transform: scaleX(0.5);
38
+ }
39
+ </style>
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <view class="u-time-axis-item">
3
+ <slot name="content" />
4
+ <view class="u-time-axis-node" :style="[nodeStyle]">
5
+ <slot name="node">
6
+ <view class="u-dot"> </view>
7
+ </slot>
8
+ </view>
9
+ </view>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { computed } from 'vue';
14
+
15
+ defineOptions({ name: 'u-time-line-item' });
16
+
17
+ /**
18
+ * timeLineItem 时间轴Item
19
+ * @description 时间轴组件一般用于物流信息展示,各种跟时间相关的记录等场景。(搭配u-time-line使用)
20
+ * @tutorial https://www.uviewui.com/components/timeLine.html
21
+ * @property {String} bg-color 左边节点的背景颜色,一般通过slot内容自定义背景颜色即可(默认#ffffff)
22
+ * @property {String | Number} node-top 节点左边图标绝对定位的top值,单位rpx
23
+ * @example <u-time-line-item node-top="2">...</u-time-line-item>
24
+ */
25
+
26
+ /**
27
+ * 节点的背景颜色
28
+ * @default "#ffffff"
29
+ */
30
+ const props = defineProps({
31
+ /** 节点的背景颜色 */
32
+ bgColor: {
33
+ type: String,
34
+ default: '#ffffff'
35
+ },
36
+ /** 节点左边图标绝对定位的top值,单位rpx */
37
+ nodeTop: {
38
+ type: [String, Number],
39
+ default: ''
40
+ }
41
+ });
42
+
43
+ /**
44
+ * 计算节点样式
45
+ * @returns 节点样式对象
46
+ */
47
+ const nodeStyle = computed(() => {
48
+ // 生成节点样式对象
49
+ const style: Record<string, string> = {
50
+ backgroundColor: props.bgColor
51
+ };
52
+ // 如果设置了 nodeTop,则添加 top 属性
53
+ if (props.nodeTop !== '') style.top = String(props.nodeTop) + 'rpx';
54
+ return style;
55
+ });
56
+ </script>
57
+
58
+ <style lang="scss" scoped>
59
+ @import '../../libs/css/style.components.scss';
60
+
61
+ .u-time-axis-item {
62
+ @include vue-flex;
63
+ flex-direction: column;
64
+ width: 100%;
65
+ position: relative;
66
+ margin-bottom: 32rpx;
67
+ }
68
+
69
+ .u-time-axis-node {
70
+ position: absolute;
71
+ top: 12rpx;
72
+ left: -40rpx;
73
+ transform-origin: 0;
74
+ transform: translateX(-50%);
75
+ @include vue-flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ z-index: 1;
79
+ font-size: 24rpx;
80
+ }
81
+
82
+ .u-dot {
83
+ height: 16rpx;
84
+ width: 16rpx;
85
+ border-radius: 100rpx;
86
+ background: #ddd;
87
+ }
88
+ </style>
@@ -0,0 +1,4 @@
1
+ export type ToastExpose = {
2
+ show: (options: Record<string, any>) => void
3
+ hide: () => void
4
+ }
@@ -0,0 +1,238 @@
1
+ <template>
2
+ <view
3
+ class="u-toast"
4
+ :class="[isShow ? 'u-show' : '', 'u-type-' + tmpConfig.type, 'u-position-' + tmpConfig.position]"
5
+ :style="{
6
+ zIndex: uZIndex
7
+ }"
8
+ >
9
+ <view class="u-icon-wrap">
10
+ <u-icon v-if="tmpConfig.icon" class="u-icon" :name="iconName" :size="30" :color="tmpConfig.type"></u-icon>
11
+ </view>
12
+ <text class="u-text">{{ tmpConfig.title }}</text>
13
+ </view>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import { ref, computed } from 'vue';
18
+ import { $u } from '../..';
19
+ import type { ToastExpose } from './types';
20
+
21
+ defineOptions({
22
+ name: 'u-toast'
23
+ });
24
+
25
+ /**
26
+ * toast 消息提示
27
+ * @description 此组件表现形式类似uni的uni.showToastAPI,但也有不同的地方。
28
+ * @tutorial https://www.uviewui.com/components/toast.html
29
+ * @property {String|Number} z-index toast展示时的z-index值
30
+ * @event {Function} show 显示toast,如需一进入页面就显示toast,请在onReady生命周期调用
31
+ * @example <u-toast ref="uToast" />
32
+ */
33
+ const props = defineProps({
34
+ /** z-index值 */
35
+ zIndex: {
36
+ type: [Number, String],
37
+ default: ''
38
+ }
39
+ });
40
+
41
+ // 是否显示toast
42
+ const isShow = ref(false);
43
+ // 定时器
44
+ let timer: ReturnType<typeof setTimeout> | null = null;
45
+ // 内置配置
46
+ const config = ref({
47
+ params: {}, // URL跳转的参数,对象
48
+ title: '', // 显示文本
49
+ type: '', // 主题类型,primary,success,error,warning,black
50
+ duration: 2000, // 显示的时间,毫秒
51
+ isTab: false, // 是否跳转tab页面
52
+ url: '', // toast消失后是否跳转页面,有则跳转,优先级高于back参数
53
+ icon: true, // 显示的图标
54
+ position: 'center', // toast出现的位置
55
+ callback: null as null | (() => void), // 执行完后的回调函数
56
+ back: false // 结束toast是否自动返回上一页
57
+ });
58
+ // 合并后的临时配置变量
59
+ const tmpConfig = ref<any>({ ...config.value });
60
+
61
+ /**
62
+ * 只有不为none,并且type为error|warning|success|info时候,才显示图标
63
+ */
64
+ const iconName = computed(() => {
65
+ if (['error', 'warning', 'success', 'info'].indexOf(tmpConfig.value.type) >= 0 && tmpConfig.value.icon) {
66
+ let icon = $u.type2icon(tmpConfig.value.type);
67
+ return icon;
68
+ }
69
+ return '';
70
+ });
71
+ /**
72
+ * 显示toast时候,如果用户有传递z-index值,优先使用
73
+ */
74
+ const uZIndex = computed(() => {
75
+ return isShow.value ? (props.zIndex ? props.zIndex : $u.zIndex.toast) : '999999';
76
+ });
77
+
78
+ /**
79
+ * 显示toast组件,由父组件通过ref.show(options)形式调用
80
+ */
81
+ function show(options: any) {
82
+ // 不将结果合并到config变量,避免多次调用u-toast,前后的配置造成混乱
83
+ tmpConfig.value = $u.deepMerge(config.value, options);
84
+ if (timer) {
85
+ // 清除定时器
86
+ clearTimeout(timer);
87
+ timer = null;
88
+ }
89
+ isShow.value = true;
90
+ timer = setTimeout(() => {
91
+ // 倒计时结束,清除定时器,隐藏toast组件
92
+ isShow.value = false;
93
+ clearTimeout(timer!);
94
+ timer = null;
95
+ // 判断是否存在callback方法,如果存在就执行
96
+ typeof tmpConfig.value.callback === 'function' && tmpConfig.value.callback();
97
+ timeEnd();
98
+ }, tmpConfig.value.duration);
99
+ }
100
+ /**
101
+ * 隐藏toast组件,由父组件通过ref.hide()形式调用
102
+ */
103
+ function hide() {
104
+ isShow.value = false;
105
+ if (timer) {
106
+ // 清除定时器
107
+ clearTimeout(timer);
108
+ timer = null;
109
+ }
110
+ }
111
+ /**
112
+ * 倒计时结束之后,进行的一些操作
113
+ */
114
+ function timeEnd() {
115
+ // 如果带有url值,根据isTab为true或者false进行跳转
116
+ if (tmpConfig.value.url) {
117
+ // 如果url没有"/"开头,添加上,因为uni的路由跳转需要"/"开头
118
+ if (tmpConfig.value.url[0] != '/') tmpConfig.value.url = '/' + tmpConfig.value.url;
119
+ // 判断是否有传递显式的参数
120
+ if (Object.keys(tmpConfig.value.params).length) {
121
+ // 判断用户传递的url中,是否带有参数
122
+ // 使用正则匹配,主要依据是判断是否有"/","?","="等,如“/page/index/index?name=mary"
123
+ // 如果有params参数,转换后无需带上"?"
124
+ let query = '';
125
+ if (/.*\/.*\?.*=.*/.test(tmpConfig.value.url)) {
126
+ // object对象转为get类型的参数
127
+ query = $u.queryParams(tmpConfig.value.params, false);
128
+ tmpConfig.value.url = tmpConfig.value.url + '&' + query;
129
+ } else {
130
+ query = $u.queryParams(tmpConfig.value.params);
131
+ tmpConfig.value.url += query;
132
+ }
133
+ }
134
+ // 如果是跳转tab页面,就使用uni.switchTab
135
+ if (tmpConfig.value.isTab) {
136
+ uni.switchTab({ url: tmpConfig.value.url });
137
+ } else {
138
+ uni.navigateTo({ url: tmpConfig.value.url });
139
+ }
140
+ } else if (tmpConfig.value.back) {
141
+ // 回退到上一页
142
+ $u.route({ type: 'back' });
143
+ }
144
+ }
145
+
146
+ defineExpose<ToastExpose>({
147
+ show,
148
+ hide
149
+ });
150
+ </script>
151
+
152
+ <style lang="scss" scoped>
153
+ @import '../../libs/css/style.components.scss';
154
+
155
+ .u-toast {
156
+ position: fixed;
157
+ z-index: -1;
158
+ transition: opacity 0.3s;
159
+ text-align: center;
160
+ color: #fff;
161
+ border-radius: 8rpx;
162
+ background: #585858;
163
+ @include vue-flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ font-size: 28rpx;
167
+ opacity: 0;
168
+ pointer-events: none;
169
+ padding: 18rpx 40rpx;
170
+ }
171
+
172
+ .u-toast.u-show {
173
+ opacity: 1;
174
+ }
175
+
176
+ .u-icon {
177
+ margin-right: 10rpx;
178
+ @include vue-flex;
179
+ align-items: center;
180
+ line-height: normal;
181
+ }
182
+
183
+ .u-position-center {
184
+ left: 50%;
185
+ top: 50%;
186
+ transform: translate(-50%, -50%);
187
+ /* #ifndef APP-NVUE */
188
+ max-width: 70%;
189
+ /* #endif */
190
+ }
191
+
192
+ .u-position-top {
193
+ left: 50%;
194
+ top: 20%;
195
+ transform: translate(-50%, -50%);
196
+ }
197
+
198
+ .u-position-bottom {
199
+ left: 50%;
200
+ bottom: 20%;
201
+ transform: translate(-50%, -50%);
202
+ }
203
+
204
+ .u-type-primary {
205
+ color: $u-type-primary;
206
+ background-color: $u-type-primary-light;
207
+ border: 1px solid rgb(215, 234, 254);
208
+ }
209
+
210
+ .u-type-success {
211
+ color: $u-type-success;
212
+ background-color: $u-type-success-light;
213
+ border: 1px solid #bef5c8;
214
+ }
215
+
216
+ .u-type-error {
217
+ color: $u-type-error;
218
+ background-color: $u-type-error-light;
219
+ border: 1px solid #fde2e2;
220
+ }
221
+
222
+ .u-type-warning {
223
+ color: $u-type-warning;
224
+ background-color: $u-type-warning-light;
225
+ border: 1px solid #faecd8;
226
+ }
227
+
228
+ .u-type-info {
229
+ color: $u-type-info;
230
+ background-color: $u-type-info-light;
231
+ border: 1px solid #ebeef5;
232
+ }
233
+
234
+ .u-type-default {
235
+ color: #fff;
236
+ background-color: #585858;
237
+ }
238
+ </style>
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <view class="u-tips" :class="['u-' + type, isShow ? 'u-tip-show' : '']" :style="tipStyle">{{ title }}</view>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { ref, computed } from 'vue';
7
+ import { $u } from '../..';
8
+
9
+ defineOptions({ name: 'u-top-tips' });
10
+
11
+ /**
12
+ * topTips 顶部提示
13
+ * @description 该组件一般用于页面顶部向下滑出一个提示,尔后自动收起的场景。
14
+ * @tutorial https://www.uviewui.com/components/topTips.html
15
+ * @property {String|Number} navbarHeight 导航栏高度(包含状态栏高度在内),单位PX
16
+ * @property {String|Number} zIndex z-index值(默认975)
17
+ * @example <u-top-tips ref="uTips"></u-top-tips>
18
+ */
19
+
20
+ const props = defineProps({
21
+ /** 导航栏高度,用于提示的初始化 */
22
+ navbarHeight: {
23
+ type: [Number, String],
24
+ default() {
25
+ let result = 0;
26
+ // #ifndef H5
27
+ result = 0;
28
+ // #endif
29
+ // #ifdef H5
30
+ result = 44;
31
+ // #endif
32
+ return result;
33
+ }
34
+ },
35
+ /** z-index值 */
36
+ zIndex: {
37
+ type: [Number, String],
38
+ default: ''
39
+ }
40
+ });
41
+
42
+ let timer: number | null = null; // 定时器
43
+ const isShow = ref(false); // 是否显示消息组件
44
+ const title = ref(''); // 组件中显示的消息内容
45
+ const type = ref<'primary' | 'success' | 'error' | 'warning' | 'info'>('primary'); // 消息的类型(颜色不同),primary,success,error,warning,info
46
+ const duration = ref(2000); // 组件显示的时间,单位为毫秒
47
+
48
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.topTips));
49
+
50
+ const tipStyle = computed(() => ({
51
+ top: Number(props.navbarHeight) + 'px',
52
+ zIndex: uZIndex.value
53
+ }));
54
+
55
+ /**
56
+ * 显示顶部提示
57
+ * @param config 配置项 { title, type, duration }
58
+ */
59
+ function show(config: { title: string; type?: string; duration?: number } = { title: '' }) {
60
+ // 先清除定时器(可能是上一次定义的,需要清除了再开始新的)
61
+ if (timer) clearTimeout(timer);
62
+ // 时间,内容,类型主题(type)等参数
63
+ if (config.duration) duration.value = config.duration;
64
+ if (config.type) type.value = config.type as any;
65
+ title.value = config.title;
66
+ isShow.value = true;
67
+ // 倒计时
68
+ timer = setTimeout(() => {
69
+ isShow.value = false;
70
+ if (timer) clearTimeout(timer);
71
+ timer = null;
72
+ }, duration.value);
73
+ }
74
+ defineExpose({ show });
75
+ </script>
76
+
77
+ <style lang="scss" scoped>
78
+ @import '../../libs/css/style.components.scss';
79
+ view {
80
+ box-sizing: border-box;
81
+ }
82
+ .u-tips {
83
+ width: 100%;
84
+ position: fixed;
85
+ z-index: 1;
86
+ padding: 20rpx 30rpx;
87
+ color: #ffffff;
88
+ font-size: 28rpx;
89
+ left: 0;
90
+ right: 0;
91
+ @include vue-flex;
92
+ align-items: center;
93
+ justify-content: center;
94
+ opacity: 0;
95
+ transform: translateY(-100%);
96
+ transition: all 0.35s linear;
97
+ }
98
+ .u-tip-show {
99
+ transform: translateY(0);
100
+ opacity: 1;
101
+ z-index: 99;
102
+ }
103
+ .u-primary {
104
+ background: $u-type-primary;
105
+ }
106
+ .u-success {
107
+ background: $u-type-success;
108
+ }
109
+ .u-warning {
110
+ background: $u-type-warning;
111
+ }
112
+ .u-error {
113
+ background: $u-type-error;
114
+ }
115
+ .u-info {
116
+ background: $u-type-info;
117
+ }
118
+ </style>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <view class="u-tr">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ defineOptions({ name: 'u-tr' });
9
+
10
+ /**
11
+ * tr 表格行标签
12
+ * @description 表格组件一般用于展示大量结构化数据的场景(搭配<u-table>使用)
13
+ * @tutorial https://www.uviewui.com/components/table.html
14
+ * @example <u-tr></u-tr>
15
+ */
16
+ </script>
17
+
18
+ <style lang="scss" scoped>
19
+ @import '../../libs/css/style.components.scss';
20
+
21
+ .u-tr {
22
+ @include vue-flex;
23
+ }
24
+ </style>