index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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' },function(){
  83. wx.redirectTo({
  84. url: '/pages/my_wallet/index'
  85. })
  86. });
  87. }).catch(err=>{
  88. return app.Tips({ title: err });
  89. });
  90. },
  91. /**
  92. * 生命周期函数--监听页面初次渲染完成
  93. */
  94. onReady: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面显示
  98. */
  99. onShow: function () {
  100. if(app.globalData.isLog && this.data.isClone){
  101. this.getUserInfo();
  102. this.getUserExtractBank();
  103. }
  104. },
  105. /**
  106. * 生命周期函数--监听页面隐藏
  107. */
  108. onHide: function () {
  109. this.setData({isClone:true});
  110. },
  111. /**
  112. * 生命周期函数--监听页面卸载
  113. */
  114. onUnload: function () {
  115. },
  116. /**
  117. * 页面相关事件处理函数--监听用户下拉动作
  118. */
  119. onPullDownRefresh: function () {
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom: function () {
  125. },
  126. /**
  127. * 用户点击右上角分享
  128. */
  129. onShareAppMessage: function () {
  130. }
  131. })