equipment.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. $(function(){
  2. $(".tab ul li").on("click",function(){
  3. $(this).siblings().removeClass("on");
  4. $(this).addClass("on");
  5. $(".tab_bd").hide().eq($(this).index()).show();
  6. })
  7. var isbuy=0;
  8. /* 靓号 */
  9. $(".liang .bd_content ul").on("click",'.liang_buy',function(){
  10. if(isbuy){
  11. return !1;
  12. }
  13. if(!uid || !token ){
  14. layer.msg("信息错误");
  15. return !1;
  16. }
  17. var _this=$(this);
  18. var liang_id=_this.data("id");
  19. var liang_state=_this.data("state");
  20. isbuy=1;
  21. $.ajax({
  22. url:'/appapi/equipment/setliang',
  23. data:{uid:uid,token:token,liangid:liang_id,state:liang_state},
  24. type:'POST',
  25. dataType:'json',
  26. success:function(data){
  27. isbuy=0;
  28. if(data.code==0){
  29. if(liang_state==0){
  30. $(".liang_buy").html("使用");
  31. $(".liang_buy").data("state",'0');
  32. _this.html("卸载");
  33. _this.data("state",'1');
  34. }else{
  35. _this.html("使用");
  36. _this.data("state",'0');
  37. }
  38. layer.msg(data.msg);
  39. return !1;
  40. }else{
  41. layer.msg(data.msg);
  42. return !1;
  43. }
  44. },
  45. error:function(){
  46. isbuy=0;
  47. layer.msg("操作失败");
  48. return !1;
  49. }
  50. })
  51. })
  52. /* 坐骑 */
  53. $(".car .bd_content ul").on("click",'.car_buy',function(){
  54. if(isbuy){
  55. return !1;
  56. }
  57. if(!uid || !token ){
  58. layer.msg("信息错误");
  59. return !1;
  60. }
  61. var _this=$(this);
  62. var car_id=_this.data("id");
  63. var car_status=_this.data("status");
  64. isbuy=1;
  65. $.ajax({
  66. url:'/appapi/equipment/setcar',
  67. data:{uid:uid,token:token,carid:car_id,status:car_status},
  68. type:'POST',
  69. dataType:'json',
  70. success:function(data){
  71. isbuy=0;
  72. if(data.code==0){
  73. if(car_status==0){
  74. $(".car_buy").html("使用");
  75. $(".car_buy").data("status",'0');
  76. _this.html("卸载");
  77. _this.data("status",'1');
  78. }else{
  79. _this.html("使用");
  80. _this.data("status",'0');
  81. }
  82. layer.msg(data.msg);
  83. return !1;
  84. }else{
  85. layer.msg(data.msg);
  86. return !1;
  87. }
  88. },
  89. error:function(){
  90. isbuy=0;
  91. layer.msg("购买失败");
  92. return !1;
  93. }
  94. })
  95. })
  96. })