account-login.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. <u-input
  23. :type="passwordType"
  24. placeholder="请输入密码"
  25. v-model="model.password"
  26. border="none"
  27. >
  28. <template slot="suffix">
  29. <view class="eye-box" @click="eyeClick">
  30. <u-icon :name="eyeIcon"></u-icon>
  31. </view>
  32. </template>
  33. </u-input>
  34. </view>
  35. </u-form-item>
  36. </u-form>
  37. </view>
  38. </template>
  39. <script>
  40. import {login} from '@/common/request/apis/login'
  41. import md5 from '@/common/request/md5.js'
  42. export default{
  43. data() {
  44. return {
  45. model:{
  46. loginName:'',
  47. password:'',
  48. },
  49. passwordType:'password',
  50. eyeIcon:'eye-off'
  51. }
  52. },
  53. methods:{
  54. eyeClick() {
  55. if(this.passwordType == 'password') {
  56. this.passwordType = 'text'
  57. this.eyeIcon = 'eye'
  58. }else {
  59. this.passwordType = 'password'
  60. this.eyeIcon = 'eye-off'
  61. }
  62. },
  63. accountLoginSubmit() {
  64. if(!this.model.loginName){
  65. return uni.$u.toast("请输入账号");
  66. }
  67. if(!this.model.password) {
  68. return uni.$u.toast("请输入密码");
  69. }
  70. let params = {
  71. ...this.model,
  72. password: md5(this.model.password)
  73. }
  74. login(params)
  75. .then(res=>{
  76. if(res.code == 200) {
  77. let err = {}
  78. if (res.data.msgTip === 'user can login') {
  79. let userInfo = {
  80. token:res.data.token,
  81. ...res.data.user
  82. }
  83. this.$store.dispatch('userLogin',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. }
  119. .eye-box {
  120. width: 100rpx;
  121. height: 88rpx;
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. }
  126. </style>