phone.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="container">
  3. <view class="input-box">
  4. <view class="icon" />
  5. <input type="number" :value="phoneNumber" placeholder="请输入手机号码" data-name='phoneNumber' @input="onInput">
  6. </view>
  7. <view class="authcode" style="margin-top:30rpx;">
  8. <view class="input-box">
  9. <view class="icon" />
  10. <input type="number" :value="password" placeholder="请输入验证码" data-name='password' @input="onInput">
  11. </view>
  12. <button class="cu-btn bg-red" :loading='loading' @click="getAuthcode">{{ butText }}</button>
  13. </view>
  14. <u-button :customStyle="butSty" :disabled="phoneNumber == '' || password == ''" :loading="loading"
  15. loadingText='登陆中...' text="确 定" @click="startLogging" />
  16. </view>
  17. </template>
  18. <script>
  19. let countDown = null;
  20. import { hexMD5 } from "./md5";
  21. import { CheckPhoneNumber } from "../../../utils/basicInspection";
  22. import { loginMsg } from "./dispose";
  23. export default {
  24. name: "Phone",
  25. data() {
  26. return {
  27. loading: false,
  28. phoneNumber: "",
  29. password: "",
  30. butText: "获取验证码",
  31. butSty: {
  32. width: "550rpx",
  33. height: "90rpx",
  34. background: "#0A3971",
  35. borderRadius: "8rpx",
  36. opacity: "0.65",
  37. borderWidth: 0,
  38. fontSize: "32rpx",
  39. fontFamily: " PingFang SC - Regular, PingFang SC",
  40. color: " #FFFFFF",
  41. margin: "134rpx auto 0",
  42. }
  43. };
  44. },
  45. mounted() {
  46. this.phoneNumber = uni.getStorageSync("phoneNumber") || "";
  47. },
  48. methods: {
  49. /* 获取验证码 */
  50. getAuthcode() {
  51. if (this.butText == '获取验证码' || this.butText == '重新获取') {
  52. if (!CheckPhoneNumber(this.phoneNumber, '请输入正确的手机号码')) return;
  53. this.$Http.getpassword({
  54. "phonenumber": this.phoneNumber,
  55. "systemclient": "wechat"
  56. }).then(res => {
  57. console.log("获取验证码", res)
  58. uni.showToast({
  59. title: res.msg,
  60. duration: 3000,
  61. icon: "none",
  62. });
  63. if (res.code == 0) return;
  64. var count = 30;
  65. this.butText = count + 's';
  66. countDown = setInterval(() => {
  67. if (count == 0) {
  68. clearInterval(countDown);
  69. this.butText = '重新获取';
  70. } else {
  71. count = count - 1;
  72. this.butText = count + 's';
  73. }
  74. }, 1000)
  75. });
  76. };
  77. },
  78. /* 输入框输入内容 */
  79. onInput(e) {
  80. this[e.currentTarget.dataset.name] = e.detail.value;
  81. },
  82. /* 开始登录 */
  83. startLogging() {
  84. if (this.loading) return;
  85. if (!CheckPhoneNumber(this.phoneNumber, '请输入正确的手机号码')) return;
  86. if (this.password == "") return uni.showToast({
  87. title: '还未填写验证码',
  88. duration: 2000,
  89. icon: "none",
  90. });
  91. this.loading = true;
  92. this.$Http.plogin({
  93. "phonenumber": this.phonenumber,
  94. "password": hexMD5(this.password),
  95. "systemclient": "wechat"
  96. }).then(res => {
  97. console.log("验证码登录", res)
  98. this.loading = false;
  99. if (res.code == 0) {
  100. uni.showToast({
  101. title: res.msg,
  102. duration: 2000,
  103. icon: "none"
  104. });
  105. } else {
  106. uni.setStorageSync("phoneNumber", this.phoneNumber);
  107. uni.setStorageSync("loginMethod", 'phone');
  108. loginMsg(res.account_list, this.$Http)
  109. }
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. @import url("./input.css");
  117. .icon {
  118. background-color: $my-color-main;
  119. }
  120. /deep/uni-checkbox.blue.checked .uni-checkbox-input {
  121. background-color: #0A3971 !important;
  122. opacity: 0.65;
  123. }
  124. .assist {
  125. display: flex;
  126. justify-content: space-between;
  127. width: 548rpx;
  128. height: 34rpx;
  129. font-size: 24rpx;
  130. font-family: PingFang SC-Regular, PingFang SC;
  131. color: #FFFFFF;
  132. margin: 26rpx auto 0;
  133. label {
  134. display: flex;
  135. align-items: center;
  136. checkbox {
  137. transform: scale(0.6);
  138. background: #0A3971;
  139. color: #0A3971;
  140. border-radius: 8rpx;
  141. opacity: 0.65;
  142. border: 2rpx solid rgba(11, 63, 126, 0.1);
  143. }
  144. }
  145. navigator {
  146. padding-right: 10rpx;
  147. }
  148. }
  149. </style>