diff --git a/src/api/currency.js b/src/api/currency.js index f15780aa..f76c4aa0 100644 --- a/src/api/currency.js +++ b/src/api/currency.js @@ -1,4 +1,5 @@ import api from "./api"; +import Message from "@/plugins/message"; /** * 获取积分配置信息 @@ -56,7 +57,11 @@ export function postCurrencyRecharge(data) { * @returns */ export function postCurrencyWithdraw(data) { - return api.post("/currency/cash", data, { - validateStatus: s => s === 201 - }); + return api + .post("/currency/cash", data, { + validateStatus: s => s === 201 + }) + .catch(({ response }) => { + Message.error(response.data); + }); } diff --git a/src/page/currency/CurrencyWithdraw.vue b/src/page/currency/CurrencyWithdraw.vue index fdfd606a..2323d0a6 100644 --- a/src/page/currency/CurrencyWithdraw.vue +++ b/src/page/currency/CurrencyWithdraw.vue @@ -72,7 +72,8 @@ export default { }, computed: { ...mapState({ - currency: "currency" + currency: "currency", + user: "CURRENTUSER" }), cash() { return this.currency.cash; @@ -83,6 +84,9 @@ export default { }, disabled() { return this.amount < this.cash.min || this.amount > this.cash.max; + }, + currentCurrency() { + return this.user.currency.sum || 0; } }, mounted() { @@ -90,6 +94,11 @@ export default { }, methods: { async handleOk() { + // 积分不足时前往充值 + if (this.amount > this.currentCurrency) { + this.$Message.error("积分不足,请充值"); + return this.$router.push({ name: "currencyRecharge" }); + } const { message } = await this.$store.dispatch( "currency/requestWithdraw", this.amount