123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <template>
- <view class="hc-login-box relative h-full p-4">
- <view class="hc-dot-box">
- <view un-absolute un-b-rounded-100 class="dot dot-1"/>
- <view un-absolute un-b-rounded-100 class="dot dot-2"/>
- <view un-absolute un-b-rounded-100 class="dot dot-3"/>
- </view>
- <view class="hc-login-container">
- <view class="hc-login-center">
- <view class="hc-login-title">欢迎登录</view>
- <view class="hc-login-text">让每一个数据更具价值</view>
- <view class="hc-login-form">
- <view class="hc-login-form-item">
- <input class="hc-login-input" v-model="formData.username" placeholder="请输入登录账户"/>
- </view>
- <view class="hc-login-form-item">
- <input type="password" class="hc-login-input" v-model="formData.password"
- placeholder="请输入登录密码"/>
- </view>
- </view>
- <button class="mt-16" :type="!formData.username || !formData.password ? 'info' : 'primary'" @click="submitClick">
- <text class="mr-5">登</text>
- <text class="ml-5">录</text>
- </button>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {ref, onMounted} from "vue";
- import {onLoad, onUnload} from '@dcloudio/uni-app'
- import {getStorage, setStorage} from "@/utils/storage";
- import {useAppStore} from "@/store";
- import {userLogin} from "@/store/user";
- import {getObjVal} from "js-fast-way";
- //初始变量
- const store = useAppStore()
- onLoad(() => {
- const user_info = getStorage('login_user_info');
- if (getObjVal(user_info)) {
- formData.value = user_info
- }
- //清除所有缓存
- store.clearStoreData()
- })
- //渲染完成
- onMounted(() => {
- })
- //登录表单
- const formData = ref({
- tenantId: "000000",
- username: '',
- password: '',
- type: "account"
- })
- //登录
- const submitClick = () => {
- const {username, password} = formData.value
- if (!username) {
- uni.showToast({
- title: '请先输入登录账户',
- icon: 'none',
- duration: 3000
- });
- } else if (!password) {
- uni.showToast({
- title: '请先输入登录密码',
- icon: 'none',
- duration: 3000
- });
- } else {
- userLogin(formData.value).then((res) => {
- uni.showToast({
- title: '登录成功',
- duration: 2000,
- mask: true
- });
- //跳转登录
- setTimeout(() => {
- uni.switchTab({
- url: '/pages/index/index'
- })
- }, 2000);
- })
- }
- }
- onUnload(()=>{
- })
- </script>
- <style lang="scss" scoped>
- page {
- height: 100%;
- }
- @import "@/style/login/login.scoped.scss";
- </style>
- <style lang="scss">
- @import "@/style/login/login.scss";
- </style>
|