login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view>
  3. <view class="wrap">
  4. <view class="title">城市智慧停车场管理<br>PDA登录</view>
  5. <u-form class="login-form" :model="form" ref="uForm">
  6. <u-form-item label="账号:" :border-bottom="false" label-width="100rpx">
  7. <u-input v-model="form.name" placeholder="请输入您的工号" placeholder-style="color:rgba(255,255,255,.5)" />
  8. </u-form-item>
  9. <u-form-item label="密码:" :border-bottom="false" label-width="100rpx">
  10. <u-input v-model="form.password" type="password" placeholder="请输入您的密码" placeholder-style="color:rgba(255,255,255,.5)" />
  11. </u-form-item>
  12. </u-form>
  13. <view class="pass-tool">
  14. <u-checkbox v-model="form.passCheck" active-color="transparent">记住密码</u-checkbox>
  15. <view class="">忘记密码?</view>
  16. </view>
  17. <view class="login-btn" @click="handleLogin">立即登录</view>
  18. </view>
  19. <u-toast ref="uToast" />
  20. <u-bottom ></u-bottom>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. pic:'https://uviewui.com/common/logo.png',
  28. userInfo:[],
  29. form:{
  30. name:'13567532565',
  31. password:'000000',
  32. passCheck:false
  33. },
  34. }
  35. },
  36. onLoad() {
  37. uni.getStorage({
  38. key:'loginData',
  39. success: (res) => {
  40. this.form.name = res.data.name;
  41. this.form.password = res.data.password;
  42. console.log('passWord',res.data)
  43. },
  44. fail: (err) => {
  45. console.log('passWord err',err)
  46. }
  47. })
  48. },
  49. methods: {
  50. openPage(path) {
  51. console.log('path',path);
  52. this.$u.route({
  53. url: path
  54. })
  55. },
  56. //登录判断
  57. // login(status){
  58. // if(!status){
  59. // console.log('config',this.config);
  60. // window.location.replace(this.config.loginUrl)
  61. // }
  62. // },
  63. handleLogin(){
  64. this.$u.api.login(this.form)
  65. .then(res=>{
  66. this.$refs.uToast.show({
  67. title: res.msg,
  68. type: 'success',
  69. });
  70. this.$u.vuex('vuex_token', res.data.accessToken);
  71. this.$u.vuex('vuex_user', res.data);
  72. this.$u.vuex('vuex_hasLogin', true);
  73. if(this.form.passCheck){
  74. uni.setStorage({
  75. key:'loginData',
  76. data:{name:this.form.name,password:this.form.password}
  77. });
  78. }else{
  79. uni.removeStorage({
  80. key:'loginData'
  81. })
  82. };
  83. this.$u.route('pages/index/index', {});
  84. console.log('getMycars',res)
  85. }).catch(err=>{
  86. this.$refs.uToast.show({
  87. title: err.msg,
  88. type: 'error',
  89. });
  90. console.log('getMycars ',err)
  91. });
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. page{
  98. height: 100%;
  99. background: linear-gradient(to bottom, #1AADFC 0%, #0566E8 100%);
  100. }
  101. @import './login.scss'
  102. </style>