login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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('companyUserId',res.user.userId);
  41. uni.setStorageSync('CompanyUserToken',res.companyUserToken);
  42. //写入TOKEN
  43. uni.navigateBack({
  44. delta:1,//返回层数,2则上上页
  45. })
  46. uni.navigateTo({
  47. url: '/pages_company/index'
  48. })
  49. }else{
  50. uni.showToast({
  51. icon:'none',
  52. title: res.msg,
  53. });
  54. }
  55. },
  56. rej => {}
  57. );
  58. },
  59. },
  60. }
  61. </script>
  62. <style lang="scss">
  63. page{
  64. height: 100%;
  65. }
  66. .content{
  67. display: flex;
  68. flex-direction: column;
  69. justify-content: space-between;
  70. .inner{
  71. padding: 20upx;
  72. .form-box{
  73. padding: 0 30upx;
  74. background: #FFFFFF;
  75. border-radius: 16upx;
  76. .form-item{
  77. padding: 30upx 0;
  78. display: flex;
  79. align-items: flex-start;
  80. border-bottom: 1px solid #F1F1F1;
  81. &:last-child{
  82. border-bottom: none;
  83. }
  84. .label{
  85. width: 150upx;
  86. text-align: left;
  87. font-size: 30upx;
  88. line-height: 44upx;
  89. font-family: PingFang SC;
  90. font-weight: 500;
  91. color: #222222;
  92. flex-shrink: 0;
  93. }
  94. input{
  95. text-align: left;
  96. }
  97. .form-input{
  98. font-size: 30upx;
  99. font-family: PingFang SC;
  100. font-weight: 500;
  101. color: #999999;
  102. text-align: left;
  103. }
  104. }
  105. }
  106. }
  107. .btn-box{
  108. height: 120upx;
  109. padding: 0 30upx;
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. .sub-btn{
  114. width: 100%;
  115. height: 88upx;
  116. line-height: 88upx;
  117. text-align: center;
  118. font-size: 30upx;
  119. font-family: PingFang SC;
  120. font-weight: bold;
  121. color: #FFFFFF;
  122. background: #2583EB;
  123. border-radius: 44upx;
  124. }
  125. }
  126. }
  127. </style>