index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <div class="finance-page">
  3. <!-- 今日收益 -->
  4. <el-card class="summary-card" shadow="hover">
  5. <div class="card-img">
  6. <div class="summary-header">
  7. <span class="title">今日收益</span>
  8. <el-tooltip content="今日收益=今日已核销到账金额-技术服务费" placement="top">
  9. <el-icon class="question-icon">
  10. <QuestionFilled />
  11. </el-icon>
  12. </el-tooltip>
  13. <el-icon class="right-icon" @click="handleTodayIncomeList">
  14. <ArrowRight />
  15. </el-icon>
  16. </div>
  17. <div class="summary-body">
  18. <el-image :src="gold" class="gold" />
  19. <div class="summary-amount">
  20. <span class="currency">¥</span>
  21. <span class="amount">{{ todayIncome }}</span>
  22. <span class="unit">元</span>
  23. </div>
  24. </div>
  25. </div>
  26. </el-card>
  27. <!-- 统计信息 -->
  28. <div class="stat-cards">
  29. <el-card v-for="stat in stats" :key="stat.key" class="stat-card" shadow="hover">
  30. <div class="stat-header">
  31. <span class="stat-title">{{ stat.title }}</span>
  32. <el-tooltip :content="stat.tooltip" placement="top" v-if="stat.tooltip">
  33. <el-icon class="question-icon" style="color: #7f9dff">
  34. <QuestionFilled />
  35. </el-icon>
  36. </el-tooltip>
  37. </div>
  38. <div class="stat-amount">
  39. {{ stat.amount }}
  40. </div>
  41. <!----:disabled="stat.key === 'withdraw' && isWithdrawDisabled(stat.amount)"-->
  42. <el-button type="primary" class="stat-btn" @click="handleAction(stat.key)">
  43. {{ stat.buttonText }}
  44. </el-button>
  45. </el-card>
  46. </div>
  47. <!-- 重置按钮 -->
  48. <!-- <el-card class="reset-card" shadow="hover">
  49. <div class="reset-content">
  50. <div class="reset-info">
  51. <h3 class="reset-title">重置到刚注册状态</h3>
  52. <p class="reset-desc">
  53. 此操作将删除所有入住申请数据、订单、优惠券、验券、消息等相关数据,恢复到刚注册时的初始状态。此操作不可恢复,请谨慎操作!
  54. </p>
  55. </div>
  56. <el-button type="danger" class="reset-btn" @click="handleResetToInitialStatus" :loading="resetLoading">
  57. 重置到刚注册状态
  58. </el-button>
  59. </div>
  60. </el-card> -->
  61. </div>
  62. </template>
  63. <script setup lang="ts">
  64. import { ref, reactive, watch, onMounted, nextTick } from "vue";
  65. import { QuestionFilled, ArrowRight } from "@element-plus/icons-vue";
  66. import gold from "../../assets/financial/gold.png";
  67. import {
  68. getAccountBalance,
  69. getTodayIncome,
  70. getPaymentCycle,
  71. checkPayPassword,
  72. resetToInitialStatus
  73. } from "@/api/modules/homeEntry";
  74. import { localGet } from "@/utils/index";
  75. import { useRouter } from "vue-router";
  76. import { ElMessage, ElMessageBox } from "element-plus";
  77. import en from "@/languages/modules/en";
  78. import { pa } from "element-plus/es/locale";
  79. const router = useRouter();
  80. const userInfo = localGet("geeker-user")?.userInfo || {};
  81. onMounted(() => {
  82. fetchGetTodayIncome();
  83. fetchAccountBalance();
  84. fetchGetPaymentCycle0();
  85. fetchGetPaymentCycle1();
  86. });
  87. const stats = reactive([
  88. {
  89. key: "withdraw",
  90. title: "可提现金额",
  91. amount: "",
  92. buttonText: "提现",
  93. tooltip: "收益产生后3天可提现,28天自动付收益产生日期+3个自然日可提现,若未提现,则按收益产生日期+28个自然日自动付"
  94. },
  95. { key: "settled", title: "已到账期金额", amount: "", buttonText: "查看", tooltip: "已到达可提现时间的金额总额" },
  96. {
  97. key: "pending",
  98. title: "未到账期金额",
  99. amount: "",
  100. buttonText: "查看",
  101. tooltip: "未到达可提现时间的账单,您需要等待账单到达结算周期后发起提现"
  102. }
  103. ]);
  104. const handleTodayIncomeList = async () => {
  105. router.push({ path: "/financialManagement/todayIncomeList" });
  106. };
  107. console.log(stats[0].amount);
  108. //已到账/未到账金额 paymentType 未到传0 已到传1
  109. const fetchGetPaymentCycle0 = async () => {
  110. let param = {
  111. storeId: userInfo.storeId,
  112. startTime: null,
  113. endTime: null,
  114. paymentType: 0, //未到
  115. incomeType: 0,
  116. pageNum: 1,
  117. pageSize: 999999
  118. };
  119. const res: any = await getPaymentCycle(param as any);
  120. if (res.code == 200) {
  121. nextTick(() => {
  122. stats[2].amount = res.data.money;
  123. });
  124. }
  125. };
  126. const fetchGetPaymentCycle1 = async () => {
  127. let param = {
  128. storeId: userInfo.storeId,
  129. startTime: null,
  130. endTime: null,
  131. paymentType: 1,
  132. incomeType: 1,
  133. pageNum: 1,
  134. pageSize: 999999
  135. };
  136. const res: any = await getPaymentCycle(param as any);
  137. if (res.code == 200) {
  138. nextTick(() => {
  139. stats[1].amount = res.data.money;
  140. });
  141. }
  142. };
  143. //可提现金额
  144. const fetchAccountBalance = async () => {
  145. let param = {
  146. storeId: userInfo.storeId
  147. };
  148. const res: any = await getAccountBalance(param as any);
  149. if (res.code == 200) {
  150. nextTick(() => {
  151. stats[0].amount = res.data.cashOutMoney; //cashOutMoney 可提现金额减未审核通过的金额
  152. });
  153. }
  154. };
  155. //今日收益
  156. const todayIncome = ref("");
  157. const fetchGetTodayIncome = async () => {
  158. let param = {
  159. storeId: userInfo.storeId
  160. };
  161. const res: any = await getTodayIncome(param as any);
  162. if (res.code == 200) {
  163. todayIncome.value = res.data;
  164. }
  165. };
  166. // 判断提现按钮是否禁用
  167. // const isWithdrawDisabled = (amount: any): boolean => {
  168. // if (!amount && amount !== 0) return true; // 金额为空或undefined
  169. // const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
  170. // return numAmount === 0 || isNaN(numAmount);
  171. // };
  172. const handleAction = async (key: string) => {
  173. if (key == "withdraw") {
  174. // 获取可提现金额
  175. const withdrawAmount = stats[0].amount;
  176. // 转换为数字类型
  177. const numAmount = typeof withdrawAmount === "string" ? parseFloat(withdrawAmount) : Number(withdrawAmount);
  178. // 校验金额是否小于0.1
  179. if (isNaN(numAmount) || numAmount < 0.1) {
  180. // 格式化金额显示
  181. const formattedAmount = isNaN(numAmount) ? "0.00" : numAmount.toFixed(2);
  182. ElMessage.warning(`可提现金额不足,最低提现金额为0.1元,当前可提现金额为¥${formattedAmount}元`);
  183. return;
  184. }
  185. // 金额校验通过,继续原有逻辑
  186. if (userInfo.alipayAccount != null && userInfo.payPassword != null) {
  187. router.push({ path: "/financialManagement/cashApply" });
  188. } else {
  189. router.push({ path: "/financialManagement/realName" });
  190. }
  191. }
  192. if (key == "settled") {
  193. router.push({ path: "/financialManagement/reconciled" });
  194. }
  195. if (key == "pending") {
  196. router.push({ path: "/financialManagement/unposted" });
  197. }
  198. };
  199. // 重置到刚注册状态
  200. // const resetLoading = ref(false);
  201. // const handleResetToInitialStatus = async () => {
  202. // try {
  203. // // 二次确认
  204. // await ElMessageBox.confirm(
  205. // "此操作将删除所有入住申请数据、订单、优惠券、验券、消息等相关数据,恢复到刚注册时的初始状态。此操作不可恢复,是否继续?",
  206. // "确认重置",
  207. // {
  208. // confirmButtonText: "确定",
  209. // cancelButtonText: "取消",
  210. // type: "warning",
  211. // dangerouslyUseHTMLString: false
  212. // }
  213. // );
  214. // resetLoading.value = true;
  215. // const res: any = await resetToInitialStatus();
  216. // if (res.code === 200 && res.success) {
  217. // ElMessage.success(res.msg || "重置成功,已退回到刚注册状态");
  218. // // 刷新页面数据或跳转到注册成功页面
  219. // setTimeout(() => {
  220. // // 可以跳转到注册成功页面或刷新当前页面
  221. // // router.push({ path: '/register-success' });
  222. // window.location.reload();
  223. // }, 1500);
  224. // } else {
  225. // ElMessage.error(res.msg || "重置失败,请稍后重试");
  226. // }
  227. // } catch (error: any) {
  228. // // 用户取消操作
  229. // if (error === "cancel") {
  230. // return;
  231. // }
  232. // console.error("重置失败:", error);
  233. // ElMessage.error(error?.response?.data?.msg || error?.message || "重置失败,请稍后重试");
  234. // } finally {
  235. // resetLoading.value = false;
  236. // }
  237. // };
  238. </script>
  239. <style scoped lang="scss">
  240. .finance-page {
  241. display: flex;
  242. flex-direction: column;
  243. gap: 20px;
  244. min-height: calc(100vh - 100px);
  245. }
  246. .summary-card {
  247. position: relative;
  248. width: 100%;
  249. overflow: hidden;
  250. border: none;
  251. border-radius: 16px;
  252. .card-img {
  253. width: 100%;
  254. height: 214px;
  255. background: url("../../assets/financial/financeBg.png") no-repeat;
  256. background-position: right;
  257. background-size: contain;
  258. }
  259. .summary-header {
  260. display: flex;
  261. gap: 8px;
  262. align-items: center;
  263. margin-bottom: 12px;
  264. font-size: 16px;
  265. color: #333333;
  266. .question-icon {
  267. color: #7293f8;
  268. cursor: pointer;
  269. }
  270. .right-icon {
  271. margin-left: 30px;
  272. font-weight: bold;
  273. color: #7293f8;
  274. cursor: pointer;
  275. }
  276. }
  277. .summary-body {
  278. display: flex;
  279. gap: 24px;
  280. align-items: center;
  281. justify-content: center;
  282. width: 757px;
  283. height: 140px;
  284. padding: 12px 0;
  285. margin: auto;
  286. font-weight: 600;
  287. background: #6c8ff8;
  288. border-radius: 74px;
  289. box-shadow: 0 5px 0 0 #355ac8;
  290. }
  291. .summary-amount {
  292. display: flex;
  293. gap: 8px;
  294. align-items: baseline;
  295. font-weight: 600;
  296. .currency {
  297. padding: 8px 16px;
  298. font-size: 80px;
  299. color: #ffffff;
  300. border-radius: 999px 0 0 999px;
  301. }
  302. .amount {
  303. font-size: 80px;
  304. color: #ffffff;
  305. }
  306. .unit {
  307. font-size: 16px;
  308. color: #ffffff;
  309. }
  310. }
  311. }
  312. .stat-cards {
  313. display: grid;
  314. grid-template-columns: repeat(3, 1fr);
  315. gap: 16px;
  316. .stat-card {
  317. padding: 16px;
  318. text-align: center;
  319. border: none;
  320. border-radius: 12px;
  321. .stat-header {
  322. display: inline-flex;
  323. gap: 6px;
  324. align-items: center;
  325. margin-bottom: 16px;
  326. font-size: 16px;
  327. color: #222222;
  328. }
  329. .stat-amount {
  330. margin-bottom: 20px;
  331. font-size: 32px;
  332. font-weight: 600;
  333. color: #222222;
  334. }
  335. .stat-btn {
  336. width: 120px;
  337. background: #7f9dff;
  338. border: none;
  339. border-radius: 6px;
  340. &:disabled {
  341. color: #ffffff;
  342. cursor: not-allowed;
  343. background: #c0c4cc;
  344. border-color: #c0c4cc;
  345. }
  346. }
  347. }
  348. }
  349. @media (width <= 1024px) {
  350. .stat-cards {
  351. grid-template-columns: repeat(1, 1fr);
  352. }
  353. }
  354. .reset-card {
  355. width: 100%;
  356. border: none;
  357. border-radius: 12px;
  358. .reset-content {
  359. display: flex;
  360. align-items: center;
  361. justify-content: space-between;
  362. padding: 20px;
  363. .reset-info {
  364. flex: 1;
  365. .reset-title {
  366. margin: 0 0 8px;
  367. font-size: 18px;
  368. font-weight: 600;
  369. color: #222222;
  370. }
  371. .reset-desc {
  372. margin: 0;
  373. font-size: 14px;
  374. line-height: 1.6;
  375. color: #666666;
  376. }
  377. }
  378. .reset-btn {
  379. padding: 12px 32px;
  380. margin-left: 24px;
  381. font-size: 16px;
  382. }
  383. }
  384. }
  385. @media (width <= 768px) {
  386. .reset-card {
  387. .reset-content {
  388. flex-direction: column;
  389. gap: 16px;
  390. align-items: flex-start;
  391. .reset-btn {
  392. width: 100%;
  393. margin-left: 0;
  394. }
  395. }
  396. }
  397. }
  398. </style>