This commit is contained in:
2023-03-21 17:56:02 +08:00
parent 995deef4d5
commit eac8674816
23 changed files with 663 additions and 63 deletions

110
pages/home/home.vue Normal file
View File

@@ -0,0 +1,110 @@
<template>
<view class="content">
<view class="header">
<view class="header-item">
<text class="header-user">登录人员{{userName}}</text>
</view>
<view class="header-item header-r">
<button class="header-button" @click="toExit">退&nbsp;&nbsp;</button>
</view>
</view>
<view class="nav-wrap">
<view class="nav-item"><text class="nav-text" @click="toJump('/pages/equipStatus/equipStatus')">设备状态修改</text></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
userName: this.$store.getters.userInfo ? JSON.parse(this.$store.getters.userInfo).id : ''
}
},
onLoad() {
},
methods: {
toJump(path) {
uni.navigateTo({
url: path
});
},
toExit () {
this.$store.dispatch('delUserInfo', '')
uni.redirectTo({
url: '/pages/login/login'
})
}
}
}
</script>
<style lang="scss" scoped>
.content{
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
width: 100%;
height: 100%;
}
.header{
display: flex;
width: 100%;
height: 44px;
background-color: #d7592f;
}
.header-item {
width: calc(50% - 10px);
padding: 0 10px;
}
.header-user {
font-size: 16px;
line-height: 44px;
color: #ffffff;
}
.header-r{
display: flex;
justify-content: flex-end;
align-items: center
}
/deep/ .header-r uni-button{
margin-right: 0;
}
.header-button{
width: 80px;
height: 30px;
font-size: 16px;
color: #333333;
line-height: 30px;
}
.nav-wrap{
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-content: center;
width: calc(100% - 40%);
height: calc(100% - 44px);
padding: 0 20%;
}
.nav-item{
display: flex;
justify-content: center;
align-items: center;
width: 30%;
height: 100px;
background-color: #acbec6;
border-radius: 10px;
margin: 7.5px 5% 7.5px 0;
}
.nav-item:nth-child(3n){
margin-right: 0;
}
.nav-text{
font-size: 22px;
line-height: 30px;
color: #ffffff;
letter-spacing: 2px;
}
</style>

View File

@@ -1,52 +0,0 @@
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

215
pages/login/login.vue Normal file
View File

@@ -0,0 +1,215 @@
<template>
<view class="login_bg">
<view class="login_wrap">
<view class="login_tab">
<view class="login_tab_line drift" :style="{'left': drift+'%'}"></view>
<view class="login_tab_item" @tap="_tabChange(0)">登录</view>
<view class="login_tab_item" @tap="_tabChange(50)">配置</view>
</view>
<view class="login_cnt drift" :style="{'left': '-'+drift*2+'%'}">
<view class="login_card">
<view class="card_wrap">
<view class="inputOuter">
<input type="text" placeholder="用户名" v-model="loginname" class="inputStyle">
<text v-show="showBtn3" class="iconfont login_icon delete_icon" @tap="clearData(3)"></text>
</view>
<view class="inputOuter">
<input :type="inputType" placeholder="密码" v-model="password" class="inputStyle">
<text class="iconfont login_icon" :class="eyeOpen ? 'eye_colse_icon' : 'eye_open_icon'" @click="passwordShow"></text>
</view>
</view>
<view class="submit">
<button class="primary-button" :disabled="disabled" @click="toLogin">&nbsp;&nbsp;</button>
</view>
<view class="scanBox">
<view class="iconfont scan_icon"></view>
<text class="san_text">扫码登录</text>
</view>
</view>
<view class="login_card">
<view class="card_wrap">
<view class="inputOuter">
<input type="text" placeholder="域名地址" v-model="baseUrl" class="inputStyle">
<text v-show="showBtn1" class="iconfont login_icon delete_icon" @tap="clearData(1)"></text>
</view>
<view class="inputOuter">
<input type="text" placeholder="图片域名地址" v-model="imgBaseUrl" class="inputStyle">
<text v-show="showBtn2" class="iconfont login_icon delete_icon" @tap="clearData(2)"></text>
</view>
</view>
<view class="submit">
<button class="primary-button" :disabled="disabled" @tap="toConfig">&nbsp;&nbsp;</button>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { RSAencrypt } from '@/utils/jsencrypt.js'
import {handLogin} from '@/utils/getData2.js'
export default {
data() {
return {
loginname: '',
password: '',
baseUrl: this.$store.getters.baseUrl,
imgBaseUrl: this.$store.getters.imgBaseUrl,
inputType: 'password',
eyeOpen: true,
drift: 0,
disabled: false,
jobnum: '',
qrcode: '',
logintype: ''
};
},
computed: {
showBtn1 () {
return this.baseUrl !== ''
},
showBtn2 () {
return this.imgBaseUrl !== ''
},
showBtn3 () {
return this.loginname !== ''
}
},
methods: {
_tabChange (num) {
this.drift = num
},
clearData (t) {
switch (t) {
case 1:
this.baseUrl = ''
break
case 2:
this.imgBaseUrl = ''
break
case 3:
this.loginname = ''
break
}
},
passwordShow () {
this.eyeOpen = !this.eyeOpen
if (this.eyeOpen) {
this.inputType = 'password'
} else {
this.inputType = 'text'
}
},
toConfig () {
let obj = {
baseUrl: this.baseUrl,
imgBaseUrl: this.imgBaseUrl
}
this.$store.dispatch('setConfig', obj)
this._tabChange(0)
},
async toLogin() {
this.disabled = true
if (this.loginname === '') {
uni.showToast({
title: '用户名不能为空',
icon: 'none'
})
this.disabled = false
return
}
if (this.password === '') {
uni.showToast({
title: '密码不能为空',
icon: 'none'
})
this.disabled = false
return
}
try {
let res = await handLogin(this.loginname, RSAencrypt(this.password))
this.$store.dispatch('saveUserInfo', JSON.stringify(res.user.user))
this.$store.dispatch('saveToken', res.token)
uni.redirectTo({
url: '/pages/home/home'
})
this.disabled = false
} catch (e) {
this.disabled = false
}
}
}
}
</script>
<style lang="stylus">
@import '../../common/style/mixin.styl';
.login_bg
_wh(100%, 100%)
_bis(#fff,'../../static/images/bg_01.png', 100%,,bottom)
.login_wrap
position fixed
left 50%
top 50%
width 44%
transform translate3d(-50%, -50%, 0)
border-radius 5px
overflow hidden
.login_tab
position relative
height 100rpx
border-bottom 1px solid #E2E2E2
margin-bottom 40rpx
.login_tab_item
float left
width 50%
_font(32rpx,100rpx,#444444,,center)
cursor pointer
.login_tab_line
position absolute
width 50%
height 2px
background-color #D7592F
left 0
bottom -1px
.login_cnt
position relative
width 200%
overflow hidden
.login_card
width 50%
float left
.card_wrap
overflow hidden
.inputOuter
position relative
width 100%
margin 40rpx auto
.inputStyle
_wh(100%,80rpx)
_font(30rpx,80rpx,#999,,)
text-indent 20rpx
border-bottom 1px solid #E2E2E2
box-sizing border-box
.login_icon
position absolute
top 20rpx
right 20rpx
.submit
width 100%
margin 40rpx auto
text-align center
.primary-button
_wh(100%, 80rpx)
background-color #d7592f
border-radius 80rpx
_font(32rpx,80rpx,#fff,,center)
.scanBox
_fj()
flex-direction column
.san_text
_font(32rpx,1,#D7592F,,center)
.drift
transition left .3s linear
</style>