editInfo.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // lionfish_comshop/pages/groupCenter/editInfo.js
  2. var timeFormat = require("../../utils/timeFormat");
  3. var app = getApp();
  4. var util = require('../../utils/util.js');
  5. var WxParse = require('../../wxParse/wxParse.js');
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. tixian_money: '',
  12. final_money: 0,
  13. sxfee: 0,
  14. type: 1,
  15. items: [
  16. { name: '1', value: '余额', show: true, checked: 'true' },
  17. { name: '2', value: '微信零钱', show: true },
  18. { name: '3', value: '支付宝', show: true },
  19. { name: '4', value: '银行卡', show: true }
  20. ]
  21. },
  22. canTixian: true,
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function(options) {
  27. var token = wx.getStorageSync('token');
  28. var that = this;
  29. app.util.request({
  30. url: 'entry/wxapp/user',
  31. data: {
  32. controller: 'community.get_community_info',
  33. token: token
  34. },
  35. dataType: 'json',
  36. success: function(res) {
  37. if (res.data.code == 0) {
  38. let rdata = res.data;
  39. let items = that.data.items;
  40. let community_info = rdata.community_info;
  41. if (community_info.head_commiss_tixianway_yuer == 0) items[0].show = false;
  42. if (community_info.head_commiss_tixianway_weixin == 0) items[1].show = false;
  43. if (community_info.head_commiss_tixianway_alipay == 0) items[2].show = false;
  44. if (community_info.head_commiss_tixianway_bank == 0) items[3].show = false;
  45. let head_commiss_tixian_publish = rdata.head_commiss_tixian_publish;
  46. WxParse.wxParse('article', 'html', head_commiss_tixian_publish, that, 15, app.globalData.systemInfo);
  47. that.setData({
  48. member_info: rdata.member_info,
  49. community_info: rdata.community_info,
  50. commission_info: rdata.commission_info,
  51. community_tixian_fee: rdata.community_tixian_fee,
  52. community_min_money: rdata.community_min_money,
  53. items
  54. });
  55. } else {
  56. //is_login
  57. wx.reLaunch({
  58. url: '/lionfish_comshop/pages/user/me',
  59. })
  60. }
  61. }
  62. })
  63. },
  64. bindTixianMoneyInput: function(t) {
  65. let max_val = this.data.commission_info.money;
  66. var value = t.detail.value;
  67. if (value > max_val) {
  68. wx.showToast({
  69. title: '本次最大可提现' + max_val + '元',
  70. icon: "none",
  71. })
  72. }
  73. let fee = this.data.community_tixian_fee;
  74. let final_money = (value * (100 - fee) / 100).toFixed(2);
  75. let sxfee = (value - final_money).toFixed(2);
  76. this.setData({
  77. tixian_money: value,
  78. final_money: final_money,
  79. sxfee
  80. })
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow: function() {
  86. },
  87. getAll: function() {
  88. var max_tixian_money = this.data.commission_info.money;
  89. let fee = this.data.community_tixian_fee;
  90. let final_money = (max_tixian_money * (100 - fee) / 100).toFixed(2);
  91. let sxfee = (max_tixian_money - final_money).toFixed(2);
  92. this.setData({
  93. tixian_money: max_tixian_money,
  94. final_money: final_money,
  95. sxfee
  96. })
  97. },
  98. /**
  99. * 提交
  100. */
  101. formSubmit: function(e) {
  102. const params = e.detail.value;
  103. let isNull = 0;
  104. for (let item in params) {
  105. params[item] = params[item].replace(/(^\s*)|(\s*$)/g, "");
  106. if (!params[item]) {
  107. wx.showToast({
  108. title: '请输入正确的表单内容',
  109. icon: 'none'
  110. })
  111. isNull = 1;
  112. break;
  113. }
  114. if (item == 'money' && params[item] * 1 <= 0) {
  115. wx.showToast({
  116. title: '请输入正确的金额',
  117. icon: 'none'
  118. })
  119. return;
  120. }
  121. }
  122. console.log(isNull)
  123. if (isNull == 1) return;
  124. params.type = this.data.type;
  125. console.log(params);
  126. let tdata = this.data;
  127. let tixian_money = parseFloat(tdata.tixian_money);
  128. let max_tixian_money = tdata.commission_info.money;
  129. let community_min_money = parseFloat(tdata.community_min_money);
  130. if (tixian_money == '' || community_min_money > tixian_money) {
  131. wx.showToast({
  132. title: '最小提现' + community_min_money + '元',
  133. icon: "none",
  134. })
  135. return false;
  136. }
  137. if (tixian_money > max_tixian_money) {
  138. wx.showToast({
  139. title: '本次最大可提现' + max_tixian_money + '元',
  140. icon: "none",
  141. })
  142. let fee = tdata.community_tixian_fee;
  143. let final_money = (max_tixian_money * (100 - fee) / 100).toFixed(2);
  144. let sxfee = (max_tixian_money - final_money).toFixed(2);
  145. this.setData({
  146. tixian_money: max_tixian_money,
  147. final_money: final_money,
  148. sxfee
  149. })
  150. return false;
  151. }
  152. if (!this.canTixian) return;
  153. this.canTixian = false;
  154. var token = wx.getStorageSync('token');
  155. var that = this;
  156. wx.showLoading();
  157. app.util.request({
  158. url: 'entry/wxapp/user',
  159. data: {
  160. controller: 'community.tixian_community_info',
  161. token: token,
  162. ...params
  163. },
  164. dataType: 'json',
  165. success: function (res) {
  166. that.canTixian = true;
  167. if (res.data.code == 0) {
  168. wx.showToast({
  169. title: "提现成功,等待审核",
  170. icon: "none",
  171. duration: 2000,
  172. mask: true,
  173. success: function () {
  174. wx.redirectTo({
  175. url: '/lionfish_comshop/pages/groupCenter/cashList',
  176. })
  177. }
  178. });
  179. } else {
  180. wx.showToast({
  181. title: "提现失败",
  182. icon: "none",
  183. duration: 2000,
  184. mask: true
  185. });
  186. }
  187. }
  188. })
  189. },
  190. /**
  191. * 切换类型
  192. */
  193. radioChange(e) {
  194. this.setData({ type: e.detail.value })
  195. }
  196. })