hookehuyr

联调用户相关页面接口

...@@ -34,6 +34,7 @@ declare module 'vue' { ...@@ -34,6 +34,7 @@ declare module 'vue' {
34 HagerMore: typeof import('./src/components/hagerMore.vue')['default'] 34 HagerMore: typeof import('./src/components/hagerMore.vue')['default']
35 HagerService: typeof import('./src/components/common/hagerService.vue')['default'] 35 HagerService: typeof import('./src/components/common/hagerService.vue')['default']
36 Navbar: typeof import('./src/components/navbar.vue')['default'] 36 Navbar: typeof import('./src/components/navbar.vue')['default']
37 + Privacy: typeof import('./src/components/privacy.vue')['default']
37 RouterLink: typeof import('vue-router')['RouterLink'] 38 RouterLink: typeof import('vue-router')['RouterLink']
38 RouterView: typeof import('vue-router')['RouterView'] 39 RouterView: typeof import('vue-router')['RouterView']
39 SlideComp: typeof import('./src/components/slideComp.vue')['default'] 40 SlideComp: typeof import('./src/components/slideComp.vue')['default']
......
1 /* 1 /*
2 * @Date: 2024-09-26 13:36:06 2 * @Date: 2024-09-26 13:36:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-24 10:26:13 4 + * @LastEditTime: 2024-10-25 14:01:25
5 * @FilePath: /hager/src/api/hager.js 5 * @FilePath: /hager/src/api/hager.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -17,6 +17,12 @@ const Api = { ...@@ -17,6 +17,12 @@ const Api = {
17 PRODUCT_SEARCH: '/srv/?a=cate&type=product_search', 17 PRODUCT_SEARCH: '/srv/?a=cate&type=product_search',
18 SOLUTION: '/srv/?a=cate&type=solution', 18 SOLUTION: '/srv/?a=cate&type=solution',
19 FOOTER: '/srv/?a=footer', 19 FOOTER: '/srv/?a=footer',
20 + REGISTER: '/srv/?a=user&type=register',
21 + LOGIN: '/srv/?a=user&type=login',
22 + GET_USER: '/srv/?a=user&type=get_user',
23 + EDIT_USER: '/srv/?a=user&type=edit_user',
24 + GET_CODE: '/srv/?a=user&type=get_code',
25 + EDIT_PASSWORD: '/srv/?a=user&type=edit_password',
20 }; 26 };
21 27
22 export const honorAPI = (params) => fn(fetch.get(Api.HONOR, params)); 28 export const honorAPI = (params) => fn(fetch.get(Api.HONOR, params));
...@@ -36,3 +42,10 @@ export const getProductSearchAPI = (params) => fn(fetch.get(Api.PRODUCT_SEARCH, ...@@ -36,3 +42,10 @@ export const getProductSearchAPI = (params) => fn(fetch.get(Api.PRODUCT_SEARCH,
36 export const getSolutionListAPI = (params) => fn(fetch.get(Api.SOLUTION, params)); 42 export const getSolutionListAPI = (params) => fn(fetch.get(Api.SOLUTION, params));
37 43
38 export const getFooterAPI = (params) => fn(fetch.get(Api.FOOTER, params)); 44 export const getFooterAPI = (params) => fn(fetch.get(Api.FOOTER, params));
45 +
46 +export const registerAPI = (params) => fn(fetch.post(Api.REGISTER, params));
47 +export const loginAPI = (params) => fn(fetch.post(Api.LOGIN, params));
48 +export const getUserInfoAPI = (params) => fn(fetch.get(Api.GET_USER, params));
49 +export const editUserInfoAPI = (params) => fn(fetch.post(Api.EDIT_USER, params));
50 +export const getCodeAPI = (params) => fn(fetch.post(Api.GET_CODE, params));
51 +export const editPasswordAPI = (params) => fn(fetch.post(Api.EDIT_PASSWORD, params));
......
1 <!-- 1 <!--
2 * @Date: 2024-10-20 09:59:52 2 * @Date: 2024-10-20 09:59:52
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-21 18:21:31 4 + * @LastEditTime: 2024-10-25 15:55:42
5 * @FilePath: /hager/src/components/common/hagerInput.vue 5 * @FilePath: /hager/src/components/common/hagerInput.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
18 <script> 18 <script>
19 import mixin from 'common/mixin'; 19 import mixin from 'common/mixin';
20 import { Message } from 'element-ui'; 20 import { Message } from 'element-ui';
21 +import { getCodeAPI } from "@/api/hager.js";
21 22
22 export default { 23 export default {
23 mixins: [mixin.init], 24 mixins: [mixin.init],
24 props: { 25 props: {
25 value: { 26 value: {
26 - type: String,
27 default: '' 27 default: ''
28 }, 28 },
29 placeholder: { 29 placeholder: {
...@@ -60,6 +60,8 @@ export default { ...@@ -60,6 +60,8 @@ export default {
60 return 'https://cdn.ipadbiz.cn/hager/icon/input/%E9%82%AE%E7%AE%B1@2x.png'; 60 return 'https://cdn.ipadbiz.cn/hager/icon/input/%E9%82%AE%E7%AE%B1@2x.png';
61 case 'pwd': 61 case 'pwd':
62 return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%AF%86%E7%A0%81@2x.png'; 62 return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%AF%86%E7%A0%81@2x.png';
63 + case 'code':
64 + return 'https://cdn.ipadbiz.cn/hager/icon/%E9%AA%8C%E8%AF%81%E7%A0%81@2x.png';
63 case 'username': 65 case 'username':
64 return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%A7%93%E5%90%8D@2x.png'; 66 return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%A7%93%E5%90%8D@2x.png';
65 case 'tel': 67 case 'tel':
...@@ -80,16 +82,8 @@ export default { ...@@ -80,16 +82,8 @@ export default {
80 // 使用 $emit 触发 input 事件,传递新的输入值 82 // 使用 $emit 触发 input 事件,传递新的输入值
81 this.$emit('input', event.target.value); 83 this.$emit('input', event.target.value);
82 }, 84 },
83 - resetPwd () { 85 + async resetPwd () {
84 - if (!this.email) { 86 + this.$emit('send', this.value);
85 - Message({
86 - showClose: true,
87 - message: '邮箱地址不能为空',
88 - type: 'warning'
89 - });
90 - } else {
91 -
92 - }
93 } 87 }
94 } 88 }
95 } 89 }
......
1 <!-- 1 <!--
2 * @Date: 2024-10-18 18:00:47 2 * @Date: 2024-10-18 18:00:47
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-22 18:19:58 4 + * @LastEditTime: 2024-10-25 13:52:46
5 * @FilePath: /hager/src/views/user/info.vue 5 * @FilePath: /hager/src/views/user/info.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
10 <div class="input-title">我的信息</div> 10 <div class="input-title">我的信息</div>
11 <div style="padding: 1rem 1.5rem 1rem 1rem;"> 11 <div style="padding: 1rem 1.5rem 1rem 1rem;">
12 <hagerInput type="email" :disable="status !== 'edit'" required v-model="email" placeholder="请输入注册邮箱地址" /> 12 <hagerInput type="email" :disable="status !== 'edit'" required v-model="email" placeholder="请输入注册邮箱地址" />
13 - <hagerInput type="pwd" :disable="status !== 'edit'" required v-model="pwd" placeholder="请输入登录密码" /> 13 + <!-- <hagerInput type="pwd" :disable="status !== 'edit'" required v-model="pwd" placeholder="请输入登录密码" /> -->
14 <hagerInput type="username" :disable="status !== 'edit'" v-model="username" placeholder="请输入姓名" /> 14 <hagerInput type="username" :disable="status !== 'edit'" v-model="username" placeholder="请输入姓名" />
15 <hagerInput type="tel" :disable="status !== 'edit'" v-model="tel" placeholder="请输入联系电话" /> 15 <hagerInput type="tel" :disable="status !== 'edit'" v-model="tel" placeholder="请输入联系电话" />
16 <hagerInput type="corp" :disable="status !== 'edit'" v-model="corp" placeholder="请输入公司名称" /> 16 <hagerInput type="corp" :disable="status !== 'edit'" v-model="corp" placeholder="请输入公司名称" />
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
19 <div class="info-footer"> 19 <div class="info-footer">
20 <div v-if="status !== 'edit'" class="submit-btn" @click="onHandle">修改信息</div> 20 <div v-if="status !== 'edit'" class="submit-btn" @click="onHandle">修改信息</div>
21 <div v-else class="edit-box"> 21 <div v-else class="edit-box">
22 - <div class="cancel btn" @click="status=''">取消</div> 22 + <div class="cancel btn" @click="onCancel">取消</div>
23 <div class="confirm btn" @click="onSubmit">确定</div> 23 <div class="confirm btn" @click="onSubmit">确定</div>
24 </div> 24 </div>
25 <div class="info-subsidiary"> 25 <div class="info-subsidiary">
...@@ -27,9 +27,7 @@ ...@@ -27,9 +27,7 @@
27 </div> 27 </div>
28 </div> 28 </div>
29 <el-dialog title="隐私政策" :visible.sync="dialogVisible"> 29 <el-dialog title="隐私政策" :visible.sync="dialogVisible">
30 - <div> 30 + <privacy></privacy>
31 - Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit quos quis iste alias! Necessitatibus veniam eum dolor dolorem enim officiis aspernatur neque, quidem tempore officia non optio eveniet aliquid minus!
32 - </div>
33 </el-dialog> 31 </el-dialog>
34 32
35 <el-drawer 33 <el-drawer
...@@ -37,7 +35,7 @@ ...@@ -37,7 +35,7 @@
37 size="100%" 35 size="100%"
38 :visible.sync="drawer" 36 :visible.sync="drawer"
39 :direction="direction"> 37 :direction="direction">
40 - <span>我来啦!</span> 38 + <privacy></privacy>
41 </el-drawer> 39 </el-drawer>
42 </div> 40 </div>
43 </template> 41 </template>
...@@ -46,37 +44,82 @@ ...@@ -46,37 +44,82 @@
46 import mixin from 'common/mixin'; 44 import mixin from 'common/mixin';
47 import hagerInput from '@/components/common/hagerInput.vue'; 45 import hagerInput from '@/components/common/hagerInput.vue';
48 import $ from 'jquery'; 46 import $ from 'jquery';
47 +import privacy from '@/components/privacy.vue';
48 +import { getUserInfoAPI, editUserInfoAPI } from "@/api/hager.js";
49 +import { MessageBox, Message } from 'element-ui';
49 50
50 export default { 51 export default {
51 mixins: [mixin.init], 52 mixins: [mixin.init],
52 data () { 53 data () {
53 return { 54 return {
54 - email: 'hr.communication@hager.com', 55 + email: '',
55 - pwd: 'hager123', 56 + pwd: '',
56 - username: '王二虎', 57 + username: '',
57 - tel: '15650569910', 58 + tel: '',
58 - corp: '海格电气集团', 59 + corp: '',
59 - department: '研发部产品经理', 60 + department: '',
60 status: '', 61 status: '',
61 dialogVisible: false, 62 dialogVisible: false,
62 drawer: false, 63 drawer: false,
63 direction: 'rtl', 64 direction: 'rtl',
64 } 65 }
65 }, 66 },
66 - mounted () { 67 + async mounted () {
67 if ($('#router-view').outerHeight() < $('.user-box').height()) { 68 if ($('#router-view').outerHeight() < $('.user-box').height()) {
68 $('#router-view').height($('.user-box').outerHeight()) 69 $('#router-view').height($('.user-box').outerHeight())
69 } 70 }
71 + // 获取用户信息
72 + this.getUserInfo();
70 }, 73 },
71 methods: { 74 methods: {
75 + async getUserInfo () {
76 + const { code, data } = await getUserInfoAPI();
77 + if (code === 1) { // 已登录
78 + this.email = data.email;
79 + this.username = data.username;
80 + this.tel = data.mobile;
81 + this.corp = data.company;
82 + this.department = data.department;
83 + }
84 + },
72 onHandle () { 85 onHandle () {
73 this.status = 'edit'; 86 this.status = 'edit';
74 }, 87 },
75 - onSubmit () { 88 + async onSubmit () {
76 - console.log('提交'); 89 + if (!this.email) {
77 - setTimeout(() => { 90 + Message({
91 + type: 'error',
92 + message: '邮箱地址不能空'
93 + });
94 + return;
95 + }
96 + // 检验邮箱地址有效性
97 + if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(this.email)) {
98 + Message({
99 + type: 'error',
100 + message: '邮箱地址格式不正确'
101 + });
102 + return;
103 + }
104 + const { code, msg } = await editUserInfoAPI({
105 + email: this.email,
106 + username: this.username,
107 + mobile: this.tel,
108 + company: this.corp,
109 + department: this.department
110 + });
111 + if (code) {
112 + Message({
113 + type: 'success',
114 + message: msg
115 + });
78 this.status = ''; 116 this.status = '';
79 - }, 1000); 117 + }
118 + },
119 + onCancel () {
120 + this.status = '';
121 + // 获取用户信息
122 + this.getUserInfo();
80 }, 123 },
81 openPrivacy () { 124 openPrivacy () {
82 if (this.is_xs) { 125 if (this.is_xs) {
......
1 <!-- 1 <!--
2 * @Date: 2024-10-18 18:00:47 2 * @Date: 2024-10-18 18:00:47
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-22 17:58:47 4 + * @LastEditTime: 2024-10-25 13:49:38
5 * @FilePath: /hager/src/views/user/login.vue 5 * @FilePath: /hager/src/views/user/login.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 <!-- TODO: 记住密码和忘记密码业务显示的问题? --> 14 <!-- TODO: 记住密码和忘记密码业务显示的问题? -->
15 <div class="pwd-box"> 15 <div class="pwd-box">
16 <!-- <div><el-checkbox v-model="checked">记住密码</el-checkbox></div> --> 16 <!-- <div><el-checkbox v-model="checked">记住密码</el-checkbox></div> -->
17 - <div><span @click="goToReset">忘记密码?</span></div> 17 + <div><span @click="goToReset">忘记/修改密码?</span></div>
18 </div> 18 </div>
19 </div> 19 </div>
20 <div class="login-footer"> 20 <div class="login-footer">
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
30 import mixin from 'common/mixin'; 30 import mixin from 'common/mixin';
31 import hagerInput from '@/components/common/hagerInput.vue'; 31 import hagerInput from '@/components/common/hagerInput.vue';
32 import $ from 'jquery'; 32 import $ from 'jquery';
33 +import { loginAPI } from '@/api/hager';
34 +import { MessageBox, Message } from 'element-ui';
33 35
34 export default { 36 export default {
35 mixins: [mixin.init], 37 mixins: [mixin.init],
...@@ -46,8 +48,37 @@ export default { ...@@ -46,8 +48,37 @@ export default {
46 } 48 }
47 }, 49 },
48 methods: { 50 methods: {
49 - onSubmit () { 51 + async onSubmit () {
50 - console.warn(); 52 + if (!this.email) {
53 + Message({
54 + type: 'error',
55 + message: '邮箱地址不能空'
56 + });
57 + return;
58 + }
59 + // 检验邮箱地址有效性
60 + if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(this.email)) {
61 + Message({
62 + type: 'error',
63 + message: '邮箱地址格式不正确'
64 + });
65 + return;
66 + }
67 + if (!this.pwd) {
68 + Message({
69 + type: 'error',
70 + message: '登录密码不能空'
71 + });
72 + return;
73 + }
74 + const { code, msg } = await loginAPI({ email: this.email, password: this.pwd });
75 + if (code) {
76 + Message({
77 + type: 'success',
78 + message: msg
79 + });
80 + this.$router.push('/');
81 + }
51 }, 82 },
52 goToRegister () { 83 goToRegister () {
53 this.$router.push('/user/register'); 84 this.$router.push('/user/register');
......
1 <!-- 1 <!--
2 * @Date: 2024-10-18 18:00:47 2 * @Date: 2024-10-18 18:00:47
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-22 18:14:41 4 + * @LastEditTime: 2024-10-25 13:37:44
5 * @FilePath: /hager/src/views/user/register.vue 5 * @FilePath: /hager/src/views/user/register.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -24,9 +24,7 @@ ...@@ -24,9 +24,7 @@
24 </div> 24 </div>
25 </div> 25 </div>
26 <el-dialog title="隐私政策" :visible.sync="dialogVisible"> 26 <el-dialog title="隐私政策" :visible.sync="dialogVisible">
27 - <div> 27 + <privacy></privacy>
28 - Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit quos quis iste alias! Necessitatibus veniam eum dolor dolorem enim officiis aspernatur neque, quidem tempore officia non optio eveniet aliquid minus!
29 - </div>
30 </el-dialog> 28 </el-dialog>
31 29
32 <el-drawer 30 <el-drawer
...@@ -34,7 +32,7 @@ ...@@ -34,7 +32,7 @@
34 size="100%" 32 size="100%"
35 :visible.sync="drawer" 33 :visible.sync="drawer"
36 :direction="direction"> 34 :direction="direction">
37 - <span>我来啦!</span> 35 + <privacy></privacy>
38 </el-drawer> 36 </el-drawer>
39 </div> 37 </div>
40 </template> 38 </template>
...@@ -43,6 +41,9 @@ ...@@ -43,6 +41,9 @@
43 import mixin from 'common/mixin'; 41 import mixin from 'common/mixin';
44 import hagerInput from '@/components/common/hagerInput.vue'; 42 import hagerInput from '@/components/common/hagerInput.vue';
45 import $ from 'jquery'; 43 import $ from 'jquery';
44 +import { registerAPI } from '@/api/hager';
45 +import { MessageBox, Message } from 'element-ui';
46 +import privacy from '@/components/privacy.vue';
46 47
47 export default { 48 export default {
48 mixins: [mixin.init], 49 mixins: [mixin.init],
...@@ -65,8 +66,37 @@ export default { ...@@ -65,8 +66,37 @@ export default {
65 } 66 }
66 }, 67 },
67 methods: { 68 methods: {
68 - onSubmit () { 69 + async onSubmit () {
69 - console.warn(); 70 + if (!this.email) {
71 + Message({
72 + type: 'error',
73 + message: '邮箱地址不能空'
74 + });
75 + return;
76 + }
77 + // 检验邮箱地址有效性
78 + if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(this.email)) {
79 + Message({
80 + type: 'error',
81 + message: '邮箱地址格式不正确'
82 + });
83 + return;
84 + }
85 + if (!this.pwd) {
86 + Message({
87 + type: 'error',
88 + message: '登录密码不能空'
89 + });
90 + return;
91 + }
92 + const { code, msg } = await registerAPI({ email: this.email, password: this.pwd, username: this.username, mobile: this.tel, company: this.corp, department: this.department });
93 + if (code) {
94 + Message({
95 + type: 'success',
96 + message: msg
97 + });
98 + this.goToLogin()
99 + }
70 }, 100 },
71 goToLogin () { 101 goToLogin () {
72 this.$router.push('/user/login'); 102 this.$router.push('/user/login');
......
1 <!-- 1 <!--
2 * @Date: 2024-10-18 18:00:47 2 * @Date: 2024-10-18 18:00:47
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-21 10:53:15 4 + * @LastEditTime: 2024-10-25 16:00:00
5 * @FilePath: /hager/src/views/user/reset.vue 5 * @FilePath: /hager/src/views/user/reset.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
9 <div class="hager-reset-page"> 9 <div class="hager-reset-page">
10 <div class="input-title">密码重置</div> 10 <div class="input-title">密码重置</div>
11 <div style="padding: 1rem 1.5rem 1rem 1rem;"> 11 <div style="padding: 1rem 1.5rem 1rem 1rem;">
12 - <hagerInput type="email" required reset v-model="email" placeholder="请输入邮箱地址" /> 12 + <hagerInput type="email" required reset @send="onSend" v-model="email" placeholder="请输入邮箱地址" />
13 - <hagerInput type="pwd" required v-model="sms" placeholder="请输入验证码" /> 13 + <hagerInput type="code" required v-model="sms" placeholder="请输入验证码" />
14 <hagerInput type="pwd" required v-model="pwd" placeholder="请输入登录密码" /> 14 <hagerInput type="pwd" required v-model="pwd" placeholder="请输入登录密码" />
15 </div> 15 </div>
16 <div class="reset-footer"> 16 <div class="reset-footer">
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
25 <script> 25 <script>
26 import mixin from 'common/mixin'; 26 import mixin from 'common/mixin';
27 import hagerInput from '@/components/common/hagerInput.vue'; 27 import hagerInput from '@/components/common/hagerInput.vue';
28 -import { Message } from 'element-ui';
29 import $ from 'jquery'; 28 import $ from 'jquery';
29 +import { getCodeAPI, editPasswordAPI } from "@/api/hager.js";
30 +import { MessageBox, Message, Loading } from 'element-ui';
30 31
31 export default { 32 export default {
32 mixins: [mixin.init], 33 mixins: [mixin.init],
...@@ -35,7 +36,8 @@ export default { ...@@ -35,7 +36,8 @@ export default {
35 email: '', 36 email: '',
36 pwd: '', 37 pwd: '',
37 sms: '', 38 sms: '',
38 - checked: false 39 + checked: false,
40 + fullscreenLoading: false
39 } 41 }
40 }, 42 },
41 mounted () { 43 mounted () {
...@@ -44,12 +46,77 @@ export default { ...@@ -44,12 +46,77 @@ export default {
44 } 46 }
45 }, 47 },
46 methods: { 48 methods: {
47 - onSubmit () { 49 + async onSend (val) {
48 - Message({ 50 + if (!val) {
49 - showClose: true, 51 + Message({
50 - message: '重置成功', 52 + type: 'error',
51 - type: 'success' 53 + message: '邮箱地址不能空'
52 - }); 54 + });
55 + return;
56 + }
57 +
58 + if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(val)) { // 检验邮箱地址有效性
59 + Message({
60 + type: 'error',
61 + message: '邮箱地址格式不正确'
62 + });
63 + return;
64 + }
65 + let loadingInstance = Loading.service({ fullscreen: true, background: 'rgba(0, 0, 0, 0.3)' });
66 + const { code, msg } = await getCodeAPI({ email: val });
67 + if (code) {
68 + Message({
69 + type: 'success',
70 + message: '发送成功'
71 + });
72 + this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
73 + loadingInstance.close();
74 + });
75 + } else {
76 + this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
77 + loadingInstance.close();
78 + });
79 + }
80 + },
81 + async onSubmit () {
82 + if (!this.email) {
83 + Message({
84 + type: 'error',
85 + message: '邮箱地址不能空'
86 + });
87 + return;
88 + }
89 + // 检验邮箱地址有效性
90 + if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(this.email)) {
91 + Message({
92 + type: 'error',
93 + message: '邮箱地址格式不正确'
94 + });
95 + return;
96 + }
97 + if (!this.sms) {
98 + Message({
99 + type: 'error',
100 + message: '验证码不能空'
101 + });
102 + return;
103 + }
104 + if (!this.pwd) {
105 + Message({
106 + type: 'error',
107 + message: '登录密码不能空'
108 + });
109 + return;
110 + }
111 + const { code, msg } = await editPasswordAPI({ email: this.email, password: this.pwd, code: this.sms });
112 + if (code) {
113 + Message({
114 + showClose: true,
115 + message: '重置成功',
116 + type: 'success'
117 + });
118 + this.$router.push('/user/login');
119 + }
53 }, 120 },
54 goBack () { 121 goBack () {
55 this.$router.go(-1); 122 this.$router.go(-1);
......