diff --git a/src/components/bottomView/main.vue b/src/components/bottomView/main.vue index e4ea10e..0e1269b 100644 --- a/src/components/bottomView/main.vue +++ b/src/components/bottomView/main.vue @@ -38,7 +38,7 @@ export default { } }, computed: { - ...mapGetters(["remainTicketNum"]), + ...mapGetters(["remainTicketNum", "ticketRule"]), modeClass() { if (this.mode === "blue") return "bottom-view-xy"; return "bottom-view-hh"; @@ -80,7 +80,6 @@ export default { data() { return { active: 0, - ticketRule: null, ticketRuleConfig: [ { ruleType: "one", @@ -105,13 +104,15 @@ export default { this.getqueryTicketRule(); }, methods: { - ...mapMutations(["SetRuleType", "SetRemainTicketNum"]), + ...mapMutations(["SetRuleType", "SetRemainTicketNum", "SetTicketRule"]), getQueryTicketNum() { queryTicketNum({ uid: this.uid }) .then(res => { - const { code, data } = res; + const { code, data, msg } = res; if (code === 200) { this.SetRemainTicketNum(data.num || 0); + } else { + this.$toast.fail(msg); } }) .catch(() => { @@ -121,9 +122,12 @@ export default { getqueryTicketRule() { queryTicketRule({ drawType: this.drawType }) .then(res => { - const { code, data } = res; + const { code, data, msg } = res; if (code === 200) { - this.ticketRule = data || null; + // this.ticketRule = data || null; + this.SetTicketRule(data || null); + } else { + this.$toast.fail(msg); } }) .catch(() => { diff --git a/src/components/luckyGridView/main.vue b/src/components/luckyGridView/main.vue index 0cfb319..c840de4 100644 --- a/src/components/luckyGridView/main.vue +++ b/src/components/luckyGridView/main.vue @@ -88,7 +88,7 @@ export default { }; }, computed: { - ...mapGetters(["ruleType", "prizeIdList"]), + ...mapGetters(["ruleType", "prizeIdList", "remainTicketNum"]), drawType() { if (this.mode === "blue") return "turntable1"; return "turntable2"; @@ -154,10 +154,12 @@ export default { getQueryPrizeInfo() { queryPrizeInfo({ drawType: this.drawType }) .then(res => { - const { code, data } = res; + const { code, data, msg } = res; if (code === 200) { this.SetPrizeInfo(data); this.prizes = this.configPrizes(data); + } else { + this.$toast.fail(msg); } }) .catch(() => { @@ -165,6 +167,14 @@ export default { }); }, postDoLottery() { + if ( + this.remainTicketNum === 0 || + this.remainTicketNum < this.curTicketRuleValue + ) { + this.$toast.fail("余额不足!"); + return; + } + this.timeout = false; this.request = false; this.$refs.LuckDraw.play(); @@ -176,7 +186,7 @@ export default { deviceId: "abc", ruleType: this.ruleType }).then(res => { - const { code, data } = res; + const { code, data, msg } = res; if (code === 200) { this.request = true; this.lotteryData = data; @@ -184,6 +194,8 @@ export default { if (this.timeout && this.request) this.stopLuckDraw(this.maxVauePrizeIndex); this.postSaveLog(); + } else { + this.$toast.fail(msg); } }); diff --git a/src/store/index.js b/src/store/index.js index 6b77d74..eb2fb13 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,7 +7,8 @@ export default new Vuex.Store({ state: { prizeInfo: [], ruleType: "one", - remainTicketNum: 0 + remainTicketNum: 0, + ticketRule: null }, getters: { prizeInfo: state => { @@ -27,6 +28,13 @@ export default new Vuex.Store({ }, remainTicketNum: state => { return state.remainTicketNum; + }, + ticketRule: state => { + return state.ticketRule; + }, + curTicketRuleValue: state => { + if (!state.ticketRule) return 0; + return state.ticketRule[state.ruleType]; } }, mutations: { @@ -38,6 +46,9 @@ export default new Vuex.Store({ }, SetRemainTicketNum(state, payload) { state.remainTicketNum = payload; + }, + SetTicketRule(state, payload) { + state.ticketRule = payload; } }, actions: {},