login.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="adminLogin">
  3. <navigation-bar-view ref="nav"></navigation-bar-view>
  4. <view class="body">
  5. <view class="input-box">
  6. <input :value="body.account" placeholder="请输入账号" placeholder-style="color: #B7B7B7" @input="changeAccount" />
  7. </view>
  8. <view class="input-box" style="margin-top: 1.7vw;">
  9. <input placeholder="请输入密码" password placeholder-style="color: #B7B7B7" @input="changePassword" />
  10. </view>
  11. <view class="btn" @click="login">登录</view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import navigationBarView from '../../components/navigationBarView.vue';
  17. export default {
  18. components: {
  19. navigationBarView
  20. },
  21. data() {
  22. return {
  23. body: {
  24. account: '',
  25. password: ''
  26. }
  27. }
  28. },
  29. onLoad() {
  30. this.body.account = uni.getStorageSync('account');
  31. },
  32. methods: {
  33. changeAccount(e) {
  34. console.log(e);
  35. this.body.account = e.detail.value;
  36. },
  37. changePassword(e) {
  38. this.body.password = e.detail.value;
  39. },
  40. login() {
  41. this.body.deviceSn = uni.getStorageSync('sn');
  42. this.$api.managerLogin(this.body).then(res => {
  43. uni.setStorageSync('access_token', res.data.token);
  44. uni.setStorageSync('account', this.body.account);
  45. uni.redirectTo({
  46. url: '/pages/admin/index'
  47. })
  48. })
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. .adminLogin {
  55. width: 100vw;
  56. height: 100vw;
  57. background-color: #FFFFFF;
  58. .body {
  59. padding: 30.3vw 7.3vw 0;
  60. .input-box {
  61. padding: 4.3vw 0;
  62. border-bottom: 2rpx solid #999999;
  63. input {
  64. font-size: 4.3vw;
  65. }
  66. }
  67. .btn {
  68. display: flex;
  69. align-items: center;
  70. justify-content: center;
  71. height: 11.5vw;
  72. border-radius: 11.5vw;
  73. margin-top: 8.1vw;
  74. font-weight: 500;
  75. font-size: 4.3vw;
  76. background: linear-gradient(to right, #FEE704, #FDD001);
  77. }
  78. }
  79. }
  80. </style>