recharge.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * 充值卡模型
  3. */
  4. define(['base', '$', 'native', 'api', 'user', 'config'], function (base, $, native, api, user) {
  5. var Recharge = function () {
  6. if (typeof Recharge.instance === 'object') {
  7. return Recharge.instance;
  8. }
  9. Recharge.instance = this;
  10. this.storagePrefix = 'recharge';
  11. }
  12. Recharge.prototype = new base();
  13. // 获取充值卡列表
  14. Recharge.prototype.getRechargeList = function (callback) {
  15. var that = this;
  16. api.getRechargeList({}, function (res) {
  17. if (res.success) {
  18. }
  19. if (typeof(callback) == 'function') {
  20. callback(res);
  21. }
  22. });
  23. };
  24. // 充值
  25. Recharge.prototype.addRechargeorder = function (data, callback) {
  26. var that = this;
  27. api.addRechargeorder({
  28. user_id: data.user_id,
  29. value:data.value,
  30. recharge_id: data.recharge_id
  31. }, function (res) {
  32. if (res.success) {
  33. //更新user
  34. }
  35. if (typeof(callback) == 'function') {
  36. callback(res);
  37. }
  38. });
  39. };
  40. return new Recharge();
  41. })