login.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. let openid = uni.getStorageSync('openid');
  46. if (!openid) {
  47. openid = uni.getStorageSync('login_openid');
  48. }
  49. this.form.openid = openid
  50. this.$api.doLogin(this.form).then(resp => {
  51. let data = resp.data;
  52. if (data.tokenInfo) {
  53. uni.setStorageSync('token', data.tokenInfo.tokenValue);
  54. uni.setStorageSync('customerId', data.admin.customerId)
  55. uni.setStorageSync('userInfo', data.admin)
  56. uni.setStorageSync('perList', data.per_list)
  57. uni.setStorageSync('openid', openid)
  58. setTimeout(() => {
  59. this.$common.to('/pages/index/index')
  60. }, 500)
  61. } else {
  62. this.$common.toast('登录失败');
  63. }
  64. })
  65. },
  66. verifyResult(res) {
  67. this.sliderVerifyFLag = false;
  68. if (res) { //校验通过
  69. this.loginFn()
  70. } else {
  71. // 校验失败,点击关闭按钮
  72. console.log("验证失败,并点了关闭")
  73. }
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss">
  79. page {
  80. background-color: #fff;
  81. }
  82. .l-topbox {
  83. //background-color: #0080ff;
  84. height: 400rpx;
  85. display: flex;
  86. align-items: center;
  87. justify-content: center;
  88. //border-radius: 0 0 30rpx 30rpx;
  89. margin-bottom: 50rpx;
  90. background-image: url(../../static/login-bg.png);
  91. background-size: 100% 100%;
  92. text {
  93. font-size: 50rpx;
  94. font-weight: bold;
  95. color: #fff;
  96. }
  97. }
  98. @import '@/common/common.scss';
  99. .box {
  100. box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.05);
  101. background-color: #fff;
  102. box-sizing: border-box;
  103. margin: 60rpx;
  104. margin-top: -150rpx;
  105. width: auto;
  106. border-radius: 10rpx;
  107. }
  108. .common-btn {
  109. margin: 100rpx 60rpx;
  110. width: auto;
  111. height: 98rpx;
  112. box-shadow: 0 30rpx 30rpx -15rpx rgba(0, 128, 255, 0.2);
  113. }
  114. </style>