login.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. computed: {
  38. },
  39. onLoad() {
  40. },
  41. onHide() {
  42. },
  43. onUnload() {
  44. },
  45. mounted() {
  46. },
  47. methods: {
  48. openContent(type){
  49. console.log(type);
  50. uni.navigateTo({
  51. url:"/pages/user/agreement?type="+type
  52. })
  53. },
  54. handleAgreement(){
  55. this.isAgreement=!this.isAgreement;
  56. },
  57. submit(){
  58. if(!this.isAgreement){
  59. uni.showToast({
  60. icon:'none',
  61. title: "请先同意协议后再登录",
  62. });
  63. return;
  64. }
  65. login(this.form).then(res => {
  66. if(res.code==200){
  67. uni.showToast({icon:'success',title: "登录成功",});
  68. uni.setStorageSync('companyId',res.user.companyId);
  69. uni.setStorageSync('companyUserId',res.user.userId);
  70. uni.setStorageSync('CompanyUserToken',res.companyUserToken);
  71. uni.redirectTo({url: '/pages/company/index' });
  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: flex-start;
  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: #FF5C03;
  146. border-radius: 44upx;
  147. }
  148. }
  149. }
  150. .tips{
  151. margin-top: 15rpx;
  152. padding: 0rpx 30rpx;
  153. display: flex;
  154. justify-content: flex-start;
  155. align-items: center;
  156. font-size: 28rpx;
  157. color: #000;
  158. checkbox{
  159. }
  160. .btn{
  161. color: #FF5C03;
  162. }
  163. }
  164. </style>