Commit 9ae6d647bf16e6bb3b884ae9c42af77d59fa9505

Authored by sqy
1 parent 8c3f7f22

'fix:重置密码,修复各种各样问题'

... ... @@ -8,14 +8,14 @@ VITE_PUBLIC_PATH = /
8 8 # Please note that no line breaks
9 9
10 10 # 本地
11   -# VITE_PROXY = [["/api","http://192.168.10.108:8080/api"]]
  11 +# VITE_PROXY = [["/api","http://192.168.10.113:8080/api"]]
12 12
13 13 # 线上
14 14 # VITE_PROXY = [["/api","http://101.133.234.90:8080/api"]]
15 15 VITE_PROXY = [["/api","http://47.99.141.212:8080/api"]]
16 16
17 17 # 实时数据的ws地址
18   -VITE_WEB_SOCKET = ws://101.133.234.90:8080/api/ws/plugins/telemetry?token=
  18 +VITE_WEB_SOCKET = ws://47.99.141.212:8080/api/ws/plugins/telemetry?token=
19 19
20 20 # Delete console
21 21 VITE_DROP_CONSOLE = true
... ...
... ... @@ -8,7 +8,7 @@ import {
8 8 SmsLoginParams,
9 9 } from './model/userModel';
10 10
11   -import { ErrorMessageMode } from '/#/axios';
  11 +import type { ErrorMessageMode } from '/#/axios';
