Guest User

Untitled

a guest
May 23rd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. # post请求
  2. $.ajax({
  3. url: "/login/do_login",
  4. type: "POST",
  5. data:{
  6. mobile:$("#mobile").val(),
  7. password: password
  8. },
  9. success:function(data){
  10. layer.closeAll();
  11. if(data.status == 0){
  12. layer.msg("成功");
  13. window.location.href="/goods/to_list";
  14. }else{
  15. layer.msg(data.msg);
  16. }
  17. },
  18. error:function(){
  19. layer.closeAll();
  20. }
  21. });
  22.  
  23. # Get请求
  24. $.ajax({
  25. url:"/goods/to_detail/"+goodsId,
  26. type:"GET",
  27. success:function(data){
  28. if(data.status == 0){
  29. render(data.data);
  30. }else{
  31. layer.msg("客户端请求有误");
  32. }
  33. },
  34. error:function(){
  35. layer.msg("客户端请求有误");
  36. }
  37. });
  38.  
  39. # 启动加载
  40. $(function(){
  41. getGoodsList();
  42. });
  43.  
  44. # 设置属性
  45. $("#buyButton").attr("disabled", true);
  46. $("#verifyCodeImg").attr("src", "/miaosha/verifyCode?goodsId="+$("#goodsId").val());
  47.  
  48. # 设置text值
  49. $("#miaoshaTip").html("秒杀倒计时:"+remainSeconds+"秒");
  50.  
  51. $("#goodsId").val()
  52.  
  53. $("#userTip").hide();
  54.  
  55. $("#verifyCodeImg").show();
  56.  
  57. #时间转换
  58. $("#startTime").text(new Date(goods.startDate).format("yyyy-MM-dd hh:mm:ss"));
  59.  
  60. # 主动轮询
  61. setTimeout(function(){getMiaoshaResult(goodsId);}, 200);
  62.  
  63. # JQuery验证插件
  64. <script type="text/javascript" th:src="@{/jquery-validation/jquery.validate.min.js}" src="../static/jquery-validation/jquery.validate.min.js"></script>
  65. <script type="text/javascript" th:src="@{/jquery-validation/localization/messages_zh.min.js}" src="../static/jquery-validation/localization/messages_zh.min.js"></script>
  66.  
  67. <input type="text" id="mobile" class="user" name="mobile" placeholder="请输入手机号码" required="true" minlength="11" maxlength="11">
  68.  
  69. function login(){
  70. $("#loginForm").validate({
  71. submitHandler:function(form){
  72. doLogin();
  73. }
  74. });
  75. }
Add Comment
Please, Sign In to add comment