login.vue 2.5 KB

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