Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. var affiliate = {
  2. customerId: 0,
  3. money: 0,
  4. bonus: 0,
  5. max_rate: 0,
  6.  
  7. getBonuses: function () {
  8.  
  9. var self = affiliate;
  10. $.ajax({
  11. url: backend_url + "/shop/?plugin=paybonus&action=get",
  12. type: "GET",
  13. data: {
  14. id: self.customerId
  15. },
  16. success: function (response) {
  17.  
  18. self.money = response.data.money;
  19. self.bonus = response.data.bonus;
  20. self.max_rate = response.data.max_rate;
  21. // $("#paybonus").find("#bonus-count").html(response.data.bonus);
  22. },
  23. error: function (xhr) {
  24. console.log(xhr);
  25. }
  26. });
  27. },
  28.  
  29. changeBonus: function () {
  30. // $("#paybonus").find("#bonus").on("input", function(){
  31. var $this = $(this);
  32. console.log($this.val());
  33. // });
  34. },
  35.  
  36. selectCustomer: function() {
  37. var self = affiliate;
  38. setTimeout(function(){
  39. self.customerId = $("#s-customer-id").val();
  40. if (self.customerId !== 0) {
  41. self.getBonuses();
  42. $("#paybonus").removeClass("hidden");
  43. }
  44.  
  45. // console.log(self.bonus);
  46. }, 400);
  47. self.debug();
  48. },
  49.  
  50. debug: function () {
  51. console.log(this);
  52. }
  53. };
  54.  
  55.  
  56. $("#customer-autocomplete").on("select", affiliate.selectCustomer);
  57.  
  58. $("#paybonus").find("#bonus").on("input", affiliate.changeBonus);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement