withdrawal.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // pages/withdrawal/withdrawal.js
  2. import {
  3. getMoneyAccountDetail,
  4. } from '../../services/index.js'
  5. let setInter = false;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. money: '',
  12. active_index: '1'
  13. },
  14. // 清除输入框内容
  15. clear() {
  16. this.setData({
  17. money: ''
  18. })
  19. },
  20. // 输入可提现最大值
  21. all() {
  22. this.setData({
  23. money: this.data.can_draw.toFixed(2)
  24. })
  25. },
  26. // 展示按钮背景
  27. show(e) {
  28. clearTimeout(setInter);
  29. setInter = setTimeout(_ => {
  30. this.setData({
  31. money: e.detail.value
  32. })
  33. }, 300)
  34. },
  35. // 改变金额格式
  36. changeMoney(e) {
  37. const _num = Number(e.detail.value);
  38. this.setData({
  39. money: (_num - _num % 10).toFixed(2)
  40. })
  41. },
  42. // 更改提现方式
  43. choose(e) {
  44. const index = e.currentTarget.dataset.index;
  45. this.setData({
  46. active_index: index
  47. })
  48. },
  49. // 提现
  50. withdrawal() {
  51. const money = Number(this.data.money);
  52. console.log(money)
  53. if (money) {
  54. wx.navigateTo({
  55. url: '/pages/withdrawal-result/withdrawal-result',
  56. })
  57. }
  58. },
  59. /**
  60. * 生命周期函数--监听页面加载
  61. */
  62. onLoad: function(options) {
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function() {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function() {
  73. getMoneyAccountDetail({
  74. user_id: wx.getStorageSync('user_id'),
  75. user_token: wx.getStorageSync('user_token'),
  76. member_id: wx.getStorageSync('member_id'),
  77. }).then(res => {
  78. if (res.errcode === 0) {
  79. const moneyBalance = res.data.MpMemberAccountAPI.moneyBalance;
  80. const can_draw = moneyBalance - moneyBalance % 10;
  81. this.setData({
  82. moneyBalance: moneyBalance.toFixed(2),
  83. can_draw,
  84. })
  85. }
  86. })
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function() {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function() {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function() {
  107. },
  108. })