balance.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <!--
  2. * @Author: wangwei
  3. * @Date: 2020-12-29 16:05:36
  4. * @LastEditTime: 2021-01-08 14:.gitignore:44
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 我的余额
  7. * @FilePath: /java-pc/src/views/member/Header.vue
  8. -->
  9. <template>
  10. <div class="sld_my_balance">
  11. <MemberTitle :memberTitle="L['我的余额']"></MemberTitle>
  12. <div class="top_info flex_row_center_center">
  13. <div class="total flex_column_between_start">
  14. <span class="title">{{ L["总金额"] }}(元):</span>
  15. <div class="red flex_row_center_center">
  16. <span class="">{{
  17. Number(balance_info.data.rechargeSum)
  18. .toFixed(2)
  19. .toString()
  20. .split(".")[0]
  21. }}</span>
  22. <span class="fixed" v-if="Number(balance_info.data.rechargeSum) > 0">
  23. .{{
  24. Number(balance_info.data.rechargeSum)
  25. .toFixed(2)
  26. .toString()
  27. .split(".")[1]
  28. }}
  29. </span>
  30. </div>
  31. </div>
  32. <div class="total flex_column_between_start">
  33. <span class="title">{{ L["可用余额"] }}(元):</span>
  34. <div class="red flex_row_center_center">
  35. <span class="">{{
  36. Number(balance_info.data.balanceAvailable)
  37. .toFixed(2)
  38. .toString()
  39. .split(".")[0]
  40. }}</span>
  41. <span
  42. class="fixed"
  43. v-if="Number(balance_info.data.balanceAvailable) > 0"
  44. >
  45. .{{
  46. Number(balance_info.data.balanceAvailable)
  47. .toFixed(2)
  48. .toString()
  49. .split(".")[1]
  50. }}
  51. </span>
  52. </div>
  53. </div>
  54. <div class="btn_con flex_column_center_center">
  55. <span
  56. v-if="rechargeSetting == 1"
  57. class="recharge pointer"
  58. @click="toRecharge"
  59. >{{ L["充值"] }}</span
  60. >
  61. <span v-if="outputEnable" class="putout pointer" @click="toPutout"
  62. >提现</span
  63. >
  64. </div>
  65. </div>
  66. <div class="nav_list flex_row_start_center">
  67. <div
  68. :class="{
  69. item: true,
  70. active: current_type == 'balance',
  71. pointer: true,
  72. }"
  73. @click="change('balance')"
  74. >
  75. {{ L["余额明细"] }}
  76. </div>
  77. <div
  78. :class="{
  79. item: true,
  80. active: current_type == 'recharge',
  81. pointer: true,
  82. }"
  83. @click="change('recharge')"
  84. v-if="rechargeSetting == 1"
  85. >
  86. {{ L["充值明细"] }}
  87. </div>
  88. <div
  89. v-if="outputEnable"
  90. :class="{
  91. item: true,
  92. active: current_type == 'toPutout',
  93. pointer: true,
  94. }"
  95. @click="change('toPutout')"
  96. >
  97. 提现明细
  98. </div>
  99. </div>
  100. <!-- 余额明细列表 -->
  101. <div v-if="current_type == 'balance'" class="list_container">
  102. <div class="top_title flex_row_center_center">
  103. <div class="time flex_row_center_center">{{ L["交易日期"] }}</div>
  104. <div class="num flex_row_center_center">{{ L["收入/支出"] }}(元)</div>
  105. <div class="reason">{{ L["变动原因"] }}</div>
  106. </div>
  107. <div
  108. class="list_item flex_row_center_center"
  109. v-for="(balanceItem, index) in balance_list.data"
  110. :key="index"
  111. >
  112. <div class="time flex_row_center_center">
  113. {{ balanceItem.createTime }}
  114. </div>
  115. <div
  116. :class="{
  117. num: true,
  118. green: true,
  119. flex_row_center_center: true,
  120. red: balanceItem.state == 2,
  121. }"
  122. >
  123. {{ balanceItem.state == 1 ? "+" : "-" }}{{ balanceItem.changeValue }}
  124. </div>
  125. <div class="reason">{{ balanceItem.description }}</div>
  126. </div>
  127. <SldCommonEmpty
  128. tip="暂无余额明细~"
  129. totalHeight="587"
  130. totalWidth="1003"
  131. v-show="!balance_list.data.length"
  132. />
  133. </div>
  134. <!-- 充值明细 -->
  135. <div v-else-if="current_type == 'recharge'" class="list_container">
  136. <div class="top_title flex_row_center_center">
  137. <div class="time flex_row_center_center">{{ L["交易日期"] }}</div>
  138. <div class="num flex_row_center_center">{{ L["充值金额"] }}(元)</div>
  139. <div class="reason">{{ L["状态"] }}</div>
  140. </div>
  141. <div
  142. class="list_item flex_row_center_center"
  143. v-for="(rechargeItem, index) in recharge_list.data"
  144. :key="index"
  145. >
  146. <div class="time flex_row_center_center">
  147. {{ rechargeItem.createTime }}
  148. </div>
  149. <div class="num flex_row_center_center">
  150. {{ rechargeItem.payAmount }}
  151. </div>
  152. <div class="reason">{{ rechargeItem.payStateValue }}</div>
  153. </div>
  154. <SldCommonEmpty
  155. tip="暂无充值明细~"
  156. totalHeight="587"
  157. totalWidth="1003"
  158. v-show="!recharge_list.data.length"
  159. />
  160. </div>
  161. <!-- 提现明细 -->
  162. <div
  163. v-else-if="outputEnable && current_type == 'toPutout'"
  164. class="list_container"
  165. >
  166. <div class="top_title putout flex_row_center_center">
  167. <div class="sn">提现单号</div>
  168. <div class="time">申请时间</div>
  169. <div class="money">提现金额</div>
  170. <div class="extra">手续费</div>
  171. <div class="state">状态</div>
  172. <div class="reason">失败原因</div>
  173. <div class="operate">操作</div>
  174. </div>
  175. <div
  176. v-for="item in output_list.data"
  177. :key="item.cashId"
  178. class="list_item putout flex_row_center_center"
  179. >
  180. <div class="sn">{{ item.cashSn }}</div>
  181. <div class="time">{{ item.applyTime }}</div>
  182. <div class="money">¥{{ item.cashAmount.toFixed(2) }}</div>
  183. <div class="extra">¥{{ item.serviceFee.toFixed(2) }}</div>
  184. <div class="state">{{ item.stateValue }}</div>
  185. <div
  186. class="reason"
  187. :title="
  188. item.failReason && item.failReason.length > 9 ? item.failReason : ''
  189. "
  190. >
  191. {{ item.failReason || "--" }}
  192. </div>
  193. <div class="operate" @click="outputInfo(item.cashId)">
  194. <span>查看</span>
  195. </div>
  196. </div>
  197. <SldCommonEmpty
  198. tip="暂无提现明细~"
  199. totalHeight="587"
  200. totalWidth="1003"
  201. v-show="!output_list.data.length"
  202. />
  203. </div>
  204. <!-- 分页 start -->
  205. <div class="flex_row_end_center sld_pagination">
  206. <el-pagination
  207. @current-change="handleCurrentChange"
  208. :currentPage="pageData.current"
  209. :page-size="pageData.pageSize"
  210. layout="prev, pager, next, jumper"
  211. :total="pageData.total"
  212. :hide-on-single-page="true"
  213. >
  214. </el-pagination>
  215. </div>
  216. <!-- 分页 end -->
  217. <el-dialog
  218. title="提示"
  219. width="420px"
  220. v-model="modalVisible"
  221. @close="close_dialog"
  222. top="30vh"
  223. >
  224. <div class="dialog_desc">
  225. 您尚未设置支付密码,请设置支付密码后再进行后续操作。
  226. </div>
  227. <div class="dialog_btn flex_row_end_center">
  228. <div class="dialog_cancle" @click="close_dialog">取消</div>
  229. <div class="dialog_set" @click="set_dialog">去设置</div>
  230. </div>
  231. </el-dialog>
  232. <el-dialog
  233. title="输入支付密码"
  234. width="420px"
  235. v-model="pdVisible"
  236. @close="close_pd"
  237. top="30vh"
  238. >
  239. <div v-if="!passwordErr" class="dialog_desc2">
  240. 请输入支付密码以完成后续操作
  241. </div>
  242. <div v-else class="dialog_desc2 error">{{ passwordErr }}</div>
  243. <input
  244. type="password"
  245. v-model="password"
  246. class="dialog_input"
  247. placeholder="请输入平台支付密码"
  248. />
  249. <div class="dialog_btn flex_row_end_center">
  250. <div class="dialog_cancle" @click="close_pd">取消</div>
  251. <div class="dialog_set" @click="submit_dialog">确认</div>
  252. </div>
  253. </el-dialog>
  254. </div>
  255. </template>
  256. <script setup>
  257. import { ElMessage, ElPagination,ElDialog } from "element-plus";
  258. import { getCurrentInstance, onMounted, reactive, ref } from "vue";
  259. // import { lang_zn } from "@/assets/language/zh";
  260. import { getCurLanguage } from '@/composables/common.js';
  261. import { useFiltersStore } from "@/store/filter.js";
  262. const router = useRouter()
  263. const filtersStore = useFiltersStore();
  264. // const L = lang_zn;
  265. const L = getCurLanguage();
  266. definePageMeta({
  267. layout: "member",
  268. middleware: ["auth"],
  269. });
  270. const { proxy } = getCurrentInstance();
  271. const memberInfo = ref(filtersStore.getMemberInfo);
  272. const modalVisible = ref(false);
  273. const pdVisible = ref(false);
  274. const passwordErr = ref("");
  275. const password = ref("");
  276. const pageData = reactive({
  277. current: 1,
  278. pageSize: 20,
  279. total: 0,
  280. });
  281. const balance_list = reactive({ data: [] });
  282. const recharge_list = reactive({ data: [] });
  283. const balance_info = reactive({ data: {} });
  284. const output_list = reactive({ data: [] });
  285. const current_type = ref("balance"); //当前列表显示的数据类型
  286. const outputEnable = ref(true); //提现是否开启
  287. const getBalanceList = () => {
  288. //获取余额明细列表
  289. var param = {};
  290. param.state = 0;
  291. param.current = pageData.current;
  292. param.pageSize = pageData.pageSize;
  293. get("v3/member/front/balanceLog/list", param)
  294. .then((res) => {
  295. if (res.state == 200) {
  296. balance_list.data = res.data.list;
  297. balance_list.data.map(
  298. (item) => (item.changeValue = new Number(item.changeValue).toFixed(2))
  299. );
  300. pageData.total = res.data.pagination.total;
  301. } else {
  302. ElMessage(res.msg);
  303. }
  304. })
  305. .catch(() => {
  306. //异常处理
  307. });
  308. };
  309. const getRechargeList = () => {
  310. //获取充值明细列表
  311. var param = {};
  312. param.current = pageData.current;
  313. param.pageSize = pageData.pageSize;
  314. get("v3/member/front/balanceRecharge/list", param)
  315. .then((res) => {
  316. if (res.state == 200) {
  317. recharge_list.data = res.data.list;
  318. recharge_list.data.map(
  319. (item) => (item.payAmount = new Number(item.payAmount).toFixed(2))
  320. );
  321. pageData.total = res.data.pagination.total;
  322. } else {
  323. ElMessage(res.msg);
  324. }
  325. })
  326. .catch(() => {
  327. //异常处理
  328. });
  329. };
  330. const getBalanceinfo = () => {
  331. //获取余额信息
  332. get("v3/member/front/balanceRecharge/getMemberBalance")
  333. .then((res) => {
  334. if (res.state == 200) {
  335. balance_info.data = res.data;
  336. } else {
  337. ElMessage(res.msg);
  338. }
  339. })
  340. .catch(() => {
  341. //异常处理
  342. });
  343. };
  344. const getOutputList = () => {
  345. //获取提现明细
  346. var param = {};
  347. param.current = pageData.current;
  348. param.pageSize = pageData.pageSize;
  349. get("v3/member/front/member/cash/log/list", param)
  350. .then((res) => {
  351. if (res.state == 200) {
  352. output_list.data = res.data.list;
  353. pageData.total = res.data.pagination.total;
  354. } else {
  355. ElMessage(res.msg);
  356. }
  357. })
  358. .catch(() => {
  359. //异常处理
  360. });
  361. };
  362. const initList = () => {
  363. if (current_type.value == "balance") {
  364. getBalanceList();
  365. } else if (current_type.value == "recharge") {
  366. getRechargeList();
  367. } else {
  368. getOutputList();
  369. }
  370. };
  371. //切换
  372. const change = (type) => {
  373. pageData.current = 1;
  374. current_type.value = type;
  375. initList();
  376. };
  377. //向前翻页
  378. const handlePrevCilickChange = () => {
  379. pageData.current--;
  380. initList();
  381. };
  382. //向后翻页
  383. const handleNextCilickChange = () => {
  384. pageData.current++;
  385. initList();
  386. };
  387. //页数改变
  388. const handleCurrentChange = (current) => {
  389. pageData.current = current;
  390. initList();
  391. };
  392. //去充值
  393. const toRecharge = () => {
  394. router.push({
  395. path: "/member/recharge",
  396. });
  397. };
  398. //提现
  399. const toPutout = () => {
  400. if (!outputEnable.value) {
  401. ElMessage.warning("提现功能已关闭");
  402. } else if (memberInfo.value.hasPayPassword == 1) {
  403. pdVisible.value = true;
  404. } else {
  405. modalVisible.value = true;
  406. }
  407. };
  408. //提现详情
  409. const outputInfo = (id) => {
  410. router.push({
  411. path: "/member/balance/info",
  412. query: {
  413. id,
  414. },
  415. });
  416. };
  417. //取消弹窗
  418. const close_dialog = () => {
  419. modalVisible.value = false;
  420. };
  421. //设置支付密码
  422. const set_dialog = () => {
  423. router.push({
  424. path: "/member/pwd/pay",
  425. query: {
  426. type: "set",
  427. },
  428. });
  429. };
  430. const close_pd = () => {
  431. pdVisible.value = false;
  432. password.value = "";
  433. passwordErr.value = "";
  434. };
  435. const submit_dialog = () => {
  436. if (!password.value) {
  437. passwordErr.value = "请输入平台支付密码";
  438. } else {
  439. get("v3/member/front/member/cash/log/verifyPwd", {
  440. payPwd: password.value,
  441. })
  442. .then((res) => {
  443. if (res.state == 200) {
  444. router.push("/member/balance/operate");
  445. } else {
  446. passwordErr.value = res.msg || "密码输入错误,请重新输入";
  447. }
  448. })
  449. .catch(() => {
  450. //异常处理
  451. });
  452. }
  453. };
  454. const getOutputEnable = () => {
  455. get("v3/system/front/setting/getSettings", {
  456. names: "withdraw_is_enable,withdraw_alipay_is_enable",
  457. })
  458. .then((res) => {
  459. if (res.state == 200) {
  460. outputEnable.value =
  461. res.data[0] == "1" && res.data[1] == "1" ? true : false;
  462. }
  463. });
  464. };
  465. const rechargeSetting = ref("");
  466. const getReChargeSetting = () => {
  467. get("v3/system/front/setting/getSettings", {
  468. names: "recharge_is_enable",
  469. })
  470. .then((res) => {
  471. if (res.state == 200) {
  472. rechargeSetting.value = res.data[0];
  473. }
  474. });
  475. };
  476. onMounted(() => {
  477. getBalanceList();
  478. getBalanceinfo();
  479. getOutputEnable();
  480. getReChargeSetting();
  481. });
  482. </script>
  483. <style lang="scss" scoped>
  484. @import "@/assets/style/balance.scss";
  485. .sld_pagination {
  486. margin-top: 20px;
  487. margin-bottom: 20px;
  488. }
  489. </style>
  490. <style lang="scss">
  491. .sld_my_balance {
  492. .el-dialog {
  493. border-radius: 6px;
  494. }
  495. .el-dialog__title {
  496. color: #000000;
  497. font-size: 20px;
  498. /*font-family: Microsoft YaHei;*/
  499. font-weight: bold;
  500. }
  501. .el-icon {
  502. font-size: 18px;
  503. position: relative;
  504. bottom: 6px;
  505. left: 4px;
  506. }
  507. .el-dialog__header {
  508. text-align: center;
  509. color: #000000;
  510. font-size: 22px;
  511. /*font-family: Microsoft YaHei;*/
  512. font-weight: bold;
  513. }
  514. .el-dialog__body {
  515. padding: 0;
  516. }
  517. }
  518. </style>