123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- var id = '';//产品id
- var countDown = '',count_down = '';
- var qs = parseQueryString(window.location.href);
- $().ready(function () {
- if(qs.id){
- id = qs.id
- }
- })
- //点击获取验证码
- function getYzmEvent () {
-
- var myreg = /^[0-9]{11}$/;
- if (!myreg.test($("#phone").val())) {
- //手机号码未填写及填写不正确
- showMsg('请正确填写手机号')
- return;
- }
- $("#mask").css({'visibility': 'visible'});
- $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val())
- // registerEvent();
- }
- /* 点击更换图片验证码*/
- function getChangeCodeImg(){
- $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val());
- }
- /*//关闭弹层*/
- function closePanel(){
- $('#mask').css({'visibility': 'hidden'});
- $("#imgYzm").val('');
- }
- // 输入图片验证码后点击确定请求短信验证码
- function goResPanel(){
- if($("#imgYzm").val() == ''){
- showMsg('请输入图片验证码')
- return;
- }
- registerSecond();
- }
- //发送短信验证码
- function registerSecond () {
- $.ajax({
- type:"post",
- url:"/user/user/registerSecond",
- dataType:'json',
- data:{
- phone:$("#phone").val(),
- smstype:1,
- qrcode:2,
- image_code:$("#imgYzm").val()
- },
- success:function (res){
- console.log(res)
- if(res && res.errno == 0){
- closePanel();
- countDown = res.rst.wait_time;
- count_down = countDown;
- var that = this;
- $("#getYzm").attr("disabled","true").css('background','#ccc');
- $("#getYzm").html(count_down);
- count_down = count_down-1;
- var time = setInterval(function () {
- $("#getYzm").html(count_down);
- count_down--;
- if(count_down < 0){
- $("#getYzm").removeAttr("disabled")
- .html('获取')
- .css('background','#32BD60');
- clearInterval(time);
- count_down = countDown;
- }
- },1000)
- }else{
- showMsg(res.err)
- }
- }
- });
- }
- //发送短信验证码
- //function registerEvent () {
- // $.ajax({
- // type:"post",
- // url:"/user/user/register",
- // dataType:'json',
- // data:{
- // phone:$("#phone").val(),
- // smstype:1,
- // qrcode:2,
- // source:'40013'
- // },
- // success: function (res){
- // console.log(res)
- // if(res && res.errno == 0){
- // countDown = res.rst.wait_time;
- // count_down = countDown;
- // var that = this;
- // $("#getYzm").attr("disabled","true").css('background','#ccc');
- // $("#getYzm").html(count_down);
- // count_down = count_down-1;
- // var time = setInterval(function () {
- // $("#getYzm").html(count_down);
- // count_down--;
- // if(count_down < 0){
- // $("#getYzm").removeAttr("disabled")
- // .html('获取')
- // .css('background','#32BD60');
- // clearInterval(time);
- // count_down = countDown;
- // }
- // },1000)
- // }else{
- // showMsg(res.err)
- // }
- // }
- // });
- //}
- //登录
- function loginEvent () {
- var myreg = /^[0-9]{11}$/;
- if (!myreg.test($("#phone").val())) {
- //手机号码未填写及填写不正确
- showMsg('请正确填写手机号')
- return;
- }
- if($("#yzm").val() == ""){
- showMsg('请输入短信验证码')
- return;
- }
- loginCodeEvent();
- }
- //短信验证码登录
- function loginCodeEvent () {
- $.ajax({
- type:"post",
- url:"/user/user/loginCode",
- dataType:'json',
- data:{
- phone:$("#phone").val(),
- code:$("#yzm").val(),
- source:'40013'
- },
- success:function(res) {
- console.log(res)
- if(res && res.errno == 0){
- window.location.href = './details.html?id=' + id;
- }else{
- showMsg(res.err)
- }
- }
- });
- }
- //提示信息
- function showMsg(msg) {
- var msg = msg;
- var msgBox = $('.alert-info');
- msgBox.children('p').text(msg);
- msgBox.show();
- setTimeout(function() {
- msgBox.hide();
- }, 2000);
- }
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, ($0, $1, $2) => {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
|