login.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <image src="/static/img/inspection_00.png" style="height: 80px;width: 80px;"></image>
  5. </view>
  6. <view class="list">
  7. <view class="list-call">
  8. <uni-icons type="person" size="28"></uni-icons>
  9. <input class="sl-input" v-model="account" type="text" maxlength="32" placeholder="请输入账号" />
  10. </view>
  11. <view class="list-call">
  12. <uni-icons type="eye" size="28"></uni-icons>
  13. <input class="sl-input" v-model="password" type="text" maxlength="32" placeholder="请输入密码"
  14. password="true" />
  15. </view>
  16. </view>
  17. <view class="button-login" hover-class="button-hover" @click="bindLogin()">
  18. <text>登录</text>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. account: '',
  27. password: ''
  28. };
  29. },
  30. methods: {
  31. bindLogin() {
  32. let that = this;
  33. if (this.account.length==0) {
  34. uni.showToast({
  35. icon: 'none',
  36. title: '请输入账号'
  37. });
  38. return;
  39. }
  40. if (this.password.length==0) {
  41. uni.showToast({
  42. icon: 'none',
  43. title: '请输入密码'
  44. });
  45. return;
  46. }
  47. var data={
  48. UserId: this.account,
  49. Password:this.password
  50. }
  51. this.$api.passwordLogin(data).then(res=>{
  52. if(!res.isSuccess){
  53. uni.showToast({
  54. icon: 'none',
  55. title: res.errMsg
  56. });
  57. return
  58. }
  59. this.$store.commit('setData', res.data.user)
  60. uni.setStorageSync('token',res.tnToken.tokenStr)
  61. //登录成功跳转
  62. uni.navigateTo({
  63. url:'/pages/index/home'
  64. });
  65. });
  66. },
  67. }
  68. }
  69. </script>
  70. <style>
  71. page {
  72. background-color: #fff;
  73. }
  74. .content {
  75. display: flex;
  76. flex-direction: column;
  77. justify-content: center;
  78. }
  79. .header {
  80. width: 161rpx;
  81. height: 161rpx;
  82. border-radius: 50%;
  83. margin-top: 30rpx;
  84. margin-left: auto;
  85. margin-right: auto;
  86. }
  87. .header image {
  88. width: 161rpx;
  89. height: 161rpx;
  90. border-radius: 50%;
  91. }
  92. .list {
  93. display: flex;
  94. flex-direction: column;
  95. padding-top: 50rpx;
  96. padding-left: 70rpx;
  97. padding-right: 70rpx;
  98. }
  99. .list-call {
  100. display: flex;
  101. flex-direction: row;
  102. justify-content: space-between;
  103. align-items: center;
  104. height: 100rpx;
  105. color: #333333;
  106. border-bottom: 0.5px solid #e2e2e2;
  107. margin-top:10px
  108. }
  109. .list-call .sl-input {
  110. flex: 1;
  111. text-align: left;
  112. font-size: 18px;
  113. margin-left: 8px;
  114. }
  115. .button-login {
  116. color: #FFFFFF;
  117. font-size:18px;
  118. width: 235px;
  119. height: 50px;
  120. background: #1989fa;
  121. border-radius:5px;
  122. line-height: 50px;
  123. text-align: center;
  124. margin-left: auto;
  125. margin-right: auto;
  126. margin-top: 50px;
  127. }
  128. </style>