Files
delivery-uniapp/sheep/components/s-auth-modal/components/account-login.vue

122 lines
3.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 账号密码登录 accountLogin -->
<template>
<view>
<!-- 标题栏 -->
<view class="head-box ss-m-b-60">
<view class="ss-m-b-20">
<view class="head-title head-title-animation">登录账号</view>
</view>
<!-- <view class="head-subtitle">如果未设置过密码请点击忘记密码</view> -->
</view>
<!-- 表单项 -->
<uni-forms
ref="accountLoginRef"
v-model="state.model"
:rules="state.rules"
validateTrigger="bind"
labelWidth="140"
labelAlign="center"
>
<uni-forms-item name="username" label="账号">
<uni-easyinput placeholder="请输入手机号" v-model="state.model.username" :inputBorder="false">
<template v-slot:right>
<button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')">
忘记密码
</button>
</template>
</uni-easyinput>
</uni-forms-item>
<uni-forms-item name="password" label="密码">
<uni-easyinput
type="password"
placeholder="请输入密码"
v-model="state.model.password"
:inputBorder="false"
>
<template v-slot:right>
<button class="ss-reset-button login-btn-start" @tap="accountLoginSubmit">登录</button>
</template>
</uni-easyinput>
</uni-forms-item>
</uni-forms>
<view class="text-center">
<text class="head-title-active head-title-line" @tap="showAuthModal('smsLogin')">
验证码登录
</text>
<!-- <text class="head-title-active head-title-line" style="margin-left:25rpx;" @click="toRegister">
骑手注册
</text> -->
</view>
</view>
</template>
<script setup>
import { ref, reactive, unref } from 'vue';
import sheep from '@/sheep';
import { mobile, password } from '@/sheep/validate/form';
import { showAuthModal, closeAuthModal } from '@/sheep/hooks/useModal';
import AuthUtil from '@/sheep/api/member/auth';
const accountLoginRef = ref(null);
const emits = defineEmits(['onConfirm']);
const props = defineProps({
agreeStatus: {
type: Boolean,
default: false,
},
});
// 数据
const state = reactive({
model: {
username: '', // 账号
mobile: '',
password: '', // 密码
},
rules: {
mobile,
password,
},
});
// 账号登录
async function accountLoginSubmit() {
// 表单验证
const validate = await unref(accountLoginRef)
.validate()
.catch((error) => {
console.log('error: ', error);
});
if (!validate) return;
// 同意协议
if (!props.agreeStatus) {
emits('onConfirm', true)
sheep.$helper.toast('请勾选同意');
return;
}
// 提交数据
const { code, data } = await AuthUtil.login(state.model);
// const { code, data } = await AuthUtil.loginAccount(state.model);
if (code === 0) {
closeAuthModal();
}
}
const toRegister = () => {
uni.navigateTo({
url: '/pages/registered/registerRiders'
})
}
</script>
<style lang="scss" scoped>
@import '../index.scss';
</style>