login.vue 2.6 KB

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