del-withdrawal.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <view class="widthdraw flexCC">
  3. <view class="bank_box flexB" @click="editAccount">
  4. <view class="flexS">
  5. <image src="../../../static/imgs/shop/bank.png" class="bank_icon"></image>
  6. <view class="bank_info" v-if="bank.account_bank">
  7. <view>{{ bank.account_bank }}</view>
  8. <text>{{ bank.account_number }}</text>
  9. </view>
  10. <view v-else style="font-size:32rpx;color:#999">添加银行卡</view>
  11. </view>
  12. <view class="change_box">
  13. <text v-if="bank.account_bank">可修改</text>
  14. <text class="iconfont iconiconfontjiantou2"></text>
  15. </view>
  16. </view>
  17. <view class="money_box">
  18. <view class="title">提现金额</view>
  19. <view class="inp flexS">
  20. <text>¥</text>
  21. <input type="digit" placeholder="请输入提现金额" v-model="amount" />
  22. </view>
  23. <view class="bottom">
  24. <text>可提现{{ this.blanceFmt(limit)}}元</text>
  25. <text class="all" @click="allWithdrawal">全部提现</text>
  26. </view>
  27. <view class="widthdraw_box">
  28. <view class="sub_btn" @click="withdraw">立即提现</view>
  29. <view class="widthdraw_hint">提现金额一般在第二天到账(遇节假日可能顺延)</view>
  30. </view>
  31. </view>
  32. <view class="pop flexCC" v-if="showPop">
  33. <view class="pop_con">
  34. <image src="../../../static/imgs/shop/hint_icon.png" class="hint_icon"></image>
  35. <view class="title">特别提醒</view>
  36. <view class="con">
  37. 您还有订单未处理完,请先完成订单。然后,尽快进行提现。
  38. </view>
  39. <view class="sub_btn" @click="skipOrder">查看订单</view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. withdraw,
  47. getBankInfo,
  48. getAccount,
  49. getNoFinishOrder
  50. } from '@/apis/shop.js';
  51. export default {
  52. data() {
  53. return {
  54. amount: '', //提现金额
  55. limit: '', //可提现金额
  56. isAll: false, //是否全部提现
  57. bank: '', //银行卡信息
  58. isOpare: true,
  59. showPop: false, //显示未处理完订单弹窗
  60. orderNum: 0, //未处理订单数量
  61. };
  62. },
  63. onShow() {
  64. uni.hideHomeButton();
  65. this.getOrder();
  66. },
  67. methods: {
  68. //获取未处理的订单
  69. getOrder() {
  70. getNoFinishOrder({
  71. page_index: 1,
  72. page_size: 6
  73. }).then(res => {
  74. if (res.code == 200) {
  75. this.orderNum = res.data.total
  76. //如果还有存在订单
  77. this.getAccount()
  78. this.getBank();
  79. if (res.data.total > 0) {
  80. this.showPop = true
  81. return false
  82. }
  83. } else {
  84. uni.showModal({
  85. content: res.data,
  86. showCancel: false
  87. })
  88. }
  89. })
  90. },
  91. //跳转到待处理订单页面
  92. skipOrder() {
  93. this.showPop = false
  94. uni.navigateTo({
  95. url: '../order-pending/order-pending'
  96. })
  97. },
  98. /*获取账户信息*/
  99. getAccount() {
  100. uni.showLoading({
  101. title: '加载中...',
  102. mask: true
  103. })
  104. getAccount().then(res => {
  105. if (res.code == 200) {
  106. const {
  107. available_amount,
  108. pending_amount
  109. } = res.data
  110. this.limit = available_amount;
  111. //如果没有存在订单
  112. if (this.orderNum === 0 && available_amount === 0 && pending_amount === 0) {
  113. uni.reLaunch({
  114. url: '../login-fail/login-fail?hint=' + '你已被系统删除'
  115. })
  116. }
  117. } else {
  118. uni.showModal({
  119. content: res.data || '获取信息失败',
  120. showCancel: false
  121. });
  122. }
  123. uni.hideLoading()
  124. }).catch(err => {
  125. uni.hideLoading()
  126. })
  127. },
  128. blanceFmt(val) {
  129. //分转化为元
  130. var num = Number(val);
  131. if (!num) {
  132. //等于0
  133. return num + '.00';
  134. } else {
  135. //不等于0
  136. num = Math.round(num * 100) / 10000;
  137. num = num.toFixed(2);
  138. num += ''; //转成字符串
  139. var reg = num.indexOf('.') > -1 ? /(\d{1,3})(?=(?:\d{3})+\.)/g : /(\d{1,3})(?=(?:\d{3})+$)/g; //千分符的正则
  140. return num.replace(reg, '$1,'); //千分位格式化
  141. }
  142. },
  143. /*获取银行卡信息*/
  144. getBank() {
  145. getBankInfo().then(res => {
  146. if (res.code == 200) {
  147. this.bank = res.data;
  148. } else {
  149. uni.showModal({
  150. content: res.data || '获取银行卡信息失败',
  151. showCancel: false
  152. });
  153. }
  154. });
  155. },
  156. /*选择银行卡*/
  157. changeBank() {
  158. uni.navigateTo({
  159. url: '../card-manage/card-manage'
  160. });
  161. },
  162. /*全部提现*/
  163. allWithdrawal() {
  164. this.amount = this.blanceFmt(this.limit);
  165. },
  166. //提现按钮
  167. withdraw() {
  168. //提现之前先确定下是否有未处理订单
  169. getNoFinishOrder({
  170. page_index: 1,
  171. page_size: 6
  172. }).then(res => {
  173. if (res.code == 200) {
  174. this.orderNum = res.data.total
  175. //如果还有存在订单
  176. if (res.data.total > 0) {
  177. this.showPop = true
  178. }
  179. } else {
  180. uni.showModal({
  181. content: res.data,
  182. showCancel: false
  183. })
  184. }
  185. })
  186. if (!this.bank.account_bank) {
  187. uni.showModal({
  188. content: '请先添加银行卡',
  189. showCancel: false
  190. });
  191. return false;
  192. }
  193. if (!this.isOpare) {
  194. uni.showModal({
  195. content: '操作频繁,稍后再试~',
  196. showCancel: false
  197. });
  198. return false;
  199. }
  200. if (!this.amount || this.amount == 0) {
  201. uni.showModal({
  202. content: '请先输入提现金额',
  203. showCancel: false
  204. });
  205. return false;
  206. }
  207. if (this.amount > Number(this.limit)) {
  208. uni.showModal({
  209. content: '超出可提现金额',
  210. showCancel: false
  211. });
  212. return false;
  213. }
  214. this.isOpare = false;
  215. uni.showLoading({
  216. title: '提现中...'
  217. });
  218. withdraw({
  219. amount: this.amount
  220. })
  221. .then(res => {
  222. if (res.code == 200) {
  223. uni.showModal({
  224. content: '提交成功!',
  225. showCancel: false,
  226. success: res => {
  227. if (res.confirm) {
  228. this.amount = ''
  229. this.getOrder()
  230. }
  231. }
  232. });
  233. } else {
  234. uni.showModal({
  235. content: res.data || '提现失败',
  236. showCancel: false
  237. });
  238. }
  239. uni.hideLoading();
  240. })
  241. .catch(err => {
  242. this.isOpare = true;
  243. uni.hideLoading();
  244. })
  245. .finally(() => {
  246. uni.hideLoading();
  247. setTimeout(() => {
  248. this.isOpare = true;
  249. }, 2000);
  250. });
  251. },
  252. /*修改银行账户信息*/
  253. editAccount() {
  254. let type = this.bank.account_number ? 1 : 0;
  255. uni.navigateTo({
  256. url: '../edit-card/edit-card?type=' + type
  257. });
  258. }
  259. }
  260. };
  261. </script>
  262. <style lang="scss" scoped>
  263. .widthdraw {
  264. width: 100%;
  265. min-height: 100%;
  266. background: #f9f9fb;
  267. padding-top: 30rpx;
  268. .bank_box {
  269. width: 100%;
  270. height: 152rpx;
  271. background: #fff;
  272. padding: 0 30rpx;
  273. box-sizing: border-box;
  274. .bank_icon {
  275. width: 84rpx;
  276. height: 84rpx;
  277. margin-right: 20rpx;
  278. }
  279. .bank_info {
  280. view {
  281. font-size: 36rpx;
  282. font-weight: bold;
  283. margin-bottom: 10rpx;
  284. }
  285. text {
  286. font-size: 28rpx;
  287. color: #999;
  288. }
  289. }
  290. .change_box {
  291. text {
  292. font-size: 32rpx;
  293. color: #999;
  294. }
  295. .iconfont {
  296. vertical-align: -2rpx;
  297. }
  298. }
  299. }
  300. .money_box {
  301. width: 100%;
  302. flex: 1;
  303. margin-top: 20rpx;
  304. border-radius: 40rpx 40rpx 0 0;
  305. background: #fff;
  306. padding: 0 30rpx;
  307. box-sizing: border-box;
  308. .title {
  309. font-size: 32rpx;
  310. font-weight: bold;
  311. padding: 20rpx 0 40rpx;
  312. }
  313. .inp {
  314. background: #f8f8f8;
  315. height: 86rpx;
  316. border-radius: 8rpx;
  317. text {
  318. font-size: 50rpx;
  319. font-weight: bold;
  320. margin: 0 20rpx;
  321. }
  322. input {
  323. width: 90%;
  324. height: 100%;
  325. }
  326. }
  327. .bottom {
  328. margin-top: 30rpx;
  329. text {
  330. font-size: 32rpx;
  331. color: #999;
  332. }
  333. .all {
  334. margin-left: 30rpx;
  335. color: $base-color;
  336. font-weight: bold;
  337. }
  338. }
  339. .widthdraw_box {
  340. margin-top: 120rpx;
  341. .widthdraw_hint {
  342. text-align: center;
  343. margin-top: 20rpx;
  344. color: #2675ff;
  345. font-weight: bold;
  346. }
  347. }
  348. }
  349. }
  350. .pop {
  351. width: 100%;
  352. height: 100vh;
  353. position: fixed;
  354. top: 0;
  355. left: 0;
  356. background-color: rgba(0, 0, 0, 0.7);
  357. z-index: 999;
  358. .hint_icon {
  359. width: 183rpx;
  360. height: 135rpx;
  361. position: relative;
  362. margin-top: -85rpx;
  363. }
  364. .pop_con {
  365. width: 648rpx;
  366. height: 442rpx;
  367. background: #fff;
  368. border-radius: 26rpx;
  369. display: flex;
  370. flex-direction: column;
  371. align-items: center;
  372. padding: 0 30rpx;
  373. box-sizing: border-box;
  374. .title {
  375. font-size: 36rpx;
  376. font-weight: bold;
  377. margin-top: 22rpx;
  378. }
  379. .con {
  380. min-height: 150rpx;
  381. margin: 20rpx 0 20rpx;
  382. font-size: 34rpx;
  383. color: $base-color;
  384. }
  385. }
  386. }
  387. // .width {
  388. // width: 690rpx;
  389. // margin: 0 auto;
  390. // .bg {
  391. // margin: 5vh auto 0;
  392. // position: relative;
  393. // image {
  394. // width: 690rpx;
  395. // height: 390rpx;
  396. // }
  397. // .bg_con {
  398. // position: absolute;
  399. // top: 20rpx;
  400. // left: 30rpx;
  401. // width: 94%;
  402. // text,
  403. // view {
  404. // color: #fff;
  405. // }
  406. // .hint {
  407. // font-size: 28rpx;
  408. // }
  409. // .price {
  410. // padding: 20rpx 0 30rpx;
  411. // text:first-child {
  412. // font-size: 56rpx;
  413. // }
  414. // text:last-child {
  415. // font-size: 80rpx;
  416. // }
  417. // }
  418. // .edit_btn {
  419. // width: 260rpx;
  420. // text-align: center;
  421. // height: 68rpx;
  422. // font-size: 30rpx;
  423. // line-height: 68rpx;
  424. // background: #ffec8e;
  425. // color: $base-color;
  426. // border-radius: 38rpx;
  427. // }
  428. // }
  429. // }
  430. // .widthdrawal {
  431. // .title {
  432. // font-size: 32rpx;
  433. // font-weight: bold;
  434. // margin: 0 0 30rpx;
  435. // }
  436. // .inp {
  437. // background: #f8f8f8;
  438. // height: 86rpx;
  439. // border-radius: 8rpx;
  440. // text {
  441. // font-size: 36rpx;
  442. // margin: 0 20rpx;
  443. // }
  444. // input {
  445. // width: 90%;
  446. // height: 100%;
  447. // }
  448. // }
  449. // .bank_info {
  450. // view {
  451. // font-size: 28rpx;
  452. // margin-top: 15rpx;
  453. // }
  454. // }
  455. // .all {
  456. // margin: 30rpx 0;
  457. // }
  458. // .way {
  459. // .iconfont,
  460. // image {
  461. // vertical-align: middle;
  462. // }
  463. // image {
  464. // margin: 0 10rpx;
  465. // }
  466. // }
  467. // }
  468. // .opera {
  469. // margin-top: 165rpx;
  470. // text-align: center;
  471. // .gray {
  472. // margin-top: 30rpx;
  473. // }
  474. // }
  475. // }
  476. </style>