2024-06-15 17:29:39 +08:00
|
|
|
|
<template>
|
2024-06-22 19:21:24 +08:00
|
|
|
|
<view class="content">
|
|
|
|
|
<view style="text-align: center;">
|
|
|
|
|
<image class="logo" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/35adb202404271727457954.png">
|
|
|
|
|
</image>
|
2024-06-22 19:48:52 +08:00
|
|
|
|
<view class="tips">欢迎登录泸优采</view>
|
2024-06-22 19:21:24 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class='card'>
|
|
|
|
|
<view style="display: flex;align-items: center;">
|
2024-07-29 17:17:31 +08:00
|
|
|
|
<text>账号:</text>
|
|
|
|
|
<up-input v-model="formData.account" placeholder="请输入账号或手机号"></up-input>
|
2024-06-22 19:21:24 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view style="margin: 30rpx 0;">
|
|
|
|
|
</view>
|
|
|
|
|
<view style="display: flex;justify-content: space-between;align-items: center;">
|
2024-07-29 17:17:31 +08:00
|
|
|
|
<text style="margin-right: 20rpx;">密码:</text>
|
|
|
|
|
<up-input v-model="formData.password" placeholder="请输入密码" password="true"></up-input>
|
2024-06-22 19:21:24 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="submit-btn">
|
|
|
|
|
<up-button @click="submit" color="#20B128" size="large">
|
|
|
|
|
登录</up-button>
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
|
2024-06-15 17:29:39 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import {
|
2024-06-17 08:38:39 +08:00
|
|
|
|
userLoginApi,
|
2024-06-17 20:47:54 +08:00
|
|
|
|
userInfoApi,
|
2024-06-22 19:21:24 +08:00
|
|
|
|
getStoreInfo,
|
2024-06-24 15:03:11 +08:00
|
|
|
|
getloginSms,
|
|
|
|
|
loginUpdateUserApi
|
2024-06-15 17:29:39 +08:00
|
|
|
|
} from "@/api/user.js";
|
|
|
|
|
import {
|
2024-06-22 19:21:24 +08:00
|
|
|
|
ref,
|
|
|
|
|
reactive
|
2024-06-15 17:29:39 +08:00
|
|
|
|
} from "vue"
|
|
|
|
|
import useUserStore from "@/store/user";
|
|
|
|
|
const userStore = useUserStore();
|
2024-06-22 19:21:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formData = reactive({
|
|
|
|
|
account: "",
|
|
|
|
|
code: "",
|
2024-07-29 17:17:31 +08:00
|
|
|
|
password:'',
|
2024-06-22 19:21:24 +08:00
|
|
|
|
terminal: 1,
|
2024-07-29 17:17:31 +08:00
|
|
|
|
scene: 1
|
2024-06-22 19:21:24 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取验证码
|
|
|
|
|
const cutDown = ref(0)
|
|
|
|
|
const flag = ref(true)
|
|
|
|
|
const code = ref('')
|
|
|
|
|
const checkPhone = (phone) => {
|
|
|
|
|
const regex = /^1[3-9]\d{9}$/;
|
|
|
|
|
return regex.test(phone) ? true : false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getCode = async () => {
|
|
|
|
|
if (!checkPhone(formData.account)) return uni.$u.toast('请输入正确的手机号')
|
|
|
|
|
await getloginSms({
|
|
|
|
|
account: formData.account
|
|
|
|
|
})
|
|
|
|
|
flag.value = false
|
|
|
|
|
cutDown.value = 60
|
|
|
|
|
let timer = setInterval(() => {
|
|
|
|
|
cutDown.value--
|
|
|
|
|
if (cutDown.value <= 0) clearInterval(timer)
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
// 获取验证码结束
|
|
|
|
|
|
|
|
|
|
|
2024-06-15 17:29:39 +08:00
|
|
|
|
const zh = ref("")
|
|
|
|
|
|
|
|
|
|
const submit = () => {
|
2024-06-17 08:38:39 +08:00
|
|
|
|
userLoginApi({
|
2024-06-22 19:48:52 +08:00
|
|
|
|
...formData
|
2024-06-15 17:29:39 +08:00
|
|
|
|
}).then(res => {
|
2024-06-17 20:47:54 +08:00
|
|
|
|
getStoreInfo().then(res => {
|
|
|
|
|
uni.setStorageSync("STORE_INFO", JSON.stringify(res.data))
|
|
|
|
|
})
|
2024-06-15 17:29:39 +08:00
|
|
|
|
uni.setStorageSync('token', res.data.token);
|
|
|
|
|
userStore.setToken(res.data.token);
|
|
|
|
|
userInfoApi().then(res => {
|
|
|
|
|
const user = res.data;
|
|
|
|
|
userStore.setUserInfo(user);
|
2024-06-24 15:03:11 +08:00
|
|
|
|
if (!user.openid) loginUpdateUserApi({
|
|
|
|
|
mobile: user.mobile
|
|
|
|
|
})
|
2024-06-15 17:29:39 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/index/index'
|
|
|
|
|
}) // 存储token到本地存储中
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-06-22 19:21:24 +08:00
|
|
|
|
<style lang='scss'>
|
|
|
|
|
.content {
|
|
|
|
|
background-color: white;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding-top: 15vh;
|
|
|
|
|
|
|
|
|
|
.logo {
|
|
|
|
|
height: 152rpx;
|
|
|
|
|
width: 152rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tips {
|
|
|
|
|
color: #444444;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
margin: 30rpx 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.card {
|
|
|
|
|
padding: 50rpx;
|
|
|
|
|
background-color: white;
|
|
|
|
|
margin-bottom: 30rpx;
|
|
|
|
|
padding-bottom: 30rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.submit-btn {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 100rpx;
|
|
|
|
|
width: 710rpx;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.code-btn {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn-text {
|
|
|
|
|
color: #20B128;
|
|
|
|
|
}
|
2024-06-15 17:29:39 +08:00
|
|
|
|
</style>
|