withdraw.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <template>
  2. <view class="main">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <view class="canWithdrawCls">
  5. <view>
  6. <view>可提现服务积分:</view>
  7. <view class="canWithdrawCls_val"
  8. ><text>{{ walletInfo.commission_able }}</text></view
  9. >
  10. </view>
  11. <view class="u-mt20 markBox">
  12. <view class="u-mr30"
  13. >待入账 <view><text></text>{{ walletInfo.wait_account }}</view>
  14. </view>
  15. <view
  16. >冻结中 <view><text></text>{{ walletInfo.freezing }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="withdrawCls">
  21. <view class="withdrawCls_lab"
  22. >提现服务积分
  23. <!-- <text>(最低提现佣金1公益服务积分)</text> -->
  24. <text>(最低提现佣金{{ walletInfo.min_extract }})</text>
  25. </view>
  26. <view class="withdrawCls_val">
  27. <!-- <text>¥</text> -->
  28. <input
  29. @input="getMoney"
  30. maxlength="10"
  31. type="digit"
  32. v-model="dataForm.public_service_points"
  33. placeholder-style="color:#CCCCCC"
  34. placeholder="提现服务积分"
  35. />
  36. </view>
  37. <view class="bg-fff">
  38. <view class="u-flex-center-sb u-1A1A1A" @click="openBankCard">
  39. <view class="u-flex">
  40. <text class="u-font30">提现方式</text>
  41. <view
  42. class="ml46 u-font28"
  43. v-if="bankCardList.length > 0 && dataForm.payment_term == 2"
  44. >
  45. <view>
  46. <image :src="bankIcon" class="img30"></image>
  47. <text class="u-ml20">{{ dataForm.bank_name }}</text>
  48. </view>
  49. <view class="u-999 u-mt5 u-ml45 u-flex">
  50. 尾号
  51. <rich-text
  52. :nodes="$mUtil.cutOut(dataForm.withdraw_account)"
  53. ></rich-text>
  54. 储蓄卡
  55. </view>
  56. </view>
  57. <view
  58. class="ml46 u-font28"
  59. v-if="bankCardList.length <= 0 && dataForm.payment_term == 2"
  60. >
  61. 添加银行卡
  62. </view>
  63. <view class="ml46 u-font28 sBox" v-if="dataForm.payment_term == 1">
  64. <image
  65. :src="$mUtil.staticUrl + '/alipay.png'"
  66. class="img30"
  67. ></image>
  68. 支付宝
  69. </view>
  70. <view class="ml46 u-font28 sBox" v-if="dataForm.payment_term == 0">
  71. <image
  72. :src="$mUtil.staticUrl + '/weChat.png'"
  73. class="img30"
  74. ></image>
  75. 微信
  76. </view>
  77. <view class="ml46 u-font28" v-if="dataForm.payment_term == 4">
  78. 提现到公益积分
  79. </view>
  80. </view>
  81. <view class="iconfont u-font24 u-666"> &#xe6c7;</view>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="btnBox">
  86. <view @click="requestWithdrawal">提交申请</view>
  87. </view>
  88. <uni-popup
  89. class="submit-popup"
  90. ref="submitPopup"
  91. type="center"
  92. :mask-click="false"
  93. >
  94. <view class="content-box">
  95. <view class="title">提交完成</view>
  96. <view class="content">
  97. <image
  98. class="success-icon"
  99. src="/static/common/success-icon.png"
  100. ></image>
  101. <view class="tip"> </view>
  102. <button class="btn" @click="closePopup()">确 定</button>
  103. </view>
  104. </view>
  105. </uni-popup>
  106. <!--弹窗选择银行卡-->
  107. <uniPopup type="bottom" ref="uniPopup">
  108. <view class="popup">
  109. <view class="bg-top">
  110. <text class="iconfont u-999" @click="close">&#xe612;</text>
  111. <text class="u-text-center ml200">选择优先付款方式</text>
  112. </view>
  113. <view class="bankCardList">
  114. <view v-for="(item, index) in bankCardList" :key="item.id">
  115. <!--index 下标,2 是类型自定义(下面支付宝,微信一样)-->
  116. <view class="item u-flex" @click="pitchOn(index, 2)">
  117. <image :src="item.icon"></image>
  118. <view class="u-ml25 rh-br u-flex-sb">
  119. <view class="u-flex">
  120. <text>{{ item.bank_name }}</text>
  121. (<rich-text :nodes="$mUtil.cutOut(item.card_num)"></rich-text
  122. >)
  123. </view>
  124. <text class="iconfont pull-right" v-if="pitchOnIndex == index"
  125. >&#xe63e;</text
  126. >
  127. </view>
  128. </view>
  129. </view>
  130. <!--添加银行卡-->
  131. <view class="item u-flex" @click="goAddBankCard">
  132. <text class="iconfont">&#xe81a;</text>
  133. <view class="u-ml25 rh-br">
  134. <text>添加银行卡</text>
  135. </view>
  136. </view>
  137. <!--支付宝-->
  138. <view class="item u-flex" @click="pitchOn(-1, 1)">
  139. <image :src="$mUtil.staticUrl + '/alipay.png'"></image>
  140. <view class="u-ml25 rh-br">
  141. <text>支付宝</text>
  142. <text class="iconfont pull-right" v-if="pitchOnIndex == -1"
  143. >&#xe63e;</text
  144. >
  145. </view>
  146. </view>
  147. <view class="item u-flex" @click="pitchOn(-2, 0)">
  148. <image :src="$mUtil.staticUrl + '/weChat.png'"></image>
  149. <view class="u-ml25 rh-br">
  150. <text>微信</text>
  151. <text class="iconfont pull-right" v-if="pitchOnIndex == -2"
  152. >&#xe63e;</text
  153. >
  154. </view>
  155. </view>
  156. <view class="item u-flex" @click="pitchOn(-3, 4)">
  157. <view class="u-ml25 rh-br">
  158. <text>提现到公益积分</text>
  159. <text class="iconfont pull-right" v-if="pitchOnIndex == -3"
  160. >&#xe63e;</text
  161. >
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </uniPopup>
  167. </view>
  168. </template>
  169. <script setup>
  170. import { ref } from "vue";
  171. import { onLoad } from "@dcloudio/uni-app";
  172. const $http = uni.$http;
  173. const dataForm = ref({
  174. public_service_points: "", // 提现金额
  175. payment_term: 2, // * 收款方式:* 0 微信,* 1 支付宝,* 2 银行线下 * 3 现金支付
  176. payee: "", // 收款人
  177. withdraw_account: "", // 提现账户
  178. withdraw_mobile: "", // 提现手机
  179. bank_name: "", // 银行名称
  180. });
  181. const bankIcon = ref("");
  182. const pitchOnIndex = ref(0);
  183. const walletInfo = ref({
  184. min_extract: 0,
  185. wait_account: 0,
  186. freezing: 0,
  187. }); // 账户信息
  188. const bankCardList = ref([]);
  189. const submitPopup = ref(null);
  190. const uniPopup = ref(null);
  191. // 生命周期
  192. onLoad(() => {
  193. // 获取账户信息
  194. getAccountMsg();
  195. // 获取银行卡列表
  196. getBankCardList();
  197. });
  198. // 方法
  199. // 获取账户信息
  200. const getAccountMsg = () => {
  201. $http.get("/withdraw/getWalletInfo", {}).then(async (res) => {
  202. if (res && res.code == 200) {
  203. if (res.data) {
  204. walletInfo.value = res.data;
  205. }
  206. }
  207. });
  208. };
  209. // 获取银行卡列表
  210. const getBankCardList = () => {
  211. $http.get("/member/bankcard/bankCardList", {}).then(async (res) => {
  212. if (res && res.code == 200) {
  213. bankCardList.value = res.list;
  214. // 默认提方式为用户银行卡列表第一张银行卡
  215. if (res.list.length > 0) {
  216. dataForm.value.bank_name = res.list[0].bank_name;
  217. dataForm.value.withdraw_account = res.list[0].card_num;
  218. bankIcon.value = res.list[0].icon;
  219. dataForm.value.payee = res.list[0].name;
  220. dataForm.value.withdraw_mobile = res.list[0].mobile;
  221. dataForm.value.user_bank_id = bankCardList.value[0].id;
  222. }
  223. }
  224. });
  225. };
  226. // 打开弹窗银行卡列表
  227. const openBankCard = () => {
  228. uniPopup.value.open();
  229. };
  230. // 关闭弹窗
  231. const close = () => {
  232. uniPopup.value.close();
  233. };
  234. // 选择提现方式
  235. const pitchOn = (index, type) => {
  236. pitchOnIndex.value = index;
  237. dataForm.value.payment_term = type;
  238. if (type == 2) {
  239. dataForm.value.bank_name = bankCardList.value[index].bank_name;
  240. dataForm.value.withdraw_account = bankCardList.value[index].card_num;
  241. bankIcon.value = bankCardList.value[index].icon;
  242. dataForm.value.user_bank_id = bankCardList.value[index].id;
  243. } else {
  244. dataForm.value.user_bank_id = null;
  245. }
  246. uniPopup.value.close();
  247. };
  248. // 跳到添加银行卡
  249. const goAddBankCard = () => {
  250. uni.navigateTo({
  251. url: "/pages/user/bankCard/addBankCard",
  252. });
  253. };
  254. // 获取输入提现金额
  255. const getMoney = (e) => {
  256. e.target.value = e.target.value.match(/^\d*(\.?\d{0,2})/g)[0] || null;
  257. // 重新赋值给 input
  258. setTimeout(() => {
  259. dataForm.value.public_service_points = e.target.value
  260. ? e.target.value * 1
  261. : "";
  262. }, 0);
  263. };
  264. // 申请提现
  265. const requestWithdrawal = () => {
  266. if (!dataForm.value.public_service_points) {
  267. uni.$uv.toast("请输入提现服务积分");
  268. return false;
  269. }
  270. if (dataForm.value.public_service_points < walletInfo.value.min_extract) {
  271. uni.$uv.toast("提现金额超出您的最低提现服务积分");
  272. return false;
  273. }
  274. if (dataForm.value.payment_term === "") {
  275. uni.$uv.toast("请选择提现方式");
  276. return false;
  277. }
  278. if (dataForm.value.payment_term == 2) {
  279. if (!dataForm.value.bank_name) {
  280. uni.$uv.toast("请先添加银行卡");
  281. return false;
  282. }
  283. }
  284. $http.post("/withdraw/memberWithdraw", dataForm.value).then(async (res) => {
  285. if (res && res.code == 200) {
  286. uni.$uv.toast("申请成功");
  287. setTimeout(() => {
  288. uni.navigateBack({
  289. success: () => {
  290. let page = getCurrentPages().pop(); // 跳转页面成功之后
  291. if (!page) {
  292. return;
  293. } else {
  294. page.onLoad(page.options); // page 自带 options 对象.
  295. }
  296. },
  297. });
  298. }, 2000);
  299. } else {
  300. uni.$uv.toast(res.msg);
  301. }
  302. });
  303. };
  304. // 关闭弹窗
  305. const closePopup = () => {
  306. submitPopup.value.close();
  307. };
  308. </script>
  309. <style lang="scss" scoped>
  310. .canWithdrawCls {
  311. font-size: 28rpx;
  312. color: #1a1a1a;
  313. padding: 60rpx;
  314. border-bottom: 8rpx solid #f5f5f5;
  315. .markBox {
  316. text {
  317. display: inline-block;
  318. width: 10rpx;
  319. }
  320. }
  321. > view {
  322. display: flex;
  323. .canWithdrawCls_val {
  324. font-size: 24rpx;
  325. align-items: baseline;
  326. text {
  327. font-size: 36rpx;
  328. color: #ff0000;
  329. }
  330. }
  331. > view {
  332. display: flex;
  333. text {
  334. font-size: 24rpx;
  335. color: #808080;
  336. }
  337. > view {
  338. color: #808080;
  339. }
  340. }
  341. }
  342. }
  343. .withdrawCls {
  344. padding: 40rpx 60rpx;
  345. .withdrawCls_lab {
  346. font-size: 28rpx;
  347. color: #1a1a1a;
  348. text {
  349. color: #808080;
  350. }
  351. }
  352. .withdrawCls_val {
  353. display: flex;
  354. align-items: center;
  355. font-size: 60rpx;
  356. padding: 30rpx 0;
  357. border-bottom: 3rpx dashed #808080;
  358. text {
  359. color: #181818;
  360. }
  361. input {
  362. margin-left: 10rpx;
  363. font-size: 42rpx;
  364. }
  365. }
  366. .withdrawTypeCls {
  367. display: flex;
  368. justify-content: space-between;
  369. margin-top: 40rpx;
  370. .withdrawTypeCls_lab {
  371. font-size: 30rpx;
  372. color: #1a1a1a;
  373. }
  374. .withdrawTypeCls_val {
  375. font-size: 28rpx;
  376. color: #999999;
  377. .selLab {
  378. color: #1a1a1a;
  379. }
  380. }
  381. .withdrawTypeCls_dir {
  382. color: #808080;
  383. }
  384. }
  385. }
  386. .btnBox {
  387. position: fixed;
  388. bottom: 0;
  389. left: 0;
  390. width: 100%;
  391. background: #ffffff;
  392. padding: 30rpx 30rpx 60rpx 30rpx;
  393. > view {
  394. display: flex;
  395. justify-content: center;
  396. align-items: center;
  397. font-size: 32rpx;
  398. color: #ffffff;
  399. padding: 20rpx 0;
  400. background: #0b844a;
  401. border-radius: 40rpx;
  402. }
  403. }
  404. .content-box {
  405. width: 440rpx;
  406. padding-bottom: 50rpx;
  407. }
  408. .bg-fff {
  409. background-color: #ffffff;
  410. padding: 26rpx 0rpx 36rpx;
  411. border-radius: 0rpx 0rpx 18px 18rpx;
  412. }
  413. .ml46 {
  414. margin-left: 46rpx;
  415. }
  416. .apply-btn {
  417. margin-top: 80rpx;
  418. button {
  419. background: #0b844a;
  420. color: #ffffff;
  421. }
  422. }
  423. .zfb-wx {
  424. padding-bottom: 24rpx;
  425. .payIcon {
  426. color: #00aaef;
  427. font-size: 32rpx;
  428. margin-right: 18rpx;
  429. }
  430. .wxIcon {
  431. color: rgb(37, 171, 56);
  432. font-size: 32rpx;
  433. margin-right: 18rpx;
  434. }
  435. }
  436. .zhInput input {
  437. width: 62%;
  438. height: 70rpx;
  439. line-height: 70rpx;
  440. padding: 0rpx 20rpx;
  441. border: 1rpx solid #d9d9d9;
  442. border-radius: 6rpx;
  443. }
  444. .popup {
  445. width: 100%;
  446. .bg-top {
  447. background-color: #f5f5f5;
  448. padding: 20rpx 30rpx;
  449. border-radius: 18rpx 18rpx 0px 0px;
  450. }
  451. .bankCardList {
  452. background-color: #ffffff;
  453. padding: 0rpx 30rpx;
  454. padding-bottom: 185rpx;
  455. .item {
  456. height: 84rpx;
  457. line-height: 84rpx;
  458. image {
  459. width: 48rpx;
  460. height: 42rpx;
  461. // margin-top: 20rpx;
  462. vertical-align: bottom;
  463. }
  464. .rh-br {
  465. width: 100%;
  466. border-bottom: 1rpx solid #e6e6e6;
  467. }
  468. .pull-right {
  469. float: right !important;
  470. }
  471. }
  472. }
  473. }
  474. .ml56 {
  475. margin-left: 56rpx;
  476. }
  477. .ml200 {
  478. margin-left: 200rpx;
  479. }
  480. .wt112 {
  481. width: 140rpx;
  482. }
  483. .img30 {
  484. width: 30rpx;
  485. height: 30rpx;
  486. }
  487. .wd-bgImg {
  488. position: relative;
  489. padding: 25rpx 0rpx;
  490. image {
  491. width: 100%;
  492. height: 200rpx;
  493. vertical-align: bottom;
  494. }
  495. .moneyInfo {
  496. position: absolute;
  497. top: 25rpx;
  498. width: 92%;
  499. .mt40 {
  500. margin-top: 40rpx;
  501. }
  502. .detail-btn button {
  503. height: 56rpx;
  504. line-height: 30rpx;
  505. border-radius: 28px;
  506. opacity: 0.82;
  507. padding: 10rpx 30rpx;
  508. background-color: #eed9a9;
  509. color: #0b844a;
  510. }
  511. }
  512. }
  513. .wdInput {
  514. background-color: #ffffff;
  515. border-radius: 18rpx 18rpx 0px 0rpx;
  516. padding: 40rpx 22rpx 32rpx;
  517. .input {
  518. height: 80rpx;
  519. line-height: 80rpx;
  520. font-size: 60rpx;
  521. border-bottom: 1rpx solid #d9d9d9;
  522. padding-bottom: 25rpx;
  523. input {
  524. height: 80rpx;
  525. line-height: 80rpx;
  526. font-size: 36rpx;
  527. }
  528. }
  529. }
  530. .u-flex-sb {
  531. display: flex;
  532. justify-content: space-between;
  533. }
  534. .sBox {
  535. display: flex;
  536. align-items: center;
  537. > image {
  538. margin-right: 10rpx;
  539. }
  540. }
  541. </style>