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 @@ 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); + } + } };