index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // pages/cash-withdrawal/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '提现',
  12. 'color':true,
  13. 'class':'0'
  14. },
  15. navList: [
  16. { 'name': '银行卡', 'icon':'icon-yinhangqia'},
  17. { 'name': '微信', 'icon': 'icon-weixin2' },
  18. { 'name': '支付宝', 'icon': 'icon-icon34' }
  19. ],
  20. currentTab: 0,
  21. index: 0,
  22. array: [],//提现银行
  23. minPrice:0.00,//最低提现金额
  24. userInfo:[],
  25. isClone:false
  26. },
  27. onLoadFun:function(){
  28. this.getUserInfo();
  29. this.getUserExtractBank();
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. },
  36. getUserExtractBank: function () {
  37. var that = this;
  38. app.baseGet(app.U({ c: 'public_api', a: 'get_user_extract_bank' }), function (res) {
  39. var array = res.data.extractBank;
  40. array.unshift("请选择银行");
  41. that.setData({ array: array, minPrice: res.data.minPrice });
  42. });
  43. },
  44. /**
  45. * 获取个人用户信息
  46. */
  47. getUserInfo: function () {
  48. var that = this;
  49. app.baseGet(app.U({ c: 'user_api', a: 'my' }), function (res) {
  50. that.setData({ userInfo: res.data });
  51. });
  52. },
  53. swichNav: function (e) {
  54. this.setData({ currentTab: e.currentTarget.dataset.current });
  55. },
  56. bindPickerChange: function (e) {
  57. this.setData({ index: e.detail.value });
  58. },
  59. subCash: function (e) {
  60. var formId = e.detail.formId, that = this, value = e.detail.value;
  61. app.baseGet(app.U({ c: 'public_api', a: "get_form_id", q: { formId: formId} }), null, null);
  62. if (that.data.currentTab == 0){//银行卡
  63. if (value.name.length == 0) return app.Tips({title:'请填写持卡人姓名'});
  64. if (value.cardnum.length == 0) return app.Tips({title:'请填写卡号'});
  65. if (that.data.index == 0) return app.Tips({title:"请选择银行"});
  66. value.extract_type = 'bank';
  67. value.bankname = that.data.array[that.data.index];
  68. } else if (that.data.currentTab == 1) {//微信
  69. value.extract_type = 'weixin';
  70. if (value.name.length == 0) return app.Tips({ title: '请填写微信号' });
  71. value.weixin = value.name;
  72. } else if (that.data.currentTab == 2) {//支付宝
  73. value.extract_type = 'alipay';
  74. if (value.name.length == 0) return app.Tips({title:'请填写账号'});
  75. value.alipay_code = value.name;
  76. }
  77. if (value.money.length == 0) return app.Tips({title:'请填写提现金额'});
  78. if (value.money < that.data.minPrice) return app.Tips({title:'提现金额不能低于' + that.data.minPrice});
  79. app.basePost(app.U({ c: 'user_api', a: 'user_extract'}),value,function (res) {
  80. that.getUserInfo();
  81. return app.Tips({title:res.msg,icon:'success'});
  82. },function(res){
  83. return app.Tips({title:res.msg});
  84. });
  85. },
  86. /**
  87. * 生命周期函数--监听页面初次渲染完成
  88. */
  89. onReady: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. if(app.globalData.isLog && this.data.isClone){
  96. this.getUserInfo();
  97. this.getUserExtractBank();
  98. }
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. this.setData({isClone:true});
  105. },
  106. /**
  107. * 生命周期函数--监听页面卸载
  108. */
  109. onUnload: function () {
  110. },
  111. /**
  112. * 页面相关事件处理函数--监听用户下拉动作
  113. */
  114. onPullDownRefresh: function () {
  115. },
  116. /**
  117. * 页面上拉触底事件的处理函数
  118. */
  119. onReachBottom: function () {
  120. },
  121. /**
  122. * 用户点击右上角分享
  123. */
  124. onShareAppMessage: function () {
  125. }
  126. })