withdrawal.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="container">
  3. <view class="fix">
  4. <view class="top"></view>
  5. <view class="head">
  6. <span class="cuIcon-back" @click="back"></span>
  7. <view class="case"> 申请提现 </view>
  8. </view>
  9. </view>
  10. <view class="form-card">
  11. <view class="section-input">
  12. <view class="label">提现金额 <i class="text-bg"></i></view>
  13. <view class="input-row">
  14. <text class="currency-symbol">¥</text>
  15. <u-input
  16. type="digit"
  17. height="80"
  18. placeholder="请输入提现金额"
  19. :customStyle="{
  20. fontSize: '42rpx',
  21. padding: '0 10rpx',
  22. marginTop: '10rpx',
  23. }"
  24. v-model="withdrawalAmount"
  25. @input="handleInput"
  26. ></u-input>
  27. </view>
  28. <view v-if="isExceeded" class="error">输入金额超过可提现余额</view>
  29. <view class="balance-info">
  30. <text>可提现余额{{ availableAmount }}元,</text>
  31. <text>手续费每笔{{ handlingFee }}元</text>
  32. <text class="all-withdraw-btn" @click="allWithdraw">全部提现</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="form-card">
  37. <view class="label">账户信息 <i class="text-bg"></i></view>
  38. <view class="bank-info">
  39. <view class="bank-label">银行账户</view>
  40. <view class="u-flex">
  41. <u-image :src="bankCardInfo.bankLogo" width="42rpx" height="42rpx"></u-image>
  42. <view class="bank-number">{{ bankCardInfo.bankName }}({{ bankCardInfo.bankCardNumber }})</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="form-card">
  47. <view class="u-flex justify-between">
  48. <view class="title">开票信息<i class="text-bg"></i></view>
  49. <view class="note">注:提现申请请上传开票凭证</view>
  50. </view>
  51. <view class="invoice-info">
  52. <text class="title">发票抬头</text>
  53. <text class="value">{{ invoiceInfo.companyName }}</text>
  54. </view>
  55. <view class="invoice-info">
  56. <text class="title">纳税人识别号</text>
  57. <text>{{ invoiceInfo.taxNo }}</text>
  58. </view>
  59. <view class="invoice-info">
  60. <text class="title">地址详情</text>
  61. <text class="value">{{ invoiceInfo.address }} {{ invoiceInfo.phone }}</text>
  62. </view>
  63. <view class="invoice-info last">
  64. <text class="title">开户银行及账号</text>
  65. <text class="value">{{ invoiceInfo.openingBank }} {{ invoiceInfo.bankAccount }}</text>
  66. </view>
  67. </view>
  68. <view class="form-card">
  69. <view class="label">上传发票 <i class="text-bg"></i></view>
  70. <u-upload
  71. ref="uUpload"
  72. :action="action"
  73. :file-list="billList"
  74. @on-success="handleSuccess"
  75. @on-remove="handleRemove"
  76. @on-choose-complete="onChooseComplete"
  77. max-count="5"
  78. multiple
  79. previewFullImage
  80. :auto-upload="true"
  81. customBtn
  82. width="146rpx"
  83. height="146rpx"
  84. >
  85. <template slot="addBtn">
  86. <image src="/static/coupon/upload.png" mode="widthFix" style="width: 146rpx; height: 146rpx"></image>
  87. </template>
  88. </u-upload>
  89. </view>
  90. <view class="footer-bar">
  91. <u-button
  92. type="primary"
  93. :disabled="!withdrawalAmount || parseFloat(withdrawalAmount) <= 0 || isExceeded"
  94. @click="applyWithdrawal"
  95. >提现</u-button
  96. >
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import api from '@/api/account';
  102. import configService from '@/common/service/config.service';
  103. import { formatAmount } from '@/common/util/util';
  104. export default {
  105. data() {
  106. return {
  107. formatAmount,
  108. action: configService.apiUrl + '/sys/common/upload',
  109. imageHttp: configService.apiUrl + '/',
  110. billList: [], //发票回显
  111. uploadedFiles: [], //已上传文件列表
  112. bankCard: {},
  113. availableAmount: '', // 当前可提现余额
  114. handlingFee: 0, // 手续费
  115. withdrawalAmount: '', // 提现金额输入框的值
  116. isExceeded: false, // 是否超过可提现余额
  117. bankCardInfo: {}, // 银行卡信息
  118. invoiceInfo: {}, // 开票信息
  119. };
  120. },
  121. watch: {
  122. withdrawalAmount(newVal, oldVal) {
  123. // 检查金额是否超过可提现余额
  124. if (parseFloat(newVal) > parseFloat(this.availableAmount)) {
  125. this.isExceeded = true;
  126. } else {
  127. this.isExceeded = false;
  128. }
  129. },
  130. },
  131. onShow() {
  132. this.init();
  133. },
  134. formatAmount,
  135. methods: {
  136. // 初始化提现数据
  137. async init() {
  138. const res = await api.initWithdrawalData();
  139. if (res.data.code === 200 && res.data.result) {
  140. const data = res.data.result;
  141. this.availableAmount = data.availableAmount;
  142. this.handlingFee = data.handlingFee;
  143. this.bankCardInfo = data.bankCardInfo;
  144. this.invoiceInfo = data.invoiceInfo;
  145. }
  146. },
  147. handleInput(val) {
  148. if (!val) {
  149. this.withdrawalAmount = '';
  150. return;
  151. }
  152. /// 保留2位小数
  153. val = val.replace(/(\.\d{2})\d+/g, '$1');
  154. // 处理前导0
  155. val = val.replace(/^0+(?=\d)/, '');
  156. this.$nextTick(() => {
  157. this.withdrawalAmount = val;
  158. });
  159. },
  160. // 上传发票
  161. handleSuccess(res) {
  162. if (res.code === 0) {
  163. this.uploadedFiles.push(this.imageHttp + res.message);
  164. console.log(this.uploadedFiles);
  165. } else {
  166. uni.showToast({
  167. title: '上传失败: ' + res.message,
  168. icon: 'none',
  169. });
  170. }
  171. },
  172. // 移除图片
  173. handleRemove(index) {
  174. this.uploadedFiles.splice(index, 1);
  175. },
  176. // 选择图片
  177. onChooseComplete(lists) {
  178. this.billList = lists;
  179. },
  180. // 全部提现
  181. allWithdraw() {
  182. this.withdrawalAmount = this.availableAmount;
  183. },
  184. // 申请提现
  185. applyWithdrawal() {
  186. // if (!this.uploadedFiles.length) {
  187. // uni.showToast({
  188. // title: '请上传发票',
  189. // icon: 'none',
  190. // });
  191. // return;
  192. // }
  193. uni.showLoading({ title: '提交中' });
  194. api
  195. .applyWithdrawal({
  196. applyAmount: this.withdrawalAmount,
  197. bankCardId: this.bankCardInfo.bankCardId,
  198. handlingFee: this.handlingFee,
  199. invoiceImgs: this.uploadedFiles,
  200. })
  201. .then((res) => {
  202. if (res.data.code === 200) {
  203. uni.hideLoading();
  204. uni.showToast({ title: '提现申请成功', icon: 'success' });
  205. setTimeout(() => {
  206. uni.navigateTo({
  207. url: '/pages/finance/submitted',
  208. });
  209. }, 1500);
  210. } else {
  211. uni.hideLoading();
  212. uni.showToast({ title: res.data.message, icon: 'none' });
  213. }
  214. });
  215. },
  216. back() {
  217. uni.navigateBack({
  218. delta: 1,
  219. });
  220. },
  221. },
  222. };
  223. </script>
  224. <style lang="scss" scoped>
  225. .container {
  226. min-height: 100vh;
  227. background-color: #f7f8fc;
  228. font-family: Source Han Sans SC;
  229. font-weight: 400;
  230. padding-bottom: 120rpx;
  231. .fix {
  232. position: sticky;
  233. top: 0;
  234. z-index: 999;
  235. /*#ifdef APP-PLUS*/
  236. .top {
  237. width: 100%;
  238. height: var(--status-bar-height);
  239. background: #fff;
  240. }
  241. /*#endif*/
  242. .head {
  243. width: 100%;
  244. height: 112rpx;
  245. padding: 20rpx;
  246. display: flex;
  247. align-items: center;
  248. background: #fff;
  249. position: relative;
  250. border-bottom: 1rpx solid #eeeeee;
  251. .cuIcon-back {
  252. font-size: 40rpx;
  253. margin-right: 40rpx;
  254. }
  255. .case {
  256. position: absolute;
  257. left: 50%;
  258. transform: translateX(-50%);
  259. font-weight: 500;
  260. font-size: 38rpx;
  261. color: #333333;
  262. }
  263. }
  264. }
  265. .form-card {
  266. background-color: #fff;
  267. padding: 30rpx;
  268. margin-bottom: 30rpx;
  269. padding: 17rpx 31rpx 21rpx;
  270. box-shadow: 0rpx 2rpx 8rpx 0rpx rgba(214, 225, 237, 0.1);
  271. .label {
  272. font-size: 30rpx;
  273. color: #333333;
  274. margin-bottom: 21rpx;
  275. .text-bg {
  276. width: 120rpx;
  277. }
  278. }
  279. }
  280. }
  281. // 提现至:银行卡选择区域
  282. .section-item {
  283. display: flex;
  284. align-items: center;
  285. justify-content: space-between;
  286. padding: 30rpx 0;
  287. border-bottom: 1rpx solid #eee;
  288. .label {
  289. font-weight: 500;
  290. font-size: 31rpx;
  291. color: #333333;
  292. }
  293. .content {
  294. display: flex;
  295. align-items: center;
  296. }
  297. }
  298. // 提现金额输入区域
  299. .section-input {
  300. .input-row {
  301. display: flex;
  302. align-items: center;
  303. padding: 20rpx 0;
  304. border-bottom: 1rpx solid #eee;
  305. .currency-symbol {
  306. font-weight: bold;
  307. font-size: 54rpx;
  308. color: #333333;
  309. padding-right: 23rpx;
  310. }
  311. }
  312. .error {
  313. text-align: right;
  314. font-size: 25rpx;
  315. color: #e55e4f;
  316. }
  317. .balance-info {
  318. font-size: 26rpx;
  319. color: rgba(51, 51, 51, 0.6);
  320. margin-top: 16rpx;
  321. font-family: Source Han Sans CN;
  322. .all-withdraw-btn {
  323. font-size: 27rpx;
  324. color: #2d4d89;
  325. margin-left: 10rpx;
  326. &:active {
  327. opacity: 0.8;
  328. }
  329. }
  330. }
  331. }
  332. // 银行信息
  333. .bank-info {
  334. display: flex;
  335. justify-content: space-between;
  336. align-items: center;
  337. margin-top: 44rpx;
  338. .bank-label {
  339. font-size: 29rpx;
  340. color: #666666;
  341. }
  342. .bank-number {
  343. padding: 0 0 5rpx 2rpx;
  344. font-size: 31rpx;
  345. color: #333333;
  346. }
  347. }
  348. // 开票信息区域
  349. .note {
  350. font-size: 27rpx;
  351. color: #999999;
  352. margin-bottom: 26rpx;
  353. }
  354. .invoice-info {
  355. padding: 21rpx 0;
  356. display: flex;
  357. justify-content: space-between;
  358. border-bottom: 1rpx solid #eeeeee;
  359. .title {
  360. font-size: 29rpx;
  361. color: #666666;
  362. }
  363. .value {
  364. font-size: 31rpx;
  365. color: #333333;
  366. max-width: 450rpx;
  367. text-align: right;
  368. }
  369. }
  370. .last {
  371. border-bottom: none;
  372. }
  373. // 底部按钮
  374. .footer-bar {
  375. z-index: 999;
  376. ::v-deep .u-btn {
  377. width: 100%;
  378. height: 76rpx;
  379. border-radius: 54rpx;
  380. background: linear-gradient(90deg, #77b6ff 0%, #449aff 100%);
  381. &.u-btn--primary--disabled {
  382. background: #a0cfff;
  383. }
  384. }
  385. }
  386. ::v-deep {
  387. .u-delete-icon {
  388. background-color: rgba(0, 0, 0, 0.6) !important;
  389. }
  390. }
  391. </style>