withdraw.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <!-- +---------------------------------------------------------------------- -->
  2. <!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
  3. <!-- +---------------------------------------------------------------------- -->
  4. <!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
  5. <!-- +---------------------------------------------------------------------- -->
  6. <!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
  7. <!-- +---------------------------------------------------------------------- -->
  8. <!-- | Author: CRMEB Team <admin@crmeb.com> -->
  9. <!-- +---------------------------------------------------------------------- -->
  10. {extend name="public/container"}
  11. {block name="title"}提现{/block}
  12. {block name="head"}
  13. <style>
  14. body {background: #FFFFFF;}
  15. </style>
  16. {/block}
  17. {block name="content"}
  18. <div v-cloak id="app" class="withdraw">
  19. <div class="tab">
  20. <div v-for="item in tabs" :key="item.value" :class="{ on: extract_type === item.value }" class="item" @click="extract_type = item.value">
  21. <div><i :class="'iconfont ' + item.icon"></i></div>
  22. <div>{{ item.name }}</div>
  23. </div>
  24. </div>
  25. <div class="content">
  26. <label v-show="extract_type == 'bank'">
  27. <div>持卡人</div>
  28. <input v-model.trim="name" type="text" placeholder="请填写持卡人姓名">
  29. </label>
  30. <label v-show="extract_type == 'bank'">
  31. <div>卡号</div>
  32. <input v-model="cardnum" type="number" placeholder="请填写卡号">
  33. </label>
  34. <label v-show="extract_type == 'bank'">
  35. <div>银行</div>
  36. <input :value="bankname" placeholder="请选择银行" readonly @focus="invokePicker">
  37. </label>
  38. <label v-show="extract_type == 'weixin'">
  39. <div>微信号</div>
  40. <input v-model.trim="weixin" type="text" placeholder="请填写微信号">
  41. </label>
  42. <label v-show="extract_type == 'alipay'">
  43. <div>用户名</div>
  44. <input v-model.trim="name" type="text" placeholder="请填写您的支付宝用户名">
  45. </label>
  46. <label v-show="extract_type == 'alipay'">
  47. <div>账号</div>
  48. <input v-model.trim="alipay_code" type="text" placeholder="请填写您的支付宝账号">
  49. </label>
  50. <label>
  51. <div>提现</div>
  52. <input type="number" placeholder="最低提现金额{$extract_min_money}" @input="inputMoney">
  53. </label>
  54. <div class="tip">当前可提现金额: {{ brokerage_price }}</div>
  55. <div class="btn">
  56. <button type="button" @click="withdraw">提现</button>
  57. </div>
  58. </div>
  59. <div :class="{ mask: dialogShow }"></div>
  60. <div :class="{ show: dialogShow }" class="dialog">
  61. <img src="{__WAP_PATH}zsff/images/withdraw.png">
  62. <div>提现申请已提交,等待人工审核</div>
  63. <button type="button" @click="confirm">知道了</button>
  64. </div>
  65. <quick-menu></quick-menu>
  66. </div>
  67. {/block}
  68. {block name="foot"}
  69. <script>
  70. require(['vue', 'helper', 'store', 'picker', 'quick'], function (Vue, $h, store, Picker) {
  71. var extract_bank = {$extract_bank};
  72. var token = '{$token}';
  73. var tabs = [
  74. {
  75. name: '银行卡',
  76. icon: 'iconyinhangqia',
  77. value: 'bank'
  78. },
  79. {
  80. name: '支付宝',
  81. icon: 'iconicon34',
  82. value: 'alipay'
  83. },
  84. {
  85. name: '微信',
  86. icon: 'iconweixin1',
  87. value: 'weixin'
  88. },
  89. {
  90. name: '余额',
  91. icon: 'iconicon-test',
  92. value: 'yue'
  93. }
  94. ];
  95. var pickerData = extract_bank.map(function (item) {
  96. return {
  97. text: item.bank_name,
  98. value: item.id
  99. };
  100. });
  101. var search = window.location.search.slice(1);
  102. var query = {};
  103. search.split('&').forEach(function (item) {
  104. item = item.split('=');
  105. query[item[0]] = item[1];
  106. });
  107. if (query.mer_id) {
  108. for (var i = tabs.length; i--;) {
  109. if (tabs[i].value === 'yue') {
  110. tabs.splice(i, 1);
  111. break;
  112. }
  113. }
  114. }
  115. new Vue({
  116. el: '#app',
  117. data: {
  118. brokerage_price: {$brokerage_price},
  119. extract_min_money: {$extract_min_money},
  120. extract_type: 'bank',
  121. name: '',
  122. cardnum: '',
  123. bankname: '',
  124. weixin: '',
  125. alipay_code: '',
  126. money: {$extract_min_money},
  127. dialogShow: false,
  128. tabs: tabs
  129. },
  130. watch: {
  131. extract_type: function (value) {
  132. this.money = '';
  133. switch (value) {
  134. case 'bank':
  135. this.name = '';
  136. this.cardnum = '';
  137. this.bankname = '';
  138. break;
  139. case 'alipay':
  140. this.name = '';
  141. this.alipay_code = '';
  142. break;
  143. case 'weixin':
  144. this.weixin = '';
  145. break;
  146. }
  147. }
  148. },
  149. created: function () {
  150. var vm = this;
  151. this.picker = new Picker({
  152. data: [pickerData]
  153. });
  154. this.picker.on('picker.select', this.pickerSelect);
  155. },
  156. methods: {
  157. pickerSelect: function (data) {
  158. var findBank = extract_bank.find(function (item) {
  159. return item.id === data[0];
  160. });
  161. this.bankname = findBank.bank_name;
  162. },
  163. invokePicker: function (event) {
  164. if (!extract_bank.length) {
  165. event.target.blur();
  166. return $h.pushMsg('暂无可以选择的银行<br>请选择其他方式进行提现');
  167. }
  168. this.picker.show();
  169. },
  170. withdraw: function () {
  171. var vm = this;
  172. var data = {
  173. extract_type: this.extract_type
  174. };
  175. if (!this.brokerage_price) {
  176. return $h.pushMsg('当前可提现金额:<br>' + this.brokerage_price);
  177. }
  178. // 银行卡
  179. if (this.extract_type === 'bank') {
  180. if (!extract_bank.length) {
  181. return $h.pushMsg('暂无可以选择的银行<br>请选择其他方式进行提现');
  182. }
  183. if (!this.name) {
  184. return $h.pushMsg('请填写持卡人姓名');
  185. }
  186. if (!this.cardnum) {
  187. return $h.pushMsg('请填写卡号');
  188. }
  189. var xhr = new XMLHttpRequest();
  190. xhr.open('POST', '//ccdcapi.alipay.com/validateAndCacheCardInfo.json', false);
  191. xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  192. xhr.send('cardBinCheck=true&cardNo=' + this.cardnum);
  193. if (!JSON.parse(xhr.responseText).validated) {
  194. return $h.pushMsg('银行卡号错误')
  195. }
  196. if (!this.bankname) {
  197. return $h.pushMsg('请选择银行');
  198. }
  199. data.name = this.name;
  200. data.cardnum = this.cardnum;
  201. data.bankname = this.bankname;
  202. }
  203. // 支付宝
  204. if (this.extract_type === 'alipay') {
  205. if (!this.name) {
  206. return $h.pushMsg('请填写您的支付宝用户名');
  207. }
  208. if (!this.alipay_code) {
  209. return $h.pushMsg('请填写您的支付宝账号');
  210. }
  211. data.name = this.name;
  212. data.alipay_code = this.alipay_code;
  213. }
  214. // 微信
  215. if (this.extract_type === 'weixin') {
  216. if (!this.weixin) {
  217. return $h.pushMsg('请填写微信号');
  218. }
  219. data.weixin = this.weixin;
  220. }
  221. if (this.money === '') {
  222. return $h.pushMsg('请填写提现金额');
  223. }
  224. if (this.extract_min_money > this.money) {
  225. return $h.pushMsg('最低提现金额:<br>' + this.extract_min_money);
  226. }
  227. if (this.extract_min_money > this.money) {
  228. return $h.pushMsg('当前可以提现金额:<br>' + this.brokerage_price);
  229. }
  230. data.money = this.money;
  231. if (query.mer_id) {
  232. data.business = 1;
  233. }
  234. store.basePost($h.U({
  235. c: 'spread',
  236. a: 'save_withdraw',
  237. q: {
  238. token: token
  239. }
  240. }), data, function (res) {
  241. vm.dialogShow = true;
  242. }, function (err) {
  243. $h.pushMsg(err.data.msg);
  244. });
  245. },
  246. confirm: function () {
  247. this.dialogShow = false;
  248. window.location.reload();
  249. },
  250. inputMoney: function (event) {
  251. this.money = event.target.value = event.target.value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/, '$1$2$3');
  252. }
  253. }
  254. });
  255. });
  256. </script>
  257. {/block}