account-login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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="password"
  24. placeholder="请输入密码"
  25. v-model="model.password"
  26. border="none"
  27. ></u-input>
  28. </view>
  29. </u-form-item>
  30. </u-form>
  31. </view>
  32. </template>
  33. <script>
  34. import {login} from '@/common/request/apis/login'
  35. import md5 from '@/common/request/md5.js'
  36. export default{
  37. data() {
  38. return {
  39. model:{
  40. loginName:'',
  41. password:''
  42. },
  43. }
  44. },
  45. methods:{
  46. accountLoginSubmit() {
  47. if(!this.model.loginName){
  48. return uni.$u.toast("请输入账号");
  49. }
  50. if(!this.model.password) {
  51. return uni.$u.toast("请输入密码");
  52. }
  53. let params = {
  54. ...this.model,
  55. password: md5(this.model.password)
  56. }
  57. login(params)
  58. .then(res=>{
  59. if(res.code == 200) {
  60. let err = {}
  61. if (res.data.msgTip === 'user can login') {
  62. let userInfo = {
  63. token:res.data.token,
  64. ...res.data.user
  65. }
  66. this.$store.dispatch('userLogin',userInfo)
  67. } else if (res.data.msgTip === 'user is not exist') {
  68. uni.$u.toast("用户不存在")
  69. } else if (res.data.msgTip === 'user password error') {
  70. uni.$u.toast("用户密码不正确")
  71. } else if (res.data.msgTip === 'user is black') {
  72. uni.$u.toast("用户被禁用")
  73. } else if (res.data.msgTip === 'tenant is black') {
  74. if (loginName === 'jsh') {
  75. uni.$u.toast("jsh用户已停用,请注册租户进行体验!")
  76. } else {
  77. uni.$u.toast("用户所属的租户被禁用")
  78. }
  79. } else if (res.data.msgTip === 'tenant is expire') {
  80. uni.$u.toast("试用期已结束,请联系客服续费")
  81. } else if (res.data.msgTip === 'access service error') {
  82. uni.$u.toast("查询服务异常")
  83. }
  84. }
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. // @import "../index.scss";
  92. .input-line {
  93. display: flex;
  94. align-items: center;
  95. width: 100%;
  96. background-color: #f5f7fb;
  97. border-radius: 16rpx;
  98. padding-left: 30rpx;
  99. height: 88rpx;
  100. box-sizing: border-box;
  101. }
  102. </style>