mall-app-t/pages/index/login.vue

196 lines
4.8 KiB
Vue
Raw Normal View History

2024-05-22 18:05:56 +08:00
<template>
2024-05-30 01:20:31 +08:00
<pb-layout :leftIcon="''" navbar="inner" :bgStyle="{ backgroundColor: '#fff' }">
<view class="login-module ss-p-x-30">
<view class="login-title ss-font-56 ss-m-b-72">
{{ title }}
</view>
<uni-forms ref="smsLoginRef" v-model="state.model" :rules="state.rules" validateTrigger="bind">
<uni-forms-item name="mobile">
2024-08-28 18:36:22 +08:00
<uni-easyinput
:styles="state.inputStyle"
trim="all"
placeholder="请输入手机号"
v-model="state.model.mobile"
:inputBorder="false"
type="number"
/>
2024-05-30 01:20:31 +08:00
</uni-forms-item>
<uni-forms-item name="code">
2024-08-28 18:36:22 +08:00
<uni-easyinput
:styles="state.inputStyle"
trim="all"
placeholder="验证码"
v-model="state.model.code"
:inputBorder="false"
type="number"
maxlength="4"
>
2024-05-30 01:20:31 +08:00
<template #right>
2024-08-28 18:36:22 +08:00
<button
:disabled="state.isMobileEnd"
:class="{ 'code-btn-end': state.isMobileEnd }"
class="ss-reset-button code-btn code-btn-start"
@tap="getSmsCode('smsLogin', state.model.mobile)"
>
2024-05-30 01:20:31 +08:00
{{ getSmsTimer('smsLogin') }}
</button>
</template>
</uni-easyinput>
</uni-forms-item>
</uni-forms>
<button class="ss-reset-button login-btn-start" @tap="smsLoginSubmit">登录</button>
<view class="agreement-box ss-flex ss-row-center" :class="{ shake: state.isShaking }">
<label class="radio ss-flex" @tap="onChange">
2024-08-28 18:36:22 +08:00
<radio
:checked="state.agreeStatus"
color="var(--ui-BG-Main)"
style="transform: scale(0.8)"
@tap.stop="onChange"
/>
2024-05-30 01:20:31 +08:00
<view class="agreement-text ss-flex ss-m-l-8">
我已阅读并遵守
<view class="tcp-text" @tap.stop="onProtocol('商家入驻协议')"> 商家入驻协议 </view>
</view>
</label>
</view>
</view>
</pb-layout>
2024-05-22 18:05:56 +08:00
</template>
<script setup>
import { ref } from 'vue'
2024-05-29 17:07:37 +08:00
import { code, mobile } from '@/peach/validate/form'
import AuthUtil from '@/peach/api/member/auth'
2024-05-23 01:44:16 +08:00
import peach from '@/peach'
2024-05-29 17:07:37 +08:00
import { showAuthModal, closeAuthModal, getSmsCode, getSmsTimer } from '@/peach/hooks/useModal'
2024-05-22 18:05:56 +08:00
const title = ref('欢迎登录')
2024-05-23 01:38:19 +08:00
const smsLoginRef = ref(null)
2024-05-22 18:05:56 +08:00
const state = ref({
2024-05-30 01:20:31 +08:00
isMobileEnd: false,
agreeStatus: false,
isShaking: false,
model: {
2024-08-28 18:36:22 +08:00
mobile: '',
code: '',
2024-05-30 01:20:31 +08:00
},
rules: {
code,
2024-08-30 17:06:53 +08:00
mobile,
2024-05-30 01:20:31 +08:00
},
inputStyle: {
backgroundColor: '#ECECEC',
},
2024-05-22 18:05:56 +08:00
})
2024-05-23 01:38:19 +08:00
function onChange() {
2024-05-30 01:20:31 +08:00
state.value.agreeStatus = !state.value.agreeStatus
2024-05-23 01:38:19 +08:00
}
2024-05-30 01:20:31 +08:00
function onProtocol() {
peach.$router.go('/pages/public/richtext?title=商家入驻协议')
}
2024-05-23 01:38:19 +08:00
2024-05-30 01:20:31 +08:00
async function smsLoginSubmit() {
const validate = await smsLoginRef.value.validate().catch((err) => {
console.log('err', err)
})
if (!validate) return
if (!state.value.agreeStatus) {
state.value.isShaking = true
setTimeout(() => {
state.value.isShaking = false
}, 1000)
2024-08-30 17:06:53 +08:00
peach.$helper.toast('请勾选同意商家入驻协议')
2024-05-30 01:20:31 +08:00
return
}
const { code } = await AuthUtil.smsLogin(state.value.model)
2024-05-23 01:38:19 +08:00
}
2024-05-22 18:05:56 +08:00
</script>
2024-05-23 01:38:19 +08:00
<style lang="scss">
.login-module {
2024-05-30 01:20:31 +08:00
.uni-easyinput {
::v-deep .uni-easyinput__content {
border-radius: 41rpx;
padding: 0 10rpx;
}
.is-focused {
2024-08-30 17:06:53 +08:00
.uniui-clear {
color: red !important;
2024-05-30 01:20:31 +08:00
}
2024-05-29 01:29:31 +08:00
}
2024-05-30 01:20:31 +08:00
}
2024-05-23 01:38:19 +08:00
}
</style>
2024-05-22 18:05:56 +08:00
<style lang="scss" scoped>
.login-module {
2024-05-30 01:20:31 +08:00
margin-top: 50%;
overflow: hidden;
.login-title {
color: '#1818d';
font-weight: 600;
}
.login-btn-start {
height: 82rpx;
line-height: normal;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
border-radius: 28rpx;
font-size: 26rpx;
font-weight: 500;
color: #fff;
}
.code-btn-start {
width: 160rpx;
height: 56rpx;
line-height: normal;
border-radius: 28rpx;
font-size: 26rpx;
font-weight: 400;
color: var(--ui-BG-Main);
opacity: 1;
}
.agreement-box {
margin: -10px auto 10px;
position: absolute;
bottom: 30rpx;
width: 100%;
.protocol-check {
transform: scale(0.7);
2024-05-22 18:05:56 +08:00
}
2024-05-23 01:38:19 +08:00
2024-05-30 01:20:31 +08:00
.agreement-text {
font-size: 26rpx;
font-weight: 500;
color: #999999;
2024-05-23 01:38:19 +08:00
2024-05-30 01:20:31 +08:00
.tcp-text {
2024-05-22 18:05:56 +08:00
color: var(--ui-BG-Main);
2024-05-30 01:20:31 +08:00
}
2024-05-23 01:38:19 +08:00
}
2024-05-30 01:20:31 +08:00
}
2024-05-23 01:38:19 +08:00
2024-05-30 01:20:31 +08:00
.shake {
animation: shake 0.05s linear 4 alternate;
}
2024-05-23 01:38:19 +08:00
2024-05-30 01:20:31 +08:00
@keyframes shake {
from {
transform: translateX(-5rpx);
2024-05-29 17:07:37 +08:00
}
2024-05-30 01:20:31 +08:00
to {
transform: translateX(5rpx);
2024-05-22 18:05:56 +08:00
}
2024-05-30 01:20:31 +08:00
}
2024-05-22 18:05:56 +08:00
}
</style>