| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <view class="loginbox">
- <view class="login_info">
- <view class="title">
- 登录
- </view>
- <u--form labelPosition="left" :model="userinfo" :rules="rules" ref="uForm">
- <u-form-item label="" prop="name" ref="item1">
- <u--input v-model="userinfo.name" border="none" placeholder="请输入账号"></u--input>
- </u-form-item>
- <u-form-item label="" prop="password" ref="item1">
- <u--input v-model="userinfo.password" border="none" placeholder="请输入密码" type="password"></u--input>
- </u-form-item>
- </u--form>
- <u-checkbox-group v-model="checkboxValue1" placement="column">
- <u-checkbox :customStyle="{marginBottom: '8px'}" label="记住密码" name="0" size="13" labelSize="13">
- </u-checkbox>
- </u-checkbox-group>
- <u-button type="primary" text="登录" @click="verify">{{isloading?"登录中...":"登录"}}</u-button>
- </view>
- </view>
- </template>
- <script>
- import {mapMutations} from 'vuex'
- export default {
- data() {
- return {
- userinfo: {
- name: "",
- password: "",
- },
- rules: {
- 'name': {
- type: 'string',
- required: true,
- message: '请输入账号',
- trigger: ['blur', 'change']
- },
- 'password': {
- type: 'string',
- required: true,
- message: '请输入密码',
- trigger: ['blur', 'change']
- },
- },
- checkboxValue1: [],
- isloading: false
- }
- },
- methods: {
- ...mapMutations(['updateInLoginPageStatus']),
- verify() {
- this.$refs.uForm.validate().then(res => {
- // uni.$u.toast('校验通过')
- this.login()
- }).catch(errors => {
- // uni.$u.toast('校验失败')
- })
- },
- async getlistinfo() {
- var that = this
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=sysmenage.usermanager.user_info',
- })
- // console.log(res)
- this.app = res.children.filter((item) => {
- return item.purview_name == "APP"
- })
- // console.log(this.app)
- if (this.app.length == 0) {
- uni.setTabBarItem({
- index: 0,
- visible: false
- });
- uni.setTabBarItem({
- index: 1,
- visible: false
- });
- uni.switchTab({
- url: "../response/index"
- })
- } else {
- var renwu = this.app[0].children.some((item) => {
- // console.log(item)
- return item.purview_name == "我的任务"
- })
- var jiandu = this.app[0].children.some((item) => {
- // console.log(item)
- return item.purview_name == "监督"
- })
- if (renwu) {
- uni.setTabBarItem({
- index: 0,
- visible: true
- });
- } else {
- uni.setTabBarItem({
- index: 0,
- visible: false
- });
- }
- if (jiandu) {
- uni.setTabBarItem({
- index: 1,
- visible: true
- });
- } else {
- uni.setTabBarItem({
- index: 1,
- visible: false
- });
- }
- if(renwu){
- uni.switchTab({
- url: "../index/index"
- })
- }else{
- uni.switchTab({
- url: "../supervise/index"
- })
- }
- }
-
- // #ifdef APP-PLUS
- plus.runtime.restart(); // 重启App
- console.log1p('重启App啦')
- // #endif
- },
- async login() {
- this.isloading = true
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=sysmenage.usermanager.user_login',
- data: {
- username: this.userinfo.name,
- password: this.userinfo.password,
- }
- })
- console.log(res)
- if (res) {
- if (this.checkboxValue1.length) {
- uni.setStorage({
- key: 'logincheckbox',
- data: 1,
- })
- uni.setStorage({
- key: 'username',
- data: this.userinfo.name,
- })
- uni.setStorage({
- key: 'password',
- data: this.userinfo.password,
- })
- } else {
- uni.setStorage({
- key: 'logincheckbox',
- data: 0,
- })
- }
- uni.setStorage({
- key: 'session_key',
- data: res.session_key,
- success: () => {
- this.getlistinfo()
- }
- })
- }else{
- console.log("登陆失败")
- }
- },
- },
- onShow() {
- this.isloading = false
- },
- onLoad() {
- this.updateInLoginPageStatus(true)
- this.isloading = false
- uni.getStorage({
- key: 'logincheckbox',
- success: (res) => {
- console.log(res)
- if (res.data) {
- this.checkboxValue1 = ["0"]
- uni.getStorage({
- key: 'username',
- success: (res) => {
- this.userinfo.name = res.data
- },
- })
- uni.getStorage({
- key: 'password',
- success: (res) => {
- this.userinfo.password = res.data
- },
- })
- uni.getStorage({
- key: 'session_key',
- success: (res) => {
- console.log(res)
- uni.removeStorage({
- key: 'session_key'
- })
- if (res.data != "") {
- this.login()
- }
- },
- })
- } else {
- this.checkboxValue1 = []
- }
- },
- })
- },
- mounted() {
- this.updateInLoginPageStatus(true)
- },
- onHide(){
- console.log('login page hide')
- this.updateInLoginPageStatus(false)
- }
- }
- </script>
- <style lang="less">
- .loginbox {
- width: 100%;
- height: 100vh;
- background-image: url(../../static/image/login.jpg);
- background-size: 100% 100%;
- padding-top: 400rpx;
- box-sizing: border-box;
- .login_info {
- width: 90%;
- margin: 0 auto;
- height: 600rpx;
- background-color: #fff;
- box-shadow: 0px 0px 8px rgba(64, 158, 255, 0.1);
- padding: 40rpx 80rpx;
- box-sizing: border-box;
- border-radius: 20rpx;
- .title {
- width: 100%;
- height: 100rpx;
- text-align: center;
- line-height: 100rpx;
- font-size: 50rpx;
- color: #409EFF;
- margin-bottom: 30px;
- }
- /deep/.u-form-item__body {
- margin-bottom: 40rpx;
- border-bottom: 1px solid rgb(214, 215, 217);
- }
- /deep/.u-button {
- margin-top: 40rpx;
- border-radius: 38rpx;
- }
- // /deep/.u-checkbox__icon-wrap{
- // width: 26rpx !important;
- // height: 26rpx !important;
- // }
- }
- }
- </style>
|