wallet-withdraw.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. (function () {
  83. //ios返回刷新
  84. var isPageHide = false;
  85. window.addEventListener('pageshow', function () {
  86. if (isPageHide) {
  87. window.location.reload();
  88. }
  89. });
  90. window.addEventListener('pagehide', function () {
  91. isPageHide = true;
  92. });
  93. })();
  94. var sourceType = getQueryString("sourceType");
  95. var sourceId = getQueryString("sourceId");
  96. var openId = getQueryString("openId")
  97. var payBankTransFee = false;// 提现到银行卡需要收取转账手续费
  98. // 所有可用余额
  99. function allAmount() {
  100. $("#amount").val(balance).trigger("input")
  101. }
  102. // 实际到账说明
  103. function actualPayTip() {
  104. var amount = $("#amount").val();
  105. var feeRatio = withdrawFeeRatio;
  106. if (sourceType === 'withdraw') {
  107. feeRatio = 0;
  108. }
  109. var preName = '';
  110. if (feeRatio > 6) {
  111. preName = '代理商收取'
  112. } else {
  113. preName = '微信收取'
  114. }
  115. var text = preName + "¥" + parseFloat(amount * (feeRatio / 1000)).toFixed(2) + ' (' + (feeRatio / 10).toFixed(2) + "%) 手续费";
  116. if (payBankTransFee && nowPayType === 'bank') {
  117. var fee = 0
  118. if (amount > 0) {
  119. fee = parseFloat(amount * (1 / 1000))
  120. if (fee <= 0.1) {
  121. fee = 0.1
  122. }
  123. if (fee >= 25) {
  124. fee = 25
  125. }
  126. }
  127. text = preName + "¥" + parseFloat(amount * (feeRatio / 1000) + fee).toFixed(2) + ',包含:支付平台单笔交易服务费率' + (feeRatio / 10).toFixed(2) +
  128. '% + 转账到银行卡交易费率' + (1 / 10).toFixed(2) + "%。"
  129. }
  130. mui.alert(text, '手续费说明')
  131. }
  132. var nowPayType = 'wechat';
  133. var nowPayName = null;
  134. var nowPayId = null;
  135. // 选择提现方式
  136. function changePayType(type, name, id) {
  137. var html = $(event.target).closest('.mui-table-view-cell').html();
  138. $("#payType").html(html).find('.pull-right').remove();
  139. mui('#payTypeMenu').popover('toggle');
  140. // 当前选中的数据
  141. nowPayType = type
  142. nowPayName = name
  143. nowPayId = id
  144. if (type === 'wechat') {
  145. $('.help-title').text('小提示:提现到微信可快速到账').parent().removeClass('top-tip-style')
  146. } else if (type === 'alipay') {
  147. } else {
  148. $('.help-title').text('小提示:提现到银行一般需要1-3个工作日').parent().addClass('top-tip-style')
  149. }
  150. }
  151. // 展示可用提现方式
  152. function showPayType() {
  153. mui('#payTypeMenu').popover('toggle');
  154. }
  155. // 没有银行卡的情况去添加银行卡
  156. function goAddCard() {
  157. var url = "/agent/index.html?#/wallet/banks";
  158. goPage(url);
  159. }
  160. // 去绑定支付宝
  161. function goBindAlipay() {
  162. goPage("./wallet-bind-alipay.html", {realName: supportAlipay.realName, loginId: supportAlipay.loginId})
  163. }
  164. //help
  165. function help() {
  166. $('.help-tip').removeClass('mui-hidden');
  167. $('body').on('touchmove', function (e) {
  168. e.preventDefault();
  169. })
  170. $(".help-close").tap(function () {
  171. $('.help-tip').addClass('mui-hidden');
  172. $('body').off('touchmove');
  173. return false;
  174. });
  175. }
  176. var sendBtn = document.getElementById('sendBtn');
  177. function sendCode() {
  178. $('.help-title').text('小提示:验证码的获取次数一天不能超过10次').parent().addClass('top-tip-style')
  179. var url = "/agent/getWithdrawCode";
  180. var data = {};
  181. var t = 60;
  182. sendBtn.innerHTML = t + " s";
  183. sendBtn.disabled = true;
  184. sendRequest(url, "GET", data, function (res) {
  185. if (res.result == 1) {
  186. mui.toast("发送成功 <br>小提示:验证码的获取次数一天不能超过10次");
  187. var interval = setInterval(function () {
  188. if (t == 0) {
  189. sendBtn.innerHTML = "重新获取";
  190. sendBtn.disabled = false;
  191. clearInterval(interval);
  192. } else {
  193. t -= 1;
  194. sendBtn.innerHTML = t + " s";
  195. sendBtn.disabled = true;
  196. }
  197. }, 1000);
  198. } else {
  199. mui.toast(res.description);
  200. }
  201. });
  202. }
  203. var balance = 0;
  204. var withdrawFeeRatio = 6;
  205. var support = {};
  206. var supportAlipay = {};
  207. $(function () {
  208. var url = "/agent/getWalletWithdrawInfo";
  209. sendRequest(url, "GET", {sourceType: sourceType, sourceId: sourceId}, function (res) {
  210. if (res.result == 1) {
  211. var payload = res.payload
  212. support = payload.support || {}
  213. supportAlipay = support.alipay || {}
  214. $("#amount").attr('placeholder', "余额" + payload.balance);
  215. balance = payload.balance
  216. withdrawFeeRatio = payload.withdrawFeeRatio;
  217. if (withdrawFeeRatio > 6) {
  218. $(".serviceFeeName").text('代理商收取')
  219. } else {
  220. $(".serviceFeeName").text('微信收取')
  221. }
  222. $(".withdrawFeeRatio").text(withdrawFeeRatio);
  223. //把注册的手机号码展示给用户
  224. var phone = payload.phone;
  225. $("#phone").text(phone);
  226. var payTypeMenu = $('#payTypeMenu .mui-table-view')
  227. var wechatText = '<i class="iconfont icon-wechat c-wechat"></i> <span>微信</span>'
  228. //默认是微信提现
  229. $("#payType").html(wechatText)
  230. var hasWe = support.wechat && support.wechat.realName
  231. var weInfo = hasWe ? ('<span class="font-b-12-8 pull-right padding-r-10">' + support.wechat.realName) : ''
  232. var wechatDom = '<li class="mui-table-view-cell" onclick="changePayType(\'wechat\')">' + wechatText + weInfo + '</li>';
  233. payTypeMenu.append(wechatDom);
  234. // ---------如果支持支付宝,则显示支付宝--------------
  235. if (support.alipay && support.alipay.support) {
  236. var ali = support.alipay
  237. var has = ali.realName && ali.loginId
  238. var fun = has ? "changePayType(\'alipay\')" : "goBindAlipay()";
  239. var dom = '<li class="mui-table-view-cell" onclick="' + fun + '"><i class="iconfont icon-alipay c-alipay"></i> <span>支付宝</span> ' +
  240. ('<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>') +
  241. '</li>';
  242. payTypeMenu.append(dom);
  243. }
  244. if (support.bank && support.bank.support) {
  245. payBankTransFee = support.bank.transFee;
  246. var cardDom = '';
  247. var len = support.bank.cards.length;
  248. if (len === 0) {
  249. cardDom = ('<li class="mui-table-view-cell " onclick="goAddCard()">' +
  250. "<div class='mui-navigate-right '><i class='iconfont icon-bank-card c-blue'></i> <span>添加银行卡</span></div>" +
  251. '</li>')
  252. } else {
  253. for (var i = 0; i < len; i++) {
  254. var item = support.bank.cards[i]
  255. var bankStyle = findBankStyle(item.bankName);
  256. var iconName = bankStyle.icon;
  257. cardDom += ('<li class="mui-table-view-cell" onclick="changePayType(\'bank\',\'' + item.bankName + '\',\'' + item.accountCode + '\')">' +
  258. '<svg class="" aria-hidden="true"><use xlink:href="#' + iconName + '"></use></svg> <span>' + item.bankName + "(" + item.accountCode.substr(-4) + ")</span>" +
  259. '</li>')
  260. }
  261. }
  262. if (payBankTransFee) {
  263. $('.bankFeeText').text('转账到银行卡,微信额外收取0.1%手续费,最低0.1元,最高25元。')
  264. }
  265. payTypeMenu.append(cardDom);
  266. }
  267. } else {
  268. mui.toast(res.description);
  269. }
  270. });
  271. $("#amount").on('input', function () {
  272. var amount = $("#amount").val();
  273. if (amount === '') {
  274. $("#withDrawBtn").addClass('disabled').attr('disabled', true);
  275. $("#amount").removeClass('active')
  276. } else {
  277. $("#withDrawBtn").removeClass('disabled').attr('disabled', false);
  278. $("#amount").addClass('active')
  279. }
  280. computeFee()
  281. });
  282. var submitFlag = false;
  283. $("#withDrawBtn").click(function () {
  284. if (!nowPayType) {
  285. mui.toast("请选择要提现的账户");
  286. return;
  287. }
  288. if ($("#amount").val() < 10) {
  289. mui.toast("最低提现金额10元");
  290. return;
  291. }
  292. if ($("#amount").val() > 20000) {
  293. mui.toast("最高提现金额2万元");
  294. return;
  295. }
  296. var code = $("#code").val();
  297. //检查验证码
  298. var codeReg = /^\d{4}$/;
  299. if (!codeReg.test(code)) {
  300. mui.toast("请输入正确的验证码");
  301. return;
  302. }
  303. if (!submitFlag) {
  304. showLoading('提现中...');
  305. submitFlag = true;
  306. var data = {
  307. code: code,
  308. sourceType: sourceType,
  309. sourceId: sourceId,
  310. openId: openId,
  311. payType: nowPayType,
  312. amount: parseFloat($("#amount").val()).toFixed(2),
  313. bankName: nowPayName,
  314. bankAccount: nowPayId
  315. };
  316. var url = "/agent/withdraw";
  317. sendRequest(url, "POST", data, function (res) {
  318. hideLoading();
  319. if (res.result == 1) {
  320. var url = "wallet-transactions-details.html?back=2&paymentId=" + res.para.paymentId;
  321. goPage(url);
  322. }
  323. else if (res.result == 2) {
  324. submitFlag = false;
  325. mui.confirm('您的姓名和微信实名认证不匹配,是否去修改?', '温馨提示', ['取消', '确认'], function (e) {
  326. if (e.index == 1) {
  327. var url = "new-info.html";
  328. goPage(url);
  329. }
  330. });
  331. }
  332. else if (res.result == 3) {
  333. // 余额不足?
  334. submitFlag = false;
  335. mui.toast(res.description || '余额不足');
  336. }
  337. else if (res.result == 4) {
  338. submitFlag = false;
  339. mui.alert("您的微信尚未实名认证,请去微信绑定银行卡或身份证完成实名认证", '温馨提示', '确定');
  340. } else {
  341. submitFlag = false;
  342. mui.toast(res.description);
  343. }
  344. }, "json");
  345. }
  346. });
  347. });
  348. function computeFee() {
  349. var amount = $("#amount").val();
  350. if (amount < 10) {
  351. return
  352. }
  353. var feeRatio = withdrawFeeRatio;
  354. if (sourceType === 'withdraw') {
  355. feeRatio = 0;
  356. }
  357. var actualPay = parseFloat(amount - amount * (feeRatio / 1000)).toFixed(2)
  358. if (payBankTransFee && nowPayType === 'bank') {
  359. var fee = 0
  360. if (amount > 0) {
  361. fee = parseFloat(amount * (1 / 1000))
  362. if (fee <= 0.1) {
  363. fee = 0.1
  364. }
  365. if (fee >= 25) {
  366. fee = 25
  367. }
  368. }
  369. actualPay = parseFloat(amount - amount * (feeRatio / 1000) - fee).toFixed(2)
  370. }
  371. $("#actualPay").html("&yen;&nbsp;" + actualPay);
  372. }
  373. </script>
  374. </body>
  375. </html>