index.js 3.2 KB

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