index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="login-index">
  3. <view class="bg-img">
  4. <image class="hi-img" src="@/static/img/hi.png" mode="scaleToFill"></image>
  5. <view class="fs-42 fc-3 fw-b">欢迎使用振合网收银系统</view>
  6. </view>
  7. <view class="info-box">
  8. <view class="fs-32 fc-3 fw-b mb-25">密码登录</view>
  9. <input v-model="phone" placeholder="请输入手机号" type="number" />
  10. <view class="p-f">
  11. <input v-model="password" placeholder="请输入密码" :password="inputType" />
  12. <view class="p-c" @click="openeye()">
  13. <uni-icons type="eye-filled" size="20" color="#999"></uni-icons>
  14. </view>
  15. </view>
  16. <view class="button-save text-align-center fs-32 fc-f" @click="toLogin()">立即登录</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import tools from "@/common/js/tools.js";
  22. import {
  23. Login
  24. } from '@/api/cashierApi.js';
  25. export default {
  26. data() {
  27. return {
  28. inputType: true,
  29. phone: '',
  30. password: '',
  31. isAJAX: false,
  32. }
  33. },
  34. mounted() {},
  35. methods: {
  36. openeye() {
  37. this.inputType = !this.inputType
  38. },
  39. toLogin() {
  40. if (this.isAJAX) {
  41. return
  42. }
  43. this.isAJAX = true;
  44. Login({
  45. phone: this.phone,
  46. password: this.password
  47. }).then((res) => {
  48. if (res.code == 1) {
  49. uni.setStorageSync('token', res.data.token);
  50. uni.setStorageSync('u_id', res.data.u_id);
  51. uni.setStorageSync('shop_id', res.data.shop_id);
  52. tools.success("登录成功");
  53. setTimeout(() => {
  54. this.isAJAX = false;
  55. uni.redirectTo({
  56. url: "/pages/index/index",
  57. });
  58. }, 1000);
  59. } else {
  60. tools.error(res.msg);
  61. this.isAJAX = false;
  62. }
  63. })
  64. },
  65. }
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. .login-index {
  70. .bg-img {
  71. width: 100%;
  72. height: 430rpx;
  73. background-image: url('@/static/img/login-bg.png');
  74. background-size: 100% 100%;
  75. box-sizing: border-box;
  76. padding: 90rpx 25rpx 0 25rpx;
  77. .hi-img {
  78. width: 118rpx;
  79. height: 60rpx;
  80. margin-bottom: 10rpx;
  81. }
  82. }
  83. .info-box {
  84. box-sizing: border-box;
  85. padding: 10rpx 27rpx;
  86. input {
  87. width: 100%;
  88. height: 83rpx;
  89. background: #F3F4F6;
  90. border-radius: 104rpx;
  91. box-sizing: border-box;
  92. padding: 0 70rpx 0 25rpx;
  93. font-size: 30rpx;
  94. margin-bottom: 35rpx;
  95. }
  96. .p-f {
  97. position: relative;
  98. .p-c {
  99. position: absolute;
  100. top: 20rpx;
  101. right: 20rpx;
  102. }
  103. }
  104. .button-save {
  105. width: 100%;
  106. height: 83rpx;
  107. line-height: 83rpx;
  108. background: #1778FD;
  109. border-radius: 104rpx;
  110. }
  111. }
  112. }
  113. </style>