2019-09-06 23:53:10 +08:00

386 lines
10 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// init({
// beforeback: function() { //获得父页面的webview
// var list = plus.webview.currentWebview().opener(); //触发父页面的自定义事件(refresh),从而进行刷新
// fire(list, 'refresh');
// //返回true,继续页面关闭逻辑
// return true;
// }
// });
var qlg_img_url = 'http://img.zgqlg.com.cn/';
var is_weixin = (function() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
})();
if(is_weixin){
$('body').hide();
setTimeout(function(){
alert('微信浏览器不支持上传图片,所以请点击右上角,用浏览器打开注册');
},500);
}
var JZL = JZL || {};
JZL.ajax = function(url, data, fnDeal, sendType, sendToken) {
if (typeof(sendType) == "undefined") sendType = 'POST';
if (typeof(sendToken) == "undefined") sendToken = 1;
$.ajax(url, {
data: data,
dataType: 'json', //服务器返回json格式数据
type: sendType, //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(result) { //服务器返回响应,根据响应结果,分析是否登录成功;
if (typeof(fnDeal) != "undefined") {
fnDeal(result);
}
},
error: function(xhr, type, errorThrown) { //异常处理;
//alert(xhr+type+errorThrown);
alert(type);
}
});
}
var wait = 120;
// 判断用户名是否存在
$('#loginName').on('blur', function() {
var loginName = $('#loginName').val();
JZL.ajax('/app/users/check_login_name', {
loginName: loginName
}, function(data) {
// //console.log(data);
if (1 != data.status) {
alert(data.msg)
}
})
})
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURI(r[2]); return null;
}
// function GetQueryString(name) {
// var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
// // var r=  "/mobile/users/reg?pName=hsfzmsn3".match(reg);
// var r = window.location.search.substr(1).match(reg);
// if (r != null)
// return unescape(r[2]);
// return null;
// }
var pName = GetQueryString('pName') ? GetQueryString('pName') : localStorage.getItem('pName');
// if (!pName) {
// pName = localStorage.getItem('pName');
// var indexNum = pName.indexOf('&');
// if (indexNum > 0) {
// pName = pName.slice(0, indexNum);
// }
// }
//
if (pName) {
// //console.log(pName);
JZL.ajax('/app/users/get_puser_info', {
pName: pName
}, function(data) {
if(data.status == 1){
pName = data.data.userPhone;
if('' == pName){
alert('请联系推荐人实名后推广');return;
}else{
$('#pName').val(pName);
$('#pName').attr('readonly', 'readonly');
$('.pNameCode').show();
}
}
})
// $('#pName').val(pname);;
// $('#pName').attr('disabled', 'disabled');
}
// 推荐人信息
//var PName = "";
$('#pName').on('blur', function() {
pName = $('#pName').val();
if (pName == ''){alert('手机号不能为空!');return;}
if (!(/^134[0-8]\d{7}$|^13[^4]\d{8}$|^14[5-9]\d{8}$|^15[^4]\d{8}$|^16[6]\d{8}$|^17[0-8]\d{8}$|^18[\d]{9}$|^19[8,9]\d{8}$/.test(pName))) {
alert("手机号码误,请重填!");
return;
}
JZL.ajax('/app/users/get_puser_info', {
pName: pName
}, function(data) {
if(data.status == 1){
$('.pNameCode').show();
}else{
alert('推荐人不存在');
}
})
})
//
//
// } else {
// $('.pNameCode').hide();
// }
//
// })
// JZL.ajax(qlgUrl('app/users/check_login_name'),{loginName:loginName},function (data) {
// // //console.log(data);
//
// if (1 != data.status) {
// alert(data.msg)
// }
// })
function time() {
if (wait == 0) {
$('#getMobileCode').removeAttr("disabled");
$('#getMobileCode').val("重新发送");
wait = 120;
} else {
$('#getMobileCode').attr("disabled", true);
$('#getMobileCode').val("重新发送(" + wait + ")");
wait--;
setTimeout(function() {
time()
},
1000)
}
}
//获取验证码
$('.row').on('click', '#getMobileCode', function() {
var pName = $('#pName').val();
if (pName == '') {
alert('手机号不能为空!');
return;
}
if (!(
/^134[0-8]\d{7}$|^13[^4]\d{8}$|^14[5-9]\d{8}$|^15[^4]\d{8}$|^16[6]\d{8}$|^17[0-8]\d{8}$|^18[\d]{9}$|^19[8,9]\d{8}$/
.test(pName))) {
alert("手机号码误,请重填!");
return;
}
var that = $(this);
that.attr("disabled", true);
$.ajax('/app/users/getPhoneVerifyCode', {
data: {
userPhone: pName
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
//console.log(data);
//服务器返回响应,根据响应结果,分析是否登录成功;
if (data.status == 1) {
time();
} else {
alert(data.msg);
}
that.removeAttr('disabled');
},
error: function(xhr, type, errorThrown) {
//异常处理;
alert(type);
that.removeAttr('disabled');
// alert(type);
}
});
})
//注册协议
$.ajax('/app/Tags/articleDetail', {
data: {
articleId: 114
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
//console.log(data);
// if(data.status==1){
// //console.log(1);
var html1 = ''
html1 = '<a oncopy="return false;" oncut="return false;">' + data.articleContent + '</a>'
$('.zcxycontent').append(html1)
// }
},
error: function(xhr, type, errorThrown) {
}
});
//上传图片
var uploader = new plupload.Uploader({
runtimes: 'html5,flash,silverlight,html4',
browse_button: 'regConfirm',
//multi_selection: false,
// container: document.getElementById('container'),
flash_swf_url: 'lib/plupload-2.1.2/js/Moxie.swf',
silverlight_xap_url: 'lib/plupload-2.1.2/js/Moxie.xap',
url: 'http://oss.aliyuncs.com',
filters: {
mime_types: [ //只允许上传图片和zip,rar文件
{
title: "Image files",
extensions: "jpg,gif,png,bmp"
}
],
max_file_size: '10mb', //最大只能上传10mb的文件
prevent_duplicates: true //不允许选取重复文件
},
init: {
PostInit: function() {
document.getElementById('regConfirm').innerHTML = '';
// document.getElementById('postfiles').onclick = function() {
// set_upload_param(uploader, '', false);
// return false;
// };
uploader.bind('FilesAdded', function() {
set_upload_param(uploader, '', false, 'test');
return false;
});
},
FilesAdded: function(up, files) {
plupload.each(files, function(file) {
document.getElementById('regConfirm').innerHTML = '<div class="files_out" id="' + file.id + '"><b></b>' +
'<div class="progress"><div class="progress-bar" style="width: 60px"></div></div>' +
'</div>';
});
},
BeforeUpload: function(up, file) {
check_object_radio();
set_upload_param(up, file.name, true);
},
UploadProgress: function(up, file) {
// //console.log(file);
var d = document.getElementById(file.id);
d.getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
var prog = d.getElementsByTagName('div')[0];
var progBar = prog.getElementsByTagName('div')[0]
progBar.style.width = 2 * file.percent + 'px';
progBar.setAttribute('aria-valuenow', file.percent);
},
FileUploaded: function(up, file, info) {
if (info.status == 200) {
$('#regConfirmImg').val(get_uploaded_object_name(file.name))
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<img data-src="' +
get_uploaded_object_name(file.name) + '" src="' + qlg_img_url + get_uploaded_object_name(file.name) + '" />';
} else {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = info.response;
}
},
Error: function(up, err) {
if (err.code == -600) {
alert("\n选择的文件太大了");
} else if (err.code == -601) {
alert("\n选择的文件后缀不对");
} else if (err.code == -602) {
alert("\n这个文件已经上传过一遍了");
} else {
alert("\nError xml:" + err.response);
}
}
}
});
uploader.init();
// $(".photos").on("click", '.regConfirm', function() {
// // UP.init("accountBookImg", "test", "accountBookImgTag")
//
// UP.init("regConfirmImg", "test", "regConfirm")
// openCamera()
// })
$('.down').on('click', '.btn', function() {
var loginName = $('#loginName').val();
// var mobileCode = $('.yzm').val();
var loginPwd = $('#loginPwd').val();
var reUserPwd = $('#reUserPwd').val();
var mobileCode = $('#mobileCode').val() ? $('#mobileCode').val() : ""; //推荐人验证码
var payPwd = $('#loginPaywd').val();
var reUserPaywd = $('#reUserPaywd').val();
var pName = $('#pName').val();
// var verifyCode = $('.tpyzm').val();
var regConfirmImg = $('#regConfirmImg').val();
if (loginName == '') {
alert('用户名不能为空!');
return;
}
if (loginPwd.length < 6) {
alert('登录密码不能小于6位');
return;
}
if (payPwd.length < 6) {
alert('操作密码不能小于6位');
return;
}
if (!(loginPwd == reUserPwd)) {
alert('两次登录密码不一致!');
return;
}
if (payPwd != reUserPaywd) {
alert('两次操作密码不一致!');
return;
}
if (regConfirmImg == '') {
alert('请上传确认书照片');
return;
}
if (mobileCode == '') {
alert('验证码不能为空!');
return;
}
// if (pName != '') {
// if ('' == mobileCode1) {
// alert('请输入推荐人验证码');
// return;
// }
// }
$(this).attr("disabled", true);
JZL.ajax('/app/users/register', {
loginName: loginName,
mobileCode: mobileCode,
loginPwd: loginPwd,
payPwd: payPwd,
pName: pName,
nameType: 3,
regConfirmImg: regConfirmImg,
// mobileCode1: mobileCode1
// verifyCode: verifyCode
},function(data){
//服务器返回响应,根据响应结果,分析是否登录成功;
alert(data.msg);
if (data.status == 1) {
// back();
// p/lus.runtime.openURL(result);
window.location.href = 'download.html';
// plus.runtime.open
} else {
// $('.yzmhh').attr('src', hyhUrl('mobile/users/getverify?rnd=' + Math.random()));
}
$('.btn').removeAttr('disabled');
});
})