login.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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="tips">
  16. <checkbox :checked="isAgreement" @click="handleAgreement()" />
  17. <view @click="handleAgreement()">您同意并接受</view>
  18. <view class="btn" @click="openContent('userHealth')">《健康客服协议》</view>
  19. </view>
  20. <view class="btn-box">
  21. <view class="sub-btn" @click="submit()">员工登录</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import {login} from '@/api/companyUser'
  27. export default {
  28. data() {
  29. return {
  30. form: {
  31. userName: null,
  32. password: null,
  33. },
  34. isAgreement:false
  35. }
  36. },
  37. methods: {
  38. openContent(type) {
  39. uni.navigateTo({
  40. url: "/pages_user/agreement?type=" + type
  41. })
  42. },
  43. handleAgreement() {
  44. this.isAgreement = !this.isAgreement;
  45. },
  46. submit() {
  47. if(!this.form.userName){
  48. uni.showToast({
  49. icon:'none',
  50. title: "请输入员工帐号",
  51. });
  52. return;
  53. }
  54. if(!this.form.password){
  55. uni.showToast({
  56. icon:'none',
  57. title: "请输入员工密码",
  58. });
  59. return;
  60. }
  61. if(!this.isAgreement){
  62. uni.showToast({
  63. icon:'none',
  64. title: "请先同意协议后再登录",
  65. });
  66. return;
  67. }
  68. login(this.form).then(
  69. res => {
  70. if (res.code == 200) {
  71. uni.showToast({
  72. icon: 'success',
  73. title: "登录成功",
  74. });
  75. uni.setStorageSync('companyId', res.user.companyId);
  76. uni.setStorageSync('companyUserId', res.user.userId);
  77. uni.setStorageSync('CompanyUserToken', res.companyUserToken);
  78. uni.redirectTo({
  79. url: '/pages_company/index'
  80. })
  81. } else {
  82. uni.showToast({
  83. icon: 'none',
  84. title: res.msg,
  85. });
  86. }
  87. },
  88. rej => {}
  89. );
  90. },
  91. },
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .tips {
  96. margin-top: 15rpx;
  97. padding: 0rpx 30rpx;
  98. display: flex;
  99. justify-content: flex-start;
  100. align-items: center;
  101. font-size: 28rpx;
  102. color: #000;
  103. checkbox {}
  104. .btn {
  105. color: #078C9D;
  106. }
  107. }
  108. .content {
  109. display: flex;
  110. flex-direction: column;
  111. justify-content: flex-start;
  112. .inner {
  113. padding: 20upx;
  114. .form-box {
  115. padding: 0 30upx;
  116. background: #FFFFFF;
  117. border-radius: 16upx;
  118. .form-item {
  119. padding: 30upx 0;
  120. display: flex;
  121. align-items: flex-start;
  122. border-bottom: 1px solid #F1F1F1;
  123. &:last-child {
  124. border-bottom: none;
  125. }
  126. .label {
  127. width: 150upx;
  128. text-align: left;
  129. font-size: 30upx;
  130. line-height: 44upx;
  131. font-family: PingFang SC;
  132. font-weight: 500;
  133. color: #222222;
  134. flex-shrink: 0;
  135. }
  136. input {
  137. text-align: left;
  138. }
  139. .form-input {
  140. font-size: 30upx;
  141. font-family: PingFang SC;
  142. font-weight: 500;
  143. color: #999999;
  144. text-align: left;
  145. }
  146. }
  147. }
  148. }
  149. .btn-box {
  150. height: 120upx;
  151. padding: 0 30upx;
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. .sub-btn {
  156. width: 100%;
  157. height: 88upx;
  158. line-height: 88upx;
  159. text-align: center;
  160. font-size: 30upx;
  161. font-family: PingFang SC;
  162. font-weight: bold;
  163. color: #FFFFFF;
  164. background: #078C9D;
  165. border-radius: 44upx;
  166. }
  167. }
  168. }
  169. </style>