hy-app 0.1.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/README.md +42 -0
- package/api/http.ts +138 -0
- package/api/index.ts +1 -0
- package/common/index.ts +1 -0
- package/common/versionControl.ts +102 -0
- package/components/dialog/TheDialog.vue +128 -0
- package/components/dialog/index.ts +38 -0
- package/components/hy-address-picker/hy-address-picker.vue +262 -0
- package/components/hy-address-picker/props.ts +27 -0
- package/components/hy-address-picker/typing.d.ts +98 -0
- package/components/hy-avatar/hy-avatar.vue +217 -0
- package/components/hy-avatar/props.ts +20 -0
- package/components/hy-avatar/typing.d.ts +64 -0
- package/components/hy-back-top/hy-back-top.vue +71 -0
- package/components/hy-back-top/props.ts +23 -0
- package/components/hy-back-top/typing.d.ts +49 -0
- package/components/hy-badge/hy-badge.vue +155 -0
- package/components/hy-badge/props.ts +19 -0
- package/components/hy-badge/typing.d.ts +60 -0
- package/components/hy-button/hy-button.vue +394 -0
- package/components/hy-button/props.ts +36 -0
- package/components/hy-button/typing.d.ts +125 -0
- package/components/hy-card/hy-card.vue +198 -0
- package/components/hy-card/props.ts +29 -0
- package/components/hy-card/typing.d.ts +112 -0
- package/components/hy-cell/hy-cell.vue +268 -0
- package/components/hy-cell/props.ts +20 -0
- package/components/hy-cell/typing.d.ts +98 -0
- package/components/hy-check-button/hy-check-button.vue +71 -0
- package/components/hy-check-button/props.ts +20 -0
- package/components/hy-check-button/typing.d.ts +79 -0
- package/components/hy-checkbox/hy-checkbox.vue +299 -0
- package/components/hy-checkbox/props.ts +28 -0
- package/components/hy-checkbox/typing.d.ts +77 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
- package/components/hy-datetime-picker/props.ts +36 -0
- package/components/hy-datetime-picker/typing.d.ts +135 -0
- package/components/hy-divider/hy-divider.vue +164 -0
- package/components/hy-divider/props.ts +21 -0
- package/components/hy-divider/typing.d.ts +64 -0
- package/components/hy-empty/hy-empty.vue +122 -0
- package/components/hy-empty/props.ts +21 -0
- package/components/hy-empty/typing.d.ts +68 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
- package/components/hy-folding-panel/props.ts +17 -0
- package/components/hy-folding-panel/typing.d.ts +59 -0
- package/components/hy-form/hy-form.vue +372 -0
- package/components/hy-form/props.ts +15 -0
- package/components/hy-form/typing.d.ts +51 -0
- package/components/hy-grid/hy-grid.vue +126 -0
- package/components/hy-grid/props.ts +16 -0
- package/components/hy-grid/typing.d.ts +62 -0
- package/components/hy-icon/hy-icon.vue +207 -0
- package/components/hy-icon/props.ts +24 -0
- package/components/hy-icon/typing.d.ts +80 -0
- package/components/hy-input/hy-input.vue +402 -0
- package/components/hy-input/props.ts +41 -0
- package/components/hy-input/typing.d.ts +148 -0
- package/components/hy-line/hy-line.vue +44 -0
- package/components/hy-line/props.ts +12 -0
- package/components/hy-line/typing.d.ts +32 -0
- package/components/hy-line-progress/hy-line-progress.vue +118 -0
- package/components/hy-line-progress/props.ts +12 -0
- package/components/hy-line-progress/typing.d.ts +28 -0
- package/components/hy-list/hy-list.vue +250 -0
- package/components/hy-list/props.ts +18 -0
- package/components/hy-list/typing.d.ts +50 -0
- package/components/hy-login/ThePhoneLogin.vue +106 -0
- package/components/hy-login/TheUserLogin.vue +391 -0
- package/components/hy-login/hy-login.vue +283 -0
- package/components/hy-login/props.ts +32 -0
- package/components/hy-login/typing.d.ts +60 -0
- package/components/hy-modal/hy-modal.vue +240 -0
- package/components/hy-modal/props.ts +24 -0
- package/components/hy-modal/typing.d.ts +70 -0
- package/components/hy-navbar/hy-navbar.vue +194 -0
- package/components/hy-navbar/props.ts +24 -0
- package/components/hy-navbar/typing.d.ts +81 -0
- package/components/hy-notice-bar/hy-column-notice.vue +130 -0
- package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
- package/components/hy-notice-bar/hy-row-notice.vue +182 -0
- package/components/hy-notice-bar/props.ts +19 -0
- package/components/hy-notice-bar/typing.d.ts +56 -0
- package/components/hy-number-step/hy-number-step.vue +428 -0
- package/components/hy-number-step/props.ts +29 -0
- package/components/hy-number-step/typing.d.ts +104 -0
- package/components/hy-overlay/hy-overlay.vue +54 -0
- package/components/hy-overlay/props.ts +10 -0
- package/components/hy-overlay/typing.d.ts +24 -0
- package/components/hy-picker/hy-picker.vue +499 -0
- package/components/hy-picker/props.ts +30 -0
- package/components/hy-picker/typing.d.ts +115 -0
- package/components/hy-popup/hy-popup.vue +269 -0
- package/components/hy-popup/props.ts +21 -0
- package/components/hy-popup/typing.d.ts +68 -0
- package/components/hy-price/hy-price.vue +86 -0
- package/components/hy-price/props.ts +13 -0
- package/components/hy-price/typing.d.ts +36 -0
- package/components/hy-qrcode/hy-qrcode.vue +153 -0
- package/components/hy-qrcode/props.ts +20 -0
- package/components/hy-qrcode/qrcode.js +1364 -0
- package/components/hy-qrcode/typing.d.ts +64 -0
- package/components/hy-radio/hy-radio.vue +319 -0
- package/components/hy-radio/props.ts +28 -0
- package/components/hy-radio/typing.d.ts +85 -0
- package/components/hy-rate/hy-rate.vue +261 -0
- package/components/hy-rate/props.ts +18 -0
- package/components/hy-rate/typing.d.ts +60 -0
- package/components/hy-read-more/hy-read-more.vue +134 -0
- package/components/hy-read-more/props.ts +20 -0
- package/components/hy-read-more/typing.d.ts +44 -0
- package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
- package/components/hy-scroll-list/props.ts +12 -0
- package/components/hy-scroll-list/typing.d.ts +28 -0
- package/components/hy-search/hy-search.vue +294 -0
- package/components/hy-search/props.ts +29 -0
- package/components/hy-search/typing.d.ts +109 -0
- package/components/hy-slider/hy-slider.vue +511 -0
- package/components/hy-slider/props.ts +21 -0
- package/components/hy-slider/typing.d.ts +68 -0
- package/components/hy-steps/hy-steps.vue +352 -0
- package/components/hy-steps/props.ts +15 -0
- package/components/hy-steps/typing.d.ts +58 -0
- package/components/hy-subsection/hy-subsection.vue +272 -0
- package/components/hy-subsection/props.ts +16 -0
- package/components/hy-subsection/typing.d.ts +44 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
- package/components/hy-swiper/hy-swiper.vue +242 -0
- package/components/hy-swiper/props.ts +30 -0
- package/components/hy-swiper/typing.d.ts +107 -0
- package/components/hy-switch/hy-switch.vue +168 -0
- package/components/hy-switch/props.ts +16 -0
- package/components/hy-switch/typing.d.ts +48 -0
- package/components/hy-tabs/hy-tabs.vue +416 -0
- package/components/hy-tabs/props.ts +26 -0
- package/components/hy-tabs/typing.d.ts +86 -0
- package/components/hy-tag/hy-tag.vue +374 -0
- package/components/hy-tag/props.ts +22 -0
- package/components/hy-tag/typing.d.ts +76 -0
- package/components/hy-textarea/hy-textarea.vue +229 -0
- package/components/hy-textarea/props.ts +26 -0
- package/components/hy-textarea/typing.d.ts +27 -0
- package/components/hy-tooltip/hy-tooltip.vue +332 -0
- package/components/hy-tooltip/props.ts +17 -0
- package/components/hy-tooltip/typing.d.ts +52 -0
- package/components/hy-transition/hy-transition.vue +150 -0
- package/components/hy-transition/index.scss +113 -0
- package/components/hy-transition/props.ts +10 -0
- package/components/hy-transition/typing.d.ts +36 -0
- package/components/hy-upload/hy-upload.vue +557 -0
- package/components/hy-upload/props.ts +29 -0
- package/components/hy-upload/typing.d.ts +147 -0
- package/components/hy-warn/hy-warn.vue +228 -0
- package/components/hy-warn/props.ts +14 -0
- package/components/hy-warn/typing.d.ts +40 -0
- package/components/hy-waterfall/hy-waterfall.vue +51 -0
- package/components/hy-waterfall/props.ts +10 -0
- package/components/hy-waterfall/typing.d.ts +20 -0
- package/components/index.ts +162 -0
- package/components/message/TheMessage.vue +169 -0
- package/components/message/index.ts +54 -0
- package/components/u-form/form.js +22 -0
- package/components/u-form/hy-form.vue +324 -0
- package/components/u-form/props.js +49 -0
- package/components/u-form/schema.js +1451 -0
- package/components/u-form/u-form.vue +267 -0
- package/components/u-form/utils.js +65 -0
- package/components/u-form-item/formItem.js +24 -0
- package/components/u-form-item/hy-form-item.vue +360 -0
- package/components/u-form-item/props.js +57 -0
- package/components/u-form-item/u-form-item.vue +294 -0
- package/components/yk-dialog/yk-dialog.vue +129 -0
- package/components/yk-tabbar/props.ts +49 -0
- package/components/yk-tabbar/yk-tabbar.vue +224 -0
- package/config/color.ts +6 -0
- package/config/icon.ts +366 -0
- package/config/index.ts +2 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +37 -0
- package/index.ts +8 -0
- package/libs/css/common.scss +0 -0
- package/libs/css/iconfont.css +379 -0
- package/libs/css/iconfont.ttf +0 -0
- package/libs/css/mixin.scss +15 -0
- package/package.json +42 -0
- package/public/icons/error.png +0 -0
- package/public/icons/success.png +0 -0
- package/public/icons/warning.png +0 -0
- package/store/index.ts +1 -0
- package/store/userInfo.ts +25 -0
- package/theme.scss +94 -0
- package/typing/index.ts +7 -0
- package/typing/modules/common.d.ts +50 -0
- package/typing/modules/dialog.ts +17 -0
- package/typing/modules/enum.ts +67 -0
- package/typing/modules/form.ts +161 -0
- package/typing/modules/http.ts +68 -0
- package/typing/modules/icon.d.ts +366 -0
- package/typing/modules/img.ts +15 -0
- package/typing/modules/rect.ts +10 -0
- package/utils/address.json +5890 -0
- package/utils/base64.ts +119 -0
- package/utils/index.ts +3 -0
- package/utils/inside.ts +310 -0
- package/utils/utils.ts +446 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-popup">
|
|
3
|
+
<HyOverlay
|
|
4
|
+
:show="show"
|
|
5
|
+
@click="overlayClick"
|
|
6
|
+
v-if="overlay"
|
|
7
|
+
:zIndex="zIndex"
|
|
8
|
+
:duration="overlayDuration"
|
|
9
|
+
:customStyle="overlayStyle"
|
|
10
|
+
:opacity="overlayOpacity"
|
|
11
|
+
></HyOverlay>
|
|
12
|
+
<HyTransition
|
|
13
|
+
:show="show"
|
|
14
|
+
:customStyle="transitionStyle"
|
|
15
|
+
:mode="positionMode"
|
|
16
|
+
:duration="duration"
|
|
17
|
+
@afterEnter="afterEnter"
|
|
18
|
+
@click="clickHandler"
|
|
19
|
+
>
|
|
20
|
+
<!-- @click.stop不能去除,去除会导致居中模式下点击内容区域触发关闭弹窗 -->
|
|
21
|
+
<view class="hy-popup__content" :style="[contentStyle]">
|
|
22
|
+
<!-- <u-status-bar v-if="safeAreaInsetTop"></u-status-bar>-->
|
|
23
|
+
<slot></slot>
|
|
24
|
+
<view
|
|
25
|
+
v-if="closeable"
|
|
26
|
+
@tap.stop="close"
|
|
27
|
+
class="hy-popup__content__close"
|
|
28
|
+
:class="['hy-popup__content__close--' + closeIconPos]"
|
|
29
|
+
hover-class="hy-popup__content__close--hover"
|
|
30
|
+
hover-stay-time="150"
|
|
31
|
+
>
|
|
32
|
+
<HyIcon
|
|
33
|
+
:name="IconConfig.CLOSE"
|
|
34
|
+
color="#909399"
|
|
35
|
+
size="18"
|
|
36
|
+
bold
|
|
37
|
+
></HyIcon>
|
|
38
|
+
</view>
|
|
39
|
+
<!-- <hy-safe-bottom v-if="safeAreaInsetBottom"></hy-safe-bottom>-->
|
|
40
|
+
</view>
|
|
41
|
+
</HyTransition>
|
|
42
|
+
</view>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script setup lang="ts">
|
|
46
|
+
import { computed, CSSProperties, ref, toRefs, watch } from "vue";
|
|
47
|
+
import defaultProps from "./props";
|
|
48
|
+
import IProps from "./typing";
|
|
49
|
+
import { addUnit, getWindowInfo } from "../../utils";
|
|
50
|
+
import { IconConfig } from "../../config";
|
|
51
|
+
|
|
52
|
+
// 组件
|
|
53
|
+
import HyTransition from "../hy-transition/hy-transition.vue";
|
|
54
|
+
import HyOverlay from "../hy-overlay/hy-overlay.vue";
|
|
55
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
56
|
+
|
|
57
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
58
|
+
const {
|
|
59
|
+
duration,
|
|
60
|
+
show,
|
|
61
|
+
closeOnClickOverlay,
|
|
62
|
+
mode,
|
|
63
|
+
zIndex,
|
|
64
|
+
bgColor,
|
|
65
|
+
round,
|
|
66
|
+
customStyle,
|
|
67
|
+
zoom
|
|
68
|
+
} = toRefs(props);
|
|
69
|
+
const emit = defineEmits(["open", "close", "click", "update:show"]);
|
|
70
|
+
|
|
71
|
+
const overlayDuration = ref(duration.value + 50);
|
|
72
|
+
|
|
73
|
+
watch(
|
|
74
|
+
() => show.value,
|
|
75
|
+
(newValue) => {
|
|
76
|
+
if (newValue) {
|
|
77
|
+
// #ifdef MP-WEIXIN
|
|
78
|
+
// const children = this.$children
|
|
79
|
+
// retryComputedComponentRect(children)
|
|
80
|
+
// #endif
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const transitionStyle = computed(() => {
|
|
86
|
+
const style: CSSProperties = {
|
|
87
|
+
zIndex: zIndex.value,
|
|
88
|
+
position: "fixed",
|
|
89
|
+
display: "flex"
|
|
90
|
+
};
|
|
91
|
+
if (mode.value !== "center") {
|
|
92
|
+
style[mode.value] = 0;
|
|
93
|
+
}
|
|
94
|
+
switch (mode.value) {
|
|
95
|
+
case "left":
|
|
96
|
+
case "right":
|
|
97
|
+
style.bottom = 0;
|
|
98
|
+
style.top = 0;
|
|
99
|
+
break;
|
|
100
|
+
case "top":
|
|
101
|
+
case "bottom":
|
|
102
|
+
style.left = 0;
|
|
103
|
+
style.right = 0;
|
|
104
|
+
break;
|
|
105
|
+
case "center":
|
|
106
|
+
Object.assign(style, {
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
"justify-content": "center",
|
|
109
|
+
top: 0,
|
|
110
|
+
left: 0,
|
|
111
|
+
right: 0,
|
|
112
|
+
bottom: 0
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return style;
|
|
120
|
+
});
|
|
121
|
+
const contentStyle = computed(() => {
|
|
122
|
+
const style: CSSProperties = {};
|
|
123
|
+
// 通过设备信息的safeAreaInsets值来判断是否需要预留顶部状态栏和底部安全局的位置
|
|
124
|
+
// 不使用css方案,是因为nvue不支持css的iPhoneX安全区查询属性
|
|
125
|
+
const { safeAreaInsets } = getWindowInfo();
|
|
126
|
+
if (mode.value !== "center") {
|
|
127
|
+
style.flex = 1;
|
|
128
|
+
}
|
|
129
|
+
// 背景色,一般用于设置为transparent,去除默认的白色背景
|
|
130
|
+
if (bgColor.value) {
|
|
131
|
+
style.backgroundColor = bgColor.value;
|
|
132
|
+
}
|
|
133
|
+
if (round.value) {
|
|
134
|
+
const value = addUnit(round.value);
|
|
135
|
+
switch (mode.value) {
|
|
136
|
+
case "top":
|
|
137
|
+
style.borderBottomLeftRadius = value;
|
|
138
|
+
style.borderBottomRightRadius = value;
|
|
139
|
+
break;
|
|
140
|
+
case "bottom":
|
|
141
|
+
style.borderTopLeftRadius = value;
|
|
142
|
+
style.borderTopRightRadius = value;
|
|
143
|
+
break;
|
|
144
|
+
case "center":
|
|
145
|
+
style.borderRadius = value;
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return Object.assign(style, customStyle.value || {});
|
|
152
|
+
});
|
|
153
|
+
const positionMode = computed(() => {
|
|
154
|
+
if (mode.value === "center") {
|
|
155
|
+
return zoom.value ? "fade-zoom" : "fade";
|
|
156
|
+
}
|
|
157
|
+
if (mode.value === "left") {
|
|
158
|
+
return "slide-left";
|
|
159
|
+
}
|
|
160
|
+
if (mode.value === "right") {
|
|
161
|
+
return "slide-right";
|
|
162
|
+
}
|
|
163
|
+
if (mode.value === "bottom") {
|
|
164
|
+
return "slide-up";
|
|
165
|
+
}
|
|
166
|
+
if (mode.value === "top") {
|
|
167
|
+
return "slide-down";
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// 点击遮罩
|
|
172
|
+
const overlayClick = () => {
|
|
173
|
+
if (closeOnClickOverlay.value) {
|
|
174
|
+
emit("update:show", false);
|
|
175
|
+
emit("close");
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const close = () => {
|
|
179
|
+
emit("update:show", false);
|
|
180
|
+
emit("close");
|
|
181
|
+
};
|
|
182
|
+
const afterEnter = () => {
|
|
183
|
+
emit("open");
|
|
184
|
+
};
|
|
185
|
+
const clickHandler = () => {
|
|
186
|
+
// 由于中部弹出时,其u-transition占据了整个页面相当于遮罩,此时需要发出遮罩点击事件,是否无法通过点击遮罩关闭弹窗
|
|
187
|
+
if (mode.value === "center") {
|
|
188
|
+
overlayClick();
|
|
189
|
+
}
|
|
190
|
+
emit("click");
|
|
191
|
+
};
|
|
192
|
+
</script>
|
|
193
|
+
|
|
194
|
+
<style lang="scss" scoped>
|
|
195
|
+
$u-popup-flex: 1 !default;
|
|
196
|
+
$u-popup-content-background-color: #fff !default;
|
|
197
|
+
|
|
198
|
+
.hy-popup {
|
|
199
|
+
flex: $u-popup-flex;
|
|
200
|
+
|
|
201
|
+
&__content {
|
|
202
|
+
background-color: $u-popup-content-background-color;
|
|
203
|
+
position: relative;
|
|
204
|
+
|
|
205
|
+
&--round-top {
|
|
206
|
+
border-top-left-radius: 0;
|
|
207
|
+
border-top-right-radius: 0;
|
|
208
|
+
border-bottom-left-radius: 10px;
|
|
209
|
+
border-bottom-right-radius: 10px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&--round-left {
|
|
213
|
+
border-top-left-radius: 0;
|
|
214
|
+
border-top-right-radius: 10px;
|
|
215
|
+
border-bottom-left-radius: 0;
|
|
216
|
+
border-bottom-right-radius: 10px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&--round-right {
|
|
220
|
+
border-top-left-radius: 10px;
|
|
221
|
+
border-top-right-radius: 0;
|
|
222
|
+
border-bottom-left-radius: 10px;
|
|
223
|
+
border-bottom-right-radius: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&--round-bottom {
|
|
227
|
+
border-top-left-radius: 10px;
|
|
228
|
+
border-top-right-radius: 10px;
|
|
229
|
+
border-bottom-left-radius: 0;
|
|
230
|
+
border-bottom-right-radius: 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&--round-center {
|
|
234
|
+
border-top-left-radius: 10px;
|
|
235
|
+
border-top-right-radius: 10px;
|
|
236
|
+
border-bottom-left-radius: 10px;
|
|
237
|
+
border-bottom-right-radius: 10px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
&__close {
|
|
241
|
+
position: absolute;
|
|
242
|
+
|
|
243
|
+
&--hover {
|
|
244
|
+
opacity: 0.4;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
&__close--top-left {
|
|
249
|
+
top: 15px;
|
|
250
|
+
left: 15px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
&__close--top-right {
|
|
254
|
+
top: 15px;
|
|
255
|
+
right: 15px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&__close--bottom-left {
|
|
259
|
+
bottom: 15px;
|
|
260
|
+
left: 15px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
&__close--bottom-right {
|
|
264
|
+
right: 15px;
|
|
265
|
+
bottom: 15px;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
show: false,
|
|
5
|
+
overlay: true,
|
|
6
|
+
mode: "bottom",
|
|
7
|
+
duration: 300,
|
|
8
|
+
closeable: false,
|
|
9
|
+
overlayStyle: {},
|
|
10
|
+
overlayOpacity: 0.5,
|
|
11
|
+
closeOnClickOverlay: true,
|
|
12
|
+
zIndex: 10075,
|
|
13
|
+
safeAreaInsetBottom: true,
|
|
14
|
+
safeAreaInsetTop: false,
|
|
15
|
+
closeIconPos: "top-right",
|
|
16
|
+
round: 0,
|
|
17
|
+
zoom: true,
|
|
18
|
+
bgColor: ""
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default defaultProps;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 是否展示弹窗 (默认 false )
|
|
6
|
+
* */
|
|
7
|
+
show: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @description 是否显示遮罩 (默认 true )
|
|
10
|
+
* */
|
|
11
|
+
overlay?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @description 弹出方向(默认 'bottom' )
|
|
14
|
+
* */
|
|
15
|
+
mode?: HyApp.LayoutType;
|
|
16
|
+
/**
|
|
17
|
+
* @description 动画时长,单位ms (默认 300 )
|
|
18
|
+
* */
|
|
19
|
+
duration?: number;
|
|
20
|
+
/**
|
|
21
|
+
* @description 是否显示关闭图标(默认 false )
|
|
22
|
+
* */
|
|
23
|
+
closeable?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description 自定义遮罩的样式
|
|
26
|
+
* */
|
|
27
|
+
overlayStyle?: CSSProperties;
|
|
28
|
+
/**
|
|
29
|
+
* @description 遮罩透明度,0-1之间(默认 0.5)
|
|
30
|
+
* */
|
|
31
|
+
overlayOpacity?: number;
|
|
32
|
+
/**
|
|
33
|
+
* @description 点击遮罩是否关闭弹窗 (默认 true )
|
|
34
|
+
* */
|
|
35
|
+
closeOnClickOverlay?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @description 层级 (默认 10075 )
|
|
38
|
+
* */
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
/**
|
|
41
|
+
* @description 是否为iPhoneX留出底部安全距离 (默认 true )
|
|
42
|
+
* */
|
|
43
|
+
safeAreaInsetBottom?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @description 是否留出顶部安全距离(状态栏高度) (默认 false )
|
|
46
|
+
* */
|
|
47
|
+
safeAreaInsetTop?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @description 自定义关闭图标位置(默认 'top-right' )
|
|
50
|
+
* */
|
|
51
|
+
closeIconPos?: "top-left" | "top-right";
|
|
52
|
+
/**
|
|
53
|
+
* @description 圆角值(默认 0)
|
|
54
|
+
* */
|
|
55
|
+
round?: number;
|
|
56
|
+
/**
|
|
57
|
+
* @description 当mode=center时 是否开启缩放(默认 true )
|
|
58
|
+
* */
|
|
59
|
+
zoom?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @description 背景颜色
|
|
62
|
+
* */
|
|
63
|
+
bgColor?: string;
|
|
64
|
+
/**
|
|
65
|
+
* @description 自定义样式
|
|
66
|
+
* */
|
|
67
|
+
customStyle?: CSSProperties;
|
|
68
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Description: 价格的样式
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<text class="hy-price" :style="priceStyle" @tap="handleClick">
|
|
7
|
+
<text class="hy-price__prefix">{{ symbol }}</text>
|
|
8
|
+
<text
|
|
9
|
+
class="hy-price__text"
|
|
10
|
+
:style="[
|
|
11
|
+
{ 'font-size': `${Number(fontSize) + Number(fontSize) * 0.8}rpx` }
|
|
12
|
+
]"
|
|
13
|
+
>{{ priceOne[0] }}
|
|
14
|
+
</text>
|
|
15
|
+
<text class="hy-price__decimal">
|
|
16
|
+
{{ "." + priceOne[1].slice(0, num) }}
|
|
17
|
+
</text>
|
|
18
|
+
</text>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { computed, CSSProperties, toRefs } from "vue";
|
|
23
|
+
import defaultProps from "./props";
|
|
24
|
+
import IProps from "./typing";
|
|
25
|
+
import { addUnit } from "../../utils";
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
28
|
+
const { text, textColor, weight, fontSize, slant, customStyle } = toRefs(props);
|
|
29
|
+
const emit = defineEmits(["click"]);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description 价格整体样式
|
|
33
|
+
* */
|
|
34
|
+
const priceStyle = computed<CSSProperties>(() => {
|
|
35
|
+
const style: CSSProperties = {
|
|
36
|
+
color: textColor.value,
|
|
37
|
+
fontWeight: weight.value,
|
|
38
|
+
fontStyle: slant.value ? "oblique" : "",
|
|
39
|
+
fontSize: addUnit(fontSize.value)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return Object.assign(style, customStyle);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @description 价格处理
|
|
47
|
+
* */
|
|
48
|
+
const priceOne = computed(() => {
|
|
49
|
+
let value = "";
|
|
50
|
+
if (typeof text.value !== "string") {
|
|
51
|
+
value = text.value.toString();
|
|
52
|
+
} else {
|
|
53
|
+
value = text.value;
|
|
54
|
+
}
|
|
55
|
+
if (/\./g.test(value)) {
|
|
56
|
+
if (Number(value)) {
|
|
57
|
+
return value.split(".");
|
|
58
|
+
} else {
|
|
59
|
+
return ["0", "00"];
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
return [value, "000000"];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @description 点击事件
|
|
68
|
+
* */
|
|
69
|
+
const handleClick = () => {
|
|
70
|
+
emit("click", text.value);
|
|
71
|
+
};
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style lang="scss" scoped>
|
|
75
|
+
.hy-price {
|
|
76
|
+
font-size: 32rpx;
|
|
77
|
+
font-weight: 500;
|
|
78
|
+
margin-top: 5px;
|
|
79
|
+
&__prefix {
|
|
80
|
+
font-size: 24rpx;
|
|
81
|
+
}
|
|
82
|
+
&__decimal {
|
|
83
|
+
font-size: 24rpx;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 传入金额值
|
|
6
|
+
* */
|
|
7
|
+
text: string | number;
|
|
8
|
+
/**
|
|
9
|
+
* @description 金额符号(默认:¥)
|
|
10
|
+
* */
|
|
11
|
+
symbol?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 保留小数点后几位数(默认:2)
|
|
14
|
+
* */
|
|
15
|
+
num?: number;
|
|
16
|
+
/**
|
|
17
|
+
* @description 字体颜色(默认:#FE3232)
|
|
18
|
+
* */
|
|
19
|
+
textColor?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @description 字体大小(默认:22)
|
|
22
|
+
* */
|
|
23
|
+
fontSize?: string | number;
|
|
24
|
+
/**
|
|
25
|
+
* @description 字体粗细(默认:500)
|
|
26
|
+
* */
|
|
27
|
+
weight?: string | number;
|
|
28
|
+
/**
|
|
29
|
+
* @description 是否倾斜(默认:false)
|
|
30
|
+
* */
|
|
31
|
+
slant?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @description 自定义样式
|
|
34
|
+
* */
|
|
35
|
+
customStyle?: CSSProperties;
|
|
36
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-qrcode" @longpress="onLongPress">
|
|
3
|
+
<view class="hy-qrcode__content" @click="preview">
|
|
4
|
+
<!-- #ifndef APP-NVUE -->
|
|
5
|
+
<canvas
|
|
6
|
+
class="hy-qrcode__canvas"
|
|
7
|
+
:id="cid"
|
|
8
|
+
:canvas-id="cid"
|
|
9
|
+
:style="{ width: addUnit(size), height: addUnit(size) }"
|
|
10
|
+
/>
|
|
11
|
+
<!-- #endif -->
|
|
12
|
+
<view
|
|
13
|
+
v-if="showLoading && loading"
|
|
14
|
+
class="hy-qrcode__loading"
|
|
15
|
+
:style="{ width: addUnit(size), height: addUnit(size) }"
|
|
16
|
+
>
|
|
17
|
+
<HyIcon :name="IconConfig.LOADING" is-rotate></HyIcon>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { getCurrentInstance, toRefs, ref, onMounted } from "vue";
|
|
25
|
+
import defaultProps from "./props";
|
|
26
|
+
import IProps from "./typing";
|
|
27
|
+
import QRCode from "./qrcode.js";
|
|
28
|
+
import { addUnit } from "../../utils";
|
|
29
|
+
import { IconConfig } from "../../config";
|
|
30
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
31
|
+
|
|
32
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
33
|
+
const { text, allowPreview } = toRefs(props);
|
|
34
|
+
const emit = defineEmits(["result", "preview", "longPress"]);
|
|
35
|
+
|
|
36
|
+
const instance = getCurrentInstance();
|
|
37
|
+
const loading = ref(false);
|
|
38
|
+
const qrcode = ref("");
|
|
39
|
+
const result = ref("");
|
|
40
|
+
|
|
41
|
+
onMounted(() => {
|
|
42
|
+
initQrCode();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const initQrCode = () => {
|
|
46
|
+
if (text.value) {
|
|
47
|
+
loading.value;
|
|
48
|
+
qrcode.value = new QRCode({
|
|
49
|
+
context: instance, // 上下文环境
|
|
50
|
+
canvasId: props.cid, // canvas-id
|
|
51
|
+
usingComponents: props.usingComponents, // 是否是自定义组件
|
|
52
|
+
showLoading: false, // 是否显示loading
|
|
53
|
+
loadingText: props.loadingText, // loading文字
|
|
54
|
+
text: text.value, // 生成内容
|
|
55
|
+
size: props.size, // 二维码大小
|
|
56
|
+
background: props.background, // 背景色
|
|
57
|
+
foreground: props.foreground, // 前景色
|
|
58
|
+
pdground: props.pdGround, // 定位角点颜色
|
|
59
|
+
correctLevel: props.lv, // 容错级别
|
|
60
|
+
image: props.icon, // 二维码图标
|
|
61
|
+
imageSize: props.iconSize, // 二维码图标大小
|
|
62
|
+
cbResult: function (res: any) {
|
|
63
|
+
// 生成二维码的回调
|
|
64
|
+
_result(res);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
uni.showToast({
|
|
69
|
+
title: "二维码内容不能为空",
|
|
70
|
+
icon: "none",
|
|
71
|
+
duration: 2000
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const _result = (res: any) => {
|
|
77
|
+
loading.value = false;
|
|
78
|
+
result.value = res;
|
|
79
|
+
emit("result", res);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const _saveCode = () => {
|
|
83
|
+
if (result.value != "") {
|
|
84
|
+
uni.saveImageToPhotosAlbum({
|
|
85
|
+
filePath: result.value,
|
|
86
|
+
success: function () {
|
|
87
|
+
uni.showToast({
|
|
88
|
+
title: "二维码保存成功",
|
|
89
|
+
icon: "success",
|
|
90
|
+
duration: 2000
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* @description 预览
|
|
98
|
+
* */
|
|
99
|
+
const preview = (e) => {
|
|
100
|
+
// 预览图片
|
|
101
|
+
// console.log(this.result)
|
|
102
|
+
if (allowPreview.value) {
|
|
103
|
+
uni.previewImage({
|
|
104
|
+
urls: [result.value],
|
|
105
|
+
longPressActions: {
|
|
106
|
+
itemList: ["保存二维码图片"],
|
|
107
|
+
success: function (data) {
|
|
108
|
+
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
|
|
109
|
+
switch (data.tapIndex) {
|
|
110
|
+
case 0:
|
|
111
|
+
_saveCode();
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
fail: function (err) {
|
|
116
|
+
console.error(err.errMsg);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
emit("preview", result.value, e);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const onLongPress = () => {
|
|
125
|
+
emit("longPress");
|
|
126
|
+
};
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<style lang="scss" scoped>
|
|
130
|
+
.hy-qrcode {
|
|
131
|
+
&__loading {
|
|
132
|
+
display: flex;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
align-items: center;
|
|
135
|
+
background-color: #f7f7f7;
|
|
136
|
+
position: absolute;
|
|
137
|
+
top: 0;
|
|
138
|
+
bottom: 0;
|
|
139
|
+
left: 0;
|
|
140
|
+
right: 0;
|
|
141
|
+
}
|
|
142
|
+
&__content {
|
|
143
|
+
position: relative;
|
|
144
|
+
|
|
145
|
+
&__canvas {
|
|
146
|
+
position: fixed;
|
|
147
|
+
top: -99999rpx;
|
|
148
|
+
left: -99999rpx;
|
|
149
|
+
z-index: -99999;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
cid: "hy-qrcode-canvas" + Math.random().toString(),
|
|
5
|
+
size: 200,
|
|
6
|
+
text: "",
|
|
7
|
+
show: true,
|
|
8
|
+
background: "#ffffff",
|
|
9
|
+
foreground: "#000000",
|
|
10
|
+
pdGround: "#000000",
|
|
11
|
+
usingComponents: true,
|
|
12
|
+
lv: 3,
|
|
13
|
+
icon: "",
|
|
14
|
+
iconSize: 40,
|
|
15
|
+
showLoading: true,
|
|
16
|
+
loadingText: "二维码生成中",
|
|
17
|
+
allowPreview: false
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default defaultProps;
|