feat: 更新
This commit is contained in:
1 parent
f717386d54
commit
145fbcf834
10 files changed
+439
-119
No files matched your search
+6
-1
@@ -57,6 +57,10 @@ const buyPack = param => {
|
|||||||
return ajax.post(`${HOST}/buyPack`, stringify(param));
|
return ajax.post(`${HOST}/buyPack`, stringify(param));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buyAndLottery = param => {
|
||||||
|
return ajax.post(`${HOST}/lottery`, stringify(param));
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
queryPrizeInfo,
|
queryPrizeInfo,
|
||||||
queryTicketNum,
|
queryTicketNum,
|
||||||
@@ -68,5 +72,6 @@ export {
|
|||||||
rateList,
|
rateList,
|
||||||
getRulePic,
|
getRulePic,
|
||||||
queryPackList,
|
queryPackList,
|
||||||
buyPack
|
buyPack,
|
||||||
|
buyAndLottery
|
||||||
};
|
};
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { money } from "@/config";
|
import { unit } from "@/config";
|
||||||
import eventBus from "@/lib/eventBus";
|
import eventBus from "@/lib/eventBus";
|
||||||
export default {
|
export default {
|
||||||
name: "BalanceView",
|
name: "BalanceView",
|
||||||
@@ -25,7 +25,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
money
|
unit
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -34,7 +34,7 @@ export default {
|
|||||||
return "balance-view-hh";
|
return "balance-view-hh";
|
||||||
},
|
},
|
||||||
moneyStr() {
|
moneyStr() {
|
||||||
return `${money}余额:`;
|
return `${unit}余额:`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import BuyGiftPop from "./main";
|
||||||
|
|
||||||
|
BuyGiftPop.install = function(Vue) {
|
||||||
|
Vue.component(BuyGiftPop.name, BuyGiftPop);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BuyGiftPop;
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
<template>
|
||||||
|
<div class="buy-Gift-pop">
|
||||||
|
<h3>购买限定装扮</h3>
|
||||||
|
<div class="buy-Gift-pop-main">
|
||||||
|
<div class="buy-Gift-pop-main-gift">
|
||||||
|
<div class="buy-Gift-pop-main-gift-image">
|
||||||
|
<img :src="giftUrl" />
|
||||||
|
</div>
|
||||||
|
<div class="buy-Gift-pop-main-gift-info">
|
||||||
|
<p>{{ giftName }}</p>
|
||||||
|
<p>{{ giftPrize }}</p>
|
||||||
|
<p>赠送{{ needNumber }}门票</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="buy-Gift-pop-main-checkbox">
|
||||||
|
<van-checkbox
|
||||||
|
class="never-notice-checkbox"
|
||||||
|
v-model="neverNotice"
|
||||||
|
checked-color="#FFEF30"
|
||||||
|
>以后不再提示</van-checkbox
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="buy-Gift-pop-main-btn">
|
||||||
|
<van-button
|
||||||
|
class="buy-Gift-pop-main-btn-buy"
|
||||||
|
type="default"
|
||||||
|
color="#FFEF30"
|
||||||
|
round
|
||||||
|
block
|
||||||
|
@click="buyHandler"
|
||||||
|
>立即购买</van-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from "vuex";
|
||||||
|
import { money } from "@/config";
|
||||||
|
import eventBus from "@/lib/eventBus";
|
||||||
|
export default {
|
||||||
|
name: "BuyGiftPop",
|
||||||
|
components: {},
|
||||||
|
props: {
|
||||||
|
needNumber: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
defaultShowImg: require("@/assets/images/logo.jpg"),
|
||||||
|
neverNotice: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters([
|
||||||
|
"happyGiftList",
|
||||||
|
"curHappyGift",
|
||||||
|
"curHappyGiftSellingPrice",
|
||||||
|
"curHappyGiftUrl"
|
||||||
|
]),
|
||||||
|
giftUrl() {
|
||||||
|
if (this.curHappyGiftUrl) return this.curHappyGiftUrl;
|
||||||
|
return this.defaultShowImg;
|
||||||
|
},
|
||||||
|
giftName() {
|
||||||
|
if (this.curHappyGift && this.curHappyGift.name)
|
||||||
|
return this.curHappyGift.name;
|
||||||
|
return "";
|
||||||
|
},
|
||||||
|
giftPrize() {
|
||||||
|
if (this.curHappyGift && this.curHappyGiftSellingPrice)
|
||||||
|
return `${this.curHappyGiftSellingPrice * this.needNumber}${money}/${
|
||||||
|
this.needNumber
|
||||||
|
}天`;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {},
|
||||||
|
created() {
|
||||||
|
if (this.happyGiftList.length === 0) this.loadPackList();
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
...mapActions(["loadPackList", "buyAndLottery"]),
|
||||||
|
buyHandler() {
|
||||||
|
if (this.neverNotice)
|
||||||
|
localStorage.setItem("_toupaipaidui_never_notice_", true);
|
||||||
|
// this.buyAndLottery({ packNum: this.needNumber });
|
||||||
|
eventBus.$emit("buyAndLotteryEvent", this.needNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.buy-Gift-pop {
|
||||||
|
padding: 30px 60px;
|
||||||
|
& > h3 {
|
||||||
|
font-size: 36px;
|
||||||
|
font-family: PingFang SC;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #222222;
|
||||||
|
line-height: 72px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
&-main {
|
||||||
|
margin-top: 36px;
|
||||||
|
&-gift {
|
||||||
|
// height: 188px;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
background: linear-gradient(90deg, #d782ff 0%, #a457f4 100%);
|
||||||
|
border-radius: 30px;
|
||||||
|
padding: 24px 20px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
align-items: center;
|
||||||
|
&-image {
|
||||||
|
width: 140px;
|
||||||
|
height: 140px;
|
||||||
|
background: rgba(121, 30, 188, 0.2);
|
||||||
|
border-radius: 24px;
|
||||||
|
padding: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
& > img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-info {
|
||||||
|
padding-left: 36px;
|
||||||
|
font-size: 24px;
|
||||||
|
font-family: PingFang SC;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #ffffff;
|
||||||
|
line-height: 36px;
|
||||||
|
& > :first-child {
|
||||||
|
font-size: 30px;
|
||||||
|
line-height: 46px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-checkbox {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 60px;
|
||||||
|
}
|
||||||
|
&-btn {
|
||||||
|
width: 320px;
|
||||||
|
height: 10px;
|
||||||
|
margin: 50px auto 0;
|
||||||
|
&-buy {
|
||||||
|
color: #222 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.never-notice-checkbox {
|
||||||
|
:deep(.van-checkbox__icon--checked .van-icon) {
|
||||||
|
color: #222 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -21,9 +21,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { LuckyGrid } from "vue-luck-draw";
|
|
||||||
import lotteryPrizesDialog from "@/components/lotteryPrizesDialog";
|
|
||||||
import { mapMutations, mapGetters, mapActions } from "vuex";
|
import { mapMutations, mapGetters, mapActions } from "vuex";
|
||||||
|
import { LuckyGrid } from "vue-luck-draw";
|
||||||
|
import { Dialog } from "vant";
|
||||||
|
import lotteryPrizesDialog from "@/components/lotteryPrizesDialog";
|
||||||
import eventBus from "@/lib/eventBus";
|
import eventBus from "@/lib/eventBus";
|
||||||
export default {
|
export default {
|
||||||
name: "LuckyGridView",
|
name: "LuckyGridView",
|
||||||
@@ -74,7 +75,9 @@ export default {
|
|||||||
defaultImage: require("@/assets/images/logo_tm.png"),
|
defaultImage: require("@/assets/images/logo_tm.png"),
|
||||||
showDialog: false,
|
showDialog: false,
|
||||||
timeout: false,
|
timeout: false,
|
||||||
request: false
|
request: false,
|
||||||
|
LotteryError: false,
|
||||||
|
LotteryErrorMsg: ""
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -130,13 +133,15 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
eventBus.$on("eventLottery", this.startLottery);
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.queryPrizeInfo();
|
this.queryPrizeInfo();
|
||||||
},
|
},
|
||||||
destroyed() {
|
mounted() {
|
||||||
|
eventBus.$on("eventLottery", this.startLottery);
|
||||||
|
eventBus.$on("buyAndLotteryEvent", this.buyAndLottery);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
eventBus.$off("eventLottery", this.startLottery);
|
eventBus.$off("eventLottery", this.startLottery);
|
||||||
|
eventBus.$off("buyAndLotteryEvent", this.buyAndLottery);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations([
|
...mapMutations([
|
||||||
@@ -144,39 +149,42 @@ export default {
|
|||||||
"SetCanLottery"
|
"SetCanLottery"
|
||||||
// "SetPrizeItemList"
|
// "SetPrizeItemList"
|
||||||
]),
|
]),
|
||||||
...mapActions(["getQueryPrizeInfo", "runLottery"]),
|
...mapActions(["getQueryPrizeInfo", "runLottery", "postBuyPack"]),
|
||||||
queryPrizeInfo() {
|
queryPrizeInfo() {
|
||||||
this.getQueryPrizeInfo().then(list => {
|
this.getQueryPrizeInfo().then(list => {
|
||||||
this.prizes = this.configPrizes(list);
|
this.prizes = this.configPrizes(list);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
postDoLottery() {
|
postDoLottery() {
|
||||||
if (
|
|
||||||
this.remainTicketNum === 0 ||
|
|
||||||
this.remainTicketNum < this.curTicketRuleValue
|
|
||||||
) {
|
|
||||||
this.$toast.fail("余额不足!");
|
|
||||||
this.SetCanLottery(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.timeout = false;
|
this.timeout = false;
|
||||||
this.request = false;
|
this.request = false;
|
||||||
this.$refs.LuckDraw.play();
|
this.$refs.LuckDraw.play();
|
||||||
|
|
||||||
this.runLottery().then(res => {
|
this.runLottery()
|
||||||
const { code } = res;
|
.then(res => {
|
||||||
if (code === 200) {
|
|
||||||
this.request = true;
|
this.request = true;
|
||||||
if (this.timeout && this.request)
|
const { code, message } = res;
|
||||||
this.stopLuckDraw(this.maxVauePrizeIndex);
|
if (code === 200) {
|
||||||
}
|
this.LotteryError = false;
|
||||||
});
|
if (this.timeout && this.request)
|
||||||
|
this.stopLuckDraw(this.maxVauePrizeIndex);
|
||||||
|
} else {
|
||||||
|
this.LotteryError = true;
|
||||||
|
this.LotteryErrorMsg = message;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.request = true;
|
||||||
|
this.LotteryError = true;
|
||||||
|
this.LotteryErrorMsg = "抽奖发生意外错误!";
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.timeout = true;
|
this.timeout = true;
|
||||||
if (this.timeout && this.request)
|
if (this.timeout && this.request) {
|
||||||
this.stopLuckDraw(this.maxVauePrizeIndex);
|
const stopIndex = this.LotteryError ? 0 : this.maxVauePrizeIndex;
|
||||||
|
this.stopLuckDraw(stopIndex);
|
||||||
|
}
|
||||||
}, this.runTime);
|
}, this.runTime);
|
||||||
},
|
},
|
||||||
configPrizes(prizeInfo) {
|
configPrizes(prizeInfo) {
|
||||||
@@ -209,8 +217,36 @@ export default {
|
|||||||
return prizes;
|
return prizes;
|
||||||
},
|
},
|
||||||
startLottery() {
|
startLottery() {
|
||||||
|
const localNoticeStatus = localStorage.getItem(
|
||||||
|
"_toupaipaidui_never_notice_"
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
this.remainTicketNum === 0 ||
|
||||||
|
this.remainTicketNum < this.curTicketRuleValue
|
||||||
|
) {
|
||||||
|
// this.$toast.fail("余额不足!");
|
||||||
|
const dValue = this.curTicketRuleValue - this.remainTicketNum;
|
||||||
|
if (localNoticeStatus) {
|
||||||
|
this.buyAndLottery(dValue);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
eventBus.$emit("noTickets", dValue);
|
||||||
|
this.SetCanLottery(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.postDoLottery();
|
this.postDoLottery();
|
||||||
},
|
},
|
||||||
|
buyAndLottery(dValue) {
|
||||||
|
this.postBuyPack({ packNum: dValue })
|
||||||
|
.then(() => {
|
||||||
|
this.postDoLottery();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.SetCanLottery(true);
|
||||||
|
});
|
||||||
|
},
|
||||||
stopLuckDraw(index) {
|
stopLuckDraw(index) {
|
||||||
this.$refs.LuckDraw.stop(index);
|
this.$refs.LuckDraw.stop(index);
|
||||||
},
|
},
|
||||||
@@ -226,8 +262,19 @@ export default {
|
|||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
endCallBack() {
|
endCallBack() {
|
||||||
this.showDialog = true;
|
|
||||||
this.SetCanLottery(true);
|
this.SetCanLottery(true);
|
||||||
|
if (this.LotteryError) {
|
||||||
|
Dialog.alert({
|
||||||
|
message: this.LotteryErrorMsg,
|
||||||
|
confirmButtonColor: "#9E98FF"
|
||||||
|
}).then(() => {
|
||||||
|
// on close
|
||||||
|
this.LotteryError = false;
|
||||||
|
this.LotteryErrorMsg = "";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.showDialog = true;
|
||||||
|
}
|
||||||
// this.SetPrizeItemList(this.prizeItemList);
|
// this.SetPrizeItemList(this.prizeItemList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -219,7 +219,7 @@ const getMsgFromDevice = function() {
|
|||||||
location.hostname === "localhost"
|
location.hostname === "localhost"
|
||||||
) {
|
) {
|
||||||
window.info.roomUid = 904860;
|
window.info.roomUid = 904860;
|
||||||
window.info.uid = 1000002;
|
window.info.uid = 1000009;
|
||||||
window.info.deviceId = "afhksafhksajhfs1kjahsfkjsf0000aaaaaaaacaa";
|
window.info.deviceId = "afhksafhksajhfs1kjahsfkjsf0000aaaaaaaacaa";
|
||||||
window.info.ticket =
|
window.info.ticket =
|
||||||
"eyJhbGciOiJIUzI1NiJ9.eyJ0aWNrZXRfdHlwZSI6bnVsbCwidWlkIjo5MTMzOSwidGlja2V0X2lkIjoiOGJmMTdlYmQtMTY4ZC00NTliLWI0NzUtMDU3M2Y1ZmM4MDQzIiwiZXhwIjozNjAwLCJjbGllbnRfaWQiOiJlcmJhbi1jbGllbnQifQ.MnKGEc6bSkyOkCbx26lib6J0koFDA2uiKnbwkhdk3MU";
|
"eyJhbGciOiJIUzI1NiJ9.eyJ0aWNrZXRfdHlwZSI6bnVsbCwidWlkIjo5MTMzOSwidGlja2V0X2lkIjoiOGJmMTdlYmQtMTY4ZC00NTliLWI0NzUtMDU3M2Y1ZmM4MDQzIiwiZXhwIjozNjAwLCJjbGllbnRfaWQiOiJlcmJhbi1jbGllbnQifQ.MnKGEc6bSkyOkCbx26lib6J0koFDA2uiKnbwkhdk3MU";
|
||||||
|
|||||||
+5
-1
@@ -13,7 +13,9 @@ import {
|
|||||||
Empty,
|
Empty,
|
||||||
Icon,
|
Icon,
|
||||||
PullRefresh,
|
PullRefresh,
|
||||||
Button
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
CheckboxGroup
|
||||||
} from "vant";
|
} from "vant";
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
@@ -29,6 +31,8 @@ Vue.use(Empty);
|
|||||||
Vue.use(Icon);
|
Vue.use(Icon);
|
||||||
Vue.use(PullRefresh);
|
Vue.use(PullRefresh);
|
||||||
Vue.use(Button);
|
Vue.use(Button);
|
||||||
|
Vue.use(Checkbox);
|
||||||
|
Vue.use(CheckboxGroup);
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
|
|||||||
+96
-7
@@ -6,7 +6,9 @@ import {
|
|||||||
queryTicketRule,
|
queryTicketRule,
|
||||||
doLottery,
|
doLottery,
|
||||||
saveLog,
|
saveLog,
|
||||||
queryTicketNum
|
queryTicketNum,
|
||||||
|
queryPackList,
|
||||||
|
buyPack
|
||||||
} from "@/api";
|
} from "@/api";
|
||||||
import { getMsgFromDevice, getQueryString } from "@/lib/tool";
|
import { getMsgFromDevice, getQueryString } from "@/lib/tool";
|
||||||
import { unit } from "@/config";
|
import { unit } from "@/config";
|
||||||
@@ -27,6 +29,7 @@ export default new Vuex.Store({
|
|||||||
ruleType: "one",
|
ruleType: "one",
|
||||||
remainTicketNum: 0,
|
remainTicketNum: 0,
|
||||||
goldNum: 0,
|
goldNum: 0,
|
||||||
|
happyGiftList: [],
|
||||||
ticketRule: null,
|
ticketRule: null,
|
||||||
canLottery: true,
|
canLottery: true,
|
||||||
lotteryRecordRateVo: {},
|
lotteryRecordRateVo: {},
|
||||||
@@ -80,12 +83,28 @@ export default new Vuex.Store({
|
|||||||
goldNum: state => {
|
goldNum: state => {
|
||||||
return state.goldNum;
|
return state.goldNum;
|
||||||
},
|
},
|
||||||
|
happyGiftList: state => {
|
||||||
|
return state.happyGiftList;
|
||||||
|
},
|
||||||
|
curHappyGift: (state, getters) => {
|
||||||
|
return getters.happyGiftList[0] || null;
|
||||||
|
},
|
||||||
|
curHappyGiftSellingPrice: (state, getters) => {
|
||||||
|
if (getters.curHappyGift && getters.curHappyGift.sellingPrice)
|
||||||
|
return getters.curHappyGift.sellingPrice;
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
curHappyGiftUrl: (state, getters) => {
|
||||||
|
if (getters.curHappyGift && getters.curHappyGift.imgUrl)
|
||||||
|
return getters.curHappyGift.imgUrl;
|
||||||
|
return "";
|
||||||
|
},
|
||||||
ticketRule: state => {
|
ticketRule: state => {
|
||||||
return state.ticketRule;
|
return state.ticketRule;
|
||||||
},
|
},
|
||||||
curTicketRuleValue: state => {
|
curTicketRuleValue: state => {
|
||||||
if (!state.ticketRule) return 0;
|
if (!state.ticketRule) return 0;
|
||||||
return state.ticketRule[state.ruleType];
|
return state.ticketRule[state.ruleType].times;
|
||||||
},
|
},
|
||||||
canLottery: state => {
|
canLottery: state => {
|
||||||
return state.canLottery;
|
return state.canLottery;
|
||||||
@@ -183,6 +202,9 @@ export default new Vuex.Store({
|
|||||||
SetGoldNum(state, payload) {
|
SetGoldNum(state, payload) {
|
||||||
state.goldNum = payload;
|
state.goldNum = payload;
|
||||||
},
|
},
|
||||||
|
SetHappyGiftList(state, payload) {
|
||||||
|
state.happyGiftList = payload;
|
||||||
|
},
|
||||||
SetTicketRule(state, payload) {
|
SetTicketRule(state, payload) {
|
||||||
state.ticketRule = payload;
|
state.ticketRule = payload;
|
||||||
},
|
},
|
||||||
@@ -243,7 +265,7 @@ export default new Vuex.Store({
|
|||||||
Toast.fail("获取规则次数失败!");
|
Toast.fail("获取规则次数失败!");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
runLottery({ state, commit }) {
|
runLottery({ state, commit, dispatch }) {
|
||||||
if (!locateObj.actId) {
|
if (!locateObj.actId) {
|
||||||
Toast.fail("获取活动信息失败!");
|
Toast.fail("获取活动信息失败!");
|
||||||
return;
|
return;
|
||||||
@@ -266,18 +288,19 @@ export default new Vuex.Store({
|
|||||||
deviceId: info.deviceId
|
deviceId: info.deviceId
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const { code, data, message } = res;
|
const { code, data } = res;
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
commit("SetRemainTicketNum", data.remainTicketNum || 0);
|
// commit("SetRemainTicketNum", data.remainTicketNum || 0);
|
||||||
commit("SetLotteryData", data);
|
commit("SetLotteryData", data);
|
||||||
// dispatch("postSaveLog", option);
|
// dispatch("postSaveLog", option);
|
||||||
|
dispatch("getQueryTicketNum");
|
||||||
} else {
|
} else {
|
||||||
Toast.fail(message);
|
// Toast.fail(message);
|
||||||
}
|
}
|
||||||
resolve(res);
|
resolve(res);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
Toast.fail("抽奖发生意外错误!");
|
// Toast.fail("抽奖发生意外错误!");
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -305,6 +328,72 @@ export default new Vuex.Store({
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
Toast.fail("获取余额失败!");
|
Toast.fail("获取余额失败!");
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
loadPackList({ commit }) {
|
||||||
|
queryPackList({ actId: locateObj.actId })
|
||||||
|
.then(res => {
|
||||||
|
const { code, data, message } = res;
|
||||||
|
if (code === 200 && data && data.length) {
|
||||||
|
// this.getHappyGiftObj = data[0];
|
||||||
|
commit("SetHappyGiftList", data);
|
||||||
|
} else {
|
||||||
|
Toast.fail(message || "获取礼包失败!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
Toast.fail("获取礼包出现意外!");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
postBuyPack({ commit, getters }, option) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!getters.curHappyGift) {
|
||||||
|
Toast.fail("未获取到礼包信息!");
|
||||||
|
reject("未获取到礼包信息!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getters.curHappyGift.id) {
|
||||||
|
Toast.fail("未获取到礼包信息!");
|
||||||
|
reject("未获取到礼包信息!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.loading({
|
||||||
|
message: "加载中...",
|
||||||
|
forbidClick: true,
|
||||||
|
duration: 0
|
||||||
|
});
|
||||||
|
buyPack({
|
||||||
|
packId: getters.curHappyGift.id,
|
||||||
|
packNum: option.packNum
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
Toast.clear();
|
||||||
|
const { code, message, data } = res;
|
||||||
|
if (code === 200) {
|
||||||
|
// console.log(this.goldNum, data, this.goldNum + data);
|
||||||
|
let prize = getters.curHappyGiftSellingPrice * option.packNum;
|
||||||
|
commit("SetRemainTicketNum", getters.remainTicketNum + data);
|
||||||
|
commit("SetGoldNum", getters.goldNum - prize);
|
||||||
|
const localNoticeStatus = localStorage.getItem(
|
||||||
|
"_toupaipaidui_never_notice_"
|
||||||
|
);
|
||||||
|
if (!localNoticeStatus) Toast.success("购买成功");
|
||||||
|
resolve(res);
|
||||||
|
} else {
|
||||||
|
Toast.fail(message || "购买礼包失败!");
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
Toast.clear();
|
||||||
|
Toast.fail("购买礼包出现意外错误!");
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
buyAndLottery({ dispatch }, option) {
|
||||||
|
dispatch("postBuyPack", option).then(() => {
|
||||||
|
dispatch("runLottery");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modules: {}
|
modules: {}
|
||||||
|
|||||||
+45
-5
@@ -38,6 +38,17 @@
|
|||||||
<!-- <prizes-view></prizes-view> -->
|
<!-- <prizes-view></prizes-view> -->
|
||||||
<component :is="curComponentsName"></component>
|
<component :is="curComponentsName"></component>
|
||||||
</van-popup>
|
</van-popup>
|
||||||
|
|
||||||
|
<van-popup
|
||||||
|
v-model="buyGiftVisible"
|
||||||
|
:style="{ width: '80%', height: '82vw' }"
|
||||||
|
:close-on-click-overlay="false"
|
||||||
|
closeable
|
||||||
|
round
|
||||||
|
get-container="#app"
|
||||||
|
>
|
||||||
|
<buyGiftPop :needNumber="needNumber" />
|
||||||
|
</van-popup>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -46,8 +57,8 @@ import topButton from "@/components/topButton";
|
|||||||
import ballContent from "@/components/ballContent";
|
import ballContent from "@/components/ballContent";
|
||||||
import enterView from "@/components/enterView";
|
import enterView from "@/components/enterView";
|
||||||
import bottomView from "@/components/bottomView";
|
import bottomView from "@/components/bottomView";
|
||||||
// import prizesView from "./prizesView.vue";
|
import buyGiftPop from "@/components/buyGiftPop";
|
||||||
import { mapMutations, mapGetters } from "vuex";
|
import { mapMutations, mapGetters, mapActions } from "vuex";
|
||||||
import { tools } from "@/lib/tool";
|
import { tools } from "@/lib/tool";
|
||||||
import eventBus from "@/lib/eventBus";
|
import eventBus from "@/lib/eventBus";
|
||||||
|
|
||||||
@@ -58,7 +69,7 @@ export default {
|
|||||||
ballContent,
|
ballContent,
|
||||||
enterView,
|
enterView,
|
||||||
bottomView,
|
bottomView,
|
||||||
// prizesView
|
buyGiftPop,
|
||||||
prizesView: resolve => require(["./prizesView.vue"], resolve),
|
prizesView: resolve => require(["./prizesView.vue"], resolve),
|
||||||
ruleView: resolve => require(["./ruleView.vue"], resolve),
|
ruleView: resolve => require(["./ruleView.vue"], resolve),
|
||||||
recordView: resolve => require(["./recordView.vue"], resolve),
|
recordView: resolve => require(["./recordView.vue"], resolve),
|
||||||
@@ -69,6 +80,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
show: false,
|
show: false,
|
||||||
|
buyGiftVisible: false,
|
||||||
curBtnText: "",
|
curBtnText: "",
|
||||||
componentsName: {
|
componentsName: {
|
||||||
排行: "rank-view",
|
排行: "rank-view",
|
||||||
@@ -77,11 +89,13 @@ export default {
|
|||||||
记录: "record-view",
|
记录: "record-view",
|
||||||
数据: "data-view",
|
数据: "data-view",
|
||||||
充值: "recharge-view"
|
充值: "recharge-view"
|
||||||
}
|
},
|
||||||
|
localNoticeStatus: false,
|
||||||
|
needNumber: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(["drawType"]),
|
...mapGetters(["drawType", "happyGiftList"]),
|
||||||
curComponentsName() {
|
curComponentsName() {
|
||||||
return this.componentsName[this.curBtnText];
|
return this.componentsName[this.curBtnText];
|
||||||
},
|
},
|
||||||
@@ -94,11 +108,25 @@ export default {
|
|||||||
// console.log("this.show", this.show);
|
// console.log("this.show", this.show);
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
|
created() {
|
||||||
|
this.localNoticeStatus = localStorage.getItem(
|
||||||
|
"_toupaipaidui_never_notice_"
|
||||||
|
);
|
||||||
|
if (this.happyGiftList.length === 0) this.loadPackList();
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
eventBus.$on("rechargeView", this.showRechargeView);
|
eventBus.$on("rechargeView", this.showRechargeView);
|
||||||
|
eventBus.$on("noTickets", this.noTicketsHander);
|
||||||
|
eventBus.$on("buyAndLotteryEvent", this.closeBuyAndLotteryPopHandler);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
eventBus.$off("rechargeView", this.showRechargeView);
|
||||||
|
eventBus.$off("noTickets", this.noTicketsHander);
|
||||||
|
eventBus.$off("buyAndLotteryEvent", this.closeBuyAndLotteryPopHandler);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["SetDrawType"]),
|
...mapMutations(["SetDrawType"]),
|
||||||
|
...mapActions(["loadPackList"]),
|
||||||
clickTopButton(index) {
|
clickTopButton(index) {
|
||||||
this.SetDrawType(index);
|
this.SetDrawType(index);
|
||||||
// console.log("active", index);
|
// console.log("active", index);
|
||||||
@@ -119,6 +147,18 @@ export default {
|
|||||||
showRechargeView() {
|
showRechargeView() {
|
||||||
this.curBtnText = "充值";
|
this.curBtnText = "充值";
|
||||||
this.show = true;
|
this.show = true;
|
||||||
|
},
|
||||||
|
noTicketsHander(dValue) {
|
||||||
|
this.needNumber = dValue;
|
||||||
|
this.localNoticeStatus = localStorage.getItem(
|
||||||
|
"_toupaipaidui_never_notice_"
|
||||||
|
);
|
||||||
|
if (!this.localNoticeStatus) {
|
||||||
|
this.buyGiftVisible = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeBuyAndLotteryPopHandler() {
|
||||||
|
this.buyGiftVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+34
-74
@@ -18,7 +18,7 @@
|
|||||||
@click="selectHandler(item)"
|
@click="selectHandler(item)"
|
||||||
>
|
>
|
||||||
<p class="list-day-item">{{ item.packNum }}天</p>
|
<p class="list-day-item">{{ item.packNum }}天</p>
|
||||||
<p>{{ item.money }}{{ money }}</p>
|
<p>{{ item.prize }}{{ money }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="recharge-view-content-button">
|
<div class="recharge-view-content-button">
|
||||||
@@ -34,11 +34,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="recharge-view-footer">
|
<div class="recharge-view-footer">
|
||||||
<div class="surplus-itme">
|
<div class="surplus-itme">
|
||||||
<span>剩余欢乐券:</span
|
<span>剩余{{ unit }}:</span
|
||||||
><span class="light">{{ this.remainTicketNum }}</span>
|
><span class="light">{{ this.remainTicketNum }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="surplus-itme">
|
<div class="surplus-itme">
|
||||||
<span>剩余金币:</span><span class="light">{{ this.goldNum }}</span>
|
<span>剩余{{ money }}:</span
|
||||||
|
><span class="light">{{ this.goldNum }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,8 +47,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { queryPackList, buyPack } from "@/api";
|
import { mapGetters, mapActions } from "vuex";
|
||||||
import { mapGetters, mapMutations } from "vuex";
|
|
||||||
import { money, unit } from "@/config";
|
import { money, unit } from "@/config";
|
||||||
export default {
|
export default {
|
||||||
name: "rechargeView",
|
name: "rechargeView",
|
||||||
@@ -56,63 +56,49 @@ export default {
|
|||||||
return {
|
return {
|
||||||
money,
|
money,
|
||||||
unit,
|
unit,
|
||||||
getHappyGiftObj: null,
|
|
||||||
defaultShowImg: require("@/assets/images/logo.jpg"),
|
defaultShowImg: require("@/assets/images/logo.jpg"),
|
||||||
selectOption: [
|
|
||||||
{
|
|
||||||
packNum: 1,
|
|
||||||
money: 20
|
|
||||||
},
|
|
||||||
{
|
|
||||||
packNum: 10,
|
|
||||||
money: 200
|
|
||||||
},
|
|
||||||
{
|
|
||||||
packNum: 100,
|
|
||||||
money: 2000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
packNum: 1000,
|
|
||||||
money: 20000
|
|
||||||
}
|
|
||||||
],
|
|
||||||
curSelect: null
|
curSelect: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(["goldNum", "remainTicketNum"]),
|
...mapGetters([
|
||||||
|
"goldNum",
|
||||||
|
"remainTicketNum",
|
||||||
|
"happyGiftList",
|
||||||
|
"curHappyGift",
|
||||||
|
"curHappyGiftSellingPrice",
|
||||||
|
"curHappyGiftUrl",
|
||||||
|
"curTicketRuleValue"
|
||||||
|
]),
|
||||||
actId() {
|
actId() {
|
||||||
return this.$route.query.actId;
|
return this.$route.query.actId;
|
||||||
},
|
},
|
||||||
showImg() {
|
showImg() {
|
||||||
if (this.getHappyGiftObj && this.getHappyGiftObj.imgUrl)
|
if (this.curHappyGiftUrl) return this.curHappyGiftUrl;
|
||||||
return this.getHappyGiftObj.imgUrl;
|
|
||||||
return this.defaultShowImg;
|
return this.defaultShowImg;
|
||||||
},
|
},
|
||||||
dialogText() {
|
dialogText() {
|
||||||
return `确定花费${this.curSelect.money}${this.money}购买${this.curSelect.packNum}天${this.getHappyGiftObj.name}吗?`;
|
return `确定花费${this.curSelect.prize}${this.money}购买${this.curSelect.packNum}天${this.curHappyGift.name}吗?`;
|
||||||
|
},
|
||||||
|
selectOption() {
|
||||||
|
const arr = [1, 10, 100, 1000];
|
||||||
|
const list = [];
|
||||||
|
for (let index = 0; index < arr.length; index++) {
|
||||||
|
const element = arr[index];
|
||||||
|
list.push({
|
||||||
|
packNum: element,
|
||||||
|
prize: this.curHappyGiftSellingPrice * element
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.curSelect = this.selectOption[0];
|
this.curSelect = this.selectOption[0];
|
||||||
this.loadPackList();
|
if (this.happyGiftList.length === 0) this.loadPackList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["SetRemainTicketNum", "SetGoldNum"]),
|
...mapActions(["loadPackList", "postBuyPack"]),
|
||||||
loadPackList() {
|
|
||||||
queryPackList({ actId: this.actId })
|
|
||||||
.then(res => {
|
|
||||||
const { code, data, message } = res;
|
|
||||||
if (code === 200 && data && data.length) {
|
|
||||||
this.getHappyGiftObj = data[0];
|
|
||||||
} else {
|
|
||||||
this.$toast.fail(message || "获取礼包失败!");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$toast.fail("获取礼包出现意外!");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
selectHandler(item) {
|
selectHandler(item) {
|
||||||
this.curSelect = item;
|
this.curSelect = item;
|
||||||
},
|
},
|
||||||
@@ -122,47 +108,21 @@ export default {
|
|||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
openDialog() {
|
openDialog() {
|
||||||
if (!this.getHappyGiftObj) return;
|
if (!this.curHappyGift) return;
|
||||||
if (!this.getHappyGiftObj.id) return;
|
if (!this.curHappyGift.id) return;
|
||||||
this.$dialog
|
this.$dialog
|
||||||
.confirm({
|
.confirm({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
|
confirmButtonColor: "#9E98FF",
|
||||||
message: this.dialogText
|
message: this.dialogText
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// on confirm
|
// on confirm
|
||||||
this.postBuyPack();
|
this.postBuyPack({ packNum: this.curSelect.packNum });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// on cancel
|
// on cancel
|
||||||
});
|
});
|
||||||
},
|
|
||||||
postBuyPack() {
|
|
||||||
this.$toast.loading({
|
|
||||||
message: "加载中...",
|
|
||||||
forbidClick: true,
|
|
||||||
duration: 0
|
|
||||||
});
|
|
||||||
buyPack({
|
|
||||||
packId: this.getHappyGiftObj.id,
|
|
||||||
packNum: this.curSelect.packNum
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
this.$toast.clear();
|
|
||||||
const { code, message, data } = res;
|
|
||||||
if (code === 200) {
|
|
||||||
// console.log(this.goldNum, data, this.goldNum + data);
|
|
||||||
this.SetRemainTicketNum(this.remainTicketNum + data);
|
|
||||||
this.SetGoldNum(this.goldNum - this.curSelect.money);
|
|
||||||
this.$toast.success("购买成功");
|
|
||||||
} else {
|
|
||||||
this.$toast.fail(message || "购买礼包失败!");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$toast.clear();
|
|
||||||
this.$toast.fail("购买礼包出现意外错误!");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user