cash.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const app = getApp()
  2. var api = require('../../utils/request');
  3. var util = require('../../utils/util');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. loading: false,
  10. bank: {
  11. money: 0,
  12. due_money: 0,
  13. lack_money: 0,
  14. income_monney: 0,
  15. shop_money: 0
  16. },
  17. },
  18. /**
  19. * 生命周期函数--监听页面显示
  20. */
  21. onShow: function () {
  22. this.getBank();
  23. },
  24. /**
  25. * 读取我的账单
  26. */
  27. getBank: function () {
  28. let that = this;
  29. api.Get("api/v3/fastshop/bank/index", function (result) {
  30. if (result.code == 200) {
  31. that.setData({ bank: result.data });
  32. }
  33. })
  34. },
  35. /**
  36. * 申请提现
  37. */
  38. onSubmit: function (e) {
  39. let that = this;
  40. var data = e.detail.value;
  41. var isPost = true;
  42. //安全密码
  43. if (util.isNull(data.safepassword)) {
  44. wx.showModal({
  45. content: '安全密码必须填写'
  46. })
  47. isPost = false;
  48. }
  49. if (util.isNull(data.money)) {
  50. wx.showModal({
  51. content: '提现金额必须填写'
  52. })
  53. isPost = false;
  54. } else {
  55. if (!(/^\d+$/.test(data.money))) {
  56. wx.showModal({
  57. content: '提现金额只能输入整数'
  58. })
  59. isPost = false;
  60. } else {
  61. var money = parseInt(data.money);
  62. var bank = this.data.bank;
  63. if (money > bank.due_money || money == 0) {
  64. wx.showModal({
  65. content: '超出允许提现金额'
  66. })
  67. isPost = false;
  68. }
  69. }
  70. }
  71. //提交数据
  72. if (isPost == true) {
  73. wx.showLoading({
  74. title: '提交申请中',
  75. mask: true
  76. })
  77. var parms = {
  78. money: data.money,
  79. safepassword: data.safepassword,
  80. }
  81. api.Post('api/v3/fastshop/bank/cash', parms, function (res) {
  82. wx.hideLoading();
  83. if (res.code == 200) {
  84. wx.showModal({
  85. showCancel: false,title: '友情提示',content: res.msg,
  86. complete: function () {
  87. wx.navigateBack({delta:1})
  88. }
  89. })
  90. }
  91. })
  92. }
  93. }
  94. })