Açıklama Yok

registerTwo.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. var countDown = '',count_down = '';
  2. var source = '';
  3. var scrollTop = '';
  4. var scrollTop02 = '';
  5. var qs = parseQueryString(window.location.href);
  6. $().ready(function () {
  7. if(qs.source) {source = qs.source}
  8. if(qs.source == 40025){
  9. countLandingPage({click_source:'openLink',source:source})
  10. }else{
  11. countLandingPage({click_source:'money_phone',source:source})
  12. }
  13. $(window).scroll(function(){
  14. scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置
  15. })
  16. })
  17. //点击获取验证码
  18. function getYzmEvent () {
  19. var myreg = /^[0-9]{11}$/;
  20. if (!myreg.test($("#phone").val())) {
  21. //手机号码未填写及填写不正确
  22. showMsg('请正确填写手机号')
  23. return;
  24. }
  25. countLandingPage({click_source:'achieve',source:source})
  26. $("#mask").css({'visibility': 'visible'});
  27. $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime())
  28. scrollTop02 = scrollTop;
  29. $('body').css({'position':'fixed',"top":-scrollTop});
  30. }
  31. //关闭弹层
  32. function closePanel(){
  33. $('#mask').css({'visibility': 'hidden'});
  34. //$('#maskMoney').css({'visibility': 'hidden'});
  35. $("#imgYzm").val('');
  36. $("body").css({"position":"initial"});
  37. $(window).scrollTop(scrollTop02);
  38. }
  39. /* 点击更换图片验证码*/
  40. function getChangeCodeImg(){
  41. $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime());
  42. }
  43. // 输入图片验证码后点击确定请求短信验证码
  44. function goResPanel(){
  45. if($("#imgYzm").val() == ''){
  46. showMsg('请输入图片验证码')
  47. return;
  48. }
  49. registerSecond();
  50. }
  51. //发送短信验证码
  52. function registerSecond () {
  53. $.ajax({
  54. type:"post",
  55. url:"/user/user/registerSecond",
  56. dataType:'json',
  57. data:{
  58. phone:$("#phone").val(),
  59. smstype:1,
  60. qrcode:2,
  61. image_code:$("#imgYzm").val(),
  62. source:source
  63. },
  64. success:function (res){
  65. console.log(res)
  66. if(res && res.errno == 0){
  67. closePanel();
  68. countDown = res.rst.wait_time;
  69. count_down = countDown;
  70. var that = this;
  71. $("#getYzm").attr("disabled","true").css({'background':'#ccc','color':"#ffffff"});
  72. $("#getYzm").html(count_down);
  73. count_down = count_down-1;
  74. var time = setInterval(function () {
  75. $("#getYzm").html(count_down);
  76. count_down--;
  77. if(count_down < 0){
  78. $("#getYzm").removeAttr("disabled")
  79. .html('发送验证码')
  80. .css({'background':'#fbde3a','color':'#fe474b'});
  81. clearInterval(time);
  82. count_down = countDown;
  83. }
  84. },1000)
  85. }else{
  86. showMsg(res.err)
  87. }
  88. }
  89. });
  90. }
  91. //登录
  92. function loginEvent () {
  93. var myreg = /^[0-9]{11}$/;
  94. if (!myreg.test($("#phone").val())) {
  95. //手机号码未填写及填写不正确
  96. showMsg('请正确填写手机号')
  97. return;
  98. }
  99. if($("#phoneYzm").val() == ""){
  100. showMsg('请输入短信验证码')
  101. return;
  102. }
  103. loginCodeEvent();
  104. }
  105. //短信验证码登录
  106. function loginCodeEvent () {
  107. countLandingPage({click_source:'click',source:source})
  108. $.ajax({
  109. type:"post",
  110. url:"/user/user/loginCode",
  111. dataType:'json',
  112. data:{
  113. phone:$("#phone").val(),
  114. code:$("#phoneYzm").val(),
  115. source:source
  116. },
  117. success:function(res) {
  118. console.log(res)
  119. if(res && res.errno == 0){
  120. goAppEvent();//下载
  121. // $("#maskMoney").css({'visibility': 'visible'});
  122. // scrollTop02 = scrollTop;
  123. // $('body').css({'position':'fixed',"top":-scrollTop});
  124. }else{
  125. showMsg(res.err)
  126. }
  127. }
  128. });
  129. }
  130. //点击下载app
  131. function goAppEvent () {
  132. if(source == 40025){
  133. countLandingPage({click_source:'download-1Page',source:source})
  134. }else{
  135. countLandingPage({click_source:'download',source:source})
  136. }
  137. showMsg('注册成功')
  138. var downLoad = [{
  139. source:'40038',
  140. url:'http://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/xhz_qtt12.apk'
  141. },{
  142. source:'40045',
  143. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/qtt_04.apk'
  144. },{
  145. source:'40077',
  146. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/ss_uc_06.apk'
  147. },{
  148. source:'40025',
  149. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/xhz_40025.apk'
  150. }]
  151. if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){//小花猪ios下载链接
  152. window.location.href = 'https://apps.apple.com/cn/app/%E5%80%9F%E4%BD%A0%E7%94%A8-%E5%87%AD%E8%8A%9D%E9%BA%BB%E4%BF%A1%E7%94%A8500%E5%88%86%E5%80%9F%E6%AC%BE10000%E5%85%83/id1281868947';
  153. return;
  154. }
  155. downLoad.forEach(function (item, index) {
  156. if(source == item.source){
  157. setTimeout(function () {
  158. window.location.href = item.url;
  159. },1000)
  160. return;
  161. }
  162. })
  163. }
  164. //埋点
  165. function countLandingPage (data) {
  166. $.ajax({
  167. type:'post',
  168. url:'/user/log/countLandingPage',
  169. dataType:'json',
  170. data:data,
  171. success:function (res) {
  172. console.log(res)
  173. }
  174. })
  175. }
  176. //提示信息
  177. function showMsg(msg) {
  178. var msg = msg;
  179. var msgBox = $('.alert-info');
  180. msgBox.children('p').text(msg);
  181. msgBox.show();
  182. setTimeout(function() {
  183. msgBox.hide();
  184. }, 2000);
  185. }
  186. //获取地址栏参数
  187. function parseQueryString(url) {
  188. var urlObj = {};
  189. var reg = /([^?=&]+)=([^?=&]+)/g;
  190. url.replace(reg, ($0, $1, $2) => {
  191. urlObj[$1] = decodeURIComponent($2);
  192. })
  193. return urlObj;
  194. }