个人中心:手机 + 密码登录

pull/34/MERGE
YunaiV 2023-12-28 23:14:22 +08:00
parent f0e8ff1f87
commit cbaf3a2512
4 changed files with 27 additions and 95 deletions

View File

@ -1,6 +1,19 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
const AuthUtil = { const AuthUtil = {
// 使用手机 + 密码登录
login: (data) => {
return request({
url: '/app-api/member/auth/login',
method: 'POST',
data,
custom: {
showSuccess: true,
loadingMsg: '登录中',
successMsg: '登录成功',
},
});
},
// 使用手机 + 验证码登录 // 使用手机 + 验证码登录
smsLogin: (data) => { smsLogin: (data) => {
return request({ return request({

View File

@ -3,38 +3,8 @@ import request2 from '@/sheep/request2';
import $platform from '@/sheep/platform'; import $platform from '@/sheep/platform';
export default { export default {
getUnused: () =>
request2({
url: 'promotion/coupon/get-unused-count',
method: 'GET',
custom: {
showLoading: false,
auth: true,
},
}),
// 账号登录
accountLogin: (data) =>
request({
url: '/user/api/user/accountLogin',
method: 'POST',
data,
custom: {
showSuccess: true,
loadingMsg: '登录中',
},
}),
// 绑定、更换手机号
changeMobile: (data) =>
request({
url: '/user/api/user/changeMobile',
method: 'POST',
data,
custom: {
showSuccess: true,
loadingMsg: '验证中',
},
}),
// 添加分享记录 // 添加分享记录
addShareLog: (data) => addShareLog: (data) =>
@ -54,20 +24,6 @@ export default {
params, params,
}), }),
}, },
// 账号登出
logout: (data) =>
request({
url: '/user/api/user/logout',
method: 'POST',
data,
}),
// 账号注销
logoff: (data) =>
request({
url: '/user/api/user/logoff',
method: 'POST',
data,
}),
address: { address: {
default: () => default: () =>

View File

@ -21,8 +21,8 @@
labelWidth="140" labelWidth="140"
labelAlign="center" labelAlign="center"
> >
<uni-forms-item name="account" label="账号"> <uni-forms-item name="mobile" label="账号">
<uni-easyinput placeholder="请输入账号" v-model="state.model.account" :inputBorder="false"> <uni-easyinput placeholder="请输入账号" v-model="state.model.mobile" :inputBorder="false">
<template v-slot:right> <template v-slot:right>
<button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')"> <button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')">
忘记密码 忘记密码
@ -48,10 +48,11 @@
</template> </template>
<script setup> <script setup>
import { computed, watch, ref, reactive, unref } from 'vue'; import { ref, reactive, unref } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { account, password } from '@/sheep/validate/form'; import { mobile, password } from '@/sheep/validate/form';
import { showAuthModal, closeAuthModal } from '@/sheep/hooks/useModal'; import { showAuthModal, closeAuthModal } from '@/sheep/hooks/useModal';
import AuthUtil from '@/sheep/api/member/auth';
const accountLoginRef = ref(null); const accountLoginRef = ref(null);
@ -63,19 +64,20 @@
default: false, default: false,
}, },
}); });
// //
const state = reactive({ const state = reactive({
model: { model: {
account: '', // mobile: '', //
password: '', // password: '', //
}, },
rules: { rules: {
account, mobile,
password, password,
}, },
}); });
// 1. //
async function accountLoginSubmit() { async function accountLoginSubmit() {
// //
const validate = await unref(accountLoginRef) const validate = await unref(accountLoginRef)
@ -93,12 +95,10 @@
} }
// //
sheep.$api.user.accountLogin(state.model).then((res) => { const { code, data } = await AuthUtil.login(state.model);
if (res.error === 0) { if (code === 0) {
// sheep.$store('user').getInfo();
closeAuthModal(); closeAuthModal();
} }
});
} }
</script> </script>

View File

@ -22,24 +22,6 @@ export const mobile = {
], ],
}; };
// 账户
export const account = {
rules: [
{
required: true,
errorMessage: '请输入账号',
},
{
validateFunction: function (rule, value, data, callback) {
if (value.length < 5) {
callback('账号长度不能小于5位');
}
return true;
},
},
],
};
// 密码 // 密码
export const password = { export const password = {
rules: [ rules: [
@ -58,24 +40,6 @@ export const password = {
], ],
}; };
// 昵称
export const username = {
rules: [
{
required: true,
errorMessage: '请输入用户名',
},
{
validateFunction: function (rule, value, data, callback) {
if (value.length < 5) {
callback('用户名长度不能小于5位');
}
return true;
},
},
],
};
// 短信验证码 // 短信验证码
export const code = { export const code = {
rules: [ rules: [
@ -195,7 +159,6 @@ export default {
realName, realName,
password, password,
code, code,
account,
taxNo, taxNo,
taxName, taxName,
}; };