withdraw.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <!-- 提现 -->
  2. <template>
  3. <view class="draw-money-wrap">
  4. <view class="head-box">
  5. <shopro-navbar :background="{ background: 'none' }" :backTextStyle="{ color: '#fff' }" backText="提现" backIconColor="#fff"></shopro-navbar>
  6. <!-- 可提现 -->
  7. <view class="wallet-num-box u-flex u-col-center u-row-between">
  8. <view class="">
  9. <view class="num-title">可提现金额(元)</view>
  10. <view class="wallet-num">{{ userInfo.money || '0.00' }}</view>
  11. </view>
  12. <button class="u-reset-button log-btn" @tap="$Router.push({ path: '/pages/user/wallet/withdraw-log' })">提现记录</button>
  13. </view>
  14. </view>
  15. <!-- 提现输入卡片-->
  16. <view class="draw-card">
  17. <view class="card-title">提现金额</view>
  18. <view class="input-box u-flex u-col-center">
  19. <view calss="unit">¥</view>
  20. <input class="u-flex-1 u-p-l-10" type="number" @input="onWithdrawInput" v-model="money" :placeholder-style="placeholderStyle" placeholder="请输入提现金额" />
  21. </view>
  22. <view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
  23. <view class="name">提现至</view>
  24. <view class="bank-list u-flex" @tap="showWithdrawList = true">
  25. <view class="empty-text" v-if="!withdrawType">请选择提现方式</view>
  26. <view class="sel-box u-flex u-col-center" v-else>
  27. <image class="item-img" :src="withdrawList[withdrawType].icon" mode=""></image>
  28. <view class="item-title u-m-l-20">{{ withdrawList[withdrawType].title }}</view>
  29. </view>
  30. <text class="u-iconfont uicon-arrow-right" style="#C4C4C4;"></text>
  31. </view>
  32. </view>
  33. <!-- 提现信息 -->
  34. <view class="bank-info u-m-b-80">
  35. <view class="u-flex u-row-between u-col-center" v-if="withdrawType">
  36. <block v-if="withdrawType === 'wechat'">
  37. <view class="bank-info-title">
  38. {{ !withdrawInfo ? '暂无微信授权信息' : `${withdrawInfo.bank_name || ''} [${withdrawInfo.card_no || ''}] ${withdrawInfo.real_name || ''}` }}
  39. </view>
  40. <button v-if="!withdrawInfo" class="u-reset-button bind-btn u-m-l-20" @tap="bindThirdOauth()">绑定</button>
  41. </block>
  42. <block v-else>
  43. <view class="bank-info-title">
  44. {{
  45. !withdrawInfo
  46. ? `暂无${withdrawList[withdrawType].title}信息`
  47. : `${withdrawInfo.bank_name || ''} [${withdrawInfo.card_no || ''}] ${withdrawInfo.real_name || ''}`
  48. }}
  49. </view>
  50. <button class="u-reset-button bind-btn u-m-l-20" @tap="toBind">{{ withdrawInfo ? '修改' : '添加' }}</button>
  51. </block>
  52. </view>
  53. </view>
  54. <button class="u-reset-button save-btn" @tap="withdraw">确认提现</button>
  55. </view>
  56. <!-- 提现说明 -->
  57. <view class="draw-notice">
  58. <view class="title">提现说明</view>
  59. <view class="draw-list">1.单次最低提现 {{ ruleInfo.min }} 元,最高提现 {{ ruleInfo.max }} 元;</view>
  60. <view class="draw-list">
  61. 2.每日最多可提现次数: {{ ruleInfo.perday_num ? ruleInfo.perday_num : '不限' }};每日最多提现金额(元):
  62. {{ ruleInfo.perday_amount ? ruleInfo.perday_amount : '不限' }};
  63. </view>
  64. <view class="draw-list">3.每笔收取提现手续费 {{ ruleInfo.service_fee }}%;</view>
  65. <view class="draw-list">4.提现结果请查收对应渠道服务通知;</view>
  66. <view class="draw-list">5.如有疑问请及时联系客服。</view>
  67. </view>
  68. <!-- 提现方式 -->
  69. <u-popup v-if="ruleInfo && ruleInfo.methods.length" v-model="showWithdrawList" mode="bottom" safe-area-inset-bottom :closeable="false" border-radius="30">
  70. <view class="page_box withdraw-modal">
  71. <view class="modal-head u-flex u-row-center u-col-center">选择提现方式</view>
  72. <view class="content_box modal-content">
  73. <u-radio-group v-model="selectedWithdrawType" activeColor="#A36FFF" wrap>
  74. <view class="type-item u-p-x-24 u-p-y-30" v-if="ruleInfo.methods.includes(item.value)" v-for="(item, index) in withdrawList" :key="index">
  75. <u-radio shape="circle" iconSize="30" :name="item.value" labelWidth="100%">
  76. <view class="item-left u-flex u-col-center u-m-l-30">
  77. <image class="item-img" :src="item.icon" mode=""></image>
  78. <view class="item-title u-m-l-20">{{ item.title }}</view>
  79. </view>
  80. </u-radio>
  81. </view>
  82. </u-radio-group>
  83. </view>
  84. <view class="modal-bottom"><button class="u-reset-button modal-save-btn" @tap="onSaveWithdrawType">确定</button></view>
  85. </view>
  86. </u-popup>
  87. <!-- 绑定修改银行信息 -->
  88. <u-popup v-model="showBindForm" mode="bottom" safe-area-inset-bottom @close="initForm" :closeable="false" border-radius="30">
  89. <!-- 标题 -->
  90. <view class="form-box u-p-20">
  91. <view class="head-title u-flex u-col-center u-row-center">{{ formTitle }}</view>
  92. <!-- 绑定银行卡 -->
  93. <u-form v-if="withdrawType === 'bank'" :model="form.data" :rules="form.bankRules" ref="bank" :errorType="errorType">
  94. <u-form-item :labelStyle="labelStyle" label-width="150" label-position="left" label="持卡人:" prop="real_name">
  95. <u-input placeholder="请输入持卡人" :placeholderStyle="placeholderStyle" v-model="form.data.real_name" type="text"></u-input>
  96. </u-form-item>
  97. <u-form-item :labelStyle="labelStyle" label-width="150" label-position="left" label="开户行:" prop="bank_name">
  98. <u-input placeholder="请输入开户行" :placeholderStyle="placeholderStyle" v-model="form.data.bank_name" type="text"></u-input>
  99. </u-form-item>
  100. <u-form-item :labelStyle="labelStyle" label-position="left" label="银行卡号:" prop="card_no" label-width="150">
  101. <u-input placeholder="请输入银行卡号" :placeholderStyle="placeholderStyle" v-model="form.data.card_no" type="number"></u-input>
  102. </u-form-item>
  103. </u-form>
  104. <!-- 绑定支付宝 -->
  105. <u-form v-if="withdrawType === 'alipay'" :model="form.data" :rules="form.aliPayRules" ref="alipay" :errorType="errorType">
  106. <u-form-item :labelStyle="labelStyle" label-width="150" label-position="left" label="真实姓名:" prop="real_name">
  107. <u-input placeholder="请输入真实姓名" :placeholderStyle="placeholderStyle" v-model="form.data.real_name" type="text"></u-input>
  108. </u-form-item>
  109. <u-form-item :labelStyle="labelStyle" label-position="left" label="支付宝账号:" prop="card_no" label-width="170">
  110. <u-input placeholder="请输入支付宝账号" :placeholderStyle="placeholderStyle" v-model="form.data.card_no" type="text"></u-input>
  111. </u-form-item>
  112. </u-form>
  113. <view class="u-flex u-col-center u-row-between">
  114. <button class="u-reset-button form-cancel-btn u-m-y-40" @tap="showBindForm = false">取消</button>
  115. <button class="u-reset-button form-save-btn u-m-y-40" @tap="saveForm">确定</button>
  116. </view>
  117. </view>
  118. </u-popup>
  119. <!-- modal -->
  120. <u-modal
  121. ref="uModal"
  122. v-model="showModal"
  123. :show-cancel-button="true"
  124. confirm-color="#7063D2"
  125. cancel-color="#666666"
  126. @confirm="$Router.push('/pages/user/wallet/withdraw-log')"
  127. confirm-text="查看记录"
  128. cancel-text="继续提现"
  129. content="您的申请提现已提交"
  130. title="申请成功"
  131. ></u-modal>
  132. </view>
  133. </template>
  134. <script>
  135. import { mapState, mapActions, mapGetters } from 'vuex';
  136. import FormValidate from '@/shopro/validate/form';
  137. import wechat from '@/shopro/wechat/wechat';
  138. export default {
  139. components: {},
  140. data() {
  141. return {
  142. showModal: false,
  143. money: '', //提现金额
  144. ruleInfo: '', //提现规则
  145. formTitle: '',
  146. withdrawType: '',
  147. showBindForm: false,
  148. selectedWithdrawType: '',
  149. withdrawInfo: {}, //提现信息
  150. showWithdrawList: false,
  151. withdrawList: {
  152. bank: {
  153. icon: this.$IMG_URL + '/imgs/wallet/bank_type.png',
  154. title: '银行卡转账',
  155. value: 'bank'
  156. },
  157. wechat: {
  158. icon: this.$IMG_URL + '/imgs/wallet/wx_type.png',
  159. title: '微信零钱',
  160. value: 'wechat'
  161. },
  162. alipay: {
  163. icon: this.$IMG_URL + '/imgs/wallet/ali_type.png',
  164. title: '支付宝账户',
  165. value: 'alipay'
  166. }
  167. },
  168. // 表单样式
  169. errorType: ['message'],
  170. labelStyle: {
  171. 'font-size': '30rpx',
  172. 'font-weight': '500',
  173. color: '#333'
  174. },
  175. placeholderStyle: 'font-size: 30rpx; font-weight: 500;color:#C2C7CF;',
  176. form: {
  177. data: {
  178. real_name: '',
  179. bank_name: '',
  180. card_no: ''
  181. },
  182. bankRules: {
  183. real_name: FormValidate.realName,
  184. bank_name: FormValidate.bankName,
  185. card_no: FormValidate.bankCode
  186. },
  187. alipayRules: {
  188. real_name: FormValidate.realName,
  189. card_no: FormValidate.alipayAccount
  190. }
  191. }
  192. };
  193. },
  194. computed: {
  195. ...mapGetters(['userInfo','initRecharge'])
  196. },
  197. async onLoad() {
  198. this.getWithdrawRules();
  199. },
  200. methods: {
  201. // 确认提现方式
  202. onSaveWithdrawType() {
  203. this.withdrawType = this.selectedWithdrawType;
  204. this.showWithdrawList = false;
  205. this.getWithdrawInfo();
  206. },
  207. async bindThirdOauth() {
  208. let that = this;
  209. wechat.bind();
  210. that.getWithdrawInfo();
  211. },
  212. // 提现检验
  213. onWithdrawInput(e) {
  214. let sVal = String(e.detail.value);
  215. sVal = sVal.replace(/\b(0+)/gi, '');
  216. sVal = sVal.replace(/[^\d]/g, '');
  217. this.money = sVal;
  218. },
  219. // 提现
  220. withdraw() {
  221. const that = this;
  222. if (!this.withdrawType) {
  223. this.$u.toast('请选择提现方式');
  224. return;
  225. }
  226. if (this.money <= 0) {
  227. this.$u.toast('请输入提现金额');
  228. return;
  229. }
  230. that.$http(
  231. 'money.walletApply',
  232. {
  233. type: that.withdrawType,
  234. money: that.money
  235. },
  236. '申请中...',
  237. false
  238. ).then(res => {
  239. if (res.code === 1) {
  240. that.money = '';
  241. that.showModal = true;
  242. // #ifdef MP-WEIXIN
  243. this.$store.commit('subscribeMessage', 'wallet');
  244. // #endif
  245. that.$store.dispatch('getUserInfo');
  246. } else {
  247. that.$u.toast(res.msg);
  248. }
  249. });
  250. },
  251. initForm() {
  252. this.form.data = {
  253. real_name: '',
  254. bank_name: '',
  255. card_no: ''
  256. };
  257. },
  258. // 绑定,修改
  259. toBind() {
  260. this.showBindForm = true;
  261. this.form.data = {
  262. ...this.form.data,
  263. ...this.withdrawInfo
  264. };
  265. switch (this.withdrawType) {
  266. case 'bank':
  267. this.formTitle = this.withdrawInfo ? '修改银行卡' : '添加银行卡';
  268. this.$nextTick(() => {
  269. this.$refs.bank.setRules(this.form.bankRules);
  270. });
  271. break;
  272. case 'alipay':
  273. this.formTitle = this.withdrawInfo ? '修改支付宝' : '添加支付宝';
  274. this.$nextTick(() => {
  275. this.$refs.alipay.setRules(this.form.alipayRules);
  276. });
  277. break;
  278. default:
  279. break;
  280. }
  281. },
  282. // 确认提交表单
  283. saveForm() {
  284. let that = this;
  285. this.$refs[this.withdrawType].validate().then(res => {
  286. if (res) {
  287. that.$http(
  288. 'money.bankEdit',
  289. {
  290. type: that.withdrawType,
  291. ...that.form.data
  292. },
  293. '提交中...'
  294. ).then(res => {
  295. if (res.code === 1) {
  296. that.showBindForm = false;
  297. that.$u.toast(res.msg);
  298. that.initForm();
  299. that.getWithdrawInfo();
  300. }
  301. });
  302. }
  303. });
  304. },
  305. // 提现规则
  306. getWithdrawRules() {
  307. let that = this;
  308. that.$http('money.walletRule').then(res => {
  309. if (res.code === 1) {
  310. that.ruleInfo = res.data;
  311. that.selectedWithdrawType = that.ruleInfo.methods[0];
  312. }
  313. });
  314. },
  315. // 获取提现信息
  316. getWithdrawInfo() {
  317. let that = this;
  318. that.$http(
  319. 'money.bankInfo',
  320. {
  321. type: that.withdrawType
  322. },
  323. '',
  324. false
  325. ).then(res => {
  326. that.withdrawInfo = res.code === 1 ? res.data : null;
  327. });
  328. }
  329. }
  330. };
  331. </script>
  332. <style lang="scss">
  333. .head-box {
  334. background: url($IMG_URL+'/imgs/user/draw_money_head_bg.png') no-repeat;
  335. background-size: 100% auto;
  336. min-height: 400rpx;
  337. padding-bottom: var(--status-bar-height);
  338. // 可提现
  339. .wallet-num-box {
  340. padding: 20rpx 40rpx 0;
  341. .num-title {
  342. font-size: 26rpx;
  343. font-weight: 500;
  344. color: #ffffff;
  345. margin-bottom: 20rpx;
  346. }
  347. .wallet-num {
  348. font-size: 60rpx;
  349. font-weight: 500;
  350. color: #ffffff;
  351. }
  352. .log-btn {
  353. width: 170rpx;
  354. height: 60rpx;
  355. line-height: 60rpx;
  356. background: rgba(255, 255, 255, 0.1);
  357. border: 1rpx solid #eeeeee;
  358. border-radius: 30rpx;
  359. padding: 0;
  360. font-size: 26rpx;
  361. font-weight: 500;
  362. color: #ffffff;
  363. }
  364. }
  365. }
  366. // 提现输入卡片
  367. .draw-card {
  368. background-color: #fff;
  369. border-radius: 20rpx;
  370. width: 690rpx;
  371. min-height: 530rpx;
  372. margin: -70rpx auto 0;
  373. padding: 30rpx;
  374. .card-title {
  375. font-size: 30rpx;
  376. font-weight: 500;
  377. color: #333333;
  378. margin-bottom: 30rpx;
  379. }
  380. .input-box {
  381. width: 624rpx;
  382. border-bottom: 1rpx solid #eee;
  383. height: 100rpx;
  384. margin-bottom: 40rpx;
  385. .unit {
  386. font-size: 48rpx;
  387. color: #333;
  388. }
  389. }
  390. .bank-box {
  391. .name {
  392. font-size: 28rpx;
  393. font-weight: 500;
  394. color: #333333;
  395. }
  396. .bank-list {
  397. .empty-text {
  398. font-size: 28rpx;
  399. font-weight: 400;
  400. color: #999999;
  401. }
  402. .sel-box {
  403. .item-img {
  404. width: 36rpx;
  405. height: 36rpx;
  406. }
  407. .item-title {
  408. font-size: 28rpx;
  409. color: #333333;
  410. }
  411. }
  412. }
  413. }
  414. .bank-info {
  415. height: 50rpx;
  416. font-size: 28rpx;
  417. font-weight: 400;
  418. color: #999999;
  419. .bank-info-title {
  420. width: 500rpx;
  421. }
  422. .bind-btn {
  423. padding: 0 20rpx;
  424. line-height: 50rpx;
  425. background: #f5f6f8;
  426. border-radius: 20rpx;
  427. color: #999;
  428. }
  429. }
  430. .save-btn {
  431. width: 616rpx;
  432. height: 86rpx;
  433. line-height: 86rpx;
  434. background: linear-gradient(-90deg, #a36fff, #5336ff);
  435. box-shadow: 0px 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
  436. border-radius: 43rpx;
  437. font-size: 30rpx;
  438. font-weight: 500;
  439. color: #ffffff;
  440. }
  441. }
  442. // 提现说明
  443. .draw-notice {
  444. width: 684rpx;
  445. min-height: 327rpx;
  446. background: #ffffff;
  447. border-radius: 20rpx;
  448. padding: 30rpx 35rpx;
  449. margin: 20rpx auto;
  450. .title {
  451. font-size: 30rpx;
  452. font-weight: 500;
  453. color: #333333;
  454. margin-bottom: 30rpx;
  455. }
  456. .draw-list {
  457. font-size: 24rpx;
  458. font-weight: 400;
  459. color: #999999;
  460. margin-bottom: 10rpx;
  461. }
  462. }
  463. // 提现费方式
  464. .withdraw-modal {
  465. min-height: 600rpx;
  466. background-color: #fff;
  467. .modal-head {
  468. height: 80rpx;
  469. font-size: 30rpx;
  470. font-weight: 600;
  471. color: #333333;
  472. border-bottom: 1rpx solid rgba(#dfdfdf, 0.5);
  473. }
  474. .modal-content {
  475. .type-item {
  476. height: 100rpx;
  477. border-bottom: 1rpx solid rgba(#dfdfdf, 0.5);
  478. width: 750rpx;
  479. .item-img {
  480. width: 36rpx;
  481. height: 36rpx;
  482. }
  483. .item-title {
  484. font-size: 28rpx;
  485. color: #333333;
  486. }
  487. }
  488. }
  489. .modal-bottom {
  490. padding: 30rpx;
  491. .modal-save-btn {
  492. width: 690rpx;
  493. height: 80rpx;
  494. line-height: 80rpx;
  495. background: linear-gradient(90deg, #a36fff, #5336ff);
  496. box-shadow: 0 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
  497. border-radius: 40rpx;
  498. font-weight: 500;
  499. color: #ffffff;
  500. }
  501. }
  502. }
  503. // 绑定
  504. .form-box {
  505. .head-title {
  506. height: 100rpx;
  507. font-size: 34rpx;
  508. font-weight: 600;
  509. }
  510. .form-save-btn {
  511. width: 340rpx;
  512. height: 80rpx;
  513. line-height: 80rpx;
  514. background: linear-gradient(90deg, #a36fff, #5336ff);
  515. box-shadow: 0 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
  516. border-radius: 40rpx;
  517. font-weight: 500;
  518. color: #ffffff;
  519. }
  520. .form-cancel-btn {
  521. width: 340rpx;
  522. height: 80rpx;
  523. line-height: 80rpx;
  524. border: 1rpx solid #999;
  525. border-radius: 40rpx;
  526. font-weight: 500;
  527. color: #999;
  528. }
  529. }
  530. </style>