123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <view class="content">
- <view class="text-area">
- <view class="text-area-content">
- <view class="logoText">
- <!-- :src="imgSrc('/profile/logo/logo.png')" -->
- <image class="logo" :src="imgSrc('/profile/logo/logo.png')"></image>
- <image
- class="logo1"
- :src="imgSrc('/profile/logo/schoolName.jpg')"
- mode="aspectFit"></image>
- <!-- <text class="text1"></text> -->
- </view>
- <text class="text2">实验室管理系统</text>
- </view>
- <view class="form-area">
- <view class="form-area-content">
- <view class="name-area">
- <text class="input-label">工号</text>
- <!-- <i class="iconfont icon-a-shezhi2" style="margin-right: 10rpx;"></i> -->
- <u--input
- clearable
- placeholder="请输入工号"
- border="none"
- v-model="form.account"
- maxlength="10"></u--input>
- </view>
- <view class="pwd-area">
- <text class="input-label">
- 密码
- </text>
- <!-- <i class="iconfont icon-a-shezhi2" style="margin-right: 10rpx;"></i> -->
- <view class="password-input">
- <u--input
- border="none"
- v-model="form.password"
- placeholder="请输入密码"
- clearable
- :type="pwdType"
- >
- </u--input>
- <i @click="showPwd()" class="iconfont" style="margin-left: 10rpx;" :class="showP?'icon-xianshi':'icon-yincang'"></i>
- </view>
-
- </view>
- </view>
- </view>
- <button class="form-area-btn" @click="toLogin">登 录</button>
-
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import { getImage } from '@/api/visitor.js'
- 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:'',
- password:''
- },
- showP:false,
- showPassword: true,
- pwdType:"password"
- };
- },
- methods:{
- showPwd(){
- this.showP = !this.showP
- if(this.showP){
- this.pwdType = "text"
- }else{
- this.pwdType = "password"
- }
-
- },
- imgSrc(src) {
- return getImage(src)
- },
- toLogin(){
- uni.showLoading({
- title:"正在登录中",
- icon:'none',
- mask:true
- })
- 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.switchTab({
- 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: 25%;
- transform: translateY(-20%);
- text-align: center;
- width: 80%;
- // overflow: hidden;
- }
- .text-area-content{
- // animation-name: logoText;
- // animation-duration: 1s;
- .logoText{
- .logo{
- height: 100rpx;
- width: 100rpx;
- }
- .logo1{
- height: 100rpx;
- width: 320rpx;
- }
- .text1_bck{
- color: $uni-text-color;
- font-size: 56rpx;
- transform:translateY(-10%);
- height: 100rpx;
- line-height: 100rpx;
- }
- margin-bottom: 20rpx;
- -webkit-box-reflect: below -20% -webkit-linear-gradient(transparent, transparent 50%, rgba(255, 255, 255, .3));
- }
- .text2{
- color: rgba(128, 128, 128, 1);
- font-size: 36rpx;
- line-height: 150%;
- }
- }
- .form-area{
- margin-top: 80rpx;
- margin-bottom: 160rpx;
- .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-bottom: rgba(0, 0, 0, 0.2) solid 2rpx;
- text-align: left;
- // box-sizing: border-box;
- display: flex;
- // align-items: center;
- flex-direction: column;
- margin-bottom: 10rpx;
-
- }
- .name-area{
- // border-radius: 20rpx 20rpx 0 0;
- }
- .pwd-area{
- // border-radius:0 0 20rpx 20rpx ;
- .password-input{
- display:flex;
- align-items: center;
- .iconfont{
- color: #8c8986;
- }
- }
- }
- .input-label{
- margin: 16rpx 0;
- font-size: 36rpx;
- }
- }
-
- .form-area-btn{
- height: 100rpx;
- width: 100%;
- line-height: 100rpx;
- outline: none;
- background: #19be6b;
- color: $uni-text-color-inverse;
- border-radius: 20rpx;
- margin-top: 30rpx;
- font-size: 32rpx;
- }
-
- @keyframes logoText {
- from {
- transform: scaleY(0);
- }
- to {
- transform: scaleY(1);
- }
- }
- </style>
|