cash.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. var app = getApp();
  2. // pages/cash/cash.js
  3. Page({
  4. data: {
  5. ooo:'',
  6. _num:0,
  7. url: app.globalData.urlImages,
  8. hiddentap: true,
  9. hidde: true,
  10. minmoney:'',
  11. money:'',
  12. index:0,
  13. array:["请选择银行","招商银行","建设银行","农业银行"]
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad:function (opends) {
  19. app.setBarColor();
  20. var money = opends.money;
  21. var that = this;
  22. that.setData({
  23. money: money
  24. })
  25. this.getUserExtractBank();
  26. wx.request({
  27. url: app.globalData.url + '/routine/auth_api/minmoney?uid=' + app.globalData.uid,
  28. method: 'POST',
  29. success: function (res) {
  30. that.setData({
  31. minmoney: res.data.msg
  32. })
  33. }
  34. })
  35. },
  36. getUserExtractBank:function () {
  37. var that = this;
  38. wx.request({
  39. url: app.globalData.url + '/routine/auth_api/get_user_extract_bank?uid=' + app.globalData.uid,
  40. method: 'get',
  41. success: function (res) {
  42. that.setData({
  43. array: res.data.data
  44. });
  45. }
  46. });
  47. },
  48. cardtap:function(e){
  49. var flag = this.data.hiddentap;
  50. if (flag){
  51. this.setData({
  52. hiddentap: false
  53. })
  54. }else{
  55. this.setData({
  56. hiddentap: true
  57. })
  58. }
  59. },
  60. idnumtap: function (e) {
  61. this.setData({
  62. _num: e.target.dataset.idnum,
  63. hiddentap: true
  64. })
  65. if (e.target.dataset.idnum==1){
  66. this.setData({
  67. hidde: false
  68. })
  69. }else{
  70. this.setData({
  71. hidde: true
  72. })
  73. }
  74. },
  75. maskhide:function(e){
  76. this.setData({
  77. hiddentap: true
  78. })
  79. },
  80. bindPickerChange:function(e){
  81. this.setData({
  82. index: e.detail.value
  83. })
  84. },
  85. formSubmit:function(e){
  86. var header = {
  87. // 'content-type': 'application/x-www-form-urlencoded',
  88. 'cookie': app.globalData.sessionId//读取cookie
  89. };
  90. var that = this;
  91. var flag = true;
  92. var warn = "";
  93. var minmon = that.data.minmoney;
  94. var mymoney = that.data.money;
  95. var list={};
  96. if (that.data.hidde==true){
  97. list.$name = e.detail.value.name;
  98. list.cardnum = e.detail.value.cardnum;
  99. list.bankname = that.data.array[that.data.index];
  100. list.money = e.detail.value.money;
  101. list.money = Number(list.money);
  102. list.extract_type = 'bank';
  103. if (list.$name == "") {
  104. warn = "请填写持卡人姓名";
  105. } else if (list.cardnum == "") {
  106. warn = "请输入银行卡号";
  107. } else if (list.bankname == "请选择银行") {
  108. warn = "请选择银行";
  109. } else if (list.money < minmon) {
  110. warn = "请输入正确的金额"
  111. } else if (list.money > mymoney) {
  112. warn = "您的余额不足"
  113. }else {
  114. flag = false;
  115. }
  116. if (flag == true) {
  117. wx.showModal({
  118. title: '提示',
  119. content: warn
  120. })
  121. }
  122. } else {
  123. list.weixin = e.detail.value.weixin;
  124. list.money = e.detail.value.wmoney;
  125. list.money = Number(list.money);
  126. list.extract_type = 'weixin';
  127. if (list.weixin == "") {
  128. warn = "请填写微信号";
  129. } else if (list.money < minmon) {
  130. warn = "请输入正确的金额"
  131. } else if (list.money > mymoney) {
  132. warn = "您的余额不足"
  133. } else {
  134. flag = false;
  135. }
  136. if (flag == true) {
  137. wx.showModal({
  138. title: '提示',
  139. content: warn
  140. })
  141. }
  142. }
  143. wx.request({
  144. url: app.globalData.url + '/routine/auth_api/user_extract?uid=' + app.globalData.uid,
  145. data: { lists: list},
  146. method: 'POST',
  147. header: header,
  148. success: function (res) {
  149. // console.log(res);
  150. wx.showToast({
  151. title: res.data.msg,
  152. icon: 'success',
  153. duration: 1500
  154. })
  155. // that.setData({
  156. // mainArray: res.data.data
  157. // })
  158. }
  159. })
  160. }
  161. })