wallet-withdraw.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="author" content=""/>
  6. <meta name="description" content=""/>
  7. <meta name="keywords" content="扫码支付,线上投币,运营数据,物联网"/>
  8. <meta name="format-detection" content="telephone=no,email=no"/>
  9. <meta name="viewport"
  10. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  11. <meta http-equiv="pragma" content="no-cache">
  12. <meta http-equiv="cache-control" content="no-cache">
  13. <meta http-equiv="expires" content="0">
  14. <title>提现</title>
  15. <link rel="stylesheet" href="/components/lib/mui.min.css"/>
  16. <link rel="stylesheet" href="/components/custom/css/common.css"/>
  17. <link rel="stylesheet" href="/app/css/xyf.common.min.css">
  18. <style>
  19. </style>
  20. </head>
  21. <body class="wallet-withdraw-page">
  22. <h5 class="padding-10 margin-0 " onclick="help()"><span class="help-title">小提示:提现到微信可快速到账</span> <i
  23. class="iconfont icon-help-info mui-pull-right"></i></h5>
  24. <div class="mui-input-group wallet-withdraw">
  25. <div class="mui-input-row autoheight">
  26. <p class="outway mui-navigate-right padding-l-r-15" id="payType" onclick="showPayType()"></p>
  27. </div>
  28. <div class="mui-input-row padding-l-r-15 autoheight">
  29. <p class="outmoney"><span class="amountUnit">&yen;</span>
  30. <input type="number" class="" id="amount" maxlength="12" placeholder="" autocomplete="off"
  31. autocapitalize="off"
  32. autocorrect="off" spellcheck="false"
  33. onkeypress="return myNumberic(event)">
  34. </p>
  35. <div class="amount-all c-blue" onclick="allAmount()">全部</div>
  36. </div>
  37. <div class="mui-input-row" onclick="actualPayTip()">
  38. <p class="font-13 padding-l-r-15" style="width: 100% !important;">
  39. 实际到账 <span id="actualPay">&yen;0.00</span>
  40. <i class="c-blue mui-pull-right font-14">查看原因</i>
  41. </p>
  42. </div>
  43. </div>
  44. <div class="mui-input-group wallet-withdraw custom-top">
  45. <div class="mui-input-row">
  46. <p class="padding-l-r-15">验证手机
  47. <i class="mui-pull-right font-b-16" id="phone"></i>
  48. </p>
  49. </div>
  50. <div class="input-row code input-clear">
  51. <input id="code" type="tel" maxlength="4" placeholder="验证码">
  52. <button id="sendBtn" type="button" onclick="sendCode()">获取验证码</button>
  53. </div>
  54. </div>
  55. <div class="custom-subt">
  56. <input class="mui-btn-block disabled" type="button" id="withDrawBtn" value="提现">
  57. </div>
  58. <!-- help tips -->
  59. <div class="help-tip mui-hidden">
  60. <div class="help-card autoheight">
  61. <div class="help-bd">
  62. <h4>温馨提示</h4>
  63. <ol>
  64. <li>支付平台单笔交易服务费<span class="withdrawFeeRatio c-red">6</span> ‰;</li>
  65. <li>转账到银行卡到账需要1-3个工作日,请耐心等待;<span class="bankFeeText"></span></li>
  66. <li>转账最低金额为10元;单笔转账限额和单日转账限额由支付平台配置决定,默认单笔5000元,每日最高限额20,000元;</li>
  67. </ol>
  68. </div>
  69. <div class="help-close">我知道了</div>
  70. </div>
  71. </div>
  72. <div id="payTypeMenu" class="mui-popover mui-popover-action mui-popover-bottom">
  73. <ul class="mui-table-view">
  74. </ul>
  75. </div>
  76. <script src="/components/lib/jquery.min.js"></script>
  77. <script src="/components/lib/mui.min.js"></script>
  78. <script src="/components/custom/js/common.js"></script>
  79. <script src="/components/custom/js/iconfont.js"></script>
  80. <script src="/app/js/xyf.common.js"></script>
  81. <script>
  82. var sourceType = getQueryString("sourceType");
  83. var sourceId = getQueryString("sourceId");
  84. var openId = getQueryString("openId")
  85. var payBankTransFee = false;// 提现到银行卡需要收取转账手续费
  86. // 所有可用余额
  87. function allAmount() {
  88. $("#amount").val(balance).trigger("input")
  89. }
  90. // 实际到账说明
  91. function actualPayTip() {
  92. var amount = $("#amount").val();
  93. var feeRatio = withdrawFeeRatio;
  94. if (sourceType === 'withdraw') {
  95. feeRatio = 0;
  96. }
  97. var preName = '';
  98. if (feeRatio > 6) {
  99. preName = '代理商收取'
  100. } else {
  101. preName = '微信收取'
  102. }
  103. var text = preName + "¥" + parseFloat(amount * (feeRatio / 1000)).toFixed(2) + ' (' + (feeRatio / 10).toFixed(2) + "%) 手续费";
  104. if (payBankTransFee && nowPayType === 'bank') {
  105. var fee = 0
  106. if (amount > 0) {
  107. fee = parseFloat(amount * (1 / 1000))
  108. if (fee <= 0.1) {
  109. fee = 0.1
  110. }
  111. if (fee >= 25) {
  112. fee = 25
  113. }
  114. }
  115. text = preName + "¥" + parseFloat(amount * (feeRatio / 1000) + fee).toFixed(2) + ',包含:支付平台单笔交易服务费率' + (feeRatio / 10).toFixed(2) +
  116. '% + 转账到银行卡交易费率' + (1 / 10).toFixed(2) + "%。"
  117. }
  118. mui.alert(text, '手续费说明')
  119. }
  120. var nowPayType = 'wechat';
  121. var nowPayName = null;
  122. var nowPayId = null;
  123. // 选择提现方式
  124. function changePayType(type, name, id) {
  125. var html = $(event.target).closest('.mui-table-view-cell').html();
  126. $("#payType").html(html).find('.pull-right').remove();
  127. mui('#payTypeMenu').popover('toggle');
  128. // 当前选中的数据
  129. nowPayType = type
  130. nowPayName = name
  131. nowPayId = id
  132. if (type === 'wechat') {
  133. $('.help-title').text('小提示:提现到微信可快速到账').parent().removeClass('top-tip-style')
  134. } else if (type === 'alipay') {
  135. } else {
  136. $('.help-title').text('小提示:提现到银行一般需要1-3个工作日').parent().addClass('top-tip-style')
  137. }
  138. }
  139. // 展示可用提现方式
  140. function showPayType() {
  141. mui('#payTypeMenu').popover('toggle');
  142. }
  143. // 没有银行卡的情况去添加银行卡
  144. function goAddCard() {
  145. var url = "wallet-bank.html";
  146. goPage(url);
  147. }
  148. // 去绑定支付宝
  149. function goBindAlipay() {
  150. goPage("./wallet-bind-alipay.html", {realName: supportAlipay.realName, loginId: supportAlipay.loginId})
  151. }
  152. //help
  153. function help() {
  154. $('.help-tip').removeClass('mui-hidden');
  155. $('body').on('touchmove', function (e) {
  156. e.preventDefault();
  157. })
  158. $(".help-close").tap(function () {
  159. $('.help-tip').addClass('mui-hidden');
  160. $('body').off('touchmove');
  161. return false;
  162. });
  163. }
  164. var sendBtn = document.getElementById('sendBtn');
  165. function sendCode() {
  166. $('.help-title').text('小提示:验证码的获取次数一天不能超过10次').parent().addClass('top-tip-style')
  167. var url = "/agent/getWithdrawCode";
  168. var data = {};
  169. var t = 60;
  170. sendBtn.innerHTML = t + " s";
  171. sendBtn.disabled = true;
  172. sendRequest(url, "GET", data, function (res) {
  173. if (res.result == 1) {
  174. mui.toast("发送成功 <br>小提示:验证码的获取次数一天不能超过10次");
  175. var interval = setInterval(function () {
  176. if (t == 0) {
  177. sendBtn.innerHTML = "重新获取";
  178. sendBtn.disabled = false;
  179. clearInterval(interval);
  180. } else {
  181. t -= 1;
  182. sendBtn.innerHTML = t + " s";
  183. sendBtn.disabled = true;
  184. }
  185. }, 1000);
  186. } else {
  187. mui.toast(res.description);
  188. }
  189. });
  190. }
  191. var balance = 0;
  192. var withdrawFeeRatio = 6;
  193. var support = {};
  194. var supportAlipay = {};
  195. $(function () {
  196. var url = "/agent/getWalletWithdrawInfo";
  197. sendRequest(url, "GET", {sourceType: sourceType, sourceId: sourceId}, function (res) {
  198. if (res.result == 1) {
  199. var payload = res.payload
  200. support = payload.support || {}
  201. supportAlipay = support.alipay || {}
  202. $("#amount").attr('placeholder', "余额" + payload.balance);
  203. balance = payload.balance
  204. payBankTransFee = payload.payBankTransFee;
  205. withdrawFeeRatio = payload.withdrawFeeRatio;
  206. if (withdrawFeeRatio > 6) {
  207. $(".serviceFeeName").text('代理商收取')
  208. } else {
  209. $(".serviceFeeName").text('微信收取')
  210. }
  211. $(".withdrawFeeRatio").text(withdrawFeeRatio);
  212. //把注册的手机号码展示给用户
  213. var phone = payload.phone;
  214. $("#phone").text(phone);
  215. var payTypeMenu = $('#payTypeMenu .mui-table-view')
  216. var wechatText = '<i class="iconfont icon-wechat c-wechat"></i> <span>微信</span>'
  217. //默认是微信提现
  218. $("#payType").html(wechatText)
  219. var hasWe = support.wechat && support.wechat.realName
  220. var weInfo = hasWe ? ('<span class="font-b-12-8 pull-right padding-r-10">' + support.wechat.realName) : ''
  221. var wechatDom = '<li class="mui-table-view-cell" onclick="changePayType(\'wechat\')">' + wechatText + weInfo + '</li>';
  222. payTypeMenu.append(wechatDom);
  223. // ---------如果支持支付宝,则显示支付宝--------------
  224. if (support.alipay && support.alipay.support) {
  225. var ali = support.alipay
  226. var has = ali.realName && ali.loginId
  227. var fun = has ? "changePayType(\'alipay\')" : "goBindAlipay()";
  228. var dom = '<li class="mui-table-view-cell" onclick="' + fun + '"><i class="iconfont icon-alipay c-alipay"></i> <span>支付宝</span> ' +
  229. ('<div class="pull-right padding-r-10 font-b-12-8 mui-navigate-right">' + (has ? (ali.loginId + ' (' + ali.realName + ')') : '') + ' <span class="font-b-8 c-blue" onclick="goBindAlipay()">' + (has ? '去修改' : '去配置') + '</span></div>') +
  230. '</li>';
  231. payTypeMenu.append(dom);
  232. }
  233. var cardDom = '';
  234. if (payload.bankAccount) {
  235. var bankStyle = findBankStyle(payload.bankName);
  236. var iconName = bankStyle.icon;
  237. cardDom = $('<li class="mui-table-view-cell" onclick="changePayType(\'bank\',\'' + payload.bankName + '\',\'' + payload.bankAccount + '\')">' +
  238. '<svg class="" aria-hidden="true"><use xlink:href="#' + iconName + '"></use></svg> <span>' + payload.bankName + "(" + payload.bankAccount.substr(-4) + ")</span>" +
  239. '</li>')
  240. } else {
  241. cardDom = $('<li class="mui-table-view-cell " onclick="goAddCard()">' +
  242. "<div class='mui-navigate-right '><i class='iconfont icon-bank-card c-blue'></i> <span>添加银行卡</span></div>" +
  243. '</li>')
  244. }
  245. if (payBankTransFee) {
  246. $('.bankFeeText').text('转账到银行卡,微信额外收取0.1%手续费,最低0.1元,最高25元。')
  247. }
  248. payTypeMenu.append(cardDom);
  249. } else {
  250. mui.toast(res.description);
  251. }
  252. });
  253. $("#amount").on('input', function () {
  254. var amount = $("#amount").val();
  255. if (amount === '') {
  256. $("#withDrawBtn").addClass('disabled').attr('disabled', true);
  257. $("#amount").removeClass('active')
  258. } else {
  259. $("#withDrawBtn").removeClass('disabled').attr('disabled', false);
  260. $("#amount").addClass('active')
  261. }
  262. computeFee()
  263. });
  264. var submitFlag = false;
  265. $("#withDrawBtn").click(function () {
  266. if (!nowPayType) {
  267. mui.toast("请选择要提现的账户");
  268. return;
  269. }
  270. if ($("#amount").val() < 10) {
  271. mui.toast("最低提现金额10元");
  272. return;
  273. }
  274. if ($("#amount").val() > 20000) {
  275. mui.toast("最高提现金额2万元");
  276. return;
  277. }
  278. var code = $("#code").val();
  279. //检查验证码
  280. var codeReg = /^\d{4}$/;
  281. if (!codeReg.test(code)) {
  282. mui.toast("请输入正确的验证码");
  283. return;
  284. }
  285. if (!submitFlag) {
  286. showLoading('提现中...');
  287. submitFlag = true;
  288. var data = {
  289. code: code,
  290. sourceType: sourceType,
  291. sourceId: sourceId,
  292. openId: openId,
  293. payType: nowPayType,
  294. amount: parseFloat($("#amount").val()).toFixed(2),
  295. bankName: nowPayName,
  296. bankAccount: nowPayId
  297. };
  298. var url = "/agent/withdraw";
  299. sendRequest(url, "POST", data, function (res) {
  300. hideLoading();
  301. if (res.result == 1) {
  302. var url = "wallet-transactions-details.html?back=2&paymentId=" + res.para.paymentId;
  303. goPage(url);
  304. }
  305. else if (res.result == 2) {
  306. submitFlag = false;
  307. mui.confirm('您的姓名和微信实名认证不匹配,是否去修改?', '温馨提示', ['取消', '确认'], function (e) {
  308. if (e.index == 1) {
  309. var url = "new-info.html";
  310. goPage(url);
  311. }
  312. });
  313. }
  314. else if (res.result == 3) {
  315. // 余额不足?
  316. submitFlag = false;
  317. mui.toast(res.description || '余额不足');
  318. }
  319. else if (res.result == 4) {
  320. submitFlag = false;
  321. mui.alert("您的微信尚未实名认证,请去微信绑定银行卡或身份证完成实名认证", '温馨提示', '确定');
  322. } else {
  323. submitFlag = false;
  324. mui.toast(res.description);
  325. }
  326. }, "json");
  327. }
  328. });
  329. });
  330. function computeFee() {
  331. var amount = $("#amount").val();
  332. if (amount < 10) {
  333. return
  334. }
  335. var feeRatio = withdrawFeeRatio;
  336. if (sourceType === 'withdraw') {
  337. feeRatio = 0;
  338. }
  339. var actualPay = parseFloat(amount - amount * (feeRatio / 1000)).toFixed(2)
  340. if (payBankTransFee && nowPayType === 'bank') {
  341. var fee = 0
  342. if (amount > 0) {
  343. fee = parseFloat(amount * (1 / 1000))
  344. if (fee <= 0.1) {
  345. fee = 0.1
  346. }
  347. if (fee >= 25) {
  348. fee = 25
  349. }
  350. }
  351. actualPay = parseFloat(amount - amount * (feeRatio / 1000) - fee).toFixed(2)
  352. }
  353. $("#actualPay").html("&yen;&nbsp;" + actualPay);
  354. }
  355. </script>
  356. </body>
  357. </html>