login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view>
  3. <view class="l-topbox">
  4. <text>欢迎登录场站管理系统</text>
  5. </view>
  6. <view class="box">
  7. <view class="item">
  8. <view class="l">登录名:</view>
  9. <view class="r">
  10. <u-input v-model="form.key" placeholder="登录名"/>
  11. </view>
  12. </view>
  13. <view class="item">
  14. <view class="l">密码:</view>
  15. <view class="r">
  16. <u-input v-model="form.password" placeholder="输入密码" type="password"/>
  17. </view>
  18. </view>
  19. <!-- <view class="item">
  20. <view class="l">验证码:</view>
  21. <view class="r">
  22. <u-input placeholder="输入验证码"/>
  23. <view class="btn">发送</view>
  24. </view>
  25. </view> -->
  26. </view>
  27. <view class="common-btn" @click="sliderVerifyFLag = true">确认登录</view>
  28. <slider-verify :isShow="sliderVerifyFLag" @touchSliderResult="verifyResult" ref="verifyElement"></slider-verify>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. sliderVerifyFLag: false, //滑块验证
  36. form:{
  37. key:'',
  38. password:''
  39. }
  40. }
  41. },
  42. methods: {
  43. loginFn(){
  44. if(!this.form.key){
  45. this.$common.toast('请输入登录名');
  46. return;
  47. }
  48. if(!this.form.password){
  49. this.$common.toast('请输入密码');
  50. return;
  51. }
  52. this.$api.doLogin(this.form).then(resp=>{
  53. let data=resp.data;
  54. if(data.tokenInfo){
  55. uni.setStorageSync('token',data.tokenInfo.tokenValue);
  56. uni.setStorageSync('customerId',data.admin.customerId)
  57. uni.setStorageSync('info',data.admin)
  58. uni.setStorageSync('perList',data.per_list)
  59. this.$common.to('/pages/index/index')
  60. }else{
  61. this.$common.toast('登录失败');
  62. }
  63. })
  64. },
  65. verifyResult(res) {
  66. this.sliderVerifyFLag = false;
  67. if (res) { //校验通过
  68. this.loginFn()
  69. }else{
  70. // 校验失败,点击关闭按钮
  71. console.log("验证失败,并点了关闭")
  72. }
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. page{
  79. background-color: #fff;
  80. }
  81. .l-topbox{
  82. //background-color: #0080ff;
  83. height: 400rpx;
  84. display: flex;
  85. align-items: center;
  86. justify-content: center;
  87. //border-radius: 0 0 30rpx 30rpx;
  88. margin-bottom: 50rpx;
  89. background-image: url(../../static/login-bg.png);
  90. background-size: 100% 100%;
  91. text{
  92. font-size: 50rpx;
  93. font-weight: bold;
  94. color: #fff;
  95. }
  96. }
  97. @import '@/common/common.scss';
  98. .box{
  99. box-shadow: 0 10rpx 30rpx rgba(0,0,0,0.05);
  100. background-color: #fff;
  101. box-sizing: border-box;
  102. margin: 60rpx;
  103. margin-top: -150rpx;
  104. width: auto;
  105. border-radius: 10rpx;
  106. }
  107. .common-btn{
  108. margin: 100rpx 60rpx;
  109. width: auto;
  110. height: 98rpx;
  111. box-shadow: 0 30rpx 30rpx -15rpx rgba(0,128,255,0.2);
  112. }
  113. </style>