123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <template>
- <view class="content">
- <view class="status_bar"></view>
- <view class="logo">
- <image src="~@/static/logo.png" mode="aspectFit"></image>
- </view>
- <view class="title">
- <text>E信管理</text>
- </view>
- <view class="login_box">
- <view class="item">
- <view class="name">工号</view>
- <view class="input">
- <input type="text" value="" v-model="user.username" />
- </view>
- <view class="icon icon_avatar"></view>
- </view>
- <view class="item">
- <view class="name">密码</view>
- <view class="input">
- <input type="password" value="" v-model="user.password" />
- </view>
- <view class="icon icon_password"></view>
- </view>
- </view>
- <view class="tips">
- <text>忘记密码?请联系信息科管理员重置</text>
- </view>
- <!-- <view class="tips">
- <text>忘记密码?请联系信息科重置密码</text>
- </view> -->
- <view class="login_btn" @click="loginBtn()">
- <text>登录</text>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- user: {
- username: '',
- password: ''
- }
- };
- },
- onLoad() {
- },
- methods: {
- loginBtn() {
- const user = this.user
- uni.setStorageSync('login_password', this.user.password)
- // 判断是否为空
- if (user.username == '' || user.password == '') {
- uni.showToast({
- icon: "none",
- title: "请填写用户信息"
- })
- return false
- }
- this.$api.login({
- username: user.username,
- password: user.password
- }).then((res) => {
- if (res.data.code === 0) {
- // console.log(res.data.data.token_type +''+res.data.data.access_token)
- console.log(res.data.data.user.mobile)
- uni.setStorageSync('Authorization', res.data.data.access_token)
- uni.setStorageSync('token_type', res.data.data.token_type)
- // 存储用户基本信息
- uni.setStorageSync('user', res.data.data.user);
- // 存储电话号码
- uni.setStorageSync('mobile', res.data.data.user.mobile);
- setTimeout(function() {
- uni.showToast({
- icon: "none",
- title: "登录成功"
- })
- uni.switchTab({
- url:"../../tabbar/index/index",
- success: () => {
- //#ifdef H5
- window.location.reload();
- //#endif
- }
- })
- }, 500)
- // #ifdef APP-PLUS
- plus.runtime.restart();
- // #endif
- } else if (res.data.code === 1001) {
- uni.showToast({
- icon: "none",
- title: "用户不存在"
- })
- } else if (res.data.code === 1002) {
- uni.showToast({
- icon: "none",
- title: "密码错误"
- })
- } else {
- return false
- }
- }).catch((err) => {
- console.log('request fail', err);
- uni.showToast({
- icon: "none",
- title: err
- })
- })
- },
- }
- }
- </script>
- <style lang="scss">
- page {}
- .content {
- width: 749rpx;
- height: 100vh;
- background-image: url(~@/static/login.png);
- background-size: cover;
- background-position: center center;
- background-repeat: no-repeat;
- .logo {
- width: 344rpx;
- height: 350rpx;
- margin: 0 auto;
- padding-top: 100rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .title {
- margin: 0 auto;
- margin-top: 32rpx;
- width: 288rpx;
- height: 47rpx;
- font-size: 36rpx;
- font-family: MicrosoftYaHei;
- color: #FFFFFF;
- line-height: 47rpx;
- text-align: center;
- }
- .login_box {
- padding-top: 40px;
- .item {
- margin: 0 auto;
- margin-bottom: 20px;
- width: 500rpx;
- height: 45px;
- background: #FFFFFF;
- border-radius: 25px;
- padding-left: 20px;
- padding-right: 20px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- .name {
- width: 80rpx;
- font-size: 16px;
- color: #009FE8;
- line-height: 45px;
- }
- .input {
- width: 280rpx;
- input {
- height: 45px;
- color: #666;
- }
- }
- .icon {}
- .icon_avatar {
- margin-left: 10rpx;
- width: 25px;
- height: 25px;
- background-image: url(./icon/Avatar.png);
- background-size: cover;
- background-repeat: no-repeat;
- }
- .icon_password {
- margin-left: 18rpx;
- width: 25px;
- height: 28px;
- background-image: url(./icon/Password.png);
- background-size: cover;
- background-repeat: no-repeat;
- }
- }
- }
- .tips {
- margin: 0 auto;
- margin-top: 25px;
- text-align: center;
- font-size: 14px;
- color: #ECF0F1;
- line-height: 40px;
- text-align: center;
- }
- .login_btn {
- margin: 0 auto;
- margin-top: 40px;
- width: 200px;
- height: 50px;
- background: rgba(100, 220, 255, 0.8);
- border-radius: 25px;
- text-align: center;
- line-height: 50px;
- text {
- font-size: 18px;
- color: #FFFFFF;
- letter-spacing: 4px;
- }
- }
- }
- </style>
|