phone.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="container">
  3. <view class="input-box">
  4. <view class="iconfont icon-shoujihao" />
  5. <input class="input" placeholder-class="placeholder" type="number" :value="phoneNumber" placeholder="请输入手机号码"
  6. data-name='phoneNumber' @input="onInput">
  7. </view>
  8. <view class="authcode" style="margin-top:15px;">
  9. <view class="input-box">
  10. <view class="iconfont icon-duanxinyanzheng" />
  11. <input class="input" placeholder-class="placeholder" type="number" :value="password" placeholder="请输入验证码"
  12. data-name='password' @input="onInput">
  13. </view>
  14. <button class="cu-btn bg-red" :loading='loading' @click="getAuthcode">{{ butText }}</button>
  15. </view>
  16. <u-button :customStyle="butSty" :disabled="phoneNumber == '' || password == ''" :loading="loading"
  17. loadingText='登陆中...' @click="startLogging">
  18. <text style="font-size: 4.267vw;">
  19. 确 定
  20. </text>
  21. </u-button>
  22. </view>
  23. </template>
  24. <script>
  25. let countDown = null;
  26. import { hexMD5 } from "./md5";
  27. import { CheckPhoneNumber } from "../../../utils/basicInspection";
  28. import { loginMsg } from "./dispose";
  29. export default {
  30. name: "Phone",
  31. props: {
  32. isAgreement: Boolean
  33. },
  34. data() {
  35. return {
  36. loading: false,
  37. phoneNumber: "",
  38. password: "",
  39. butText: "获取验证码",
  40. butSty: {
  41. width: "73.333vw",
  42. height: "12.000vw",
  43. background: "#0A3971",
  44. borderRadius: "1.067vw",
  45. opacity: "0.65",
  46. borderWidth: 0,
  47. fontFamily: " PingFang SC - Regular, PingFang SC",
  48. color: " #FFFFFF",
  49. margin: "17.867vw auto 0"
  50. }
  51. };
  52. },
  53. mounted() {
  54. this.phoneNumber = uni.getStorageSync("phoneNumber") || "";
  55. },
  56. methods: {
  57. /* 获取验证码 */
  58. getAuthcode() {
  59. if (this.butText == '获取验证码' || this.butText == '重新获取') {
  60. if (!CheckPhoneNumber(this.phoneNumber, '请输入正确的手机号码')) return;
  61. this.$Http.getpassword({
  62. "phonenumber": this.phoneNumber,
  63. "systemclient": "marketingtool"
  64. }).then(res => {
  65. console.log("获取验证码", res)
  66. uni.showToast({
  67. title: res.msg,
  68. duration: 3000,
  69. icon: "none",
  70. });
  71. if (res.code == 0) return;
  72. var count = 30;
  73. this.butText = count + 's';
  74. countDown = setInterval(() => {
  75. if (count == 0) {
  76. clearInterval(countDown);
  77. this.butText = '重新获取';
  78. } else {
  79. count = count - 1;
  80. this.butText = count + 's';
  81. }
  82. }, 1000)
  83. });
  84. };
  85. },
  86. /* 输入框输入内容 */
  87. onInput(e) {
  88. this[e.currentTarget.dataset.name] = e.detail.value;
  89. },
  90. /* 开始登录 */
  91. startLogging() {
  92. if (this.loading) return;
  93. if (!this.isAgreement) return uni.showToast({
  94. title: '请阅读并勾选用户协议',
  95. icon: 'none',
  96. })
  97. if (!CheckPhoneNumber(this.phoneNumber, '请输入正确的手机号码')) return;
  98. if (this.password == "") return uni.showToast({
  99. title: '还未填写验证码',
  100. duration: 2000,
  101. icon: "none",
  102. });
  103. this.loading = true;
  104. this.$Http.plogin({
  105. "phonenumber": this.phoneNumber,
  106. "password": hexMD5(this.password),
  107. "systemclient": "marketingtool"
  108. }).then(res => {
  109. console.log("验证码登录", res)
  110. this.loading = false;
  111. if (res.code == 0) {
  112. uni.showToast({
  113. title: res.msg,
  114. duration: 2000,
  115. icon: "none"
  116. });
  117. } else {
  118. uni.setStorageSync("phoneNumber", this.phoneNumber);
  119. uni.setStorageSync("loginMethod", 'phone');
  120. loginMsg(res.account_list, this.$Http)
  121. }
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. .input-box {
  129. display: flex;
  130. align-items: center;
  131. width: 275px;
  132. height: 45px;
  133. background: #FFFFFF;
  134. border-radius: 4px;
  135. opacity: 0.65;
  136. margin: 0 auto;
  137. .input {
  138. font-size: 14px;
  139. height: 30px;
  140. line-height: 30px;
  141. }
  142. .placeholder {
  143. font-size: 12px !important;
  144. }
  145. .iconfont {
  146. font-size: 11px;
  147. padding: 0 10px;
  148. color: #052E5D;
  149. }
  150. }
  151. .icon {
  152. width: 16px;
  153. height: 16px;
  154. margin: 0 10px;
  155. }
  156. input {
  157. width: 80%;
  158. }
  159. /* 验证码 */
  160. .authcode {
  161. display: flex;
  162. justify-content: space-between;
  163. height: 45px;
  164. width: 275px;
  165. margin: 0 auto 0;
  166. }
  167. .authcode .input-box {
  168. width: 170px;
  169. }
  170. .authcode .cu-btn {
  171. width: 97px;
  172. height: 45px;
  173. background: #0A3971;
  174. border-radius: 4px;
  175. opacity: 0.65;
  176. margin-left: 8px;
  177. font-size: 12px;
  178. font-family: PingFang SC-Regular, PingFang SC;
  179. padding: 0;
  180. }
  181. .icon {
  182. background-color: #dd524d;
  183. }
  184. /deep/uni-checkbox.blue.checked .uni-checkbox-input {
  185. background-color: #0A3971 !important;
  186. opacity: 0.65;
  187. }
  188. .assist {
  189. display: flex;
  190. justify-content: space-between;
  191. width: 274px;
  192. height: 17px;
  193. font-size: 12px;
  194. font-family: PingFang SC-Regular, PingFang SC;
  195. color: #FFFFFF;
  196. margin: 13px auto 0;
  197. label {
  198. display: flex;
  199. align-items: center;
  200. checkbox {
  201. transform: scale(0.6);
  202. background: #0A3971;
  203. color: #0A3971;
  204. border-radius: 4px;
  205. opacity: 0.65;
  206. border: 1px solid rgba(11, 63, 126, 0.1);
  207. }
  208. }
  209. navigator {
  210. padding-right: 5px;
  211. }
  212. }
  213. /deep/.u-button__loading-text {
  214. font-size: 14px !important;
  215. }
  216. </style>