login.vue 2.9 KB

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