feat:更新泡泡抽奖

This commit is contained in:
dengtongyu committed 2021-09-19 16:48:54 +08:00
1 parent e5e2ccc95b
commit 7ae7ad5029
17 files changed
+715 -297

No files matched your search

+17 -74
View File
@@ -25,8 +25,7 @@
import balanceView from "./balanceView.vue";
import lotteryBtn from "./lotteryBtn.vue";
import ticketView from "./ticketView.vue";
import { queryTicketNum, queryTicketRule } from "@/api";
import { mapMutations, mapGetters } from "vuex";
import { mapMutations, mapGetters, mapActions } from "vuex";
export default {
name: "BottomView",
components: {
@@ -40,8 +39,18 @@ export default {
default: "turntable1"
}
},
data() {
return {
active: 0
};
},
computed: {
...mapGetters(["remainTicketNum", "ticketRule"]),
...mapGetters([
"remainTicketNum",
"ticketRule",
"ticketRuleList",
"ticketRuleConfig"
]),
modeClass() {
if (this.drawType === "turntable1") return "bottom-view-xy";
return "bottom-view-hh";
@@ -51,92 +60,26 @@ export default {
},
roomUid() {
return this.$route.query.roomUid;
},
ticketRuleList() {
const list = [];
if (!this.ticketRule) return list;
for (let index = 0; index < this.ticketRuleConfig.length; index++) {
const element = this.ticketRuleConfig[index];
const val = this.ticketRule[element.ruleType];
list.push({
label: element.name,
desc: `${val}张鱼券`,
value: val,
ruleType: element.ruleType
});
}
return list;
}
},
watch: {
drawType() {
this.active = 0;
this.getqueryTicketRule();
this.getqueryTicketRule(this.drawType);
},
active() {
this.SetRuleType(this.ticketRuleConfig[this.active].ruleType);
}
},
data() {
return {
active: 0,
ticketRuleConfig: [
{
ruleType: "one",
name: "1次",
index: 0
},
{
ruleType: "ten",
name: "10次",
index: 1
},
{
ruleType: "hundred",
name: "100次",
index: 2
}
]
};
},
created() {
this.getQueryTicketNum();
this.getqueryTicketRule();
this.getQueryTicketNum({ uid: this.uid });
this.getqueryTicketRule(this.drawType);
},
methods: {
...mapMutations(["SetRuleType", "SetRemainTicketNum", "SetTicketRule"]),
getQueryTicketNum() {
queryTicketNum({ uid: this.uid })
.then(res => {
const { code, data, msg } = res;
if (code === 200) {
this.SetRemainTicketNum(data.num || 0);
} else {
this.$toast.fail(msg);
}
})
.catch(() => {
this.$toast.fail("获取余额失败!");
});
},
getqueryTicketRule() {
queryTicketRule({ drawType: this.drawType })
.then(res => {
const { code, data, msg } = res;
if (code === 200) {
// this.ticketRule = data || null;
this.SetTicketRule(data || null);
} else {
this.$toast.fail(msg);
}
})
.catch(() => {
this.$toast.fail("获取规则次数失败!");
});
},
...mapMutations(["SetRuleType"]),
...mapActions(["getqueryTicketRule", "getQueryTicketNum"]),
clickTicketView(item, index) {
this.active = index;
// this.SetRuleType(item.ruleType);
}
}
};