12 12
13 13 enum Api {
14 14 Login = '/auth/login',
... ... @@ -19,6 +19,8 @@ enum Api {
19 19 GetPermCode = '/role/me/permissions',
20 20 RefreshToken = '/auth/token',
21 21 SendLoginSmsCode = '/noauth/sendLoginSmsCode/',
  22 + ResetCode = '/noauth/resetCode/',
  23 + ResetPassword = '/noauth/reset/',
22 24 }
23 25
24 26 /**
... ... @@ -78,9 +80,17 @@ export function smsCodeLoginApi(params: SmsLoginParams, mode: ErrorMessageMode =
78 80 );
79 81 }
80 82
81   -export function forgetPasswordApi(params) {
  83 +// 密码重置验证码
  84 +export function passwordResetCode(mobile) {
82 85 return defHttp.post({
83   - url: '',
84   - params,
  86 + url: Api.ResetCode + mobile,
  87 + });
  88 +}
  89 +
  90 +// 重置密码
  91 +export function forgetPasswordApi(data) {
  92 + return defHttp.post({
  93 + url: Api.ResetPassword + data.phoneNumber,
  94 + data,
85 95 });
86 96 }
... ...
... ... @@ -45,6 +45,7 @@
45 45 const lockStore = useLockStore();
46 46
47 47 const getRealName = computed(() => userStore.getUserInfo?.realName);
  48 + console.log(getRealName);
48 49 const [register, { closeModal }] = useModalInner();
49 50
50 51 const [registerForm, { validateFields, resetFields }] = useForm({
... ... @@ -95,7 +96,7 @@
95 96 &__entry {
96 97 position: relative;
97 98 //height: 240px;
98   - padding: 130px 30px 30px 30px;
  99 + padding: 130px 30px 30px;
99 100 border-radius: 10px;
100 101 }
101 102
... ... @@ -105,7 +106,6 @@
105 106 left: calc(50% - 45px);
106 107 width: auto;
107 108 text-align: center;
108   -
109 109 &-img {
110 110 width: 70px;
111 111 border-radius: 50%;
... ... @@ -113,6 +113,9 @@
113 113
114 114 &-name {
115 115 margin-top: 5px;
  116 + display: flex;
  117 + width: 100%;
  118 + // margin-left: -15px;
116 119 }
117 120 }
118 121
... ...
... ... @@ -85,6 +85,7 @@
85 85 import { getAuthCache } from '/@/utils/auth';
86 86 import { Upload } from 'ant-design-vue';
87 87 import { PlusOutlined } from '@ant-design/icons-vue';
  88 + import { useUserStore } from '/@/store/modules/user';
88 89 import type { FileItem } from '/@/components/Upload/src/typing';
89 90
90 91 const schema: DescItem[] = [
... ... @@ -126,6 +127,7 @@
126 127 const getBackendV: any = ref({});
127 128 const getData: any = ref({});
128 129 const updataPersonlData: any = ref({});
  130 + const userStore = useUserStore();
129 131 // const getUpdateUserInfo: any = ref({});
130 132 const [registerDesc] = useDescription({
131 133 title: '个人详情',
... ... @@ -209,6 +211,8 @@
209 211 getPersonalValue.value.username = getBackendV.value.username;
210 212 getPersonalValue.value.avatar = peresonalPic.value;
211 213 getData.value = await personalPut(getPersonalValue.value);
  214 + console.log(getData.value.realName);
  215 + userStore.setUserInfo(getData.value);
212 216 updatePersonalData.value = getData.value;
213 217 createMessage.success('修改成功');
214 218 const setUpdateUserInfo = JSON.stringify(getData.value);
... ...
... ... @@ -56,7 +56,7 @@ export default {
56 56 alert: '锁屏密码错误',
57 57 backToLogin: '返回登录',
58 58 entry: '进入系统',
59   - placeholder: '请输入锁屏密码或者用户密码',
  59 + placeholder: '请输入锁屏密码或者重新登录',
60 60 },
61 61 login: {
62 62 backSignIn: '返回',
... ...
... ... @@ -31,29 +31,10 @@ export const useLockStore = defineStore({
31 31 },
32 32 // Unlock
33 33 async unLock(password?: string) {
34   - const userStore = useUserStore();
35 34 if (this.lockInfo?.pwd === password) {
36 35 this.resetLockInfo();
37 36 return true;
38 37 }
39   - const tryLogin = async () => {
40   - try {
41   - const username = userStore.getUserInfo?.username;
42   - const res = await userStore.login({
43   - username,
44   - password: password!,
45   - goHome: false,
46   - mode: 'none',
47   - });
48   - if (res) {
49   - this.resetLockInfo();
50   - }
51   - return res;
52   - } catch (error) {
53   - return false;
54   - }
55   - };
56   - return await tryLogin();
57 38 },
58 39 },
59 40 });
... ...
... ... @@ -4,13 +4,7 @@ import { defineStore } from 'pinia';
4 4 import { store } from '/@/store';
5 5 import { RoleEnum } from '/@/enums/roleEnum';
6 6 import { PageEnum } from '/@/enums/pageEnum';
7   -import {
8   - JWT_TOKEN_KEY,
9   - REFRESH_TOKEN_KEY,
10   - ROLES_KEY,
11   - TOKEN_KEY,
12   - USER_INFO_KEY,
13   -} from '/@/enums/cacheEnum';
  7 +import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY, ROLES_KEY, USER_INFO_KEY } from '/@/enums/cacheEnum';
14 8 import { getAuthCache, setAuthCache } from '/@/utils/auth';
15 9 import {
16 10 LoginParams,
... ...
... ... @@ -71,7 +71,7 @@ export const formSchema: FormSchema[] = [
71 71 component: 'Input',
72 72 componentProps: {
73 73 placeholder: '请输入联系人姓名',
74   - maxLength: 255,
  74 + maxLength: 30,
75 75 },
76 76 },
77 77 {
... ...
... ... @@ -6,11 +6,6 @@ import { numberRule } from '/@/utils/rules';
6 6
7 7 export const columns: BasicColumn[] = [
8 8 {
9   - title: '创建时间',
10   - dataIndex: 'createTime',
11   - width: 150,
12   - },
13   - {
14 9 title: '名称',
15 10 dataIndex: 'name',
16 11 width: 150,
... ... @@ -26,10 +21,21 @@ export const columns: BasicColumn[] = [
26 21 width: 100,
27 22 },
28 23 {
  24 + title: '默认配置',
  25 + dataIndex: 'default',
  26 + width: 100,
  27 + format: (text) => (text ? '是' : '否'),
  28 + },
  29 + {
29 30 title: '描述',
30 31 dataIndex: 'description',
31 32 width: 150,
32 33 },
  34 + {
  35 + title: '创建时间',
  36 + dataIndex: 'createTime',
  37 + width: 150,
  38 + },
33 39 ];
34 40
35 41 export const searchFormSchema: FormSchema[] = [
... ...
... ... @@ -22,6 +22,9 @@
22 22 label: '设置为默认',
23 23 icon: 'ant-design:profile-outlined',
24 24 onClick: handleSetDefault.bind(null, record),
  25 + ifShow: () => {
  26 + return record.default === false;
  27 + },
25 28 },
26 29 {
27 30 label: '详情',
... ... @@ -102,7 +105,7 @@
102 105 bordered: true,
103 106 showIndexColumn: false,
104 107 actionColumn: {
105   - width: 200,
  108 + width: 250,
106 109 title: '操作',
107 110 dataIndex: 'action',
108 111 slots: { customRender: 'action' },
... ...
... ... @@ -33,14 +33,6 @@ export const columns: BasicColumn[] = [
33 33 width: 200,
34 34 },
35 35 {
36   - title: '内容',
37   - dataIndex: 'content',
38   - width: 120,
39   - format: (text: string, record: Recordable) => {
40   - return !record.content ? '' : record.content.slice(3, record.content.length - 4);
41   - },
42   - },
43   - {
44 36 title: '发送者',
45 37 dataIndex: 'senderName',
46 38 width: 200,
... ...
... ... @@ -5,23 +5,7 @@
5 5 >
6 6 <div
7 7 :class="`${prefixCls}__unlock`"
8   - class="
9   - absolute
10   - top-0
11   - left-1/2
12   - flex
13   - pt-5
14   - h-16
15   - items-center
16   - justify-center
17   - sm:text-md
18   - xl:text-xl
19   - text-white
20   - flex-col
21   - cursor-pointer
22   - transform
23   - translate-x-1/2
24   - "
  8 + class="absolute top-0 left-1/2 flex pt-5 h-16 items-center justify-center sm:text-md xl:text-xl text-white flex-col cursor-pointer transform translate-x-1/2"
25 9 @click="handleShowForm(false)"
26 10 v-show="showDate"
27 11 >
... ... @@ -140,7 +124,7 @@
140 124 }
141 125
142 126 function goLogin() {
143   - userStore.logout();
  127 + userStore.logout(true);
144 128 lockStore.resetLockInfo();
145 129 }
146 130
... ...
... ... @@ -40,7 +40,7 @@
40 40 import { CountdownInput } from '/@/components/CountDown';
41 41 import { useI18n } from '/@/hooks/web/useI18n';
42 42 import { useLoginState, useFormRules, LoginStateEnum } from './useLogin';
43   - import { forgetPasswordApi } from '/@/api/sys/user';
  43 + import { passwordResetCode, forgetPasswordApi } from '/@/api/sys/user';
44 44 const FormItem = Form.Item;
45 45 const { t } = useI18n();
46 46 const { handleBackLogin, getLoginState, setLoginState } = useLoginState();
... ... @@ -58,22 +58,39 @@
58 58 const getShow = computed(() => unref(getLoginState) === LoginStateEnum.RESET_PASSWORD);
59 59
60 60 async function handleReset() {
61   - setLoginState(LoginStateEnum.LOGIN);
62 61 const form = unref(formRef);
63 62 if (!form) return;
  63 + const value = await form.validate();
  64 + if (!value) return;
  65 + const { mobile, password, sms } = value;
  66 + try {
  67 + loading.value = true;
  68 + await forgetPasswordApi({
  69 + phoneNumber: mobile,
  70 + userId: sms,
  71 + password,
  72 + });
  73 + } catch (e) {
  74 + return;
  75 + } finally {
  76 + loading.value = false;
  77 + }
  78 + message.success('密码重置成功');
64 79 await form.resetFields();
  80 + setLoginState(LoginStateEnum.LOGIN);
65 81 }
66 82
67 83 async function sendLoginSms() {
68 84 const reg =
69 85 /^[1](([3][0-9])|([4][0,1,4-9])|([5][0-3,5-9])|([6][2,5,6,7])|([7][0-8])|([8][0-9])|([9][0-3,5-9]))[0-9]{8}$/;
70 86 if (reg.test(formData.mobile)) {
71   - const sendRes = await forgetPasswordApi(formData.mobile);
72   - if (!sendRes) {
73   - message.error('发送失败');
74   - return false;
  87 + const sendRes = await passwordResetCode(formData.mobile);
  88 + console.log(sendRes);
  89 + if (sendRes === '') {
  90 + console.log('发送成功了');
  91 + return true;
75 92 }
76   - return true;
  93 + return false;
77 94 } else {
78 95 message.error('请输入正确手机号码');
79 96 }
... ...
... ... @@ -60,10 +60,16 @@
60 60 </ACol>
61 61 </ARow>
62 62 </Form>
  63 + <Modal v-model:visible="visible" :footer="null" centered>
  64 + <template #title>
  65 + <CloseCircleFilled class="modal-icon-error" /><span class="ml-2">错误提示</span>
  66 + </template>
  67 + <span class="ml-2" style="color: red">用户名或密码不正确</span>
  68 + </Modal>
63 69 </template>
64 70 <script lang="ts" setup>
65 71 import { reactive, ref, unref, computed } from 'vue';
66   - import { Checkbox, Form, Input, Row, Col, Button } from 'ant-design-vue';
  72 + import { Checkbox, Form, Input, Row, Col, Button, Modal } from 'ant-design-vue';
67 73 import LoginFormTitle from './LoginFormTitle.vue';
68 74
69 75 import { useI18n } from '/@/hooks/web/useI18n';
... ... @@ -74,6 +80,7 @@
74 80 import { useDesign } from '/@/hooks/web/useDesign';
75 81 import { getPlatForm } from '/@/api/oem/index';
76 82 import { createLocalStorage } from '/@/utils/cache/index';
  83 + import { CloseCircleFilled } from '@ant-design/icons-vue';
77 84
78 85 const ACol = Col;
79 86 const ARow = Row;
... ... @@ -87,7 +94,7 @@
87 94 const { setLoginState, getLoginState } = useLoginState();
88 95 const { getFormRules } = useFormRules();
89 96 const storage = createLocalStorage();
90   -
  97 + const visible = ref(false);
91 98 const formRef = ref();
92 99 const loading = ref(false);
93 100 const rememberMe = ref(false);
... ... @@ -100,6 +107,7 @@
100 107 const { validForm } = useFormValid(formRef);
101 108
102 109 const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN);
  110 +
103 111 async function handleLogin() {
104 112 const data = await validForm();
105 113 if (!data) return;
... ... @@ -113,7 +121,7 @@
113 121 const userInfo = await userStore.login({
114 122 password: data.password,
115 123 username: data.account,
116   - mode: 'none', //不要默认的错误提示
  124 + mode: 'modal', //不要默认的错误提示
117 125 });
118 126 if (userInfo) {
119 127 notification.success({
... ... @@ -132,12 +140,8 @@
132 140 link.href = res.icon ?? '/favicon.ico';
133 141 document.getElementsByTagName('head')[0].appendChild(link);
134 142 }
135   - } catch (error) {
136   - createErrorModal({
137   - title: t('sys.api.errorTip'),
138   - content: (error as unknown as Error).message || t('sys.api.networkExceptionMsg'),
139   - getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body,
140   - });
  143 + } catch (error: any) {
  144 + visible.value = true;
141 145 } finally {
142 146 loading.value = false;
143 147 }
... ...
... ... @@ -78,6 +78,7 @@
78 78 async function handleLogin() {
79 79 const data = await validForm();
80 80 if (!data) return;
  81 +
81 82 const userInfo = await userStore.smsCodelogin(
82 83 toRaw({
83 84 phoneNumber: data.phoneNumber,
... ...
... ... @@ -10,23 +10,11 @@ export const schemas: FormSchema[] = [
10 10 colProps: {
11 11 span: 24,
12 12 },
  13 + required: true,
13 14 componentProps: {
14 15 maxLength: 100,
15 16 placeholder: '请输入公司名称',
16 17 },
17   - dynamicRules: () => {
18   - return [
19   - {
20   - required: false,
21   - validator: (_, value) => {
22   - if (String(value).length > 100) {
23   - return Promise.reject('字数不超过100个字');
24   - }
25   - return Promise.resolve();
26   - },
27   - },
28   - ];
29   - },
30 18 },
31 19 {
32 20 field: 'abbreviation',
... ... @@ -148,23 +136,11 @@ export const schemas: FormSchema[] = [
148 136 colProps: {
149 137 span: 24,
150 138 },
  139 + required: true,
151 140 componentProps: {
152 141 maxLength: 100,
153 142 placeholder: '请输入详细地址',
154 143 },
155   - dynamicRules: () => {
156   - return [
157   - {
158   - required: false,
159   - validator: (_, value) => {
160   - if (String(value).length > 100) {
161   - return Promise.reject('字数不超过100个字');
162   - }
163   - return Promise.resolve();
164   - },
165   - },
166   - ];
167   - },
168 144 },
169 145
170 146 {
... ... @@ -174,23 +150,11 @@ export const schemas: FormSchema[] = [
174 150 colProps: {
175 151 span: 24,
176 152 },
  153 + required: true,
177 154 componentProps: {
178 155 maxLength: 25,
179 156 placeholder: '请输入联系人',
180 157 },
181   - dynamicRules: () => {
182   - return [
183   - {
184   - required: false,
185   - validator: (_, value) => {
186   - if (String(value).length > 25) {
187   - return Promise.reject('字数不超过25个字');
188   - }
189   - return Promise.resolve();
190   - },
191   - },
192   - ];
193   - },
194 158 },
195 159 {
196 160 field: 'tel',
... ...
... ... @@ -3,15 +3,15 @@
3 3 <Card class="tab-card" :bordered="false">
4 4 <Tabs v-model:activeKey="activeKey" tab-position="left">
5 5 <Tabs.TabPane key="企业信息" tab="企业信息" />
6   - <Tabs.TabPane key="平台定制" tab="平台定制" />
7   - <Tabs.TabPane key="APP定制" tab="APP定制" />
  6 + <Tabs.TabPane key="平台信息" tab="平台信息" />
  7 + <Tabs.TabPane key="APP信息" tab="APP信息" />
8 8 </Tabs>
9 9 </Card>
10 10
11 11 <div style="width: 100%">
12 12 <Card class="card" :title="activeKey" :bordered="false" :bodyStyle="{ display: 'none' }" />
13 13 <EnterpriseInfo v-if="activeKey === '企业信息'" />
14   - <CVIDraw v-else-if="activeKey === '平台定制'" />
  14 + <CVIDraw v-else-if="activeKey === '平台信息'" />
15 15 <AppDraw v-else />
16 16 </div>
17 17 </div>
... ...