//-------------------------------------------短信提交验证------------------------------------------//
$(function(){
var daoshu = 60;
var timer = null;
//手机号
function checkPhone(){
var phoneNumber = $.trim($(\'#t_code\').val());
var phone = document.getElementById(\'t_code\').value;
var smsCode = $.trim($(\'#smsCode\').val());
if (phoneNumber == null || phoneNumber == \"\") {
//com.prompt(\'请输入手机号!\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'请输入手机号\');
return false;
//手机号正则
}else if(!(/^1[3456789]\\d{9}$/.test(phone))) {
//com.prompt(\'手机号格式错误\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'手机号格式错误\');
return false;
}
return true;
}
//手机验证码
function checkSmsCode(){
var smsCode = $.trim($(\'#smsCode\').val());
if (smsCode == null || smsCode == \"\") {
if(parent.location.href.indexOf(\'reg\') >= 0){
// com.prompt(\'请输入验证码\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'请输入验证码\');
}else{
// com.prompt(\'请输入验证码\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'请输入验证码\');
}
return false;
}
return true;
}
//发送短信验证码
$(\".send-sms\").click(function(){
var mobile = $.trim($(\'#t_code\').val());
//console.log(typeof mobile);
if(!mobile){
// com.prompt(\"请输入手机号\");
return false;
}
if(!checkPhone()){
return false;
}
send_login_code(mobile);
});
//获取验证码倒计时1分钟
function fn_daoshu(){
$(\".daoshu\").show();
daoshu -- ;
$(\".daoshu\").text(daoshu +\'s\');
if(daoshu == 0){
clear_Inter();
}
}
//清楚定时器
function clear_Inter(){
daoshu = 60;
$(\".daoshu\").text(\'60s\').hide();
clearInterval(timer);
}
//发送短信验证码
function send_login_code(mobile)
{
$(\".daoshu\").show();
var code;
if($(\"#get_code\").css(\"display\") == \'none\'){
code = \'is_empty\';
}else {
if($(\'#yz_code\').val() == \'\'){
com.prompt(\'请输入图形验证码\');
return false;
}
code = $(\'#yz_code\').val();
}
timer = setInterval(fn_daoshu,1000);
$(\"#smsCode\").attr(\"disabled\" , false);
$(\"#smsCode\").attr(\"disabled\" , false);
$.ajax({
type:\"POST\",
url:com.url.get_sms_code,
data:{
mobile: mobile,
},
datatype: \"json\",
success:function(res){
if(res.status == \'true\'){
com.prompt(\"发送成功\");
// $(\'#yaerror\').show();
// $(\'#yaerror span\').html(\'发送成功!\');
}else{
com.prompt(res.info);
clear_Inter();
return false;
}
},
error: function(res){
//com.prompt(\'请重新获取\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'请重新获取\');
clear_Inter();
return false;
// console.log(res)
}
});
}
//用户名
$(\"#t_usrname\").focus(function(){
if($(this).val().length>0){
$(\'#userdelIco\').show();
}
})
$(\"#t_usrname\").blur(function(){
var username = $(\'#t_usrname\').val();
if(username == \'\') return false;
//只能输入中文 英文 和空格
var reg =/^[a-zA-Z\\u4e00-\\u9fa5\\s ]{1,20}$/;
if(!(reg.test(username))) {
//com.prompt(\'姓名格式不正确\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'姓名格式不正确\');
return false;
}
// $(\'#userdelIco\').hide();
return true;
});
//手机验证码
function t_usrname(){
var username = $(\'#t_usrname\').val();
var reg =/^[a-zA-Z\\u4e00-\\u9fa5\\s ]{1,20}$/;
if(username == null || username == \"\") {
return true;
}else if(username!=\'\'){
if(!(reg.test(username))) {
//com.prompt(\'姓名格式不正确\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'姓名格式不正确\');
return false;
}
}
return true;
}
$(\'#t_usrname\').on(\"input\",function(){
var username = $.trim($(\'#t_usrname\').val());
if(username.length>0){
$(this).parent(\'.posiv\').siblings(\'.delico\').show();
$(this).parent(\'.posiv\').siblings(\'.delico\').click;
}
})
//手机号焦点校验
$(\'#t_code\').on(\"focus\",function(){
if($(this).val().length>0){
$(\'#teldelIco\').show();
}
//已登录状态
if(parseInt(is_login)>\'0\' && parseInt(need_bind_mobie)>\'1\') {
$(\'#seleid\').show(400);
$(\'#seleid\').html(need_bind_mobie)
document.querySelector(\'#seleid\'). =showMobile;
}else{
$(\'.flp.vufk\').show();
}
})
function showMobile(){
$(\'#t_code\').val(this.innerHTML)
$(\'#seleid\').hide();
$(\'.flp.vufk\').hide(400);
$(\'#yaerror\').hide();
}
//已登录
if(parseInt(is_login)>\'0\' && parseInt(need_bind_mobie)>\'1\'){
$(\'#tel_msg\').click(function() {
var phone = $.trim($(\'#t_code\').val());//手机号
var user_name = $.trim($(\"#t_usrname\").val());//用户名
var source = $.trim($(\"#source\").val()); //暂时写死
//换号了
if(phone!=need_bind_mobie){
console.log(\'换号了\')
$(\'#yusuc\').hide();
$(\'.flp.vufk\').show(400);
$(\'#sendSms_Box\').show();
noLogin();
}else{
$(\'.flp.vufk\').hide(400);
console.log(\'没换号\')
//没换号
var userInfo = {
user_name: user_name,
mobile: phone, //手机号
source:source,
pf_source:2,
ip: returnCitySN[\"cip\"]
};
if(!t_usrname()){
return false;
}
if(!checkPhone()){
return false;
}
sendApiData({reg_source:userInfo.source,mobile:userInfo.mobile,name:userInfo.user_name,pf_source:2,ip: returnCitySN[\"cip\"]});
}
})
}else{
console.log(\'没登录\')
$(\'.flp.vufk\').show();
$(\'#tel_msg\').click(function(){
//没登录
noLogin();
})
}
//手机号失焦校验
$(\'#t_code\').blur(function(){
if(!checkPhone()){
return false;
}
})
//正在输入检验
$(\'#t_code\').on(\"input\",function(){
var phoneNumber = $.trim($(\'#t_code\').val());
if(parseInt(is_login)>\'0\' && parseInt(need_bind_mobie)>\'1\'){
if(phoneNumber!=need_bind_mobie){
$(\'#seleid\').hide();
$(\'.flp.vufk\').show(400);
}
if(phoneNumber==need_bind_mobie){
$(\'.flp.vufk\').hide(400);
}
}else {
$(\'.flp.vufk\').show();
}
if(phoneNumber.length>0){
$(this).parent(\'.posiv\').siblings(\'.delico\').show();
$(this).parent(\'.posiv\').siblings(\'.delico\').click;
}
var phone = document.getElementById(\'t_code\').value;
var smsCode = $.trim($(\'#smsCode\').val());
if (phoneNumber == null || phoneNumber == \"\") {
$(this).parent(\'.posiv\').siblings(\'.delico\').hide();
$(\".send-sms\").css({\"background\":\"#eee\",\"color\":\"#999\"});
// $(\".send-sms\").attr(\'disabled\',\'disabled\');
return false;
//手机号正则
}else if(!(/^1[3456789]\\d{9}$/.test(phone))) {
$(\".send-sms\").css({\"background\":\"#eee\",\"color\":\"#999\"});
return false;
}
$(\".send-sms\").css({\"background\":\"#ff5922\",\"color\":\"#fff\"});
$(\".send-sms.dbing\").css({\"background\":\"#b41f5e\",\"color\":\"#fff\"});
$(\'#yaerror\').hide();
$(\'#yaerror span\').html(\'\');
$(\'.flp.vufk\').show();
})
$(\'#userdelIco\').click(function(){
$(this).siblings(\'.posiv\').find(\'.ptxt\').val(\'\');
// $(\'#t_usrname\').val(\'\');
clear_Inter();
$(this).hide();
$(\'.test_required\').hide();
if($(\'#yaerror span\').html()==\'姓名格式不正确\'){
$(\'#yaerror\').hide();
if(!checkPhone()){
return false;
}
}
})
$(\'#teldelIco\').click(function(){
$(this).siblings(\'.posiv\').find(\'.ptxt\').val(\'\');
$(\".send-sms\").css({\"background\":\"#eee\",\"color\":\"#999\"});
$(\"#smsCode\").attr(\'disabled\',\'disabled\').val(\'\');
clear_Inter();
$(this).hide();
$(\'.test_required\').hide();
if($(\'#yaerror span\').html()==\'手机号格式错误\'){
$(\'#yaerror\').hide();
}
if($(\'#yaerror span\').html()==\'请输入验证码\'){
$(\'#yaerror\').hide();
}
if($(\'#yaerror span\').html()==\'验证码错误\'){
$(\'#yaerror\').hide();
}
})
//没登录做验证
function noLogin(){
var phone = $.trim($(\'#t_code\').val());
var source = $.trim($(\"#source\").val()); //暂时写死
var yz_code = $.trim($(\'#smsCode\').val());
var user_name =$.trim($(\"#t_usrname\").val());
var userInfo = {
user_name:user_name,
mobile : phone, //手机号
code : yz_code , //验证码
source : source //来源渠道
};
if(!t_usrname()){
return false;
}
if(!checkPhone()){
return false;
}
if(!checkSmsCode()){
return false;
}
mobile_submit(userInfo);
}
//手机号登陆start
function mobile_submit(userInfo){
$.ajax({
type:\"POST\",
url: com.url.check_sms_code,
data:{
user_name:userInfo.user_name,
mobile : userInfo.mobile,
code : userInfo.code,
source : userInfo.source
},
dataType: \'json\',
success: function(res){
if(res.status == \'true\'){
// com.prompt(\'已提交\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'已提交\');
$(\'#t_code\').val(\'\');
$(\'#t_usrname\').val(\'\');
clear_Inter();
$(\"#smsCode\").attr(\'disabled\',\'disabled\').val(\'\');
$(\".send-sms\").css({\"background\":\"#eee\",\"color\":\"#999\"});
$(\'.delico\').hide();
$(\'#yaerror\').hide();
$(\'#yaerror\').html(\'\');
sendApiData({reg_source:userInfo.source,mobile:userInfo.mobile,name:userInfo.user_name,pf_source:2,ip: returnCitySN[\"cip\"]});
$(\'#yusuc\').show();
$(\'#sendSms_Box\').hide();
$(\'.module_10 .sendheight\').css(\'height\',\'14rem\');
$(\'.pic_online10\').css(\'height\',\'17rem\');
$(\'.ddt.last_getUser\').css(\'height\',\'11rem\');
$(\'.No9,.last_getUser.fsd\').css(\'height\',\'12rem\');
$(\'.index_apply .twrap06\').css(\'height\',\'12.3rem\');
}else{
//com.prompt(\"验证码错误\");
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'验证码错误\');
}
},
error: function(res){
// com.prompt(\'请重新提交\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'请重新提交!\');
// console.log(res)
}
})
}
//手机号登陆start,最终提交代码
function sendApiData(userInfo){
$.ajax({
type:\"GET\",
url: ucse_host+\'/xuemao/formcollection/save_form_data.json\',
data:userInfo,
xhrFields: {
withCredentials: true
},
dataType: \'json\',
success: function(res){
if(res.result == \'succ\'){
$(\'#yusuc\').show();
$(\'#sendSms_Box\').hide();
$(\'.module_10 .sendheight\').css(\'height\',\'14rem\');
$(\'.pic_online10\').css(\'height\',\'17rem\');
$(\'.ddt.last_getUser\').css(\'height\',\'11rem\');
$(\'.No9,.last_getUser.fsd\').css(\'height\',\'12rem\');
$(\'.index_apply .twrap06\').css(\'height\',\'12.3rem\');
}else{
//com.prompt(\"验证码错误\");
$(\'#yaerror\').show();
$(\'.vufk .error\').show();
}
},
error: function(res){
//com.prompt(\'请重新提交\');
$(\'#yaerror\').show();
$(\'#yaerror span\').html(\'请重新提交\');
// console.log(res)
}
})
}
//点击其他位置隐藏
$(\'body\').click(function(e) {
var target = $(e.target);
if(!target.is(\'#t_code\') && !target.is(\'#seleid\')) {
$(\'#seleid\').hide();
}
});
$(\'body\').click(function(e) {
var target = $(e.target);
if(!target.is(\'#t_usrname\')) {
$(\'#userdelIco\').hide();
}
});
$(\'body\').click(function(e) {
var target = $(e.target);
if(!target.is(\'#t_code\')) {
$(\'#teldelIco\').hide();
}
});
})
继续阅读与本文标签相同的文章
理性审视云计算合规性问题误区和现实
JavaScript获取日期方法
-
SQL 中 Left Join 转为 Inner Join 的实际应用
2026-05-19栏目: 教程
-
82天突破1000star,项目团队梳理出软件开源必须注意的8个方面
2026-05-19栏目: 教程
-
是真“开发者”,就来一“测”到底!
2026-05-19栏目: 教程
-
山西晋城携手阿里构建城市云平台,66个政务系统已上云
2026-05-19栏目: 教程
-
阿里云物联网平台设备升级OTA演示
2026-05-19栏目: 教程
