login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <view class="form-item">
  6. <text class="label">员工帐号</text>
  7. <input type="text" v-model="form.userName" placeholder="登录帐号" placeholder-class="form-input" />
  8. </view>
  9. <view class="form-item">
  10. <text class="label">员工密码</text>
  11. <input type="password" v-model="form.password" placeholder="登录密码" placeholder-class="form-input" />
  12. </view>
  13. </view>
  14. </view>
  15. <view class="btn-box">
  16. <view class="sub-btn" @click="submit()">员工登录</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {login} from '../api/companyUser.js'
  22. export default {
  23. data() {
  24. return {
  25. form:{
  26. userName:null,
  27. password:null,
  28. }
  29. }
  30. },
  31. methods: {
  32. submit(){
  33. login(this.form).then(
  34. res => {
  35. if(res.code==200){
  36. uni.showToast({
  37. icon:'success',
  38. title: "登录成功",
  39. });
  40. uni.setStorageSync('CompanyUserToken',res.companyUserToken);
  41. //写入TOKEN
  42. uni.navigateBack({
  43. delta:1,//返回层数,2则上上页
  44. })
  45. uni.navigateTo({
  46. url: '/pages_company/index'
  47. })
  48. }else{
  49. uni.showToast({
  50. icon:'none',
  51. title: res.msg,
  52. });
  53. }
  54. },
  55. rej => {}
  56. );
  57. },
  58. },
  59. }
  60. </script>
  61. <style lang="scss">
  62. page{
  63. height: 100%;
  64. }
  65. .content{
  66. display: flex;
  67. flex-direction: column;
  68. justify-content: space-between;
  69. .inner{
  70. padding: 20upx;
  71. .form-box{
  72. padding: 0 30upx;
  73. background: #FFFFFF;
  74. border-radius: 16upx;
  75. .form-item{
  76. padding: 30upx 0;
  77. display: flex;
  78. align-items: flex-start;
  79. border-bottom: 1px solid #F1F1F1;
  80. &:last-child{
  81. border-bottom: none;
  82. }
  83. .label{
  84. width: 150upx;
  85. text-align: left;
  86. font-size: 30upx;
  87. line-height: 44upx;
  88. font-family: PingFang SC;
  89. font-weight: 500;
  90. color: #222222;
  91. flex-shrink: 0;
  92. }
  93. input{
  94. text-align: left;
  95. }
  96. .form-input{
  97. font-size: 30upx;
  98. font-family: PingFang SC;
  99. font-weight: 500;
  100. color: #999999;
  101. text-align: left;
  102. }
  103. }
  104. }
  105. }
  106. .btn-box{
  107. height: 120upx;
  108. padding: 0 30upx;
  109. display: flex;
  110. align-items: center;
  111. justify-content: center;
  112. .sub-btn{
  113. width: 100%;
  114. height: 88upx;
  115. line-height: 88upx;
  116. text-align: center;
  117. font-size: 30upx;
  118. font-family: PingFang SC;
  119. font-weight: bold;
  120. color: #FFFFFF;
  121. background: #2583EB;
  122. border-radius: 44upx;
  123. }
  124. }
  125. }
  126. </style>