withdrawal.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. var http = require("../../utils/http.js");
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. settledAmount: 0,
  8. amount: null,
  9. "frequency": 0, //天数
  10. "number": 0, //提现次数
  11. "amountMax": 0, //最大金额
  12. "amountMin": 0, //最低金额
  13. "paymentExplain": '' //其他提示
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function(options) {
  19. this.getDisInfoData();
  20. this.loadWithdrawCashRule(); //提现规则
  21. },
  22. /**
  23. * 获取用户钱包数据
  24. */
  25. getDisInfoData: function() {
  26. wx.showLoading();
  27. var params = {
  28. url: "/p/distribution/user/info",
  29. method: "GET",
  30. // data: {
  31. // shopId: 1
  32. // },
  33. callBack: res => {
  34. console.log(res)
  35. this.setData({
  36. settledAmount: res.distributionUserWallet.settledAmount,
  37. addupAmount: res.distributionUserWallet.addupAmount
  38. });
  39. wx.hideLoading();
  40. }
  41. }
  42. http.request(params);
  43. },
  44. /**
  45. * 确认提现
  46. */
  47. confirmWithdraw: function() {
  48. if (!this.data.amount || this.data.amount <= 0) {
  49. wx.showToast({
  50. title: '请输入正确金额!',
  51. icon: 'none',
  52. })
  53. return;
  54. } else if (this.data.amount > this.data.settledAmount) {
  55. wx.showToast({
  56. title: '余额不足',
  57. icon: "none"
  58. })
  59. return;
  60. }
  61. wx.showLoading({
  62. mask: true
  63. })
  64. http.request({
  65. url: "/p/distribution/withdrawCash/apply",
  66. method: "POST",
  67. data: {
  68. // shopId: 1,
  69. amount: this.data.amount
  70. },
  71. callBack: res => {
  72. wx.hideLoading();
  73. wx.showModal({
  74. content: '提现申请已提交',
  75. showCancel: false,
  76. complete: function() {
  77. wx.navigateBack();
  78. }
  79. })
  80. }
  81. });
  82. },
  83. onAmountInput: function(e) {
  84. this.setData({
  85. amount: e.detail.value
  86. });
  87. },
  88. onAllWithdraw: function() {
  89. this.setData({
  90. amount: this.data.settledAmount
  91. });
  92. },
  93. /**
  94. * 加载提现规则
  95. */
  96. loadWithdrawCashRule: function() {
  97. var ths = this;
  98. wx.showLoading();
  99. var params = {
  100. url: "/p/distribution/withdrawCash/info",
  101. method: "GET",
  102. // data: {
  103. // shopId: 1
  104. // },
  105. callBack: function(res) {
  106. wx.hideLoading();
  107. ths.setData({
  108. frequency: res.frequency,
  109. number: res.number,
  110. amountMax: res.amountMax,
  111. amountMin: res.amountMin,
  112. paymentExplain: res.paymentExplain
  113. });
  114. }
  115. };
  116. http.request(params);
  117. }
  118. })