uview-pro 0.2.2 → 0.2.4
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 +44 -0
- package/components/u-action-sheet/u-action-sheet.vue +10 -3
- package/components/u-alert-tips/u-alert-tips.vue +13 -2
- package/components/u-avatar/u-avatar.vue +16 -2
- package/components/u-avatar-cropper/weCropper.js +36 -8
- package/components/u-avatar-cropper/weCropper.ts +28 -7
- package/components/u-back-top/u-back-top.vue +4 -1
- package/components/u-button/u-button.vue +11 -1
- package/components/u-calendar/types.ts +3 -1
- package/components/u-calendar/u-calendar.vue +172 -17
- package/components/u-car-keyboard/u-car-keyboard.vue +22 -3
- package/components/u-cell-item/u-cell-item.vue +13 -2
- package/components/u-checkbox/u-checkbox.vue +78 -62
- package/components/u-checkbox-group/types.ts +1 -1
- package/components/u-checkbox-group/u-checkbox-group.vue +77 -26
- package/components/u-circle-progress/u-circle-progress.vue +6 -2
- package/components/u-city-select/u-city-select.vue +32 -4
- package/components/u-collapse/u-collapse.vue +131 -14
- package/components/u-collapse-item/u-collapse-item.vue +132 -60
- package/components/u-column-notice/u-column-notice.vue +40 -6
- package/components/u-count-down/u-count-down.vue +20 -4
- package/components/u-count-to/u-count-to.vue +9 -2
- package/components/u-divider/u-divider.vue +10 -2
- package/components/u-dropdown/u-dropdown.vue +16 -3
- package/components/u-dropdown-item/u-dropdown-item.vue +6 -1
- package/components/u-field/u-field.vue +23 -4
- package/components/u-form/u-form.vue +5 -1
- package/components/u-form-item/u-form-item.vue +37 -7
- package/components/u-full-screen/u-full-screen.vue +8 -1
- package/components/u-grid-item/u-grid-item.vue +5 -1
- package/components/u-icon/u-icon.vue +15 -2
- package/components/u-image/u-image.vue +10 -2
- package/components/u-input/u-input.vue +19 -4
- package/components/u-keyboard/u-keyboard.vue +13 -2
- package/components/u-lazy-load/u-lazy-load.vue +10 -8
- package/components/u-line-progress/u-line-progress.vue +9 -1
- package/components/u-loading/u-loading.vue +7 -1
- package/components/u-loadmore/u-loadmore.vue +6 -1
- package/components/u-message-input/u-message-input.vue +19 -4
- package/components/u-modal/u-modal.vue +8 -1
- package/components/u-navbar/u-navbar.vue +18 -4
- package/components/u-no-network/u-no-network.vue +3 -1
- package/components/u-notice-bar/u-notice-bar.vue +6 -1
- package/components/u-number-keyboard/u-number-keyboard.vue +19 -6
- package/components/u-picker/u-picker.vue +49 -10
- package/components/u-popup/u-popup.vue +19 -3
- package/components/u-radio/u-radio.vue +19 -5
- package/components/u-radio-group/u-radio-group.vue +11 -1
- package/components/u-read-more/u-read-more.vue +7 -1
- package/components/u-row-notice/u-row-notice.vue +37 -6
- package/components/u-search/u-search.vue +14 -2
- package/components/u-section/u-section.vue +7 -1
- package/components/u-select/u-select.vue +22 -5
- package/components/u-skeleton/u-skeleton.vue +18 -3
- package/components/u-slider/u-slider.vue +11 -2
- package/components/u-steps/u-steps.vue +11 -2
- package/components/u-sticky/u-sticky.vue +4 -1
- package/components/u-swipe-action/u-swipe-action.vue +8 -1
- package/components/u-swiper/u-swiper.vue +31 -6
- package/components/u-switch/u-switch.vue +6 -1
- package/components/u-tabbar/u-tabbar.vue +22 -4
- package/components/u-tabs/u-tabs.vue +8 -1
- package/components/u-tabs-swiper/u-tabs-swiper.vue +21 -3
- package/components/u-tag/u-tag.vue +9 -1
- package/components/u-text/types.ts +4 -1
- package/components/u-text/u-text.vue +18 -3
- package/components/u-upload/types.ts +8 -2
- package/components/u-upload/u-upload.vue +17 -3
- package/iconfont.css +2 -1
- package/index.ts +11 -2
- package/libs/css/style.vue.scss +1 -1
- package/libs/function/$parent.ts +4 -1
- package/libs/function/colorGradient.ts +18 -4
- package/libs/function/deepMerge.ts +2 -1
- package/libs/function/getParent.ts +5 -1
- package/libs/function/md5.ts +17 -5
- package/libs/function/queryParams.ts +5 -1
- package/libs/function/test.ts +7 -3
- package/libs/function/timeFormat.ts +2 -1
- package/libs/function/type2icon.ts +4 -1
- package/libs/hooks/index.ts +1 -1
- package/libs/hooks/useComponent.ts +759 -0
- package/libs/hooks/useEmitter.ts +4 -2
- package/libs/hooks/useParent.ts +22 -20
- package/libs/index.ts +34 -5
- package/libs/request/index.ts +24 -5
- package/libs/util/async-validator.d.ts +16 -3
- package/libs/util/emitter.ts +12 -2
- package/libs/util/eventBus.ts +86 -0
- package/libs/util/logger.ts +364 -0
- package/libs/util/mitt.ts +4 -1
- package/package.json +1 -1
- package/readme.md +3 -1
- package/types/global.d.ts +39 -3
|
@@ -9,16 +9,18 @@ export default {
|
|
|
9
9
|
name: 'u-collapse',
|
|
10
10
|
options: {
|
|
11
11
|
addGlobalClass: true,
|
|
12
|
+
// #ifndef MP-TOUTIAO
|
|
12
13
|
virtualHost: true,
|
|
14
|
+
// #endif
|
|
13
15
|
styleIsolation: 'shared'
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
18
|
</script>
|
|
17
19
|
|
|
18
20
|
<script setup lang="ts">
|
|
19
|
-
import { ref } from 'vue';
|
|
21
|
+
import { nextTick, onMounted, ref } from 'vue';
|
|
20
22
|
import { CollapseProps } from './types';
|
|
21
|
-
import { $u } from '../../';
|
|
23
|
+
import { $u, useParent } from '../../';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* collapse 手风琴
|
|
@@ -34,33 +36,148 @@ import { $u } from '../../';
|
|
|
34
36
|
* @example <u-collapse></u-collapse>
|
|
35
37
|
*/
|
|
36
38
|
const props = defineProps(CollapseProps);
|
|
37
|
-
|
|
38
39
|
const emit = defineEmits(['change']);
|
|
39
40
|
|
|
40
|
-
//
|
|
41
|
-
const children =
|
|
41
|
+
// 使用通信库的父组件Hook
|
|
42
|
+
const { children, broadcast, getChildrenExposed } = useParent('u-collapse');
|
|
43
|
+
|
|
44
|
+
// 当前激活的面板 - 只在手风琴模式下使用
|
|
45
|
+
const activeName = ref<string | number>('');
|
|
46
|
+
|
|
47
|
+
onMounted(() => {
|
|
48
|
+
nextTick(() => {
|
|
49
|
+
// 初始化:收集所有open为true的项
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
initializeActiveName();
|
|
52
|
+
}, 100);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
42
55
|
|
|
43
56
|
/**
|
|
44
|
-
*
|
|
57
|
+
* 初始化activeName - 找到第一个open为true的项
|
|
45
58
|
*/
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
function initializeActiveName() {
|
|
60
|
+
if (props.accordion) {
|
|
61
|
+
// 手风琴模式下,取第一个open为true的项作为初始激活项
|
|
62
|
+
const childrenExposed = getChildrenExposed();
|
|
63
|
+
const openChild = childrenExposed.find(child => child.exposed.isShow === true);
|
|
64
|
+
if (openChild) {
|
|
65
|
+
activeName.value = openChild.exposed.itemName || '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
/**
|
|
53
71
|
* collapse item被点击,由collapse item调用父组件方法
|
|
54
72
|
*/
|
|
55
|
-
function onChange(
|
|
56
|
-
|
|
73
|
+
function onChange(name: string | number) {
|
|
74
|
+
if (props.accordion) {
|
|
75
|
+
// 手风琴模式
|
|
76
|
+
const childrenExposed = getChildrenExposed();
|
|
77
|
+
const targetChild = childrenExposed.find(child => child.exposed.itemName === name);
|
|
78
|
+
if (targetChild?.exposed.isShow.value === true) {
|
|
79
|
+
// 目标项当前是展开状态,点击后要关闭它
|
|
80
|
+
activeName.value = '';
|
|
81
|
+
broadcast('closeAll', {});
|
|
82
|
+
} else {
|
|
83
|
+
// 目标项当前是关闭状态,点击后要展开它并关闭其他
|
|
84
|
+
activeName.value = name;
|
|
85
|
+
broadcast('openSingle', { targetName: name });
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
// 非手风琴模式 - 只通知目标项切换状态
|
|
89
|
+
broadcast('toggleSingle', { targetName: name });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 收集当前所有展开的项
|
|
93
|
+
let currentActiveNames: (string | number)[] = [];
|
|
94
|
+
if (props.accordion) {
|
|
95
|
+
currentActiveNames = activeName.value ? [activeName.value] : [];
|
|
96
|
+
} else {
|
|
97
|
+
// 对于非手风琴模式,我们不知道所有项的状态,所以这里不处理
|
|
98
|
+
currentActiveNames = [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
emit('change', props.accordion ? activeName.value || '' : currentActiveNames);
|
|
57
102
|
}
|
|
58
103
|
|
|
104
|
+
/**
|
|
105
|
+
* 设置激活的面板
|
|
106
|
+
*/
|
|
107
|
+
function setActiveNames(names: string | number | (string | number)[]) {
|
|
108
|
+
if (props.accordion) {
|
|
109
|
+
// 手风琴模式
|
|
110
|
+
const name = Array.isArray(names) ? names[0] : names;
|
|
111
|
+
activeName.value = name || '';
|
|
112
|
+
if (name) {
|
|
113
|
+
broadcast('openSingle', { targetName: name });
|
|
114
|
+
} else {
|
|
115
|
+
broadcast('closeAll', {});
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
// 非手风琴模式
|
|
119
|
+
const namesArray = Array.isArray(names) ? names : [names];
|
|
120
|
+
broadcast('setMultiple', { targetNames: namesArray });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 打开所有面板
|
|
126
|
+
*/
|
|
127
|
+
function openAll() {
|
|
128
|
+
if (props.accordion) {
|
|
129
|
+
console.warn('手风琴模式下不能打开所有面板');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const childrenExposed = getChildrenExposed();
|
|
133
|
+
const allNames = childrenExposed.map(child => child.exposed.itemName).filter(Boolean);
|
|
134
|
+
broadcast('setMultiple', { targetNames: allNames });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 关闭所有面板
|
|
139
|
+
*/
|
|
140
|
+
function closeAll() {
|
|
141
|
+
broadcast('closeAll', {});
|
|
142
|
+
if (props.accordion) {
|
|
143
|
+
activeName.value = '';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 重新初始化,用于动态内容变化
|
|
149
|
+
*/
|
|
150
|
+
function init() {
|
|
151
|
+
const childrenExposed = getChildrenExposed();
|
|
152
|
+
childrenExposed.forEach(child => {
|
|
153
|
+
if (child.exposed.init) {
|
|
154
|
+
child.exposed.init();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// 重新初始化activeName
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
initializeActiveName();
|
|
161
|
+
}, 150);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 使用defineExpose暴露给外部
|
|
59
165
|
defineExpose({
|
|
166
|
+
// props
|
|
60
167
|
props,
|
|
61
|
-
|
|
168
|
+
|
|
169
|
+
// 状态
|
|
170
|
+
activeName,
|
|
171
|
+
|
|
172
|
+
// 方法
|
|
173
|
+
onChange,
|
|
174
|
+
setActiveNames,
|
|
175
|
+
openAll,
|
|
176
|
+
closeAll,
|
|
62
177
|
init,
|
|
63
|
-
|
|
178
|
+
|
|
179
|
+
// 计算属性
|
|
180
|
+
childrenCount: () => children.length
|
|
64
181
|
});
|
|
65
182
|
</script>
|
|
66
183
|
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="u-collapse-item" :style="`${$u.toStyle(itemStyle)}${$u.toStyle(customStyle)}`" :class="customClass">
|
|
3
|
-
<view
|
|
3
|
+
<view
|
|
4
|
+
:hover-stay-time="200"
|
|
5
|
+
class="u-collapse-head"
|
|
6
|
+
@tap.stop="headClick"
|
|
7
|
+
:hover-class="hoverClass"
|
|
8
|
+
:style="headStyle"
|
|
9
|
+
>
|
|
4
10
|
<template v-if="!slots['title-all']">
|
|
5
11
|
<view v-if="!slots['title']" class="u-collapse-title u-line-1" :style="titleStyle">
|
|
6
12
|
{{ title }}
|
|
7
13
|
</view>
|
|
8
14
|
<slot v-else name="title" />
|
|
9
15
|
<view class="u-icon-wrap">
|
|
10
|
-
<u-icon v-if="
|
|
16
|
+
<u-icon v-if="showArrow" :color="arrowColor" :name="isShow ? 'arrow-up' : 'arrow-down'" />
|
|
11
17
|
</view>
|
|
12
18
|
</template>
|
|
13
19
|
<slot v-else name="title-all" />
|
|
@@ -26,7 +32,9 @@ export default {
|
|
|
26
32
|
name: 'u-collapse-item',
|
|
27
33
|
options: {
|
|
28
34
|
addGlobalClass: true,
|
|
35
|
+
// #ifndef MP-TOUTIAO
|
|
29
36
|
virtualHost: true,
|
|
37
|
+
// #endif
|
|
30
38
|
styleIsolation: 'shared'
|
|
31
39
|
}
|
|
32
40
|
};
|
|
@@ -34,9 +42,8 @@ export default {
|
|
|
34
42
|
|
|
35
43
|
<script setup lang="ts">
|
|
36
44
|
import { ref, watch, onMounted, useSlots, getCurrentInstance, nextTick, computed } from 'vue';
|
|
37
|
-
import { $u } from '../..';
|
|
45
|
+
import { $u, useChildren, useParentEvents } from '../..';
|
|
38
46
|
import { CollapseItemProps } from './types';
|
|
39
|
-
import { useParent } from '../../libs/hooks/useParent';
|
|
40
47
|
|
|
41
48
|
/**
|
|
42
49
|
* collapseItem 手风琴Item
|
|
@@ -59,50 +66,77 @@ const instance = getCurrentInstance();
|
|
|
59
66
|
|
|
60
67
|
const isShow = ref(false);
|
|
61
68
|
const elId = ref('');
|
|
62
|
-
const height = ref('0');
|
|
63
|
-
const headStyle = ref<Record<string, any>>({});
|
|
64
|
-
const bodyStyle = ref<Record<string, any>>({});
|
|
65
|
-
const itemStyle = ref<Record<string, any>>({});
|
|
66
|
-
const arrowColor = ref('');
|
|
67
|
-
const hoverClass = ref('');
|
|
68
|
-
const accordion = ref(true); // 是否显示右侧箭头
|
|
69
|
-
const arrow = ref(true);
|
|
69
|
+
const height = ref('0');
|
|
70
|
+
const headStyle = ref<Record<string, any>>({});
|
|
71
|
+
const bodyStyle = ref<Record<string, any>>({});
|
|
72
|
+
const itemStyle = ref<Record<string, any>>({});
|
|
73
|
+
const arrowColor = ref('');
|
|
74
|
+
const hoverClass = ref('');
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
// 使用通信库的子组件Hook
|
|
77
|
+
const { childId, parentExposed } = useChildren('u-collapse-item', 'u-collapse');
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
{ immediate: true }
|
|
79
|
-
);
|
|
79
|
+
// 计算属性
|
|
80
|
+
const showArrow = computed(() => {
|
|
81
|
+
return parentExposed.value?.props ? parentExposed.value.props.arrow : true;
|
|
82
|
+
});
|
|
80
83
|
|
|
81
|
-
/**
|
|
82
|
-
* 获取父组件的配置项
|
|
83
|
-
*/
|
|
84
84
|
const titleStyle = computed(() => {
|
|
85
85
|
let style = { textAlign: props.align ? props.align : 'left' };
|
|
86
86
|
|
|
87
|
-
if (isShow.value && props.activeStyle && !
|
|
87
|
+
if (isShow.value && props.activeStyle && !showArrow.value) {
|
|
88
88
|
style = $u.deepMerge(style, props.activeStyle);
|
|
89
89
|
}
|
|
90
90
|
return $u.toStyle(style);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
// 获取唯一标识符
|
|
94
|
+
const itemName = computed(() => {
|
|
95
|
+
// 优先级:name > index > childId
|
|
96
|
+
if (props.name !== undefined && props.name !== '') {
|
|
97
|
+
return props.name;
|
|
98
|
+
} else if (props.index !== undefined && props.index !== '') {
|
|
99
|
+
return props.index;
|
|
100
|
+
} else {
|
|
101
|
+
return childId;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 设置显示状态
|
|
107
|
+
*/
|
|
108
|
+
function setShowState(show: boolean) {
|
|
109
|
+
if (isShow.value !== show) {
|
|
110
|
+
isShow.value = show;
|
|
111
|
+
|
|
112
|
+
// 如果展开,需要重新计算高度
|
|
113
|
+
if (show) {
|
|
114
|
+
nextTick(() => {
|
|
115
|
+
queryRect();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 本地触发change事件
|
|
120
|
+
emit('change', {
|
|
121
|
+
index: props.index,
|
|
122
|
+
name: itemName.value,
|
|
123
|
+
show: isShow.value
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
93
128
|
/**
|
|
94
129
|
* 异步获取内容,或者动态修改了内容时,需要重新初始化
|
|
95
130
|
*/
|
|
96
131
|
function init() {
|
|
97
|
-
if (
|
|
98
|
-
headStyle.value = parentExposed.props.headStyle;
|
|
99
|
-
bodyStyle.value = parentExposed.props.bodyStyle;
|
|
100
|
-
arrowColor.value = parentExposed.props.arrowColor;
|
|
101
|
-
hoverClass.value = parentExposed.props.hoverClass;
|
|
102
|
-
|
|
103
|
-
itemStyle.value = parentExposed.props.itemStyle;
|
|
104
|
-
accordion.value = parentExposed.props.accordion;
|
|
132
|
+
if (parentExposed.value?.props) {
|
|
133
|
+
headStyle.value = parentExposed.value.props.headStyle || {};
|
|
134
|
+
bodyStyle.value = parentExposed.value.props.bodyStyle || {};
|
|
135
|
+
arrowColor.value = parentExposed.value.props.arrowColor || '#909399';
|
|
136
|
+
hoverClass.value = parentExposed.value.props.hoverClass || 'u-hover-class';
|
|
137
|
+
itemStyle.value = parentExposed.value.props.itemStyle || {};
|
|
105
138
|
}
|
|
139
|
+
|
|
106
140
|
elId.value = $u.guid();
|
|
107
141
|
nextTick(() => {
|
|
108
142
|
queryRect();
|
|
@@ -114,46 +148,82 @@ function init() {
|
|
|
114
148
|
*/
|
|
115
149
|
function headClick() {
|
|
116
150
|
if (props.disabled) return;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} else {
|
|
122
|
-
vm.exposed.isShow.value = !vm.exposed.isShow.value;
|
|
123
|
-
emit('change', {
|
|
124
|
-
index: props.index,
|
|
125
|
-
show: vm.exposed.isShow.value
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
} else {
|
|
130
|
-
isShow.value = !isShow.value;
|
|
131
|
-
emit('change', {
|
|
132
|
-
index: props.index,
|
|
133
|
-
show: isShow.value
|
|
134
|
-
});
|
|
151
|
+
|
|
152
|
+
// 通知父组件状态变化
|
|
153
|
+
if (parentExposed.value?.onChange) {
|
|
154
|
+
parentExposed.value.onChange(itemName.value);
|
|
135
155
|
}
|
|
136
|
-
if (isShow.value) parentExposed && parentExposed.onChange && parentExposed.onChange(props.index);
|
|
137
156
|
}
|
|
138
157
|
|
|
139
158
|
/**
|
|
140
159
|
* 查询内容高度
|
|
141
160
|
*/
|
|
142
161
|
function queryRect() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
162
|
+
$u.getRect('#' + elId.value, instance)
|
|
163
|
+
.then((res: any) => {
|
|
164
|
+
if (res && res.height) {
|
|
165
|
+
height.value = res.height + 'px';
|
|
166
|
+
}
|
|
167
|
+
// #ifdef MP-TOUTIAO
|
|
168
|
+
if (isShow.value) {
|
|
169
|
+
height.value = 'auto';
|
|
170
|
+
}
|
|
171
|
+
// #endif
|
|
172
|
+
})
|
|
173
|
+
.catch((err: any) => {
|
|
174
|
+
console.warn('queryRect error:', err);
|
|
175
|
+
height.value = 'auto';
|
|
176
|
+
});
|
|
151
177
|
}
|
|
152
178
|
|
|
179
|
+
// 使用自动取消监听注册父组件事件
|
|
180
|
+
useParentEvents(childId, {
|
|
181
|
+
openSingle: (data: any) => {
|
|
182
|
+
// 只有目标项展开,其他都关闭
|
|
183
|
+
const shouldShow = data.targetName === itemName.value;
|
|
184
|
+
setShowState(shouldShow);
|
|
185
|
+
},
|
|
186
|
+
closeAll: () => {
|
|
187
|
+
setShowState(false);
|
|
188
|
+
},
|
|
189
|
+
setMultiple: (data: any) => {
|
|
190
|
+
const shouldShow = data.targetNames.includes(itemName.value);
|
|
191
|
+
setShowState(shouldShow);
|
|
192
|
+
},
|
|
193
|
+
toggleSingle: (data: any) => {
|
|
194
|
+
// 只有目标项才切换状态
|
|
195
|
+
if (data.targetName === itemName.value) {
|
|
196
|
+
setShowState(!isShow.value);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
153
201
|
onMounted(() => {
|
|
202
|
+
// 关键修复:根据 open 属性设置初始状态
|
|
203
|
+
setShowState(props.open);
|
|
204
|
+
// 初始化
|
|
154
205
|
init();
|
|
155
206
|
});
|
|
156
207
|
|
|
208
|
+
// 监听 open 属性变化
|
|
209
|
+
watch(
|
|
210
|
+
() => props.open,
|
|
211
|
+
newVal => {
|
|
212
|
+
setShowState(newVal);
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// 监听父组件exposed的变化
|
|
217
|
+
watch(
|
|
218
|
+
parentExposed,
|
|
219
|
+
newExposed => {
|
|
220
|
+
if (newExposed) {
|
|
221
|
+
init();
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{ deep: true, immediate: true }
|
|
225
|
+
);
|
|
226
|
+
|
|
157
227
|
defineExpose({
|
|
158
228
|
init,
|
|
159
229
|
isShow,
|
|
@@ -164,7 +234,9 @@ defineExpose({
|
|
|
164
234
|
itemStyle,
|
|
165
235
|
arrowColor,
|
|
166
236
|
hoverClass,
|
|
167
|
-
|
|
237
|
+
itemName: itemName.value,
|
|
238
|
+
queryRect,
|
|
239
|
+
setShowState
|
|
168
240
|
});
|
|
169
241
|
</script>
|
|
170
242
|
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
class="u-notice-bar"
|
|
4
|
+
:style="{ background: computeBgColor, padding: props.padding }"
|
|
5
|
+
:class="[props.type ? `u-type-${props.type}-light-bg` : '']"
|
|
6
|
+
>
|
|
3
7
|
<view class="u-icon-wrap">
|
|
4
|
-
<u-icon
|
|
8
|
+
<u-icon
|
|
9
|
+
class="u-left-icon"
|
|
10
|
+
v-if="props.volumeIcon"
|
|
11
|
+
name="volume-fill"
|
|
12
|
+
:size="props.volumeSize"
|
|
13
|
+
:color="computeColor"
|
|
14
|
+
></u-icon>
|
|
5
15
|
</view>
|
|
6
16
|
<swiper
|
|
7
17
|
:disable-touch="props.disableTouch"
|
|
@@ -13,14 +23,33 @@
|
|
|
13
23
|
class="u-swiper"
|
|
14
24
|
>
|
|
15
25
|
<swiper-item v-for="(item, index) in props.list" :key="index" class="u-swiper-item">
|
|
16
|
-
<view
|
|
26
|
+
<view
|
|
27
|
+
class="u-news-item u-line-1"
|
|
28
|
+
:style="textStyle"
|
|
29
|
+
@tap="click(index)"
|
|
30
|
+
:class="['u-type-' + props.type]"
|
|
31
|
+
>
|
|
17
32
|
{{ item }}
|
|
18
33
|
</view>
|
|
19
34
|
</swiper-item>
|
|
20
35
|
</swiper>
|
|
21
36
|
<view class="u-icon-wrap">
|
|
22
|
-
<u-icon
|
|
23
|
-
|
|
37
|
+
<u-icon
|
|
38
|
+
@click="getMore"
|
|
39
|
+
class="u-right-icon"
|
|
40
|
+
v-if="props.moreIcon"
|
|
41
|
+
name="arrow-right"
|
|
42
|
+
:size="26"
|
|
43
|
+
:color="computeColor"
|
|
44
|
+
></u-icon>
|
|
45
|
+
<u-icon
|
|
46
|
+
@click="close"
|
|
47
|
+
class="u-right-icon"
|
|
48
|
+
v-if="props.closeIcon"
|
|
49
|
+
name="close"
|
|
50
|
+
:size="24"
|
|
51
|
+
:color="computeColor"
|
|
52
|
+
></u-icon>
|
|
24
53
|
</view>
|
|
25
54
|
</view>
|
|
26
55
|
</template>
|
|
@@ -56,7 +85,12 @@ defineOptions({ name: 'u-column-notice' });
|
|
|
56
85
|
|
|
57
86
|
const props = defineProps(ColumnNoticeProps);
|
|
58
87
|
|
|
59
|
-
const emit = defineEmits<{
|
|
88
|
+
const emit = defineEmits<{
|
|
89
|
+
(e: 'click', index: number): void;
|
|
90
|
+
(e: 'close'): void;
|
|
91
|
+
(e: 'getMore'): void;
|
|
92
|
+
(e: 'end'): void;
|
|
93
|
+
}>();
|
|
60
94
|
|
|
61
95
|
/**
|
|
62
96
|
* 计算字体颜色,如果没有自定义的,就用uview主题颜色
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="u-countdown">
|
|
3
|
-
<view
|
|
3
|
+
<view
|
|
4
|
+
class="u-countdown-item"
|
|
5
|
+
:style="[itemStyle]"
|
|
6
|
+
v-if="props.showDays && (props.hideZeroDay || (!props.hideZeroDay && d != '00'))"
|
|
7
|
+
>
|
|
4
8
|
<view class="u-countdown-time" :style="[letterStyle]">
|
|
5
9
|
{{ d }}
|
|
6
10
|
</view>
|
|
7
11
|
</view>
|
|
8
12
|
<view
|
|
9
13
|
class="u-countdown-colon"
|
|
10
|
-
:style="{
|
|
14
|
+
:style="{
|
|
15
|
+
fontSize: props.separatorSize + 'rpx',
|
|
16
|
+
color: props.separatorColor,
|
|
17
|
+
paddingBottom: props.separator == 'colon' ? '4rpx' : 0
|
|
18
|
+
}"
|
|
11
19
|
v-if="props.showDays && (props.hideZeroDay || (!props.hideZeroDay && d != '00'))"
|
|
12
20
|
>
|
|
13
21
|
{{ props.separator == 'colon' && props.showHours ? ':' : '天' }}
|
|
@@ -19,7 +27,11 @@
|
|
|
19
27
|
</view>
|
|
20
28
|
<view
|
|
21
29
|
class="u-countdown-colon"
|
|
22
|
-
:style="{
|
|
30
|
+
:style="{
|
|
31
|
+
fontSize: props.separatorSize + 'rpx',
|
|
32
|
+
color: props.separatorColor,
|
|
33
|
+
paddingBottom: props.separator == 'colon' ? '4rpx' : 0
|
|
34
|
+
}"
|
|
23
35
|
v-if="props.showHours"
|
|
24
36
|
>
|
|
25
37
|
{{ props.separator == 'colon' && props.showMinutes ? ':' : '时' }}
|
|
@@ -31,7 +43,11 @@
|
|
|
31
43
|
</view>
|
|
32
44
|
<view
|
|
33
45
|
class="u-countdown-colon"
|
|
34
|
-
:style="{
|
|
46
|
+
:style="{
|
|
47
|
+
fontSize: props.separatorSize + 'rpx',
|
|
48
|
+
color: props.separatorColor,
|
|
49
|
+
paddingBottom: props.separator == 'colon' ? '4rpx' : 0
|
|
50
|
+
}"
|
|
35
51
|
v-if="props.showMinutes"
|
|
36
52
|
>
|
|
37
53
|
{{ props.separator == 'colon' && props.showSeconds ? ':' : '分' }}
|
|
@@ -162,9 +162,16 @@ function count(ts: number) {
|
|
|
162
162
|
let val: number;
|
|
163
163
|
if (props.useEasing) {
|
|
164
164
|
if (countDown.value) {
|
|
165
|
-
val =
|
|
165
|
+
val =
|
|
166
|
+
localStartVal.value -
|
|
167
|
+
easingFn(progress, 0, localStartVal.value - Number(props.endVal), localDuration.value);
|
|
166
168
|
} else {
|
|
167
|
-
val = easingFn(
|
|
169
|
+
val = easingFn(
|
|
170
|
+
progress,
|
|
171
|
+
localStartVal.value,
|
|
172
|
+
Number(props.endVal) - localStartVal.value,
|
|
173
|
+
localDuration.value
|
|
174
|
+
);
|
|
168
175
|
}
|
|
169
176
|
} else {
|
|
170
177
|
if (countDown.value) {
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
}"
|
|
10
10
|
@tap="onClick"
|
|
11
11
|
>
|
|
12
|
-
<view
|
|
12
|
+
<view
|
|
13
|
+
class="u-divider-line"
|
|
14
|
+
:class="[type ? 'u-divider-line--bordercolor--' + type : '']"
|
|
15
|
+
:style="lineStyle"
|
|
16
|
+
></view>
|
|
13
17
|
<view
|
|
14
18
|
v-if="useSlot"
|
|
15
19
|
class="u-divider-text"
|
|
@@ -19,7 +23,11 @@
|
|
|
19
23
|
}"
|
|
20
24
|
><slot
|
|
21
25
|
/></view>
|
|
22
|
-
<view
|
|
26
|
+
<view
|
|
27
|
+
class="u-divider-line"
|
|
28
|
+
:class="[type ? 'u-divider-line--bordercolor--' + type : '']"
|
|
29
|
+
:style="lineStyle"
|
|
30
|
+
></view>
|
|
23
31
|
</view>
|
|
24
32
|
</template>
|
|
25
33
|
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="u-dropdown">
|
|
3
|
-
<view
|
|
4
|
-
|
|
3
|
+
<view
|
|
4
|
+
class="u-dropdown__menu"
|
|
5
|
+
:style="{ height: $u.addUnit(height) }"
|
|
6
|
+
:class="{ 'u-border-bottom': borderBottom }"
|
|
7
|
+
>
|
|
8
|
+
<view
|
|
9
|
+
class="u-dropdown__menu__item"
|
|
10
|
+
v-for="(item, index) in menuList"
|
|
11
|
+
:key="index"
|
|
12
|
+
@tap.stop="menuClick(index)"
|
|
13
|
+
>
|
|
5
14
|
<view class="u-flex">
|
|
6
15
|
<text
|
|
7
16
|
class="u-dropdown__menu__item__text"
|
|
8
17
|
:style="{
|
|
9
|
-
color: item.disabled
|
|
18
|
+
color: item.disabled
|
|
19
|
+
? '#c0c4cc'
|
|
20
|
+
: index === current || highlightIndex == index
|
|
21
|
+
? activeColor
|
|
22
|
+
: inactiveColor,
|
|
10
23
|
fontSize: $u.addUnit(titleSize)
|
|
11
24
|
}"
|
|
12
25
|
>{{ item.title }}</text
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
:key="index"
|
|
13
13
|
:title-style="{ color: modelValue == item.value ? activeColor : inactiveColor }"
|
|
14
14
|
>
|
|
15
|
-
<u-icon
|
|
15
|
+
<u-icon
|
|
16
|
+
v-if="modelValue == item.value"
|
|
17
|
+
name="checkbox-mark"
|
|
18
|
+
:color="activeColor"
|
|
19
|
+
size="32"
|
|
20
|
+
></u-icon>
|
|
16
21
|
</u-cell-item>
|
|
17
22
|
</u-cell-group>
|
|
18
23
|
</view>
|