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.
Files changed (206) hide show
  1. package/README.md +42 -0
  2. package/api/http.ts +138 -0
  3. package/api/index.ts +1 -0
  4. package/common/index.ts +1 -0
  5. package/common/versionControl.ts +102 -0
  6. package/components/dialog/TheDialog.vue +128 -0
  7. package/components/dialog/index.ts +38 -0
  8. package/components/hy-address-picker/hy-address-picker.vue +262 -0
  9. package/components/hy-address-picker/props.ts +27 -0
  10. package/components/hy-address-picker/typing.d.ts +98 -0
  11. package/components/hy-avatar/hy-avatar.vue +217 -0
  12. package/components/hy-avatar/props.ts +20 -0
  13. package/components/hy-avatar/typing.d.ts +64 -0
  14. package/components/hy-back-top/hy-back-top.vue +71 -0
  15. package/components/hy-back-top/props.ts +23 -0
  16. package/components/hy-back-top/typing.d.ts +49 -0
  17. package/components/hy-badge/hy-badge.vue +155 -0
  18. package/components/hy-badge/props.ts +19 -0
  19. package/components/hy-badge/typing.d.ts +60 -0
  20. package/components/hy-button/hy-button.vue +394 -0
  21. package/components/hy-button/props.ts +36 -0
  22. package/components/hy-button/typing.d.ts +125 -0
  23. package/components/hy-card/hy-card.vue +198 -0
  24. package/components/hy-card/props.ts +29 -0
  25. package/components/hy-card/typing.d.ts +112 -0
  26. package/components/hy-cell/hy-cell.vue +268 -0
  27. package/components/hy-cell/props.ts +20 -0
  28. package/components/hy-cell/typing.d.ts +98 -0
  29. package/components/hy-check-button/hy-check-button.vue +71 -0
  30. package/components/hy-check-button/props.ts +20 -0
  31. package/components/hy-check-button/typing.d.ts +79 -0
  32. package/components/hy-checkbox/hy-checkbox.vue +299 -0
  33. package/components/hy-checkbox/props.ts +28 -0
  34. package/components/hy-checkbox/typing.d.ts +77 -0
  35. package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
  36. package/components/hy-datetime-picker/props.ts +36 -0
  37. package/components/hy-datetime-picker/typing.d.ts +135 -0
  38. package/components/hy-divider/hy-divider.vue +164 -0
  39. package/components/hy-divider/props.ts +21 -0
  40. package/components/hy-divider/typing.d.ts +64 -0
  41. package/components/hy-empty/hy-empty.vue +122 -0
  42. package/components/hy-empty/props.ts +21 -0
  43. package/components/hy-empty/typing.d.ts +68 -0
  44. package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
  45. package/components/hy-folding-panel/props.ts +17 -0
  46. package/components/hy-folding-panel/typing.d.ts +59 -0
  47. package/components/hy-form/hy-form.vue +372 -0
  48. package/components/hy-form/props.ts +15 -0
  49. package/components/hy-form/typing.d.ts +51 -0
  50. package/components/hy-grid/hy-grid.vue +126 -0
  51. package/components/hy-grid/props.ts +16 -0
  52. package/components/hy-grid/typing.d.ts +62 -0
  53. package/components/hy-icon/hy-icon.vue +207 -0
  54. package/components/hy-icon/props.ts +24 -0
  55. package/components/hy-icon/typing.d.ts +80 -0
  56. package/components/hy-input/hy-input.vue +402 -0
  57. package/components/hy-input/props.ts +41 -0
  58. package/components/hy-input/typing.d.ts +148 -0
  59. package/components/hy-line/hy-line.vue +44 -0
  60. package/components/hy-line/props.ts +12 -0
  61. package/components/hy-line/typing.d.ts +32 -0
  62. package/components/hy-line-progress/hy-line-progress.vue +118 -0
  63. package/components/hy-line-progress/props.ts +12 -0
  64. package/components/hy-line-progress/typing.d.ts +28 -0
  65. package/components/hy-list/hy-list.vue +250 -0
  66. package/components/hy-list/props.ts +18 -0
  67. package/components/hy-list/typing.d.ts +50 -0
  68. package/components/hy-login/ThePhoneLogin.vue +106 -0
  69. package/components/hy-login/TheUserLogin.vue +391 -0
  70. package/components/hy-login/hy-login.vue +283 -0
  71. package/components/hy-login/props.ts +32 -0
  72. package/components/hy-login/typing.d.ts +60 -0
  73. package/components/hy-modal/hy-modal.vue +240 -0
  74. package/components/hy-modal/props.ts +24 -0
  75. package/components/hy-modal/typing.d.ts +70 -0
  76. package/components/hy-navbar/hy-navbar.vue +194 -0
  77. package/components/hy-navbar/props.ts +24 -0
  78. package/components/hy-navbar/typing.d.ts +81 -0
  79. package/components/hy-notice-bar/hy-column-notice.vue +130 -0
  80. package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
  81. package/components/hy-notice-bar/hy-row-notice.vue +182 -0
  82. package/components/hy-notice-bar/props.ts +19 -0
  83. package/components/hy-notice-bar/typing.d.ts +56 -0
  84. package/components/hy-number-step/hy-number-step.vue +428 -0
  85. package/components/hy-number-step/props.ts +29 -0
  86. package/components/hy-number-step/typing.d.ts +104 -0
  87. package/components/hy-overlay/hy-overlay.vue +54 -0
  88. package/components/hy-overlay/props.ts +10 -0
  89. package/components/hy-overlay/typing.d.ts +24 -0
  90. package/components/hy-picker/hy-picker.vue +499 -0
  91. package/components/hy-picker/props.ts +30 -0
  92. package/components/hy-picker/typing.d.ts +115 -0
  93. package/components/hy-popup/hy-popup.vue +269 -0
  94. package/components/hy-popup/props.ts +21 -0
  95. package/components/hy-popup/typing.d.ts +68 -0
  96. package/components/hy-price/hy-price.vue +86 -0
  97. package/components/hy-price/props.ts +13 -0
  98. package/components/hy-price/typing.d.ts +36 -0
  99. package/components/hy-qrcode/hy-qrcode.vue +153 -0
  100. package/components/hy-qrcode/props.ts +20 -0
  101. package/components/hy-qrcode/qrcode.js +1364 -0
  102. package/components/hy-qrcode/typing.d.ts +64 -0
  103. package/components/hy-radio/hy-radio.vue +319 -0
  104. package/components/hy-radio/props.ts +28 -0
  105. package/components/hy-radio/typing.d.ts +85 -0
  106. package/components/hy-rate/hy-rate.vue +261 -0
  107. package/components/hy-rate/props.ts +18 -0
  108. package/components/hy-rate/typing.d.ts +60 -0
  109. package/components/hy-read-more/hy-read-more.vue +134 -0
  110. package/components/hy-read-more/props.ts +20 -0
  111. package/components/hy-read-more/typing.d.ts +44 -0
  112. package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
  113. package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
  114. package/components/hy-scroll-list/props.ts +12 -0
  115. package/components/hy-scroll-list/typing.d.ts +28 -0
  116. package/components/hy-search/hy-search.vue +294 -0
  117. package/components/hy-search/props.ts +29 -0
  118. package/components/hy-search/typing.d.ts +109 -0
  119. package/components/hy-slider/hy-slider.vue +511 -0
  120. package/components/hy-slider/props.ts +21 -0
  121. package/components/hy-slider/typing.d.ts +68 -0
  122. package/components/hy-steps/hy-steps.vue +352 -0
  123. package/components/hy-steps/props.ts +15 -0
  124. package/components/hy-steps/typing.d.ts +58 -0
  125. package/components/hy-subsection/hy-subsection.vue +272 -0
  126. package/components/hy-subsection/props.ts +16 -0
  127. package/components/hy-subsection/typing.d.ts +44 -0
  128. package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
  129. package/components/hy-swiper/hy-swiper.vue +242 -0
  130. package/components/hy-swiper/props.ts +30 -0
  131. package/components/hy-swiper/typing.d.ts +107 -0
  132. package/components/hy-switch/hy-switch.vue +168 -0
  133. package/components/hy-switch/props.ts +16 -0
  134. package/components/hy-switch/typing.d.ts +48 -0
  135. package/components/hy-tabs/hy-tabs.vue +416 -0
  136. package/components/hy-tabs/props.ts +26 -0
  137. package/components/hy-tabs/typing.d.ts +86 -0
  138. package/components/hy-tag/hy-tag.vue +374 -0
  139. package/components/hy-tag/props.ts +22 -0
  140. package/components/hy-tag/typing.d.ts +76 -0
  141. package/components/hy-textarea/hy-textarea.vue +229 -0
  142. package/components/hy-textarea/props.ts +26 -0
  143. package/components/hy-textarea/typing.d.ts +27 -0
  144. package/components/hy-tooltip/hy-tooltip.vue +332 -0
  145. package/components/hy-tooltip/props.ts +17 -0
  146. package/components/hy-tooltip/typing.d.ts +52 -0
  147. package/components/hy-transition/hy-transition.vue +150 -0
  148. package/components/hy-transition/index.scss +113 -0
  149. package/components/hy-transition/props.ts +10 -0
  150. package/components/hy-transition/typing.d.ts +36 -0
  151. package/components/hy-upload/hy-upload.vue +557 -0
  152. package/components/hy-upload/props.ts +29 -0
  153. package/components/hy-upload/typing.d.ts +147 -0
  154. package/components/hy-warn/hy-warn.vue +228 -0
  155. package/components/hy-warn/props.ts +14 -0
  156. package/components/hy-warn/typing.d.ts +40 -0
  157. package/components/hy-waterfall/hy-waterfall.vue +51 -0
  158. package/components/hy-waterfall/props.ts +10 -0
  159. package/components/hy-waterfall/typing.d.ts +20 -0
  160. package/components/index.ts +162 -0
  161. package/components/message/TheMessage.vue +169 -0
  162. package/components/message/index.ts +54 -0
  163. package/components/u-form/form.js +22 -0
  164. package/components/u-form/hy-form.vue +324 -0
  165. package/components/u-form/props.js +49 -0
  166. package/components/u-form/schema.js +1451 -0
  167. package/components/u-form/u-form.vue +267 -0
  168. package/components/u-form/utils.js +65 -0
  169. package/components/u-form-item/formItem.js +24 -0
  170. package/components/u-form-item/hy-form-item.vue +360 -0
  171. package/components/u-form-item/props.js +57 -0
  172. package/components/u-form-item/u-form-item.vue +294 -0
  173. package/components/yk-dialog/yk-dialog.vue +129 -0
  174. package/components/yk-tabbar/props.ts +49 -0
  175. package/components/yk-tabbar/yk-tabbar.vue +224 -0
  176. package/config/color.ts +6 -0
  177. package/config/icon.ts +366 -0
  178. package/config/index.ts +2 -0
  179. package/global/index.ts +6 -0
  180. package/global/register-properties.ts +37 -0
  181. package/index.ts +8 -0
  182. package/libs/css/common.scss +0 -0
  183. package/libs/css/iconfont.css +379 -0
  184. package/libs/css/iconfont.ttf +0 -0
  185. package/libs/css/mixin.scss +15 -0
  186. package/package.json +42 -0
  187. package/public/icons/error.png +0 -0
  188. package/public/icons/success.png +0 -0
  189. package/public/icons/warning.png +0 -0
  190. package/store/index.ts +1 -0
  191. package/store/userInfo.ts +25 -0
  192. package/theme.scss +94 -0
  193. package/typing/index.ts +7 -0
  194. package/typing/modules/common.d.ts +50 -0
  195. package/typing/modules/dialog.ts +17 -0
  196. package/typing/modules/enum.ts +67 -0
  197. package/typing/modules/form.ts +161 -0
  198. package/typing/modules/http.ts +68 -0
  199. package/typing/modules/icon.d.ts +366 -0
  200. package/typing/modules/img.ts +15 -0
  201. package/typing/modules/rect.ts +10 -0
  202. package/utils/address.json +5890 -0
  203. package/utils/base64.ts +119 -0
  204. package/utils/index.ts +3 -0
  205. package/utils/inside.ts +310 -0
  206. package/utils/utils.ts +446 -0
