excharge.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. var app = getApp();
  2. Page({
  3. mixins: [require('../../mixin/commonMixin.js')],
  4. data: {
  5. type: 1,
  6. tixian_money: '',
  7. final_money: 0
  8. },
  9. canTixian: true,
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. },
  15. onShow: function () {
  16. wx.showLoading();
  17. this.getData();
  18. },
  19. getData: function () {
  20. let token = wx.getStorageSync('token');
  21. app.util.ProReq('supplymobile.supply_managemoney_panel', { token }).then(res => {
  22. let {
  23. supply_min_apply_money,
  24. supply_commiss,
  25. tixian_waylist,
  26. supply_tixian_free,
  27. supply_tixian_notice
  28. } = res.data;
  29. // 查询是否有自定义选中 没有则第一个显示的
  30. let type = 0;
  31. let tixian_waylist_keys = Object.keys(tixian_waylist);
  32. tixian_waylist_keys.forEach(item=>{
  33. if (tixian_waylist[item].is_default_check) {
  34. type = item;
  35. return
  36. }
  37. })
  38. if(type==0) {
  39. try {
  40. tixian_waylist_keys.forEach(item=>{
  41. if (tixian_waylist[item].is_show==1) {
  42. type = item;
  43. tixian_waylist[item].is_default_check = 1;
  44. throw Error();
  45. }
  46. })
  47. } catch (e) {
  48. }
  49. }
  50. this.setData({
  51. type,
  52. supply_min_apply_money,
  53. supply_commiss,
  54. tixian_waylist,
  55. supply_tixian_free,
  56. supply_tixian_notice
  57. })
  58. }).catch(err => {
  59. console.log(err)
  60. app.util.message(err.msg || '请求出错', '', 'error');
  61. })
  62. },
  63. formSubmit: function (e) {
  64. const params = e.detail.value;
  65. let isNull = 0;
  66. let { type, tixian_money, supply_commiss, supply_min_apply_money, supply_tixian_free } = this.data;
  67. let errortip = [{}, {
  68. account: '微信真实姓名'
  69. }, {
  70. bankusername: '支付宝真实姓名',
  71. account: '支付宝账户'
  72. }, {
  73. card_name: '银行卡名称',
  74. card_username: '持卡人姓名',
  75. account: '银行卡账户'
  76. }, {
  77. account: '微信真实姓名'
  78. }];
  79. for (let item in params) {
  80. params[item] = params[item].replace(/(^\s*)|(\s*$)/g, "");
  81. if (!params[item]) {
  82. const itemTip = errortip[type][item];
  83. wx.showToast({
  84. title: '请输入' + (itemTip || '正确的表单内容'),
  85. icon: 'none'
  86. })
  87. isNull = 1;
  88. break;
  89. }
  90. if (item == 'money' && params[item] * 1 <= 0) {
  91. wx.showToast({
  92. title: '请输入正确的金额',
  93. icon: 'none'
  94. })
  95. return;
  96. }
  97. }
  98. if (isNull == 1) return;
  99. params.type = type;
  100. tixian_money = parseFloat(tixian_money);
  101. let max_tixian_money = supply_commiss.money;
  102. supply_min_apply_money = parseFloat(supply_min_apply_money);
  103. if (tixian_money == '' || supply_min_apply_money > tixian_money) {
  104. wx.showToast({
  105. title: '最小提现' + supply_min_apply_money + '元',
  106. icon: "none",
  107. })
  108. return false;
  109. }
  110. if (tixian_money > max_tixian_money) {
  111. wx.showToast({
  112. title: '本次最大可提现' + max_tixian_money + '元',
  113. icon: "none",
  114. })
  115. let final_money = (max_tixian_money * (100 - supply_tixian_free) / 100).toFixed(2);
  116. this.setData({
  117. tixian_money: max_tixian_money,
  118. final_money: final_money
  119. })
  120. return false;
  121. }
  122. if (!this.canTixian) return;
  123. this.canTixian = false;
  124. wx.showLoading();
  125. var token = wx.getStorageSync('token');
  126. let that = this;
  127. let data = {
  128. supply_apply_type: params.type,
  129. account: params.account || '',
  130. card_name: params.card_name || '',
  131. card_username: params.card_username || '',
  132. ti_money: params.money,
  133. token
  134. }
  135. app.util.ProReq('supplymobile.supply_applymoney', data).then(res => {
  136. wx.showToast({
  137. title: '已提交申请',
  138. icon: 'none',
  139. success: function () {
  140. that.canTixian = true;
  141. that.setData({
  142. canPay: false,
  143. tixian_money: '',
  144. final_money: 0
  145. })
  146. that.getData();
  147. }
  148. })
  149. }).catch(err=>{
  150. that.canTixian = true;
  151. wx.showToast({
  152. title: err.msg || '提交失败,请重试',
  153. icon: 'none'
  154. })
  155. })
  156. },
  157. /**
  158. * 获得焦点
  159. */
  160. bindIptFocus: function () {
  161. this.setData({
  162. onFocus: true
  163. })
  164. },
  165. /**
  166. * 失去焦点
  167. */
  168. bindIptBlur: function () {
  169. this.setData({
  170. onFocus: false
  171. })
  172. },
  173. radioChange(e) {
  174. this.setData({
  175. type: e.detail.value
  176. })
  177. },
  178. bindTixianMoneyInput: function (t) {
  179. let max_val = this.data.supply_commiss.money;
  180. var value = t.detail.value;
  181. if (!(/^(\d?)+(\.\d{0,2})?$/.test(value))) {
  182. value = value.substring(0, value.length - 1);
  183. value = parseFloat(value);
  184. }
  185. if (value > max_val) {
  186. wx.showToast({
  187. title: '本次最大可提现' + max_val + '元',
  188. icon: "none",
  189. })
  190. }
  191. let fee = this.data.supply_tixian_free;
  192. let val = parseFloat(value) > 0 ? parseFloat(value) : 0;
  193. let final_money = (val * (100 - fee) / 100).toFixed(2);
  194. let canPay = false;
  195. value ? canPay = true : canPay = false;
  196. this.setData({
  197. tixian_money: value,
  198. final_money: final_money,
  199. canPay
  200. })
  201. return value;
  202. },
  203. getAll: function () {
  204. const tdata = this.data;
  205. var max_tixian_money = tdata.supply_commiss.money * 1;
  206. let fee = tdata.supply_tixian_free;
  207. let final_money = (max_tixian_money * (100 - fee) / 100).toFixed(2);
  208. let canPay = false;
  209. max_tixian_money ? canPay = true : canPay = false;
  210. this.setData({
  211. tixian_money: max_tixian_money,
  212. final_money: final_money,
  213. canPay
  214. })
  215. }
  216. })