<script type="text/javascript"> $(function () { let v = urlparam.get('key'); storage.set("key", v); $("#app").validate({ onclick: true, onfocusout: false, onkeyup: false, onkeyup: false, onsubmit: false, //errorPlacement: function (error, element) { // layer.tips(error.html(), '#' + element[0].id, { // tips: 3, // tipsMore: true // }); //}, rules: { phoneNumber: { required: true }, verification_code: { required: true } }, messages: { phoneNumber: { required: "The Phone number is invalid" }, verification_code: { required: "Enter the correct verification code" } } }); }) function validateForm() { return $("#app").validate().element($("#phoneNumber")); } var vm = new Vue({ el: '#app', data: { phone_number: "", code: "" }, mounted() { }, methods: { submit() { var flag = $("#app").valid(); if (!flag) { return; } else { axios({ method: 'post', url: '/Home/FMRegister1', // 自定义请求头 headers: { 'Content-Type': 'application/json;charset=utf-8', 'Accept-Language': '@AppSettingsConstVars.Country_AcceptLanguage' }, params: { mobile: this.phone_number, code: this.code } }).then(res => { if (res.data.Code == 100) { let model = { "phone": this.phone_number, "code": this.code }; storage.set("l_phone", model); location.href = "/home/RegisterNext"; } else { layer.msg(res.data.Msg); } }).catch(function (error) { // 请求失败处理 console.log('error' + error); }); } }, sendcode() { var fla = validateForm(); console.log(fla); if (!fla) { alert(0); return; } else { axios({ method: 'get', url: '/Home/GetSms', // 自定义请求头 headers: { 'Content-Type': 'application/json;charset=utf-8', 'Accept-Language': '@AppSettingsConstVars.Country_AcceptLanguage' }, // timeout: 1000, // 默认值是 `0` (永不超时) params: { mobile: this.phone_number } }).then(res => { if (res.data.Code == 100) { $(".sign_clock").removeClass('send').addClass('wait'); var second = 60; $(".sign_clock").text("Resend(" + second + "s)"); var interval = setInterval(function () { second--; $(".sign_clock").text("Resend(" + second + "s)"); if (second === 0) { $(".call_captcha").show(); $(".sign_clock").removeClass('wait').addClass('send'); $(".sign_clock").text("Send"); clearInterval(interval); } }, 1000); } else { layer.msg(res.data.Msg); } }).catch(function (error) { // 请求失败处理 console.log('error' + error); }); } } } }); </script>
标签:function,code,记录,res,clock,phone,error From: https://www.cnblogs.com/elsons/p/16827728.html