cash.js 5.0 KB

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