applyextract.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // pages/mine/mydc/applyextract/applyextract.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. amount: '',
  9. extractAmount: '',
  10. wv_account_bank: '',
  11. wv_account_number: '',
  12. wv_account_number_short: '',
  13. wv_account_name: '',
  14. loading: false
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function(options) {
  20. var that = this
  21. this.setData({
  22. amount: options.amount
  23. })
  24. wx.request({
  25. url: app.globalData.url + '/checkDcIntroducers',
  26. method: 'get',
  27. data: {
  28. wv_phone: app.globalData.userphone
  29. },
  30. success: function(res) {
  31. that.setData({
  32. wv_account_bank: res.data.wv_account_bank,
  33. wv_account_number_short: res.data.wv_account_number,
  34. wv_account_number: res.data.wv_account_number,
  35. wv_account_name: res.data.wv_account_name
  36. })
  37. },
  38. fail() {
  39. app.timeOut()
  40. }
  41. })
  42. let _this = this;
  43. _this.setData({
  44. navH: app.globalData.navHeight
  45. })
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady: function() {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow: function() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面隐藏
  59. */
  60. onHide: function() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面卸载
  64. */
  65. onUnload: function() {
  66. },
  67. /**
  68. * 页面相关事件处理函数--监听用户下拉动作
  69. */
  70. onPullDownRefresh: function() {
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom: function() {
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage: function() {
  81. },
  82. AmountInput: function(e) {
  83. this.setData({
  84. extractAmount: e.detail.value
  85. })
  86. },
  87. getAll: function() {
  88. this.setData({
  89. extractAmount: Number(this.data.amount).toFixed(2)
  90. })
  91. },
  92. applyExtract: function() {
  93. var that = this
  94. var re = /^\d{0,8}\.{0,1}(\d{1,2})?$/;
  95. if (!re.test(this.data.extractAmount)) {
  96. wx.showToast({
  97. title: '金额输入错误!',
  98. icon: 'none',
  99. duration: 1500
  100. })
  101. that.setData({
  102. extractAmount: ''
  103. })
  104. } else if (Number(this.data.extractAmount) > Number(this.data.amount) || Number(this.data.extractAmount) <= 1) {
  105. wx.showToast({
  106. title: '提现金额不能超过奖励金额,并且不能为0!',
  107. icon: 'none',
  108. duration: 2000
  109. })
  110. that.setData({
  111. extractAmount: ''
  112. })
  113. } else {
  114. this.setData({
  115. loading: true
  116. })
  117. wx.showLoading({
  118. title: '保存中......',
  119. icon: 'loading',
  120. duration: 5500
  121. })
  122. wx.request({
  123. url: app.globalData.url + '/insertDcIntroducerExtract',
  124. method: 'post',
  125. header: {
  126. "Content-Type": "application/x-www-form-urlencoded"
  127. },
  128. data: {
  129. wue_phone: app.globalData.userphone,
  130. wue_account_name: this.data.wv_account_name,
  131. wue_bank_card: this.data.wv_account_number,
  132. wue_type: 1,
  133. wue_applysum: this.data.extractAmount
  134. },
  135. success: function(res) {
  136. that.setData({
  137. loading: false
  138. })
  139. if (res.data == 1) {
  140. wx.hideLoading()
  141. that.setData({
  142. loading: false
  143. })
  144. //发送消息
  145. wx.showToast({
  146. title: '成功!',
  147. icon: 'success',
  148. duration: 2000
  149. })
  150. // 发送消息
  151. wx.request({
  152. url: app.globalData.url + '/WXSendExtractMessage',
  153. method: 'get',
  154. data: {
  155. wue_applysum: that.data.extractAmount,
  156. wue_phone: app.globalData.userphone,
  157. wue_bank_card: that.data.wv_account_number,
  158. wue_account_name: that.data.wv_account_name,
  159. }
  160. })
  161. //减掉金额
  162. that.setData({
  163. amount: that.data.amount - that.data.extractAmount,
  164. extractAmount: ''
  165. })
  166. } else {
  167. wx.hideLoading()
  168. that.setData({
  169. loading: false
  170. })
  171. wx.showToast({
  172. title: '保存失败,请联系相关人员!',
  173. icon: 'none',
  174. duration: 2000
  175. })
  176. }
  177. },
  178. fail() {
  179. app.timeOut()
  180. }
  181. })
  182. }
  183. }
  184. })