index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var util = require('../../../../utils/util.js');
  2. var api = require('../../../../config/api.js');
  3. Page({
  4. data: {
  5. list: [],
  6. cash:0,//可提现金额
  7. page: 1,
  8. limit: 10,
  9. totalPages: 1
  10. },
  11. onLoad: function(options) {
  12. // 页面初始化 options为页面跳转所带来的参数
  13. this.setData({
  14. cash: options.m
  15. });
  16. this.getList();
  17. },
  18. onPullDownRefresh() {
  19. wx.showNavigationBarLoading() //在标题栏中显示加载
  20. this.getList();
  21. wx.hideNavigationBarLoading() //完成停止加载
  22. wx.stopPullDownRefresh() //停止下拉刷新
  23. },
  24. getList: function() {
  25. wx.showLoading({
  26. title: '加载中',
  27. });
  28. setTimeout(function() {
  29. wx.hideLoading()
  30. }, 2000);
  31. let that = this;
  32. util.request(api.DisCashoutList, {
  33. page: that.data.page,
  34. limit: that.data.limit
  35. }).then(function(res) {
  36. if (res.errno === 0) {
  37. console.log(res.data);
  38. that.setData({
  39. list: that.data.list.concat(res.data.list),
  40. totalPages: res.data.pages
  41. });
  42. }
  43. wx.hideLoading();
  44. });
  45. },
  46. btnCashout:function(){//提现申请
  47. let that = this;
  48. wx.showModal({
  49. title: '',
  50. content: '确定要申请提现? 提现金额:'+that.data.cash,
  51. success: function(res) {
  52. if (res.confirm) {
  53. util.request(api.DisCashoutApply, {
  54. amount: that.data.cash
  55. }, 'GET').then(function(res) {
  56. if (res.errno === 0) {
  57. wx.showToast({
  58. title: '提现申请成功,请等待管理员处理',
  59. });
  60. setTimeout(function() {
  61. that.setData({
  62. page:1,
  63. limit:0,
  64. list:[],
  65. cash:0
  66. })
  67. that.getList();
  68. }, 2000);
  69. } else {
  70. util.showErrorToast(res.errmsg);
  71. }
  72. });
  73. }
  74. }
  75. });
  76. },
  77. onReady: function() {
  78. // 页面渲染完成
  79. },
  80. onShow: function() {
  81. // 页面显示
  82. },
  83. onHide: function() {
  84. // 页面隐藏
  85. },
  86. onUnload: function() {
  87. // 页面关闭
  88. },
  89. onReachBottom:function(){
  90. if (this.data.totalPages > this.data.page) {
  91. this.setData({
  92. page: this.data.page + 1
  93. });
  94. this.getList();
  95. } else {
  96. wx.showToast({
  97. title: '没有更多提现申请了',
  98. icon: 'none',
  99. duration: 2000
  100. });
  101. return false;
  102. }
  103. }
  104. })