account-login.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!-- 账号密码登录 accountLogin -->
  2. <template>
  3. <view>
  4. <!-- 表单项 -->
  5. <u-form
  6. ref="accountLoginRef"
  7. labelWidth="140"
  8. labelAlign="left"
  9. labelPosition="top"
  10. >
  11. <u-form-item prop="loginName" label="账号">
  12. <view class="input-line">
  13. <u-input
  14. placeholder="请输入账号"
  15. v-model="model.loginName"
  16. border="none"
  17. ></u-input>
  18. </view>
  19. </u-form-item>
  20. <u-form-item prop="password" label="密码">
  21. <view class="input-line">
  22. <input
  23. :type="passwordType"
  24. placeholder="请输入密码"
  25. v-model="model.password"
  26. border="none"
  27. >
  28. </input>
  29. <view class="eye-box" @click="eyeClick">
  30. <u-icon :name="eyeIcon"></u-icon>
  31. </view>
  32. </view>
  33. </u-form-item>
  34. </u-form>
  35. </view>
  36. </template>
  37. <script>
  38. import {login} from '@/common/request/apis/login'
  39. import md5 from '@/common/request/md5.js'
  40. export default{
  41. data() {
  42. return {
  43. model:{
  44. loginName:'',
  45. password:'',
  46. },
  47. passwordType:'password',
  48. eyeIcon:'eye-off'
  49. }
  50. },
  51. methods:{
  52. eyeClick() {
  53. if(this.passwordType == 'password') {
  54. this.passwordType = 'text'
  55. this.eyeIcon = 'eye'
  56. }else {
  57. this.passwordType = 'password'
  58. this.eyeIcon = 'eye-off'
  59. }
  60. },
  61. accountLoginSubmit() {
  62. if(!this.model.loginName){
  63. return uni.$u.toast("请输入账号");
  64. }
  65. if(!this.model.password) {
  66. return uni.$u.toast("请输入密码");
  67. }
  68. let params = {
  69. ...this.model,
  70. password: md5(this.model.password)
  71. }
  72. login(params)
  73. .then(res=>{
  74. if(res.code == 200) {
  75. let err = {}
  76. if (res.data.msgTip === 'user can login') {
  77. let userInfo = {
  78. token:res.data.token,
  79. roleName: res.data.roleName,
  80. ...res.data.user
  81. }
  82. this.$store.dispatch('userLogin',userInfo)
  83. console.log('userInfo======',userInfo)
  84. } else if (res.data.msgTip === 'user is not exist') {
  85. uni.$u.toast("用户不存在")
  86. } else if (res.data.msgTip === 'user password error') {
  87. uni.$u.toast("用户密码不正确")
  88. } else if (res.data.msgTip === 'user is black') {
  89. uni.$u.toast("用户被禁用")
  90. } else if (res.data.msgTip === 'tenant is black') {
  91. if (loginName === 'jsh') {
  92. uni.$u.toast("jsh用户已停用,请注册租户进行体验!")
  93. } else {
  94. uni.$u.toast("用户所属的租户被禁用")
  95. }
  96. } else if (res.data.msgTip === 'tenant is expire') {
  97. uni.$u.toast("试用期已结束,请联系客服续费")
  98. } else if (res.data.msgTip === 'access service error') {
  99. uni.$u.toast("查询服务异常")
  100. }
  101. }
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. // @import "../index.scss";
  109. .input-line {
  110. display: flex;
  111. align-items: center;
  112. width: 100%;
  113. background-color: #f5f7fb;
  114. border-radius: 16rpx;
  115. padding-left: 30rpx;
  116. height: 88rpx;
  117. box-sizing: border-box;
  118. input{
  119. width: 100%;
  120. }
  121. }
  122. .eye-box {
  123. width: 100rpx;
  124. height: 88rpx;
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. }
  129. </style>