Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix(currency): (#586) 积分提现时若积分不足则前往充值
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Oct 15, 2018
1 parent 9090730 commit ff44e94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/api/currency.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import api from "./api";
import Message from "@/plugins/message";

/**
* 获取积分配置信息
Expand Down Expand Up @@ -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);
});
}
11 changes: 10 additions & 1 deletion src/page/currency/CurrencyWithdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export default {
},
computed: {
...mapState({
currency: "currency"
currency: "currency",
user: "CURRENTUSER"
}),
cash() {
return this.currency.cash;
Expand All @@ -83,13 +84,21 @@ export default {
},
disabled() {
return this.amount < this.cash.min || this.amount > this.cash.max;
},
currentCurrency() {
return this.user.currency.sum || 0;
}
},
mounted() {
if (!this.cash.rule) this.$store.dispatch("currency/getCurrencyInfo");
},
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
Expand Down

0 comments on commit ff44e94

Please sign in to comment.