@@ -0,0 +1,283 @@
1
+ <template>
2
+ <view class="normal-login-container">
3
+ <view class="logo-content align-center flex justify-center">
4
+ <image class="image" :src="props.logo" mode="widthFix"></image>
5
+ </view>
6
+ <!-- 登录 -->
7
+ <view class="login-form-content">
8
+ <view class="form-top">
9
+ <view
10
+ class="top-col"
11
+ v-for="(item, i) in tabs"
12
+ :key="i"
13
+ @tap="currentTab = i"
14
+ >
15
+ <view class="form-top-title">
16
+ {{ item.name }}
17
+ </view>
18
+ <view
19
+ :class="i === currentTab ? 'line' : ''"
20
+ :style="'background:' + props.themeColor"
21
+ ></view>
22
+ </view>
23
+ </view>
24
+ <TheUserLogin
25
+ v-if="'user' === indexCode(currentTab)"
26
+ ref="userLoginRef"
27
+ :themeColor="props.themeColor"
28
+ :prefix="props.prefix"
29
+ :isShowPwd="isShowPwd"
30
+ :userPlaceholder="userPlaceholder"
31
+ :pwdPlaceholder="pwdPlaceholder"
32
+ :customUserValidator="props.customUserValidator"
33
+ :customPwdValidator="props.customPwdValidator"
34
+ :userNumValidator="props.userNumValidator"
35
+ :pwdNumValidator="props.pwdNumValidator"
36
+ />
37
+ <ThePhoneLogin
38
+ v-if="'phone' === indexCode(currentTab)"
39
+ ref="phoneLoginRef"
40
+ :themeColor="props.themeColor"
41
+ :customPhoneValidator="props.customPhoneValidator"
42
+ />
43
+ <view class="action-btn">
44
+ <HyButton class="login-btn" :color="props.themeColor" @click="loginFn"
45
+ >登录
46
+ </HyButton>
47
+ </view>
48
+ <view class="footer">
49
+ <view
50
+ class="footer__tips"
51
+ v-for="(item, i) in menu"
52
+ :key="i"
53
+ @click="clickMenuFn(i)"
54
+ >{{ item }}</view
55
+ >
56
+ </view>
57
+ </view>
58
+ </view>
59
+ </template>
60
+
61
+ <script lang="ts" setup>
62
+ import { ref, toRefs, computed, watch } from "vue";
63
+ import { storeToRefs } from "pinia";
64
+ import { encryptData } from "../../utils";
65
+ import { useUserInfo } from "../../store";
66
+ import defaultProps from "./props";
67
+ import IProps from "./typing";
68
+
69
+ // 组件
70
+ import TheUserLogin from "./TheUserLogin.vue";
71
+ import ThePhoneLogin from "./ThePhoneLogin.vue";
72
+ import HyButton from "../hy-button/hy-button.vue";
73
+
74
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
75
+ const emit = defineEmits(["login", "handleClickMenu"]);
76
+
77
+ const userInfoStore = useUserInfo();
78
+ const { userForm, rememberPsw } = storeToRefs(userInfoStore);
79
+ const indexCode = computed(() => {
80
+ return (temp: string | number) => {
81
+ switch (Number(props.loginType)) {
82
+ case 1:
83
+ return "user";
84
+ case 2:
85
+ return "phone";
86
+ default:
87
+ if (temp == 0) {
88
+ return "user";
89
+ } else {
90
+ return "phone";
91
+ }
92
+ }
93
+ };
94
+ });
95
+ const selectModel = (temp: number) => {
96
+ return new Promise((resolve, reject) => {
97
+ switch (Number(props.loginType)) {
98
+ case 1:
99
+ resolve("user");
100
+ break;
101
+ case 2:
102
+ resolve("phone");
103
+ break;
104
+ default:
105
+ if (temp == 0) {
106
+ resolve("user");
107
+ } else {
108
+ resolve("phone");
109
+ }
110
+ break;
111
+ }
112
+ });
113
+ };
114
+ const tabs = ref([
115
+ {
116
+ name: "账号登录"
117
+ },
118
+ {
119
+ name: "验证码登录"
120
+ }
121
+ ]);
122
+ const currentTab = ref(0);
123
+ const userLoginRef = ref<typeof TheUserLogin>(null);
124
+ const phoneLoginRef = ref<typeof ThePhoneLogin>(null);
125
+ watch(
126
+ () => Number(props.loginType),
127
+ (newVal) => {
128
+ tabs.value = computed(() => {
129
+ switch (newVal) {
130
+ case 1:
131
+ return [{ name: "账号登录" }];
132
+ case 2:
133
+ return [{ name: "验证码登录" }];
134
+ default:
135
+ return [{ name: "账号登录" }, { name: "验证码登录" }];
136
+ }
137
+ }).value;
138
+ },
139
+ { immediate: true, deep: true }
140
+ );
141
+
142
+ /**
143
+ * 登录用户名
144
+ * */
145
+ const loginFn = async () => {
146
+ const type = await selectModel(currentTab.value);
147
+ switch (type) {
148
+ case "user":
149
+ let user = userForm.value.name;
150
+ let pwd = userForm.value.pwd;
151
+ await userLoginRef.value.loginFn();
152
+ //缓存账号和密码
153
+ if (rememberPsw.value == 1) {
154
+ uni.setStorageSync(
155
+ `${props.prefix}_account`,
156
+ encryptData({
157
+ rememberPsw: rememberPsw.value,
158
+ userName: user,
159
+ password: pwd
160
+ })
161
+ );
162
+ } else {
163
+ // 如果没有选记住密码就移除之前保存的
164
+ uni.removeStorageSync(`${props.prefix}_account`);
165
+ uni.setStorageSync(
166
+ `${props.prefix}_account`,
167
+ encryptData({ rememberPsw: rememberPsw.value })
168
+ );
169
+ }
170
+ emit("login", { user, pwd });
171
+ break;
172
+ case "phone":
173
+ await phoneLoginRef.value.loginFn();
174
+ break;
175
+ default:
176
+ break;
177
+ }
178
+ };
179
+
180
+ /**
181
+ * 点击下面小菜单
182
+ * */
183
+ const clickMenuFn = (index: number) => {
184
+ emit("handleClickMenu", index);
185
+ };
186
+ </script>
187
+
188
+ <style lang="scss" scoped>
189
+ .normal-login-container {
190
+ width: 100%;
191
+ height: 100vh;
192
+ padding: 0 60rpx;
193
+ /* #ifndef APP-PLUS-NVUE */
194
+ box-sizing: border-box;
195
+ /* #endif */
196
+ display: flex;
197
+ justify-content: center;
198
+ flex-direction: column;
199
+ //align-items: center;
200
+
201
+ /*logo图片展示*/
202
+ .logo-content {
203
+ width: 300rpx;
204
+ display: flex;
205
+ justify-content: center;
206
+ align-items: center;
207
+ /* #ifndef APP-PLUS-NVUE */
208
+ margin: 0 auto 100rpx;
209
+ box-sizing: border-box;
210
+ height: auto;
211
+ .image {
212
+ width: 100%;
213
+ height: auto;
214
+ }
215
+ /* #endif */
216
+ }
217
+
218
+ /*登录模块*/
219
+ .login-form-content {
220
+ //text-align: center;
221
+ box-shadow: 0px 5px 4px 0px rgba(200, 200, 200, 0.5);
222
+ border-radius: 10px;
223
+ background: #ffffff;
224
+ padding: 28rpx 50rpx 50rpx;
225
+
226
+ .form-top {
227
+ display: flex;
228
+ justify-content: space-around;
229
+ margin-bottom: 40rpx;
230
+
231
+ .top-col {
232
+ display: flex;
233
+ flex-direction: column;
234
+ justify-content: center;
235
+ align-items: center;
236
+
237
+ .form-top-title {
238
+ font-size: 28rpx;
239
+ }
240
+
241
+ .line {
242
+ width: 90rpx;
243
+ height: 4rpx;
244
+ margin-top: 6rpx;
245
+ }
246
+ }
247
+ }
248
+
249
+ .mui-input-row {
250
+ display: flex;
251
+ /* #ifndef APP-PLUS-NVUE */
252
+ justify-self: start;
253
+ /* #endif */
254
+ margin-top: 27rpx;
255
+ }
256
+
257
+ .action-btn {
258
+ margin-top: 30rpx;
259
+ }
260
+
261
+ .footer {
262
+ display: flex;
263
+ justify-content: space-around;
264
+ /* #ifndef APP-PLUS-NVUE */
265
+ margin: auto 20%;
266
+ /* #endif */
267
+
268
+ &__tips {
269
+ font-size: 12px;
270
+ margin-top: 27rpx;
271
+ text-align: center;
272
+ color: grey;
273
+ text-decoration: underline;
274
+ }
275
+ }
276
+
277
+ .xieyi {
278
+ color: #333;
279
+ margin-top: 40rpx;
280
+ }
281
+ }
282
+ }
283
+ </style>
@@ -0,0 +1,32 @@
1
+ import IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ logo: "",
5
+ loginType: 0,
6
+ themeColor: "#20D56E",
7
+ prefix: "gxh",
8
+ isShowPwd: false,
9
+ userPlaceholder: "输入您的用户名",
10
+ pwdPlaceholder: "输入您的密码",
11
+ menu: ["立即注册", "忘记密码?"],
12
+ customUserValidator: () => ({}),
13
+ customPwdValidator: () => ({}),
14
+ userNumValidator: () => ({}),
15
+ pwdNumValidator: () => ({
16
+ min: 6,
17
+ max: 20,
18
+ message: "长度在6-20个字符之间",
19
+ trigger: ["blur", "change"]
20
+ }),
21
+ customPhoneValidator: () => ({
22
+ // 自定义验证函数,见上说明
23
+ validator: (rule, value, callback) => {
24
+ // 上面有说,返回true表示校验通过,返回false表示不通过
25
+ return /^[1][0-9]{10}$/.test(value);
26
+ },
27
+ message: "手机号码不正确",
28
+ trigger: ["change", "blur"]
29
+ })
30
+ };
31
+
32
+ export default defaultProps;
@@ -0,0 +1,60 @@
1
+ export default interface IProps {
2
+ /**
3
+ * @description 登录logo
4
+ * */
5
+ logo?: string;
6
+ /**
7
+ * @description 登录类型:可选:1-用户密码登录、2-手机验证码登录、其他-两者都可以
8
+ * */
9
+ loginType?: number | string;
10
+ /**
11
+ * @description 主题颜色
12
+ * */
13
+ themeColor?: string;
14
+ /**
15
+ * @description 浏览器缓存名称前缀
16
+ * */
17
+ prefix?: string;
18
+ /**
19
+ * @description 是否需要显示密码操作
20
+ * */
21
+ isShowPwd?: boolean;
22
+ /**
23
+ * @description 用户输入框占位提示
24
+ * */
25
+ userPlaceholder?: string;
26
+ /**
27
+ * @description 密码输入框占位提示
28
+ * */
29
+ pwdPlaceholder?: string;
30
+ /**
31
+ * @description 底部小菜单
32
+ * */
33
+ menu?: string[];
34
+ /**
35
+ * @description 自定义用户名效验
36
+ * customUserValidator: {
37
+ * validator: (rule, value, callback) => {
38
+ * },
39
+ * message: '提示信息',
40
+ * trigger: ['change','blur'],
41
+ * }
42
+ * */
43
+ customUserValidator?: Record<string, any>;
44
+ /**
45
+ * @description 自定义密码效验
46
+ * */
47
+ customPwdValidator?: Record<string, any>;
48
+ /**
49
+ * @description 用户名输入数量校验
50
+ * */
51
+ userNumValidator?: Record<string, any>;
52
+ /**
53
+ * @description 密码输入数量校验
54
+ * */
55
+ pwdNumValidator?: Record<string, any>;
56
+ /**
57
+ * @description 自定义手机效验规则
58
+ * */
59
+ customPhoneValidator?: Record<string, any>;
60
+ }
@@ -0,0 +1,240 @@
1
+ <template>
2
+ <HyPopup
3
+ mode="center"
4
+ :zoom="zoom"
5
+ :show="show"
6
+ :customStyle="{
7
+ borderRadius: '6px',
8
+ overflow: 'hidden',
9
+ marginTop: `-${addUnit(negativeTop)}`
10
+ }"
11
+ :closeOnClickOverlay="closeOnClickOverlay"
12
+ :safeAreaInsetBottom="false"
13
+ :duration="400"
14
+ @click="clickHandler"
15
+ >
16
+ <view
17
+ class="hy-modal"
18
+ :style="{
19
+ width: addUnit(width)
20
+ }"
21
+ >
22
+ <view class="hy-modal__title" v-if="title">{{ title }}</view>
23
+ <view
24
+ class="hy-modal__content"
25
+ :style="{
26
+ paddingTop: `${title ? 12 : 25}px`
27
+ }"
28
+ >
29
+ <slot>
30
+ <text class="hy-modal__content__text">
31
+ {{ content }}
32
+ </text>
33
+ </slot>
34
+ </view>
35
+ <view
36
+ class="hy-modal__button-group--confirm-button"
37
+ v-if="$slots.confirmButton"
38
+ >
39
+ <slot name="confirmButton"></slot>
40
+ </view>
41
+ <template v-else>
42
+ <view
43
+ class="hy-modal__button-group"
44
+ :style="{
45
+ flexDirection: buttonReverse ? 'row-reverse' : 'row'
46
+ }"
47
+ >
48
+ <view
49
+ class="hy-modal__button-group__wrapper u-modal__button-group__wrapper--cancel"
50
+ :hover-stay-time="150"
51
+ hover-class="hy-modal__button-group__wrapper--hover"
52
+ :class="[
53
+ showCancelButton &&
54
+ !showConfirmButton &&
55
+ 'hy-modal__button-group__wrapper--only-cancel'
56
+ ]"
57
+ v-if="showCancelButton"
58
+ @tap.stop="cancelHandler"
59
+ >
60
+ <text
61
+ class="hy-modal__button-group__wrapper__text"
62
+ :style="{
63
+ color: cancelColor
64
+ }"
65
+ >{{ cancelText }}</text
66
+ >
67
+ </view>
68
+ <view
69
+ class="hy-modal__button-group__wrapper--line"
70
+ v-if="showConfirmButton && showCancelButton"
71
+ ></view>
72
+ <view
73
+ class="hy-modal__button-group__wrapper u-modal__button-group__wrapper--confirm"
74
+ :hover-stay-time="150"
75
+ hover-class="hy-modal__button-group__wrapper--hover"
76
+ :class="[
77
+ !showCancelButton &&
78
+ showConfirmButton &&
79
+ 'hy-modal__button-group__wrapper--only-confirm'
80
+ ]"
81
+ v-if="showConfirmButton"
82
+ @tap="confirmHandler"
83
+ >
84
+ <HyIcon
85
+ v-if="loading"
86
+ :name="IconConfig.LOADING"
87
+ :isRotate="loading"
88
+ ></HyIcon>
89
+ <text
90
+ v-else
91
+ class="hy-modal__button-group__wrapper__text"
92
+ :style="{
93
+ color: confirmColor
94
+ }"
95
+ >{{ confirmText }}</text
96
+ >
97
+ </view>
98
+ </view>
99
+ </template>
100
+ </view>
101
+ </HyPopup>
102
+ </template>
103
+
104
+ <script setup lang="ts">
105
+ import { ref, toRefs, watch } from "vue";
106
+ import defaultProps from "./props";
107
+ import IProps from "./typing";
108
+ import { addUnit } from "../../utils";
109
+ import { IconConfig } from "../../config";
110
+
111
+ // 组件
112
+ import HyIcon from "../hy-icon/hy-icon.vue";
113
+ import HyPopup from "../hy-popup/hy-popup.vue";
114
+
115
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
116
+ const { show, asyncClose, closeOnClickOverlay } = toRefs(props);
117
+ const emit = defineEmits(["confirm", "cancel", "close", "update:show"]);
118
+
119
+ const loading = ref<boolean>(false);
120
+
121
+ watch(
122
+ () => show.value,
123
+ (newValue) => {
124
+ if (newValue && loading.value) loading.value = false;
125
+ }
126
+ );
127
+
128
+ /**
129
+ * @description 点击确定按钮
130
+ * */
131
+ const confirmHandler = () => {
132
+ // 如果配置了异步关闭,将按钮值为loading状态
133
+ if (asyncClose.value) {
134
+ loading.value = true;
135
+ } else {
136
+ emit("update:show", false);
137
+ }
138
+ emit("confirm");
139
+ };
140
+
141
+ /**
142
+ * @description 点击取消按钮
143
+ * */
144
+ const cancelHandler = () => {
145
+ emit("update:show", false);
146
+ emit("cancel");
147
+ };
148
+
149
+ /**
150
+ * @description 点击遮罩
151
+ * */
152
+ const clickHandler = () => {
153
+ if (closeOnClickOverlay.value) {
154
+ emit("update:show", false);
155
+ emit("close");
156
+ }
157
+ };
158
+ </script>
159
+
160
+ <style lang="scss" scoped>
161
+ @import "../../libs/css/mixin.scss";
162
+ @import "../../theme.scss";
163
+
164
+ $u-modal-border-radius: 6px;
165
+
166
+ .hy-modal {
167
+ width: 650rpx;
168
+ border-radius: $hy-border-radius-base;
169
+ overflow: hidden;
170
+
171
+ &__title {
172
+ display: flex;
173
+ flex-direction: column;
174
+ justify-content: center;
175
+ align-items: center;
176
+ font-size: 16px;
177
+ font-weight: bold;
178
+ color: $hy-color-title;
179
+ text-align: center;
180
+ padding-top: 25px;
181
+ }
182
+
183
+ &__content {
184
+ padding: 12px 25px 25px 25px;
185
+ @include flex;
186
+ justify-content: center;
187
+
188
+ &__text {
189
+ text-align: v-bind(contentTextAlign);
190
+ font-size: 15px;
191
+ color: $hy-text-color-grey;
192
+ flex: 1;
193
+ }
194
+ }
195
+
196
+ &__button-group {
197
+ border-top: $hy-border-line;
198
+ @include flex;
199
+
200
+ &--confirm-button {
201
+ flex-direction: column;
202
+ padding: 0 25px 15px 25px;
203
+ }
204
+
205
+ &__wrapper {
206
+ flex: 1;
207
+ @include flex;
208
+ justify-content: center;
209
+ align-items: center;
210
+ height: 48px;
211
+
212
+ &--line {
213
+ background: $hy-text-color-light;
214
+ width: 1px;
215
+ height: 48px;
216
+ }
217
+
218
+ &--confirm,
219
+ &--only-cancel {
220
+ border-bottom-right-radius: $hy-border-radius-base;
221
+ }
222
+
223
+ &--cancel,
224
+ &--only-confirm {
225
+ border-bottom-left-radius: $hy-border-radius-base;
226
+ }
227
+
228
+ &--hover {
229
+ background-color: $hy-bg-color-grey;
230
+ }
231
+
232
+ &__text {
233
+ color: $hy-color-subtitle;
234
+ font-size: 16px;
235
+ text-align: center;
236
+ }
237
+ }
238
+ }
239
+ }
240
+ </style>
@@ -0,0 +1,24 @@
1
+ import IProps from "./typing";
2
+ import { ColorConfig } from "../../config";
3
+
4
+ const defaultProps: IProps = {
5
+ show: false,
6
+ title: "",
7
+ content: "",
8
+ confirmText: "确认",
9
+ cancelText: "取消",
10
+ showConfirmButton: true,
11
+ showCancelButton: false,
12
+ confirmColor: ColorConfig.primary,
13
+ cancelColor: "#606266",
14
+ buttonReverse: false,
15
+ zoom: true,
16
+ asyncClose: false,
17
+ closeOnClickOverlay: false,
18
+ negativeTop: 0,
19
+ width: "650rpx",
20
+ confirmButtonShape: "",
21
+ contentTextAlign: "left"
22
+ };
23
+
24
+ export default defaultProps;
@@ -0,0 +1,70 @@
1
+ export default interface IProps {
2
+ /**
3
+ * @description 是否显示模态框,请赋值给show (默认 false )
4
+ * */
5
+ show: boolean;
6
+ /**
7
+ * @description 标题内容
8
+ * */
9
+ title?: string;
10
+ /**
11
+ * @description 模态框内容,如传入slot内容,则此参数无效
12
+ * */
13
+ content?: string;
14
+ /**
15
+ * @description 确认按钮的文字 (默认 '确认' )
16
+ * */
17
+ confirmText?: string;
18
+ /**
19
+ * @description 取消按钮的文字 (默认 '取消' )
20
+ * */
21
+ cancelText?: string;
22
+ /**
23
+ * @description 是否显示确认按钮 (默认 true )
24
+ * */
25
+ showConfirmButton?: boolean;
26
+ /**
27
+ * @description 是否显示取消按钮 (默认 false )
28
+ * */
29
+ showCancelButton?: boolean;
30
+ /**
31
+ * @description 确认按钮的颜色 (默认 '#2979ff' )
32
+ * */
33
+ confirmColor?: string;
34
+ /**
35
+ * @description 取消按钮的颜色 (默认 '#606266' )
36
+ * */
37
+ cancelColor?: string;
38
+ /**
39
+ * @description 对调确认和取消的位置 (默认 false )
40
+ * */
41
+ buttonReverse?: boolean;
42
+ /**
43
+ * @description 是否开启缩放模式 (默认 true )
44
+ * */
45
+ zoom?: boolean;
46
+ /**
47
+ * @description 是否异步关闭,只对确定按钮有效,见上方说明 (默认 false )
48
+ * */
49
+ asyncClose?: boolean;
50
+ /**
51
+ * @description 是否允许点击遮罩关闭Modal (默认 false )
52
+ * */
53
+ closeOnClickOverlay?: boolean;
54
+ /**
55
+ * @description 往上偏移的值,给一个负的margin-top,往上偏移,避免和键盘重合的情况,单位任意,数值则默认为px单位 (默认 0 )
56
+ * */
57
+ negativeTop?: number;
58
+ /**
59
+ * @description modal宽度,不支持百分比,可以数值,px,rpx单位 (默认 '650rpx' )
60
+ * */
61
+ width?: string | number;
62
+ /**
63
+ * @description 确认按钮的样式,如设置,将不会显示取消按钮
64
+ * */
65
+ confirmButtonShape?: HyApp.ShapeType;
66
+ /**
67
+ * @description 文案对齐方式
68
+ * */
69
+ contentTextAlign?: HyApp.LeftRightType | "center";
70
+ }