Files
hht-tongbo/pages/login/login.vue

154 lines
3.9 KiB
Vue
Raw Normal View History

2022-11-16 17:11:24 +08:00
<template>
<view class="zd_content bg">
<view class="p1">欢迎来到</view>
2022-10-15 10:00:08 +08:00
<view class="p2">海亮铜箔手持系统</view>
2022-11-16 17:11:24 +08:00
<view class="input-box">
<input class="large-input" type="text" placeholder="请输入用户名" v-model="user">
2022-10-10 10:19:18 +08:00
</view>
2022-11-16 17:11:24 +08:00
<div class="input-box">
<input class="large-input" :password="!showPassword" placeholder="请输入密码" v-model="password">
<span class="iconfont icon_eye_close" :class="[showPassword ? 'icon_eye_active' : '']" @tap="changePassword">&#xe6a0;</span>
2022-10-10 10:19:18 +08:00
</div>
<view class="radio-box">
<view class="radio-wrap">
2022-10-11 17:03:44 +08:00
<span class="iconfont icon_unchecked" :class="{'icon_checked': saveUser}" @tap="toSaveUser">&#xe66b;</span>
2022-10-10 10:19:18 +08:00
<text class="radio-label">记住用户名</text>
</view>
2022-10-11 17:03:44 +08:00
<text class="setup-text" @tap="setup">设置</text>
2022-11-11 16:37:46 +08:00
<text class="setup-text" @tap="isUpdate">升级版本</text>
2022-10-10 10:19:18 +08:00
</view>
2022-11-01 14:25:20 +08:00
<button class="login-btn" :disabled="disabled" @tap="toLogin">确认登录</button>
2022-11-16 17:11:24 +08:00
<!-- <button class="login-btn" @tap="test">打印</button> -->
</view>
</template>
2022-10-10 10:19:18 +08:00
<script>
2022-11-01 14:25:20 +08:00
import {getCLodop, getPrinterList} from "@/utils/CLodopfuncs.js"
2022-10-10 10:19:18 +08:00
import { RSAencrypt } from '@/utils/jsencrypt.js'
2022-11-09 13:30:32 +08:00
import {handLogin} from '@/utils/getData2.js'
2022-11-11 16:37:46 +08:00
export default {
2022-11-16 17:11:24 +08:00
data() {
return {
2022-10-10 10:19:18 +08:00
user: this.$store.getters.loginName ? this.$store.getters.loginName : '',
password: '',
showPassword: false,
saveUser: this.$store.getters.loginName ? true : false,
2022-11-16 17:11:24 +08:00
disabled: false
}
2022-10-14 15:46:39 +08:00
},
2022-10-15 16:43:09 +08:00
created () {
2022-11-16 17:11:24 +08:00
},
2022-11-01 14:25:20 +08:00
methods: {
2022-11-11 16:37:46 +08:00
isUpdate () {
uni.navigateTo({
url: `/pages/login/upgrade`
})
2022-11-09 13:30:32 +08:00
},
2022-11-01 14:25:20 +08:00
test() {
let LODOP = getCLodop();
// 更换为打印服务器ip 不需要加前缀
LODOP.PRINT_INIT(null, "192.168.81.198");
// 打印机序号 规则为打印服务器打印机列表倒数从0开始 -1为默认打印机
LODOP.SET_PRINTER_INDEX(-1);
// 设置打印纸大小
LODOP.SET_PRINT_PAGESIZE(1, 800, 600, "");
// 根据需求插入打印代码
LODOP.PRINT(); // 打印
// LODOP.PREVIEW()
2022-11-16 17:11:24 +08:00
},
2022-10-10 10:19:18 +08:00
toSaveUser() {
this.saveUser = !this.saveUser
},
changePassword() {
this.showPassword = !this.showPassword
},
setup () {
uni.redirectTo({
url: '/pages/login/setup'
})
},
async toLogin() {
2022-11-28 14:59:47 +08:00
uni.redirectTo({
url: '/pages/home/home'
})
2022-10-10 10:19:18 +08:00
this.disabled = true
if (this.user === '') {
uni.showToast({
title: '用户名不能为空',
icon: 'none'
})
this.disabled = false
return
}
2022-10-11 10:31:02 +08:00
if (this.password === '') {
2022-10-10 10:19:18 +08:00
uni.showToast({
title: '密码不能为空',
icon: 'none'
})
this.disabled = false
return
}
try {
let res = await handLogin(this.user, RSAencrypt(this.password))
2022-10-10 19:58:07 +08:00
if (this.saveUser) {
this.$store.dispatch('saveLoginName', this.user)
2022-10-10 10:19:18 +08:00
} else {
2022-10-10 19:58:07 +08:00
this.$store.dispatch('delLoginName', '')
2022-10-10 10:19:18 +08:00
}
2022-10-10 19:58:07 +08:00
this.$store.dispatch('saveUserInfo', JSON.stringify(res.user.user))
this.$store.dispatch('saveToken', res.token)
uni.redirectTo({
url: '/pages/home/home'
})
2022-10-10 10:19:18 +08:00
this.disabled = false
} catch (e) {
this.disabled = false
}
2022-11-16 17:11:24 +08:00
}
}
}
</script>
2022-10-10 10:19:18 +08:00
<style lang="stylus" scoped>
@import '../../common/style/mixin.styl';
2022-11-16 17:11:24 +08:00
.p1
_font(60rpx,75rpx,#444)
padding-top: 90rpx
.p2
_font(50rpx,1,#444)
2022-10-10 10:19:18 +08:00
padding: 40rpx 0 25rpx
.input-box
2022-11-16 17:11:24 +08:00
_fj()
2022-10-10 10:19:18 +08:00
margin-top 68rpx
2022-11-16 17:11:24 +08:00
height 75rpx
border-bottom 1rpx solid #e2e2e2
2022-10-10 10:19:18 +08:00
.large-input
_wh(calc(100% - 40rpx), 74rpx)
2022-11-16 17:11:24 +08:00
_font(32rpx,74rpx,#999)
2022-10-10 10:19:18 +08:00
padding-left 10rpx
.radio-box
_fj()
margin: 25rpx 0 70rpx 0
height: 34rpx
.radio-wrap
2022-11-11 16:37:46 +08:00
_fj(flex-start)
2022-10-10 10:19:18 +08:00
height: 34rpx
2022-11-11 16:37:46 +08:00
flex: 2
2022-10-10 10:19:18 +08:00
.radio-label
_font(28rpx, 28rpx,#333)
2022-10-11 10:31:02 +08:00
padding-left: 10rpx
2022-10-10 10:19:18 +08:00
.setup-text
2022-10-11 10:31:02 +08:00
_font(28rpx, 28rpx,$red,,right)
2022-11-11 16:37:46 +08:00
padding-left 25rpx
2022-10-10 10:19:18 +08:00
.bg
2022-10-11 17:03:44 +08:00
background-color: #fff;
2022-10-10 10:19:18 +08:00
_bis('../../static/image/login_bg.png', 100%,,bottom)
2022-11-16 17:11:24 +08:00
.login-btn
width 100%
border-radius 46rpx
_font(36rpx,92rpx,#fff,,center)
2022-10-10 10:19:18 +08:00
background-color $red
2022-10-15 15:29:58 +08:00
.zd_content
2022-10-14 09:34:25 +08:00
height: 100%
2022-11-16 17:11:24 +08:00
</style>