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,18 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
list: [],
|
|
5
|
+
containerHeight: "100%",
|
|
6
|
+
itemHeight: 50,
|
|
7
|
+
marginBottom: 10,
|
|
8
|
+
padding: 10,
|
|
9
|
+
borderRadius: "3px",
|
|
10
|
+
background: "transparent",
|
|
11
|
+
border: false,
|
|
12
|
+
line: 1,
|
|
13
|
+
keyField: "id",
|
|
14
|
+
load: "loadMore",
|
|
15
|
+
showDivider: true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default defaultProps;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export default interface IProps {
|
|
2
|
+
/**
|
|
3
|
+
* @description 数据列表
|
|
4
|
+
* */
|
|
5
|
+
list: (AnyObject | string)[];
|
|
6
|
+
/**
|
|
7
|
+
* @description 容器高度,必须给个高度,否则加载全部数据
|
|
8
|
+
* */
|
|
9
|
+
containerHeight: string;
|
|
10
|
+
/**
|
|
11
|
+
* @description 子容器的高度,必须和内容一致,否则计算有问题
|
|
12
|
+
* */
|
|
13
|
+
itemHeight?: number | string;
|
|
14
|
+
/**
|
|
15
|
+
* @description 子容器的内边距
|
|
16
|
+
* */
|
|
17
|
+
padding?: number | string;
|
|
18
|
+
/**
|
|
19
|
+
* @description 子容器的底部,会计算到容器内
|
|
20
|
+
* */
|
|
21
|
+
marginBottom?: number | string;
|
|
22
|
+
/**
|
|
23
|
+
* @description 子容器的圆角,单位px
|
|
24
|
+
* */
|
|
25
|
+
borderRadius?: number | string;
|
|
26
|
+
/**
|
|
27
|
+
* @description 容器背景色
|
|
28
|
+
* */
|
|
29
|
+
background?: string;
|
|
30
|
+
/**
|
|
31
|
+
* @description 是否显示边框(默认false)
|
|
32
|
+
* */
|
|
33
|
+
border?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @description 展示几列
|
|
36
|
+
* */
|
|
37
|
+
line?: number;
|
|
38
|
+
/**
|
|
39
|
+
* @description 加载状态
|
|
40
|
+
* */
|
|
41
|
+
load?: "loadMore" | "loading" | "noMore";
|
|
42
|
+
/**
|
|
43
|
+
* @description 每一项的唯一标识key
|
|
44
|
+
* */
|
|
45
|
+
keyField?: string;
|
|
46
|
+
/**
|
|
47
|
+
* @description 显示底部加载状态
|
|
48
|
+
* */
|
|
49
|
+
showDivider?: boolean;
|
|
50
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="user-login">
|
|
3
|
+
<u-form
|
|
4
|
+
:model="phoneForm"
|
|
5
|
+
ref="formRef"
|
|
6
|
+
:rules="phoneRules"
|
|
7
|
+
labelWidth="30"
|
|
8
|
+
>
|
|
9
|
+
<!--手机号输入-->
|
|
10
|
+
<u-form-item prop="phone">
|
|
11
|
+
<u-input
|
|
12
|
+
v-model="phoneForm.phone"
|
|
13
|
+
placeholder="请输入手机号"
|
|
14
|
+
:clearable="true"
|
|
15
|
+
border="bottom"
|
|
16
|
+
>
|
|
17
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
18
|
+
<template #prefix>
|
|
19
|
+
<u-icon name="phone" :color="themeColor"></u-icon>
|
|
20
|
+
</template>
|
|
21
|
+
<!-- #endif -->
|
|
22
|
+
</u-input>
|
|
23
|
+
</u-form-item>
|
|
24
|
+
|
|
25
|
+
<!--验证码输入-->
|
|
26
|
+
<u-form-item prop="code">
|
|
27
|
+
<u-input
|
|
28
|
+
v-model="phoneForm.code"
|
|
29
|
+
border="bottom"
|
|
30
|
+
placeholder="请填写验证码"
|
|
31
|
+
:color="themeColor"
|
|
32
|
+
>
|
|
33
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
34
|
+
<template #prefix>
|
|
35
|
+
<u-icon name="fingerprint" :color="themeColor"></u-icon>
|
|
36
|
+
</template>
|
|
37
|
+
<!-- #endif -->
|
|
38
|
+
</u-input>
|
|
39
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
40
|
+
<template #right>
|
|
41
|
+
<u-button
|
|
42
|
+
text="获取验证码"
|
|
43
|
+
:color="themeColor"
|
|
44
|
+
size="mini"
|
|
45
|
+
></u-button>
|
|
46
|
+
</template>
|
|
47
|
+
<!-- #endif -->
|
|
48
|
+
</u-form-item>
|
|
49
|
+
</u-form>
|
|
50
|
+
</view>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
import { reactive, ref } from "vue";
|
|
55
|
+
import { storeToRefs } from "pinia";
|
|
56
|
+
import { useUserInfo } from "../../store";
|
|
57
|
+
|
|
58
|
+
interface IProps {
|
|
59
|
+
themeColor: string;
|
|
60
|
+
customPhoneValidator: Record<string, any>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const props = withDefaults(defineProps<IProps>(), {
|
|
64
|
+
themeColor: "",
|
|
65
|
+
customPhoneValidator: () => ({})
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const userInfoStore = useUserInfo();
|
|
69
|
+
const { phoneForm } = storeToRefs(userInfoStore);
|
|
70
|
+
const formRef = ref(null);
|
|
71
|
+
|
|
72
|
+
const phoneRules = reactive({
|
|
73
|
+
phone: [
|
|
74
|
+
{
|
|
75
|
+
required: true,
|
|
76
|
+
message: "请先输入手机号",
|
|
77
|
+
// 可以单个或者同时写两个触发验证方式
|
|
78
|
+
trigger: ["change"]
|
|
79
|
+
},
|
|
80
|
+
props.customPhoneValidator
|
|
81
|
+
],
|
|
82
|
+
code: [
|
|
83
|
+
{
|
|
84
|
+
type: "string",
|
|
85
|
+
required: true,
|
|
86
|
+
message: "请输入验证码",
|
|
87
|
+
// 可以单个或者同时写两个触发验证方式
|
|
88
|
+
trigger: ["blur", "change"]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 登录效验
|
|
95
|
+
* */
|
|
96
|
+
const loginFn = () => {
|
|
97
|
+
return new Promise((resolve) => {
|
|
98
|
+
formRef.value.validate().then((res) => {
|
|
99
|
+
resolve();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
defineExpose({
|
|
104
|
+
loginFn
|
|
105
|
+
});
|
|
106
|
+
</script>
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="user-login">
|
|
3
|
+
<HyForm ref="form_1Ref" :columns="userColumns" :formData="userForm">
|
|
4
|
+
<template #user="{ record, errorStyle }">
|
|
5
|
+
<HyInput
|
|
6
|
+
v-model="userForm.name"
|
|
7
|
+
:placeholder="userPlaceholder"
|
|
8
|
+
:clearable="true"
|
|
9
|
+
border="bottom"
|
|
10
|
+
:customStyle="errorStyle"
|
|
11
|
+
@change="handleChange($event, record)"
|
|
12
|
+
@blur="handleBlur($event, record)"
|
|
13
|
+
>
|
|
14
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
15
|
+
<template #prefix>
|
|
16
|
+
<HyIcon :name="IconConfig.MINE" :color="themeColor"></HyIcon>
|
|
17
|
+
</template>
|
|
18
|
+
<template #suffix>
|
|
19
|
+
<HyIcon
|
|
20
|
+
:name="
|
|
21
|
+
!showChoice
|
|
22
|
+
? IconConfig.ARROW_DOWN_FILL
|
|
23
|
+
: IconConfig.ARROW_UP_FILL
|
|
24
|
+
"
|
|
25
|
+
@tap="showChoice = !showChoice"
|
|
26
|
+
:color="themeColor"
|
|
27
|
+
></HyIcon>
|
|
28
|
+
<view class="dialog-view" v-if="showChoice && choiceList.length">
|
|
29
|
+
<view
|
|
30
|
+
class="dialog-title"
|
|
31
|
+
v-for="(item, index) in choiceList"
|
|
32
|
+
:key="index"
|
|
33
|
+
@click="btnChoiceClick(index)"
|
|
34
|
+
>
|
|
35
|
+
{{ item.user }}
|
|
36
|
+
</view>
|
|
37
|
+
</view>
|
|
38
|
+
</template>
|
|
39
|
+
<!-- #endif -->
|
|
40
|
+
</HyInput>
|
|
41
|
+
</template>
|
|
42
|
+
<template #pwd="{ record }">
|
|
43
|
+
<HyInput
|
|
44
|
+
:type="showPwd ? 'text' : 'password'"
|
|
45
|
+
v-model="userForm.pwd"
|
|
46
|
+
:placeholder="pwdPlaceholder"
|
|
47
|
+
:clearable="true"
|
|
48
|
+
border="bottom"
|
|
49
|
+
:password-icon="false"
|
|
50
|
+
>
|
|
51
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
52
|
+
<template #prefix>
|
|
53
|
+
<HyIcon :name="IconConfig.LOCK" :color="themeColor"></HyIcon>
|
|
54
|
+
</template>
|
|
55
|
+
<template v-if="isShowPwd" #suffix>
|
|
56
|
+
<HyIcon
|
|
57
|
+
size="16"
|
|
58
|
+
@click="showPasswordFn"
|
|
59
|
+
color="#c8c9cc"
|
|
60
|
+
:name="showPwd ? 'eye-fill' : 'eye-off'"
|
|
61
|
+
></HyIcon>
|
|
62
|
+
</template>
|
|
63
|
+
<!-- #endif -->
|
|
64
|
+
</HyInput>
|
|
65
|
+
</template>
|
|
66
|
+
</HyForm>
|
|
67
|
+
<!-- <u-form-->
|
|
68
|
+
<!-- :model="userForm"-->
|
|
69
|
+
<!-- ref="form_1Ref"-->
|
|
70
|
+
<!-- :rules="userRules"-->
|
|
71
|
+
<!-- labelWidth="30"-->
|
|
72
|
+
<!-- >-->
|
|
73
|
+
<!-- <!–账户输入–>-->
|
|
74
|
+
<!-- <u-form-item prop="name">-->
|
|
75
|
+
<!-- <u-input-->
|
|
76
|
+
<!-- v-model="userForm.name"-->
|
|
77
|
+
<!-- :placeholder="userPlaceholder"-->
|
|
78
|
+
<!-- :clearable="true"-->
|
|
79
|
+
<!-- border="bottom"-->
|
|
80
|
+
<!-- >-->
|
|
81
|
+
<!-- <!– #ifndef APP-PLUS-NVUE –>-->
|
|
82
|
+
<!-- <template #prefix>-->
|
|
83
|
+
<!-- <u-icon name="account" :color="themeColor"></u-icon>-->
|
|
84
|
+
<!-- </template>-->
|
|
85
|
+
<!-- <template #suffix>-->
|
|
86
|
+
<!-- <u-icon-->
|
|
87
|
+
<!-- :name="!showChoice ? 'arrow-down-fill' : 'arrow-up-fill'"-->
|
|
88
|
+
<!-- @tap="showChoice = !showChoice"-->
|
|
89
|
+
<!-- :color="themeColor"-->
|
|
90
|
+
<!-- ></u-icon>-->
|
|
91
|
+
<!-- <view class="dialog-view" v-if="showChoice && choiceList.length">-->
|
|
92
|
+
<!-- <view-->
|
|
93
|
+
<!-- class="dialog-title"-->
|
|
94
|
+
<!-- v-for="(item, index) in choiceList"-->
|
|
95
|
+
<!-- :key="index"-->
|
|
96
|
+
<!-- @click="btnChoiceClick(index)"-->
|
|
97
|
+
<!-- >-->
|
|
98
|
+
<!-- {{ item.user }}-->
|
|
99
|
+
<!-- </view>-->
|
|
100
|
+
<!-- </view>-->
|
|
101
|
+
<!-- </template>-->
|
|
102
|
+
<!-- <!– #endif –>-->
|
|
103
|
+
<!-- </u-input>-->
|
|
104
|
+
<!-- </u-form-item>-->
|
|
105
|
+
|
|
106
|
+
<!-- <!–密码输入–>-->
|
|
107
|
+
<!-- <u-form-item prop="pwd">-->
|
|
108
|
+
<!-- <u-input-->
|
|
109
|
+
<!-- :type="showPwd ? 'input' : 'password'"-->
|
|
110
|
+
<!-- v-model="userForm.pwd"-->
|
|
111
|
+
<!-- :placeholder="pwdPlaceholder"-->
|
|
112
|
+
<!-- :clearable="true"-->
|
|
113
|
+
<!-- border="bottom"-->
|
|
114
|
+
<!-- :password-icon="false"-->
|
|
115
|
+
<!-- >-->
|
|
116
|
+
<!-- <!– #ifndef APP-PLUS-NVUE –>-->
|
|
117
|
+
<!-- <template #prefix>-->
|
|
118
|
+
<!-- <u-icon name="lock" :color="themeColor"></u-icon>-->
|
|
119
|
+
<!-- </template>-->
|
|
120
|
+
<!-- <template v-if="isShowPwd" #suffix>-->
|
|
121
|
+
<!-- <u-icon-->
|
|
122
|
+
<!-- size="16"-->
|
|
123
|
+
<!-- @click="showPasswordFn"-->
|
|
124
|
+
<!-- color="#c8c9cc"-->
|
|
125
|
+
<!-- :name="showPwd ? 'eye-fill' : 'eye-off'"-->
|
|
126
|
+
<!-- ></u-icon>-->
|
|
127
|
+
<!-- </template>-->
|
|
128
|
+
<!-- <!– #endif –>-->
|
|
129
|
+
<!-- </u-input>-->
|
|
130
|
+
<!-- </u-form-item>-->
|
|
131
|
+
<!-- </u-form>-->
|
|
132
|
+
<!-- 记住密码 -->
|
|
133
|
+
<view class="mui-input-row mui-checkbox">
|
|
134
|
+
<!-- <u-checkbox-group v-model="rememberPassword" @change="checkboxChange">-->
|
|
135
|
+
<!-- <u-checkbox-->
|
|
136
|
+
<!-- label="记住密码"-->
|
|
137
|
+
<!-- name="1"-->
|
|
138
|
+
<!-- :active-color="themeColor"-->
|
|
139
|
+
<!-- ></u-checkbox>-->
|
|
140
|
+
<!-- </u-checkbox-group>-->
|
|
141
|
+
|
|
142
|
+
<HyCheckbox
|
|
143
|
+
:columns="rememberList"
|
|
144
|
+
shape="square"
|
|
145
|
+
v-model="rememberPassword"
|
|
146
|
+
@change="checkboxChange"
|
|
147
|
+
></HyCheckbox>
|
|
148
|
+
</view>
|
|
149
|
+
</view>
|
|
150
|
+
</template>
|
|
151
|
+
|
|
152
|
+
<script setup lang="ts">
|
|
153
|
+
import { ref, reactive, computed, onMounted, onUnmounted } from "vue";
|
|
154
|
+
import { onHide } from "@dcloudio/uni-app";
|
|
155
|
+
import { storeToRefs } from "pinia";
|
|
156
|
+
import { useUserInfo } from "../../store";
|
|
157
|
+
import { decryptData, encryptData } from "../../utils";
|
|
158
|
+
|
|
159
|
+
// 组件
|
|
160
|
+
import HyCheckbox from "../hy-checkbox/hy-checkbox.vue";
|
|
161
|
+
import HyForm from "../hy-form/hy-form.vue";
|
|
162
|
+
import HyInput from "../hy-input/hy-input.vue";
|
|
163
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
164
|
+
import { FormColumnsType, FormTypeEnum, IconConfig } from "@/package";
|
|
165
|
+
|
|
166
|
+
interface IProps {
|
|
167
|
+
themeColor: string;
|
|
168
|
+
prefix: string;
|
|
169
|
+
isShowPwd: boolean;
|
|
170
|
+
userPlaceholder: string;
|
|
171
|
+
pwdPlaceholder: string;
|
|
172
|
+
customUserValidator: Record<string, any>;
|
|
173
|
+
customPwdValidator: Record<string, any>;
|
|
174
|
+
userNumValidator: Record<string, any>;
|
|
175
|
+
pwdNumValidator: Record<string, any>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const props = withDefaults(defineProps<IProps>(), {
|
|
179
|
+
themeColor: "",
|
|
180
|
+
prefix: "gxh",
|
|
181
|
+
isShowPwd: false,
|
|
182
|
+
userPlaceholder: "",
|
|
183
|
+
pwdPlaceholder: "",
|
|
184
|
+
customUserValidator: () => ({}),
|
|
185
|
+
customPwdValidator: () => ({}),
|
|
186
|
+
userNumValidator: () => ({}),
|
|
187
|
+
pwdNumValidator: () => ({})
|
|
188
|
+
});
|
|
189
|
+
const emit = defineEmits(["handleHistory", "handleCheckbox"]);
|
|
190
|
+
const userInfoStore = useUserInfo();
|
|
191
|
+
const { userForm, choiceList, rememberPsw } = storeToRefs(userInfoStore);
|
|
192
|
+
|
|
193
|
+
const userColumns = reactive([
|
|
194
|
+
{
|
|
195
|
+
field: "user",
|
|
196
|
+
label: "",
|
|
197
|
+
type: FormTypeEnum.CUSTOM,
|
|
198
|
+
rules: [props.customUserValidator, props.userNumValidator]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
field: "pwd",
|
|
202
|
+
label: "",
|
|
203
|
+
type: FormTypeEnum.CUSTOM,
|
|
204
|
+
rules: [props.customUserValidator, props.pwdNumValidator]
|
|
205
|
+
}
|
|
206
|
+
]);
|
|
207
|
+
const rememberList = reactive([{ label: "记住密码", value: 1 }]);
|
|
208
|
+
const showPwd = ref<boolean>(false);
|
|
209
|
+
const showChoice = ref<boolean>(false);
|
|
210
|
+
const form_1Ref = ref<InstanceType<typeof HyForm>>();
|
|
211
|
+
// 效验用户名和密码
|
|
212
|
+
const userRules = reactive({
|
|
213
|
+
name: [
|
|
214
|
+
{
|
|
215
|
+
required: true,
|
|
216
|
+
message: "请先输入账号",
|
|
217
|
+
// 可以单个或者同时写两个触发验证方式
|
|
218
|
+
trigger: ["blur", "change"]
|
|
219
|
+
},
|
|
220
|
+
props.customUserValidator,
|
|
221
|
+
props.userNumValidator
|
|
222
|
+
],
|
|
223
|
+
pwd: [
|
|
224
|
+
{
|
|
225
|
+
required: true,
|
|
226
|
+
message: "请输入密码",
|
|
227
|
+
// 可以单个或者同时写两个触发验证方式
|
|
228
|
+
trigger: ["blur", "change"]
|
|
229
|
+
},
|
|
230
|
+
props.pwdNumValidator,
|
|
231
|
+
props.customPwdValidator
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
const rememberPassword = ref([0]);
|
|
235
|
+
const account = uni.getStorageSync(`${props.prefix}_account`);
|
|
236
|
+
const accountList = uni.getStorageSync(`${props.prefix}_choiceList`);
|
|
237
|
+
|
|
238
|
+
onMounted(() => {
|
|
239
|
+
if (!account) return;
|
|
240
|
+
const result = decryptData(account);
|
|
241
|
+
//有缓存就赋值给文本没有就清空
|
|
242
|
+
rememberPsw.value = result.rememberPsw;
|
|
243
|
+
if (account) {
|
|
244
|
+
//获取缓存的账号和密码
|
|
245
|
+
userForm.value.name = result.userName;
|
|
246
|
+
userForm.value.pwd = result.password;
|
|
247
|
+
} else {
|
|
248
|
+
userForm.value.name = "";
|
|
249
|
+
userForm.value.pwd = "";
|
|
250
|
+
}
|
|
251
|
+
if (accountList) {
|
|
252
|
+
choiceList.value = decryptData(accountList);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
onHide(() => {
|
|
257
|
+
if (!account) return;
|
|
258
|
+
//获取缓存的账号和密码
|
|
259
|
+
const { userName, password } = decryptData(account);
|
|
260
|
+
if (choiceList.value.length) {
|
|
261
|
+
// 过滤数判断是否有一样的账号
|
|
262
|
+
const filterArr = choiceList.value.filter((item) => {
|
|
263
|
+
return item.user === userName;
|
|
264
|
+
});
|
|
265
|
+
// 有一样的账号退出函数不执行下面的
|
|
266
|
+
if (filterArr.length) return;
|
|
267
|
+
}
|
|
268
|
+
// 判断是否有保存账号和密码
|
|
269
|
+
if (userName && password) {
|
|
270
|
+
// 数组前面加数据
|
|
271
|
+
choiceList.value.unshift({
|
|
272
|
+
user: userName,
|
|
273
|
+
pwd: password
|
|
274
|
+
});
|
|
275
|
+
// 数组最多只放三个账号
|
|
276
|
+
if (choiceList.value.length >= 5) {
|
|
277
|
+
choiceList.value.splice(5, 1);
|
|
278
|
+
}
|
|
279
|
+
uni.setStorageSync(
|
|
280
|
+
`${props.prefix}_choiceList`,
|
|
281
|
+
encryptData(choiceList.value)
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 登录效验
|
|
288
|
+
* */
|
|
289
|
+
const loginFn = () => {
|
|
290
|
+
return new Promise((resolve, reject) => {
|
|
291
|
+
form_1Ref.value
|
|
292
|
+
.handleSubmit()
|
|
293
|
+
.then((res) => {
|
|
294
|
+
console.log(111);
|
|
295
|
+
resolve("success" + res);
|
|
296
|
+
})
|
|
297
|
+
.catch((err) => {
|
|
298
|
+
reject("error" + err);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 勾选是否记住密码
|
|
305
|
+
* */
|
|
306
|
+
const checkboxChange = () => {
|
|
307
|
+
emit("handleCheckbox", rememberPsw.value);
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* 选择历史账号
|
|
312
|
+
* */
|
|
313
|
+
const btnChoiceClick = (index: number) => {
|
|
314
|
+
showChoice.value = false;
|
|
315
|
+
userForm.value.name = choiceList.value[index].user;
|
|
316
|
+
userForm.value.pwd = choiceList.value[index].pwd;
|
|
317
|
+
emit("handleHistory");
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* 长按操作历史账户
|
|
322
|
+
* 0-复制
|
|
323
|
+
* 1-删除
|
|
324
|
+
* */
|
|
325
|
+
const extensionFun = (index: number, username: string) => {
|
|
326
|
+
switch (index) {
|
|
327
|
+
case 0:
|
|
328
|
+
const i = choiceList.value.findIndex((item) => item.user === username);
|
|
329
|
+
choiceList.value.splice(i, 1);
|
|
330
|
+
uni.setStorageSync(
|
|
331
|
+
`${props.prefix}_choiceList`,
|
|
332
|
+
encryptData(choiceList.value)
|
|
333
|
+
);
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const showPasswordFn = () => {
|
|
341
|
+
showPwd.value = !showPwd.value;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const handleChange = (event: string, temp: FormColumnsType) => {
|
|
345
|
+
form_1Ref.value?.validateField(temp.rules, event, temp.field, "change");
|
|
346
|
+
};
|
|
347
|
+
const handleBlur = (event: string, temp: FormColumnsType) => {
|
|
348
|
+
form_1Ref.value?.validateField(temp.rules, event, temp.field, "blur");
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
defineExpose({
|
|
352
|
+
loginFn
|
|
353
|
+
});
|
|
354
|
+
</script>
|
|
355
|
+
|
|
356
|
+
<style lang="scss" scoped>
|
|
357
|
+
.user-login {
|
|
358
|
+
::v-deep .u-input__content__subfix-icon {
|
|
359
|
+
position: relative;
|
|
360
|
+
|
|
361
|
+
.dialog-view {
|
|
362
|
+
display: flex;
|
|
363
|
+
flex-direction: column;
|
|
364
|
+
justify-content: center;
|
|
365
|
+
border-radius: 20rpx;
|
|
366
|
+
border: 1rpx solid #cacaca;
|
|
367
|
+
background-color: white;
|
|
368
|
+
position: absolute;
|
|
369
|
+
overflow: hidden;
|
|
370
|
+
top: 50rpx;
|
|
371
|
+
right: 10rpx;
|
|
372
|
+
z-index: 999;
|
|
373
|
+
|
|
374
|
+
.dialog-title {
|
|
375
|
+
white-space: nowrap;
|
|
376
|
+
height: 100%;
|
|
377
|
+
color: #a6a6a6;
|
|
378
|
+
overflow: hidden;
|
|
379
|
+
font-size: 28rpx;
|
|
380
|
+
text-align: center;
|
|
381
|
+
padding: 10rpx 30rpx;
|
|
382
|
+
border-top: 1rpx solid rgba(128, 128, 128, 0.233);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.iconfont {
|
|
388
|
+
font-size: 40rpx;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
</style>
|