123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <view class="content">
- <view class="text-area">
- <view class="text-area-content">
- <text class="text1">广州医科大</text>
- <view class="line"></view>
- <text class="text2">实验室管理系统</text>
- </view>
- <view class="form-area">
- <view class="form-area-content">
- <view class="name-area">
- <u--input
- placeholder="请输入内容"
- border="none"
- v-model="form.account"></u--input>
- </view>
- <view class="pwd-area">
- <u--input
- border="none"
- v-model="form.password"
- placeholder="请输入内容"
- password
- clearable
- ></u--input>
- </view>
- </view>
- <button class="form-area-btn" @click="toLogin">登录</button>
- </view>
-
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import { login,getInfo } from "@/api/user.js"
- import { setToken } from "@/utils/auth.js"
- import cache from '@/utils/storage.js'
- export default {
- data() {
- return {
- form:{
- account:'admin',
- password:'admin123'
- },
- showPassword: true,
- pwdType:"password"
- };
- },
- methods:{
- showPwd(){
- this.pwdType = "text"
- },
- toLogin(){
- uni.showLoading()
- try{
- login(this.form.account,this.form.password).then(res=>{
- setToken(res.data.token)
- getInfo().then(res=>{
- if(res.data.code===200){
- uni.hideLoading()
- cache.session.setJSON('role',res.data.roles[0])
- cache.session.setJSON('phone',res.data.user.phonenumber)
- cache.session.setJSON('email',res.data.user.email)
- cache.session.setJSON('nickName',res.data.user.nickName)
- cache.session.setJSON('userName',res.data.user.userName)
- cache.session.setJSON('userId',res.data.user.userId)
- uni.reLaunch({
- url:'/pages/home/home'
- })
- }
- })
- })
- }catch(err){
- uni.hideLoading()
- }
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .text-area {
- display: flex;
- justify-content: center;
- flex-direction: column;
- position: fixed;
- top: 50%;
- transform: translateY(-50%);
- text-align: center;
- width: 80%;
- }
- .text-area-content{
- .text1{
- color: $uni-text-color;
- font-size: 56rpx;
- line-height: 150%;
- }
- .text2{
- color: rgba(128, 128, 128, 1);
- font-size: 30rpx;
- line-height: 150%;
- }
- .line{
- width: 354rpx;
- height: 2rpx;
- margin: auto;
- color: $uni-text-color;
- background-color: $uni-text-color-grey;
- font-size: 32rpx;
- line-height: 150%;
- text-align: center;
- }
- }
- .form-area{
- margin-top: 60rpx;
- .name-area,.pwd-area{
- width: 100%;
- height: 100rpx;
- padding-left: 20rpx;
- padding-right: 20rpx;
- color: $uni-text-color-black;
- font-size: 30rpx;
- // line-height: 150%;
- border: rgba(0, 0, 0, 1) solid 2rpx;
- text-align: left;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- }
- .name-area{
- border-radius: 20rpx 20rpx 0 0;
- }
- .pwd-area{
- border-radius:0 0 20rpx 20rpx ;
- border-top: 0;
- }
- .form-area-btn{
- height: 100rpx;
- width: 100%;
- line-height: 100rpx;
- outline: none;
- background: #000;
- color: $uni-text-color-inverse;
- border-radius: 20rpx;
- margin-top: 30rpx;
- font-size: 28rpx;
- }
- }
- </style>
|