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,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
+ <!-- &lt;!&ndash;账户输入&ndash;&gt;-->
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
+ <!-- &lt;!&ndash; #ifndef APP-PLUS-NVUE &ndash;&gt;-->
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
+ <!-- &lt;!&ndash; #endif &ndash;&gt;-->
103
+ <!-- </u-input>-->
104
+ <!-- </u-form-item>-->
105
+
106
+ <!-- &lt;!&ndash;密码输入&ndash;&gt;-->
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
+ <!-- &lt;!&ndash; #ifndef APP-PLUS-NVUE &ndash;&gt;-->
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
+ <!-- &lt;!&ndash; #endif &ndash;&gt;-->
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>