Login.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div>
  3. <x-header />
  4. <div class="Login">
  5. <div class="Login_message">
  6. <div class="Login_message_phone">绑定手机号</div>
  7. <div class="Login_message_notfiy">
  8. 已绑定过的手机号将自动同步原有账号记录
  9. </div>
  10. </div>
  11. <div class="Login_form">
  12. <div class="Login_form_item">
  13. <input
  14. placeholder="请输入你的手机号"
  15. v-model="phone"
  16. type="number"
  17. class="login_form_input"
  18. oninput="if(value.length>11)value=value.slice(0,11);if(value<0)value=0"
  19. />
  20. </div>
  21. <div class="Login_form_item">
  22. <input
  23. v-model="code"
  24. type="number"
  25. placeholder="请输入你的验证码"
  26. class="login_form_input"
  27. oninput="if(value.length>6)value=value.slice(0,6);if(value<0)value=0"
  28. />
  29. <div
  30. class="getCode_phone_wrong"
  31. v-if="isPhoneCurrect == 0"
  32. @click="getCodePhoneWrong"
  33. >
  34. 获取验证码
  35. </div>
  36. <div class="getCode" @click="getCode" v-if="isPhoneCurrect == 1">
  37. 获取验证码
  38. </div>
  39. <div class="getCode_count_down" v-if="isPhoneCurrect == 3">
  40. {{ countTime }}秒后重发
  41. </div>
  42. </div>
  43. <div class="agree_item">
  44. <input type="radio" v-model="isAgree" @click="isAgreeChange" />
  45. 我已阅读并同意<span @click="goToUserPage">用户协议</span>和<span
  46. @click="goToPrivatePage"
  47. >隐私政策</span
  48. >
  49. </div>
  50. <div class="login_btn" @click="goToLogin" v-if="isGoToLogin">
  51. 点击绑定
  52. </div>
  53. <div class="login_btn_wrong" v-if="!isGoToLogin">点击绑定</div>
  54. </div>
  55. </div>
  56. <mt-popup v-model="popupVisible" popup-transition="popup-fade">
  57. <img src="../assets/login_success.png" alt="" />
  58. <div class="login_success">
  59. 绑定成功
  60. </div>
  61. <div class="go_back_btn" @click="goBackRouter">返回</div>
  62. </mt-popup>
  63. </div>
  64. </template>
  65. <script>
  66. import { Login } from "./namespace.js";
  67. export default {
  68. name: Login.name,
  69. data() {
  70. return {
  71. //是否同意隐私政策
  72. isAgree: true,
  73. //二维码
  74. code: "",
  75. //手机号
  76. phone: "",
  77. popupVisible: false,
  78. isPhoneCurrect: 0,
  79. countTime: "",
  80. isGoToLogin: false
  81. };
  82. },
  83. methods: {
  84. //当手机号未填时
  85. getCodePhoneWrong() {
  86. this.$Toast("请填写正确的手机号码");
  87. },
  88. //点击获取二维码
  89. getCode() {
  90. console.log("获取验证码");
  91. this.isPhoneCurrect = 3;
  92. this.countTime = 60;
  93. //验证码倒计时
  94. const timer = setInterval(() => {
  95. if (this.countTime == 0) {
  96. clearTimeout(timer);
  97. this.isPhoneCurrect = 1;
  98. } else {
  99. this.countTime--;
  100. }
  101. }, 1000);
  102. },
  103. isAgreeChange() {
  104. this.isAgree = !this.isAgree;
  105. console.log(this.isAgree);
  106. },
  107. //登入操作
  108. goToLogin() {
  109. //验证手机号
  110. let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  111. if (!myreg.test(this.phone)) {
  112. this.$Toast("请填写正确的手机号码");
  113. return;
  114. }
  115. //验证码填写
  116. if (!this.code) {
  117. this.$Toast("请填写验证码");
  118. return;
  119. }
  120. //隐私协议是否勾选
  121. if (this.isAgree) {
  122. this.$Toast("请先阅读用户协议、隐私政策");
  123. return;
  124. }
  125. //弹出框
  126. this.popupVisible = !this.popupVisible;
  127. console.log("goToLogin");
  128. },
  129. //返回上级路由
  130. goBackRouter() {
  131. this.$router.back();
  132. },
  133. phoneChange() {
  134. console.log(1);
  135. },
  136. //跳转到用户页面
  137. goToUserPage() {
  138. this.$router.push("/Useragreement");
  139. localStorage.setItem("isUseragreement", "1");
  140. },
  141. //跳转到隐私页面
  142. goToPrivatePage() {
  143. this.$router.push("/Useragreement");
  144. localStorage.setItem("isUseragreement", "2");
  145. }
  146. //
  147. },
  148. watch: {
  149. //监听手机号的长度
  150. phone(val) {
  151. let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  152. if (!myreg.test(val)) {
  153. this.isPhoneCurrect = 0;
  154. } else {
  155. this.isPhoneCurrect = 1;
  156. }
  157. },
  158. //监听手机验证码两个值
  159. address(val) {
  160. console.log(val);
  161. if (val.phone && val.code) {
  162. this.isGoToLogin = true;
  163. } else {
  164. this.isGoToLogin = false;
  165. }
  166. }
  167. },
  168. computed: {
  169. //监听手机验证码两个值
  170. address() {
  171. const { phone, code } = this;
  172. return {
  173. phone,
  174. code
  175. };
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .Login {
  182. padding: 0 0.3rem;
  183. .Login_message {
  184. margin: 1rem 0 1.2rem 0;
  185. .Login_message_phone {
  186. font-size: 17px;
  187. font-weight: 600;
  188. }
  189. .Login_message_notfiy {
  190. margin-top: 15px;
  191. font-size: 14px;
  192. font-weight: 400;
  193. color: #999999;
  194. }
  195. }
  196. .Login_form {
  197. width: 100%;
  198. .Login_form_item {
  199. margin-bottom: 0.5rem;
  200. display: flex;
  201. border-bottom: 1px #ccc solid;
  202. padding: 3px;
  203. .login_form_input {
  204. font-size: 0.3rem;
  205. height: 0.5rem;
  206. border: none;
  207. width: 100%;
  208. }
  209. .login_form_input:focus {
  210. outline: none;
  211. }
  212. }
  213. .agree_item {
  214. margin-bottom: 0.7rem;
  215. span {
  216. color: #3ba3fc;
  217. }
  218. }
  219. }
  220. .getCode {
  221. color: #333333;
  222. font-size: 12px;
  223. height: 0.5rem;
  224. width: 1.8rem;
  225. line-height: 0.5rem;
  226. text-align: center;
  227. border-radius: 0.5rem;
  228. border: 1px #e5e5e5 solid;
  229. }
  230. .getCode_phone_wrong {
  231. color: white;
  232. font-size: 12px;
  233. height: 0.5rem;
  234. width: 1.8rem;
  235. line-height: 0.5rem;
  236. text-align: center;
  237. border-radius: 0.5rem;
  238. border: 1px #e5e5e5 solid;
  239. background-color: gray;
  240. }
  241. .getCode_count_down {
  242. color: white;
  243. font-size: 12px;
  244. height: 0.5rem;
  245. width: 1.8rem;
  246. line-height: 0.5rem;
  247. text-align: center;
  248. border-radius: 0.5rem;
  249. border: 1px #e5e5e5 solid;
  250. background-color: gray;
  251. }
  252. .login_btn {
  253. height: 0.7rem;
  254. line-height: 0.7rem;
  255. width: 6rem;
  256. background: #3ba3fc;
  257. text-align: center;
  258. color: white;
  259. border-radius: 0.5rem;
  260. margin-top: 1rem;
  261. margin: 0 auto;
  262. }
  263. .login_btn_wrong {
  264. height: 0.7rem;
  265. line-height: 0.7rem;
  266. width: 6rem;
  267. background: #ccc;
  268. text-align: center;
  269. color: white;
  270. border-radius: 0.5rem;
  271. margin-top: 1rem;
  272. margin: 0 auto;
  273. }
  274. }
  275. /deep/.mint-popup {
  276. padding: 1rem;
  277. border-radius: 0.2rem;
  278. position: fixed;
  279. background: #fff;
  280. top: 40%;
  281. left: 50%;
  282. -webkit-transform: translate3d(-50%, -50%, 0);
  283. transform: translate3d(-50%, -50%, 0);
  284. -webkit-backface-visibility: hidden;
  285. backface-visibility: hidden;
  286. -webkit-transition: 0.2s ease-out;
  287. transition: 0.2s ease-out;
  288. .login_success {
  289. margin-top: 10px;
  290. text-align: center;
  291. font-size: 18px;
  292. color: #333;
  293. font-weight: 600;
  294. margin-bottom: 20px;
  295. }
  296. .go_back_btn {
  297. height: 0.7rem;
  298. line-height: 0.7rem;
  299. background: #3ba3fc;
  300. text-align: center;
  301. color: white;
  302. border-radius: 0.5rem;
  303. margin: 0 auto;
  304. }
  305. }
  306. input::-webkit-outer-spin-button,
  307. input::-webkit-inner-spin-button {
  308. -webkit-appearance: none;
  309. }
  310. input[type="number"] {
  311. -moz-appearance: textfield;
  312. }
  313. </style>