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
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
## 使用文档地址
|
|
2
|
+
[华玥组件库](https://gxh-component.vercel.app/)
|
|
3
|
+
|
|
4
|
+
## 安装教程
|
|
5
|
+
|
|
6
|
+
```angular2html
|
|
7
|
+
<!--只支持vue3+uniapp的项目-->
|
|
8
|
+
pnpm install hy-app
|
|
9
|
+
|
|
10
|
+
node版本 >= 16.14.*
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 如何再div里面使用方法
|
|
14
|
+
```javascript
|
|
15
|
+
// main.ts使用方法
|
|
16
|
+
import { globalRegister } from "hy-app";
|
|
17
|
+
import { createSSRApp } from "vue";
|
|
18
|
+
export function createApp () {
|
|
19
|
+
const app = createSSRApp(App);
|
|
20
|
+
app.use(globalRegister);
|
|
21
|
+
return {
|
|
22
|
+
app,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
```vue
|
|
27
|
+
<template>
|
|
28
|
+
<!-- 获取0-10之间的随机数 -->
|
|
29
|
+
<div>{{ $hy.random(1,10) }}</div>
|
|
30
|
+
</template>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 在小程序里面配置全局组件
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"easycom": {
|
|
37
|
+
"custom": {
|
|
38
|
+
"^hy-(.*)": "hy-app/components/hy-$1/hy-$1.vue"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
package/api/http.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HttpRequestConfig,
|
|
3
|
+
HttpInterceptorManager,
|
|
4
|
+
HttpResponse
|
|
5
|
+
} from "../typing";
|
|
6
|
+
import { objectToUrlParams } from "../utils";
|
|
7
|
+
|
|
8
|
+
export default class Http {
|
|
9
|
+
/**
|
|
10
|
+
* 默认请求配置
|
|
11
|
+
*/
|
|
12
|
+
config: HttpRequestConfig = {
|
|
13
|
+
baseURL: "",
|
|
14
|
+
url: "",
|
|
15
|
+
data: {},
|
|
16
|
+
dataType: "json",
|
|
17
|
+
header: {},
|
|
18
|
+
method: "POST",
|
|
19
|
+
responseType: "text",
|
|
20
|
+
timeout: 10000
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @description 拦截器
|
|
25
|
+
*/
|
|
26
|
+
interceptor = {
|
|
27
|
+
/**
|
|
28
|
+
* @description 请求拦截 请求配置
|
|
29
|
+
* @param config
|
|
30
|
+
*/
|
|
31
|
+
request: (config: HttpRequestConfig) => {
|
|
32
|
+
if (config) {
|
|
33
|
+
this.requestBefore(config);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* @description 响应拦截
|
|
38
|
+
* @param success 成功响应
|
|
39
|
+
* @param fail 失败响应
|
|
40
|
+
*/
|
|
41
|
+
response: (
|
|
42
|
+
success: (response: HttpResponse) => any,
|
|
43
|
+
fail: (error: HttpResponse) => any
|
|
44
|
+
) => {
|
|
45
|
+
if (success) {
|
|
46
|
+
this.responseSuccess = success;
|
|
47
|
+
}
|
|
48
|
+
if (fail) {
|
|
49
|
+
this.responseFail = fail;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @description 请求拦截
|
|
56
|
+
* @param config 请求配置
|
|
57
|
+
*/
|
|
58
|
+
requestBefore(config: HttpRequestConfig) {
|
|
59
|
+
return config;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @description 成功响应
|
|
64
|
+
* @param response
|
|
65
|
+
*/
|
|
66
|
+
responseSuccess(response: UniNamespace.RequestSuccessCallbackResult) {
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @description 失败响应
|
|
72
|
+
* @param response
|
|
73
|
+
*/
|
|
74
|
+
responseFail(response: UniNamespace.GeneralCallbackResult) {
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @description uni异步请求
|
|
80
|
+
* @param options 请求配置
|
|
81
|
+
*/
|
|
82
|
+
async request(options: Record<string, any>) {
|
|
83
|
+
options.url = this.config.baseURL + options.url || this.config.url;
|
|
84
|
+
options.data = options.data || this.config.data;
|
|
85
|
+
options.header = options.header || this.config.header;
|
|
86
|
+
options.method = options.method || this.config.method;
|
|
87
|
+
options.responseType = options.responseType || this.config.responseType;
|
|
88
|
+
options.timeout = options.timeout || this.config.timeout;
|
|
89
|
+
return new Promise<any>((resolve, reject) => {
|
|
90
|
+
options = this.requestBefore(options);
|
|
91
|
+
uni.request({
|
|
92
|
+
url: options.url,
|
|
93
|
+
data: options.data,
|
|
94
|
+
header: options.header,
|
|
95
|
+
method: options.method,
|
|
96
|
+
timeout: options.timeout,
|
|
97
|
+
success: (response: UniNamespace.RequestSuccessCallbackResult) => {
|
|
98
|
+
resolve(this.responseSuccess(response));
|
|
99
|
+
},
|
|
100
|
+
fail: (error: UniNamespace.GeneralCallbackResult) => {
|
|
101
|
+
reject(this.responseFail(error));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* post请求
|
|
109
|
+
* @param url 请求地址
|
|
110
|
+
* @param params 请求JSON参数
|
|
111
|
+
* @param options 请求配置
|
|
112
|
+
*/
|
|
113
|
+
post(url: string, params?: any, options?: Record<string, any>) {
|
|
114
|
+
return this.request({
|
|
115
|
+
url: url,
|
|
116
|
+
method: "POST",
|
|
117
|
+
data: params,
|
|
118
|
+
...options
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* get请求
|
|
124
|
+
* @param url 请求地址
|
|
125
|
+
* @param params URL查询参数
|
|
126
|
+
* @param options 请求配置
|
|
127
|
+
*/
|
|
128
|
+
get(url: string, params?: any, options?: Record<string, any>) {
|
|
129
|
+
if (params) {
|
|
130
|
+
url += "?" + objectToUrlParams(params);
|
|
131
|
+
}
|
|
132
|
+
return this.request({
|
|
133
|
+
url: url,
|
|
134
|
+
method: "GET",
|
|
135
|
+
...options
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
package/api/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./http";
|
package/common/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./versionControl";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export const appInit = {
|
|
2
|
+
data() {
|
|
3
|
+
return {
|
|
4
|
+
version: ""
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
/**
|
|
8
|
+
* app更新下载版本
|
|
9
|
+
* @param version 最新版本号
|
|
10
|
+
* @param description 版本描述
|
|
11
|
+
* @param url 最新版本下载链接
|
|
12
|
+
* @returns
|
|
13
|
+
* */
|
|
14
|
+
updateVersion(content):void {
|
|
15
|
+
const { version, description, url } = content
|
|
16
|
+
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
|
17
|
+
this.version = widgetInfo.version as string
|
|
18
|
+
let _this = this
|
|
19
|
+
|
|
20
|
+
// 1代表app新包版本号大于本地版本号
|
|
21
|
+
if (this.compareVersion(version, this.version) === 1) {
|
|
22
|
+
uni.showModal({
|
|
23
|
+
title: `发现新版本V${version}`,
|
|
24
|
+
content: `更新内容:${description}`,
|
|
25
|
+
success: function (res1) {
|
|
26
|
+
if (res1.confirm) {
|
|
27
|
+
_this.downloadApp(url)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* 进行版本更新检查操作
|
|
36
|
+
* */
|
|
37
|
+
compareVersion(version1: string, version2: string) {
|
|
38
|
+
const newVersion1 = `${version1}`.split('.').length < 3 ? `${version1}`.concat('.0') : `${version1}`;
|
|
39
|
+
const newVersion2 = `${version2}`.split('.').length < 3 ? `${version2}`.concat('.0') : `${version2}`;
|
|
40
|
+
|
|
41
|
+
return this.isUpdateVersion(newVersion1 ,newVersion2);
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* 计算版本号大小,转化大小
|
|
45
|
+
* */
|
|
46
|
+
toNum(a: number | string){
|
|
47
|
+
const c = a.toString().split('.');
|
|
48
|
+
const num_place = ["", "0", "00", "000", "0000"],
|
|
49
|
+
r = num_place.reverse();
|
|
50
|
+
for (let i = 0; i < c.length; i++){
|
|
51
|
+
const len=c[i].length;
|
|
52
|
+
c[i]=r[len]+c[i];
|
|
53
|
+
}
|
|
54
|
+
return c.join('');
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* 检测版本号是否需要更新
|
|
58
|
+
* */
|
|
59
|
+
isUpdateVersion(a: number | string, b: number | string) {
|
|
60
|
+
const numA = this.toNum(a);
|
|
61
|
+
const numB = this.toNum(b);
|
|
62
|
+
return numA > numB ? 1 : numA < numB ? -1 : 0;
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* 下载新的app版本
|
|
66
|
+
* */
|
|
67
|
+
downloadApp(downloadUrl: string) {
|
|
68
|
+
uni.showLoading({
|
|
69
|
+
title: '更新中……'
|
|
70
|
+
})
|
|
71
|
+
uni.downloadFile({
|
|
72
|
+
// 存放最新安装包的地址
|
|
73
|
+
url: downloadUrl,
|
|
74
|
+
success: (downloadResult) => {
|
|
75
|
+
uni.hideLoading();
|
|
76
|
+
if (downloadResult.statusCode === 200) {
|
|
77
|
+
plus.runtime.install(downloadResult.tempFilePath,{
|
|
78
|
+
force: false
|
|
79
|
+
}, function() {
|
|
80
|
+
plus.runtime.restart();
|
|
81
|
+
}, function(e) {
|
|
82
|
+
uni.showToast({
|
|
83
|
+
title: "安装失败",
|
|
84
|
+
icon: "none"
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
uni.showToast({
|
|
89
|
+
title: "更新失败",
|
|
90
|
+
icon: "none"
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
fail: (err) => {
|
|
95
|
+
uni.showToast({
|
|
96
|
+
title: "下载失败",
|
|
97
|
+
icon: "none"
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dialog dialog-shade">
|
|
3
|
+
<view class="dialog-container">
|
|
4
|
+
<u-image
|
|
5
|
+
class="dialog-container__icon"
|
|
6
|
+
bgColor="transparent"
|
|
7
|
+
:src="icon"
|
|
8
|
+
:width="140"
|
|
9
|
+
:height="140"
|
|
10
|
+
></u-image>
|
|
11
|
+
<view class="dialog-container__title">{{ title }}</view>
|
|
12
|
+
<view class="dialog-container__content">{{ content }}</view>
|
|
13
|
+
|
|
14
|
+
<view class="dialog-container__btn">
|
|
15
|
+
<u-button
|
|
16
|
+
v-if="showCancel"
|
|
17
|
+
:text="cancelText"
|
|
18
|
+
:color="cancelColor"
|
|
19
|
+
:shape="shape"
|
|
20
|
+
size="large"
|
|
21
|
+
@click="result(false)"
|
|
22
|
+
></u-button>
|
|
23
|
+
<u-button
|
|
24
|
+
:text="confirmText"
|
|
25
|
+
:color="confirmColor"
|
|
26
|
+
:shape="shape"
|
|
27
|
+
size="large"
|
|
28
|
+
@click="result(true)"
|
|
29
|
+
></u-button>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts" setup>
|
|
36
|
+
/**
|
|
37
|
+
* @用途
|
|
38
|
+
* @author Pino
|
|
39
|
+
* @创建时间 2023-01-11 15:19
|
|
40
|
+
**/
|
|
41
|
+
import dialog from "./index";
|
|
42
|
+
|
|
43
|
+
export interface DialogParam {
|
|
44
|
+
icon?: string;
|
|
45
|
+
title?: string;
|
|
46
|
+
content?: string;
|
|
47
|
+
confirmText?: string;
|
|
48
|
+
cancelText?: string;
|
|
49
|
+
shape?: "circle" | "square";
|
|
50
|
+
confirmColor?: string;
|
|
51
|
+
cancelColor?: string;
|
|
52
|
+
showCancel?: boolean;
|
|
53
|
+
result?: Function; // 回调用户操作结果
|
|
54
|
+
}
|
|
55
|
+
const props = withDefaults(defineProps<DialogParam>(), {
|
|
56
|
+
icon: "https://pic1.imgdb.cn/item/67a74cbdd0e0a243d4fd160b.png",
|
|
57
|
+
title: "提示",
|
|
58
|
+
content: "",
|
|
59
|
+
confirmText: "确认",
|
|
60
|
+
cancelText: "取消",
|
|
61
|
+
shape: "circle",
|
|
62
|
+
confirmColor: "#906FFE",
|
|
63
|
+
cancelColor: "",
|
|
64
|
+
showCancel: false,
|
|
65
|
+
result: () => {}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const close = () => dialog.close();
|
|
69
|
+
|
|
70
|
+
const result = (isSure: boolean) => {
|
|
71
|
+
console.log(props);
|
|
72
|
+
console.log(props.result);
|
|
73
|
+
if (props.result)
|
|
74
|
+
props.result({
|
|
75
|
+
confirm: isSure,
|
|
76
|
+
cancel: isSure
|
|
77
|
+
});
|
|
78
|
+
close();
|
|
79
|
+
};
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<style lang="scss" scoped>
|
|
83
|
+
.dialog {
|
|
84
|
+
position: fixed;
|
|
85
|
+
z-index: 999999;
|
|
86
|
+
&-shade {
|
|
87
|
+
top: 0;
|
|
88
|
+
width: 100%;
|
|
89
|
+
height: 100%;
|
|
90
|
+
background: rgba(0, 0, 0, 0.5);
|
|
91
|
+
}
|
|
92
|
+
&-container {
|
|
93
|
+
position: absolute;
|
|
94
|
+
transform: translate(-50%, -50%);
|
|
95
|
+
left: 50%;
|
|
96
|
+
top: 50%;
|
|
97
|
+
border-radius: 40px;
|
|
98
|
+
background: #ffffff;
|
|
99
|
+
width: 90%;
|
|
100
|
+
//height: 300px;
|
|
101
|
+
padding: 40px 20px;
|
|
102
|
+
text-align: center;
|
|
103
|
+
|
|
104
|
+
&__icon {
|
|
105
|
+
position: absolute;
|
|
106
|
+
top: -100px;
|
|
107
|
+
left: 50%;
|
|
108
|
+
transform: translateX(-50%);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&__title {
|
|
112
|
+
margin: 20px 0;
|
|
113
|
+
font-size: 50rpx;
|
|
114
|
+
}
|
|
115
|
+
&__content {
|
|
116
|
+
margin: 20px 0;
|
|
117
|
+
font-size: 30rpx;
|
|
118
|
+
color: #c3d8db;
|
|
119
|
+
}
|
|
120
|
+
&__btn {
|
|
121
|
+
display: flex;
|
|
122
|
+
.u-button {
|
|
123
|
+
margin: 30px 10px 20px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createApp } from "vue";
|
|
2
|
+
import AlertDialogCom, { DialogParam } from "./TheDialog.vue";
|
|
3
|
+
import { ResultParam } from "../../typing";
|
|
4
|
+
|
|
5
|
+
export default class Dialog {
|
|
6
|
+
private static mountNode: HTMLElement | null = null;
|
|
7
|
+
|
|
8
|
+
public static show(param: DialogParam) {
|
|
9
|
+
let app = createApp(AlertDialogCom, { ...param });
|
|
10
|
+
this.mountNode = document.createElement("div");
|
|
11
|
+
app.mount(this.mountNode);
|
|
12
|
+
document.body.appendChild(this.mountNode);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// await用法
|
|
16
|
+
// let res = await DialogAialog.showByAwait({
|
|
17
|
+
// title: '提示',
|
|
18
|
+
// content: '确定要作废该条订单吗?',
|
|
19
|
+
// })
|
|
20
|
+
// if (res.confirm) {
|
|
21
|
+
//
|
|
22
|
+
// } else if (res.cancle) {
|
|
23
|
+
// console.log('web', '用户取消')
|
|
24
|
+
// }
|
|
25
|
+
public static showByAwait(param: DialogParam): Promise<ResultParam> {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
param.result = (res: ResultParam) => resolve(res);
|
|
28
|
+
this.show(param);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static close() {
|
|
33
|
+
if (!this.mountNode) return;
|
|
34
|
+
document.body.removeChild(this.mountNode);
|
|
35
|
+
this.mountNode = null;
|
|
36
|
+
// console.log('close', 'DialogAialog已销毁')
|
|
37
|
+
}
|
|
38
|
+
}
|