feat:更新

This commit is contained in:
dengtongyu committed 2021-08-31 23:26:41 +08:00
1 parent 8a0c0f1327
commit a7ec91cb3b
4 files changed
+93 -30

No files matched your search

+3
View File
@@ -9,11 +9,14 @@
"lint": "vue-cli-service lint --fix" "lint": "vue-cli-service lint --fix"
}, },
"dependencies": { "dependencies": {
"-": "0.0.1",
"axios": "^0.19.2", "axios": "^0.19.2",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"qs": "^6.10.1", "qs": "^6.10.1",
"swiper": "^5.4.5",
"vant": "^2.12.26", "vant": "^2.12.26",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-awesome-swiper": "^4.1.1",
"vue-luck-draw": "^3.4.6", "vue-luck-draw": "^3.4.6",
"vue-router": "^3.1.6", "vue-router": "^3.1.6",
"vuex": "^3.1.3" "vuex": "^3.1.3"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 66 KiB

+13 -1
View File
@@ -30,4 +30,16 @@ const saveLog = param => {
return ajax.post(`${HOST}/saveLog`, stringify(param), "form"); return ajax.post(`${HOST}/saveLog`, stringify(param), "form");
}; };
export { queryPrizeInfo, queryTicketNum, queryTicketRule, doLottery, saveLog }; // 抽奖中奖信息
const queryPrizeMsg = param => {
return ajax.get(`${HOST}/queryPrizeMsg`, param);
};
export {
queryPrizeInfo,
queryTicketNum,
queryTicketRule,
doLottery,
saveLog,
queryPrizeMsg
};
+77 -29
View File
@@ -1,16 +1,31 @@
<template> <template>
<div class="notice" :class="modeClass"> <div class="notice" :class="modeClass">
<div class="notice-content" v-if="gifts.length > 0"> <swiper :options="swiperOption" class="notice-swiper">
<label>{{ name }}</label> <swiper-slide
<span>在{{ modeName }}获得了</span> class="notice-swiper-slide"
<label>{{ giftsText }}</label> v-for="item in recordList"
</div> :key="item.id"
>
<div class="notice-swiper-slide-content">
<label>{{ item.nick }}</label>
<span>在{{ modeName }}获得了</span>
<label>{{ item.prizeName }}x{{ item.num }}</label>
</div>
</swiper-slide>
</swiper>
</div> </div>
</template> </template>
<script> <script>
import { queryPrizeMsg } from "@/api";
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
export default { export default {
name: "Notice", name: "Notice",
components: {
Swiper,
SwiperSlide
},
props: { props: {
mode: { mode: {
type: String, type: String,
@@ -19,12 +34,22 @@ export default {
name: { name: {
type: String, type: String,
default: "" default: ""
},
gifts: {
type: Array,
default: () => []
} }
}, },
data() {
return {
recordList: [],
swiperOption: {
direction: "vertical",
autoplay: {
delay: 3000 // 5秒切换一次
},
// 设置轮播可循环
loop: true
},
interval: 0
};
},
computed: { computed: {
modeClass() { modeClass() {
if (this.mode === "blue") return "notice-xy"; if (this.mode === "blue") return "notice-xy";
@@ -33,38 +58,61 @@ export default {
modeName() { modeName() {
if (this.mode === "blue") return "幸运扭扭蛋"; if (this.mode === "blue") return "幸运扭扭蛋";
return "豪华扭扭蛋"; return "豪华扭扭蛋";
}, }
giftsText() { },
const list = []; created() {
for (let index = 0; index < this.gifts.length; index++) { this.getQueryPrizeMsg();
const element = this.gifts[index]; },
list.push(`${element.prizeName}x${element.prizeNum}`); mounted() {
} this.interval = setInterval(this.getQueryPrizeMsg, 120 * 1000);
return list.join("、"); },
destroyed() {
clearInterval(this.interval);
},
methods: {
getQueryPrizeMsg() {
queryPrizeMsg().then(res => {
const { code, data, msg } = res;
if (code === 200) {
this.recordList = data;
} else {
this.$toast.fail(msg);
}
});
} }
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "~swiper/css/swiper.css";
.notice { .notice {
width: 618px; width: 618px;
height: 64px; height: 64px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
margin: 0 auto; margin: 0 auto;
&-content { overflow: hidden;
margin: 0 30px; &-swiper {
text-align: center; width: 100%;
line-height: 64px; height: 100%;
white-space: nowrap; &-slide {
overflow-x: auto; width: 100%;
overflow-y: hidden; height: 100%;
& > label { &-content {
color: #ffe26c; margin: 0 30px;
} text-align: center;
& > span { line-height: 64px;
color: #fff; white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
& > label {
color: #ffe26c;
}
& > span {
color: #fff;
}
}
} }
} }
} }