cashApply.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <div class="cash-apply-page">
  3. <!-- 头部 -->
  4. <div class="header">
  5. <el-button class="back-btn" @click="goBack"> 返回 </el-button>
  6. <h2 class="title">提现申请</h2>
  7. </div>
  8. <!-- 内容区域 -->
  9. <div class="content">
  10. <!-- 可提现金额 -->
  11. <div class="section">
  12. <div class="section-title">可提现金额</div>
  13. <div class="available-amount">¥{{ formatCurrency(availableAmount) }}</div>
  14. </div>
  15. <!-- 提现金额输入 -->
  16. <div class="section">
  17. <div class="section-title">提现金额</div>
  18. <div class="amount-input-wrapper">
  19. <el-input
  20. v-model="withdrawAmount"
  21. placeholder="请输入提现金额"
  22. class="amount-input"
  23. type="number"
  24. :min="0.01"
  25. :max="availableAmount"
  26. @input="handleAmountInput"
  27. />
  28. <el-button type="primary" class="withdraw-all-btn" @click="handleWithdrawAll"> 全部提现 </el-button>
  29. </div>
  30. <div class="min-amount-tip">最低提现金额为0.1元</div>
  31. </div>
  32. <!-- 提现账户 -->
  33. <div class="section">
  34. <div class="section-title">提现账户</div>
  35. <div class="account-list">
  36. <div class="account-item">
  37. <div class="account-left">
  38. <img :src="zfbIcon" alt="" class="account-icon" />
  39. <div class="account-info">
  40. <div class="account-name">
  41. {{ userInfo.name }}
  42. </div>
  43. <div class="account-number">
  44. {{ userInfo.alipayAccount }}
  45. </div>
  46. </div>
  47. </div>
  48. <div class="account-right">
  49. <div class="selected-indicator" />
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <!-- 底部按钮 -->
  55. <div class="footer">
  56. <el-button type="primary" class="submit-btn" @click="handleSubmit"> 提交申请 </el-button>
  57. </div>
  58. </div>
  59. <!-- 确认对话框 -->
  60. <el-dialog
  61. v-model="cashDialogVisible"
  62. title="提现金额域账户确认"
  63. width="500px"
  64. :close-on-click-modal="false"
  65. class="confirm-dialog"
  66. >
  67. <div class="confirm-content">
  68. <div class="confirm-item">
  69. <span class="confirm-label">提现金额:</span>
  70. <span class="confirm-value">¥ {{ withdrawAmount || "0" }}</span>
  71. </div>
  72. <div class="confirm-item">
  73. <span class="confirm-label">提现账户:</span>
  74. <span class="confirm-value">支付宝账户 ({{ userInfo.alipayAccount }})</span>
  75. </div>
  76. <div class="password-section">
  77. <div class="password-label">请输入提现密码</div>
  78. <el-input
  79. v-model="withdrawPassword"
  80. type="password"
  81. placeholder="请输入6位提现密码"
  82. maxlength="6"
  83. show-password
  84. class="password-input"
  85. @input="handlePasswordInput"
  86. />
  87. </div>
  88. </div>
  89. <template #footer>
  90. <div class="dialog-footer">
  91. <el-button class="dialog-cancel-btn" @click="handleCancelConfirm"> 取消 </el-button>
  92. <el-button type="primary" class="dialog-confirm-btn" @click="handleConfirmSubmit"> 确认 </el-button>
  93. </div>
  94. </template>
  95. </el-dialog>
  96. </div>
  97. </template>
  98. <script setup lang="ts">
  99. import { ref, onMounted } from "vue";
  100. import { useRouter } from "vue-router";
  101. import { ElMessage } from "element-plus";
  102. import { getAccountBalance, cashOut } from "@/api/modules/homeEntry";
  103. import zfbIcon from "@/assets/financial/zfb-icon.png";
  104. import { localGet } from "@/utils";
  105. const userInfo = localGet("geeker-user").userInfo;
  106. const router = useRouter();
  107. const cashDialogVisible = ref(false);
  108. const withdrawPassword = ref("");
  109. // 提现金额
  110. const withdrawAmount = ref();
  111. // 密码输入处理(只允许数字)
  112. const handlePasswordInput = (value: string) => {
  113. withdrawPassword.value = value.replace(/\D/g, "");
  114. };
  115. // 取消确认
  116. const handleCancelConfirm = () => {
  117. cashDialogVisible.value = false;
  118. withdrawPassword.value = "";
  119. };
  120. const handleConfirmSubmit = async () => {
  121. const res: any = await cashOut({
  122. storeId: userInfo.storeId,
  123. payPassword: withdrawPassword.value,
  124. withdrawalMoney: withdrawAmount.value * 100
  125. });
  126. if (res.code == 200) {
  127. ElMessage.success("提现申请已发起成功,请耐心等待");
  128. cashDialogVisible.value = false;
  129. fetchAccountBalance();
  130. } else {
  131. ElMessage.error(res.message);
  132. }
  133. };
  134. // 可提现金额
  135. const availableAmount = ref<number>(0);
  136. // 选中的账户ID
  137. const selectedAccountId = ref<number>(1);
  138. // 返回
  139. const goBack = () => {
  140. router.back();
  141. };
  142. // 格式化金额
  143. const formatCurrency = (value: number) => {
  144. return value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
  145. };
  146. // 全部提现
  147. const handleWithdrawAll = () => {
  148. withdrawAmount.value = availableAmount.value.toString();
  149. };
  150. // 金额输入处理
  151. const handleAmountInput = (value: string) => {
  152. const numValue = parseFloat(value);
  153. if (isNaN(numValue) || numValue < 0) {
  154. withdrawAmount.value = "";
  155. return;
  156. }
  157. if (numValue > availableAmount.value) {
  158. withdrawAmount.value = availableAmount.value.toString();
  159. ElMessage.warning("提现金额不能超过可提现金额");
  160. }
  161. };
  162. // 选择账户
  163. const selectAccount = (id: number) => {
  164. selectedAccountId.value = id;
  165. };
  166. // 提交申请
  167. const handleSubmit = () => {
  168. const amount = parseFloat(withdrawAmount.value);
  169. // 验证提现金额
  170. if (!withdrawAmount.value || isNaN(amount) || amount <= 0) {
  171. ElMessage.warning("请输入提现金额");
  172. return;
  173. }
  174. if (amount < 0.01) {
  175. ElMessage.warning("最低提现金额为0.01元");
  176. return;
  177. }
  178. if (amount > availableAmount.value) {
  179. ElMessage.warning("提现金额不能超过可提现金额");
  180. return;
  181. }
  182. // 验证账户
  183. if (!selectedAccountId.value) {
  184. ElMessage.warning("请选择提现账户");
  185. return;
  186. }
  187. cashDialogVisible.value = true;
  188. };
  189. // 获取可提现金额
  190. const fetchAccountBalance = async () => {
  191. let param = {
  192. storeId: userInfo.storeId
  193. };
  194. const res: any = await getAccountBalance(param as any);
  195. if (res.code == 200 && res.data) {
  196. availableAmount.value = res.data.cashOutMoney;
  197. // 根据实际API返回的数据结构更新
  198. // availableAmount.value = res.data.availableAmount || res.data.amount || 586;
  199. }
  200. };
  201. onMounted(() => {
  202. fetchAccountBalance();
  203. });
  204. </script>
  205. <style scoped lang="scss">
  206. .cash-apply-page {
  207. display: flex;
  208. flex-direction: column;
  209. width: 100%;
  210. min-height: 100vh;
  211. background-color: #ffffff;
  212. }
  213. .header {
  214. position: relative;
  215. display: flex;
  216. align-items: center;
  217. padding: 20px;
  218. border-bottom: 1px solid #e4e7ed;
  219. .back-btn {
  220. padding: 8px 16px;
  221. font-size: 14px;
  222. color: #606266;
  223. background-color: #f5f7fa;
  224. border: 1px solid #dcdfe6;
  225. border-radius: 4px;
  226. &:hover {
  227. color: #409eff;
  228. background-color: #ecf5ff;
  229. border-color: #b3d8ff;
  230. }
  231. }
  232. .title {
  233. position: absolute;
  234. left: 50%;
  235. margin: 0;
  236. font-size: 18px;
  237. font-weight: bold;
  238. color: #333333;
  239. transform: translateX(-50%);
  240. }
  241. }
  242. .content {
  243. display: flex;
  244. flex: 1;
  245. flex-direction: column;
  246. gap: 32px;
  247. padding: 24px 20px;
  248. }
  249. .section {
  250. display: flex;
  251. flex-direction: column;
  252. gap: 12px;
  253. .section-title {
  254. font-size: 16px;
  255. font-weight: 500;
  256. color: #333333;
  257. }
  258. }
  259. .available-amount {
  260. margin-top: 8px;
  261. font-size: 36px;
  262. font-weight: 600;
  263. color: #333333;
  264. }
  265. .amount-input-wrapper {
  266. display: flex;
  267. gap: 12px;
  268. align-items: center;
  269. .amount-input {
  270. flex: 1;
  271. :deep(.el-input__wrapper) {
  272. padding: 12px 16px;
  273. border-radius: 4px;
  274. }
  275. }
  276. .withdraw-all-btn {
  277. padding: 12px 20px;
  278. white-space: nowrap;
  279. background-color: #7f9dff;
  280. border: none;
  281. border-radius: 4px;
  282. }
  283. }
  284. .min-amount-tip {
  285. margin-top: 4px;
  286. font-size: 12px;
  287. color: #909399;
  288. }
  289. .account-list {
  290. display: flex;
  291. flex-direction: column;
  292. gap: 12px;
  293. margin-top: 8px;
  294. }
  295. .account-item {
  296. display: flex;
  297. align-items: center;
  298. justify-content: space-between;
  299. padding: 16px;
  300. cursor: pointer;
  301. background-color: #ffffff;
  302. border: 1px solid #dcdfe6;
  303. border-radius: 8px;
  304. transition: all 0.3s;
  305. &:hover {
  306. border-color: #7f9dff;
  307. }
  308. &.active {
  309. background-color: #ecf5ff;
  310. border-color: #7f9dff;
  311. }
  312. .account-left {
  313. display: flex;
  314. flex: 1;
  315. gap: 12px;
  316. align-items: center;
  317. .account-icon {
  318. width: 40px;
  319. height: 40px;
  320. object-fit: contain;
  321. }
  322. .account-info {
  323. display: flex;
  324. flex-direction: column;
  325. gap: 4px;
  326. .account-name {
  327. font-size: 16px;
  328. font-weight: 500;
  329. color: #333333;
  330. }
  331. .account-number {
  332. font-size: 14px;
  333. color: #909399;
  334. }
  335. }
  336. }
  337. .account-right {
  338. display: flex;
  339. align-items: center;
  340. justify-content: center;
  341. width: 24px;
  342. height: 24px;
  343. .selected-indicator {
  344. width: 16px;
  345. height: 16px;
  346. background-color: #7f9dff;
  347. border: 3px solid #ffffff;
  348. border-radius: 50%;
  349. box-shadow: 0 0 0 2px #7f9dff;
  350. }
  351. }
  352. }
  353. .footer {
  354. display: flex;
  355. justify-content: center;
  356. margin-top: 100px;
  357. .cancel-btn {
  358. padding: 20px;
  359. font-size: 16px;
  360. color: #606266;
  361. background-color: #f5f7fa;
  362. border: 1px solid #dcdfe6;
  363. border-radius: 4px;
  364. }
  365. .submit-btn {
  366. padding: 20px;
  367. font-size: 16px;
  368. color: #ffffff;
  369. background-color: #7f9dff;
  370. border: none;
  371. border-radius: 4px;
  372. }
  373. }
  374. :deep(.confirm-dialog) {
  375. .el-dialog__header {
  376. padding: 20px 24px;
  377. border-bottom: 1px solid #e4e7ed;
  378. }
  379. .el-dialog__title {
  380. font-size: 18px;
  381. font-weight: 600;
  382. color: #333333;
  383. }
  384. .el-dialog__body {
  385. padding: 24px;
  386. }
  387. }
  388. .confirm-content {
  389. display: flex;
  390. flex-direction: column;
  391. gap: 20px;
  392. .confirm-item {
  393. display: flex;
  394. gap: 12px;
  395. align-items: center;
  396. font-size: 14px;
  397. .confirm-label {
  398. min-width: 80px;
  399. font-weight: 500;
  400. color: #606266;
  401. }
  402. .confirm-value {
  403. font-weight: 500;
  404. color: #333333;
  405. }
  406. }
  407. .password-section {
  408. display: flex;
  409. flex-direction: column;
  410. gap: 12px;
  411. margin-top: 8px;
  412. .password-label {
  413. font-size: 14px;
  414. font-weight: 500;
  415. color: #606266;
  416. }
  417. .password-input {
  418. :deep(.el-input__wrapper) {
  419. padding: 12px 16px;
  420. border-radius: 4px;
  421. }
  422. }
  423. }
  424. }
  425. </style>