login.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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'
  22. export default {
  23. data() {
  24. return {
  25. form:{
  26. userName:null,
  27. password:null,
  28. }
  29. }
  30. },
  31. computed: {
  32. },
  33. onLoad() {
  34. },
  35. onHide() {
  36. },
  37. onUnload() {
  38. },
  39. mounted() {
  40. },
  41. methods: {
  42. submit(){
  43. login(this.form).then(
  44. res => {
  45. if(res.code==200){
  46. uni.showToast({
  47. icon:'success',
  48. title: "登录成功",
  49. });
  50. uni.setStorageSync('companyId',res.user.companyId);
  51. uni.setStorageSync('companyUserId',res.user.userId);
  52. uni.setStorageSync('CompanyUserToken',res.companyUserToken);
  53. uni.redirectTo({
  54. url: '/pages_company/index'
  55. })
  56. }else{
  57. uni.showToast({
  58. icon:'none',
  59. title: res.msg,
  60. });
  61. }
  62. },
  63. rej => {}
  64. );
  65. },
  66. },
  67. }
  68. </script>
  69. <style lang="scss">
  70. page{
  71. height: 100%;
  72. }
  73. .content{
  74. display: flex;
  75. flex-direction: column;
  76. justify-content: flex-start;
  77. .inner{
  78. padding: 20upx;
  79. .form-box{
  80. padding: 0 30upx;
  81. background: #FFFFFF;
  82. border-radius: 16upx;
  83. .form-item{
  84. padding: 30upx 0;
  85. display: flex;
  86. align-items: flex-start;
  87. border-bottom: 1px solid #F1F1F1;
  88. &:last-child{
  89. border-bottom: none;
  90. }
  91. .label{
  92. width: 150upx;
  93. text-align: left;
  94. font-size: 30upx;
  95. line-height: 44upx;
  96. font-family: PingFang SC;
  97. font-weight: 500;
  98. color: #222222;
  99. flex-shrink: 0;
  100. }
  101. input{
  102. text-align: left;
  103. }
  104. .form-input{
  105. font-size: 30upx;
  106. font-family: PingFang SC;
  107. font-weight: 500;
  108. color: #999999;
  109. text-align: left;
  110. }
  111. }
  112. }
  113. }
  114. .btn-box{
  115. height: 120upx;
  116. padding: 0 30upx;
  117. display: flex;
  118. align-items: center;
  119. justify-content: center;
  120. .sub-btn{
  121. width: 100%;
  122. height: 88upx;
  123. line-height: 88upx;
  124. text-align: center;
  125. font-size: 30upx;
  126. font-family: PingFang SC;
  127. font-weight: bold;
  128. color: #FFFFFF;
  129. background: #C39A58;
  130. border-radius: 44upx;
  131. }
  132. }
  133. }
  134. </style>