diff --git a/babel.config.js b/babel.config.js
index 397abca..5214e8e 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,3 +1,14 @@
module.exports = {
- presets: ["@vue/cli-plugin-babel/preset"]
+ presets: ["@vue/cli-plugin-babel/preset"],
+ plugins: [
+ [
+ "import",
+ {
+ libraryName: "vant",
+ libraryDirectory: "es",
+ style: true
+ },
+ "vant"
+ ]
+ ]
};
diff --git a/package.json b/package.json
index d156c13..9a5f266 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
"dependencies": {
"axios": "^0.19.2",
"core-js": "^3.6.4",
+ "qs": "^6.10.1",
"vant": "^2.12.26",
"vue": "^2.6.11",
"vue-luck-draw": "^3.4.6",
@@ -25,6 +26,7 @@
"@vue/cli-service": "~4.3.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
+ "babel-plugin-import": "^1.13.3",
"cross-env": "^7.0.2",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.1",
diff --git a/src/api/index.js b/src/api/index.js
index 6d8ca3e..f9cd888 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,5 +1,6 @@
import ajax from "@/lib/ajax";
import config from "@/config";
+import { stringify } from "qs";
// host
const HOST = config.host("/api", "/act");
@@ -9,4 +10,24 @@ const queryPrizeInfo = param => {
return ajax.get(`${HOST}/queryPrizeInfo`, param);
};
-export { queryPrizeInfo };
+// 获取余额
+const queryTicketNum = param => {
+ return ajax.get(`${HOST}/queryTicketNum`, param);
+};
+
+// 获取抽奖规则次数
+const queryTicketRule = param => {
+ return ajax.get(`${HOST}/queryTicketRule`, param);
+};
+
+// 抽奖
+const doLottery = param => {
+ return ajax.post(`${HOST}/doLottery`, stringify(param), "form");
+};
+
+// 保存抽奖结果
+const saveLog = param => {
+ return ajax.post(`${HOST}/saveLog`, stringify(param), "form");
+};
+
+export { queryPrizeInfo, queryTicketNum, queryTicketRule, doLottery, saveLog };
diff --git a/src/components/bottomView/lotteryBtn.vue b/src/components/bottomView/lotteryBtn.vue
index 483fa28..15089d5 100644
--- a/src/components/bottomView/lotteryBtn.vue
+++ b/src/components/bottomView/lotteryBtn.vue
@@ -1,8 +1,9 @@
-
+
diff --git a/src/components/bottomView/main.vue b/src/components/bottomView/main.vue
index 794b2d7..e4ea10e 100644
--- a/src/components/bottomView/main.vue
+++ b/src/components/bottomView/main.vue
@@ -1,17 +1,18 @@
@@ -21,6 +22,8 @@
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";
export default {
name: "BottomView",
components: {
@@ -35,32 +38,103 @@ export default {
}
},
computed: {
+ ...mapGetters(["remainTicketNum"]),
modeClass() {
if (this.mode === "blue") return "bottom-view-xy";
return "bottom-view-hh";
+ },
+ uid() {
+ return this.$route.query.uid;
+ },
+ roomUid() {
+ return this.$route.query.roomUid;
+ },
+ drawType() {
+ if (this.mode === "blue") return "turntable1";
+ return "turntable2";
+ },
+ 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: {
+ mode() {
+ this.active = 0;
+ },
+ active() {
+ this.SetRuleType(this.ticketRuleConfig[this.active].ruleType);
}
},
data() {
return {
active: 0,
- list: [
+ ticketRule: null,
+ ticketRuleConfig: [
{
- label: "1次",
- desc: "1张鱼券",
- value: 1
+ ruleType: "one",
+ name: "1次",
+ index: 0
},
{
- label: "10次",
- desc: "10张鱼券",
- value: 1
+ ruleType: "ten",
+ name: "10次",
+ index: 1
},
{
- label: "100次",
- desc: "100张鱼券",
- value: 1
+ ruleType: "hundred",
+ name: "100次",
+ index: 2
}
]
};
+ },
+ created() {
+ this.getQueryTicketNum();
+ this.getqueryTicketRule();
+ },
+ methods: {
+ ...mapMutations(["SetRuleType", "SetRemainTicketNum"]),
+ getQueryTicketNum() {
+ queryTicketNum({ uid: this.uid })
+ .then(res => {
+ const { code, data } = res;
+ if (code === 200) {
+ this.SetRemainTicketNum(data.num || 0);
+ }
+ })
+ .catch(() => {
+ this.$toast.fail("获取余额失败!");
+ });
+ },
+ getqueryTicketRule() {
+ queryTicketRule({ drawType: this.drawType })
+ .then(res => {
+ const { code, data } = res;
+ if (code === 200) {
+ this.ticketRule = data || null;
+ }
+ })
+ .catch(() => {
+ this.$toast.fail("获取规则次数失败!");
+ });
+ },
+ clickTicketView(item, index) {
+ console.log(item, index);
+ this.active = index;
+ // this.SetRuleType(item.ruleType);
+ }
}
};
diff --git a/src/components/luckyGridView/main.vue b/src/components/luckyGridView/main.vue
index e0ef5d2..0cfb319 100644
--- a/src/components/luckyGridView/main.vue
+++ b/src/components/luckyGridView/main.vue
@@ -10,15 +10,31 @@
:default-config="defaultConfig"
:default-style="defaultStyle"
:active-style="activeStyle"
- @start="startCallBack"
@end="endCallBack"
/>
+
+
+
+
+
+
![]()
+
+
{{ item.prizeName }}
+
+
+
diff --git a/src/components/topButton/topBtnView.vue b/src/components/topButton/topBtnView.vue
new file mode 100644
index 0000000..cce6a11
--- /dev/null
+++ b/src/components/topButton/topBtnView.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/eventBus.js b/src/lib/eventBus.js
new file mode 100644
index 0000000..968c96b
--- /dev/null
+++ b/src/lib/eventBus.js
@@ -0,0 +1,2 @@
+import Vue from "vue";
+export default new Vue();
diff --git a/src/main.js b/src/main.js
index 3a47006..7fcbbb2 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,9 +2,13 @@ import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
+import { Toast, Dialog } from "vant";
Vue.config.productionTip = false;
+Vue.use(Toast);
+Vue.use(Dialog);
+
new Vue({
router,
store,
diff --git a/src/store/index.js b/src/store/index.js
index fb6015f..6b77d74 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -4,8 +4,42 @@ import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
- state: {},
- mutations: {},
+ state: {
+ prizeInfo: [],
+ ruleType: "one",
+ remainTicketNum: 0
+ },
+ getters: {
+ prizeInfo: state => {
+ return state.prizeInfo;
+ },
+ prizeIdList: state => {
+ const { prizeInfo } = state;
+ const list = [];
+ for (let index = 0; index < prizeInfo.length; index++) {
+ const element = prizeInfo[index];
+ list.push(element.prizeId);
+ }
+ return list;
+ },
+ ruleType: state => {
+ return state.ruleType;
+ },
+ remainTicketNum: state => {
+ return state.remainTicketNum;
+ }
+ },
+ mutations: {
+ SetPrizeInfo(state, payload) {
+ state.prizeInfo = payload;
+ },
+ SetRuleType(state, payload) {
+ state.ruleType = payload;
+ },
+ SetRemainTicketNum(state, payload) {
+ state.remainTicketNum = payload;
+ }
+ },
actions: {},
modules: {}
});
diff --git a/src/views/Home.vue b/src/views/Home.vue
index e3094a5..d044a59 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -2,7 +2,7 @@
-
+
@@ -33,12 +33,23 @@ export default {
},
data() {
return {
- mode: "gold" // blue gold
+ active: 0
};
},
- computed: {},
+ computed: {
+ mode() {
+ if (this.active === 0) return "blue";
+ if (this.active === 1) return "gold";
+ return "blue";
+ }
+ },
mounted() {},
- methods: {}
+ methods: {
+ clickTopButton(index) {
+ this.active = index;
+ console.log("active", index);
+ }
+ }
};