Feat:寻看点和抽奖
This commit is contained in:
@@ -1,117 +0,0 @@
|
||||
<template>
|
||||
<view class="logs-view">
|
||||
<view class="btn-box">
|
||||
<button type="default" plain size="mini">抽奖日期</button>
|
||||
<button type="default" plain size="mini">抽奖结果</button>
|
||||
</view>
|
||||
|
||||
<view class="list-box">
|
||||
<view class="item flex jc-between ai-center" v-for="item in list">
|
||||
<view class="flex">
|
||||
<text class="date">{{item.drawTime}}</text>
|
||||
<text class="goods one-t">{{item.prizeName}}</text>
|
||||
</view>
|
||||
|
||||
<image class="btn flex-0" :src="webUrl+'/20220611142551342281.png'" @click="goReceive(item.id)"
|
||||
v-if="item.status==1 && item.isHit==1"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getLotteryRecordsMy
|
||||
} from "@/api/luck.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
lotteryId: null,
|
||||
list: [],
|
||||
page: 1
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.lotteryId = option.id;
|
||||
},
|
||||
onShow() {
|
||||
this.list = [];
|
||||
this.fetchList();
|
||||
},
|
||||
onReachBottom() {
|
||||
this.page++;
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
getLotteryRecordsMy(this.lotteryId, this.page).then(res => {
|
||||
for (let i = 0; i < res.data.records.length; i++) {
|
||||
this.list.push(res.data.records[i])
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
goReceive(id) {
|
||||
uni.navigateTo({
|
||||
url: "receive?id=" + id
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.logs-view {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
background: linear-gradient(180deg, #FFD884 0%, #FF5307 100%);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn-box {
|
||||
margin-top: 54rpx;
|
||||
|
||||
button {
|
||||
outline: none;
|
||||
margin: 0 88rpx;
|
||||
border: none;
|
||||
border-radius: 30rpx;
|
||||
background: linear-gradient(180deg, #ffcd1e 0%, #ff8a18 100%);
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list-box {
|
||||
height: 75vh;
|
||||
margin-top: 20rpx;
|
||||
padding: 32rpx;
|
||||
overflow-y: auto;
|
||||
|
||||
.item {
|
||||
height: 60rpx;
|
||||
margin-bottom: 16rpx;
|
||||
padding: 0 46rpx;
|
||||
border-radius: 30rpx;
|
||||
background: rgba(255, 255, 255, .4);
|
||||
font-size: 24rpx;
|
||||
|
||||
.date {
|
||||
display: inline-block;
|
||||
width: 350rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.goods {
|
||||
width: 190rpx;
|
||||
color: #FF1200;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 80rpx;
|
||||
height: 38rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,382 +0,0 @@
|
||||
<template>
|
||||
<view class="luck-view">
|
||||
<image class="bg-luck" :src="webUrl+'/20220210153759193846.png'" mode="scaleToFill"></image>
|
||||
<image class="btn-log" :src="webUrl+'/20220210142514268256.png'" mode="scaleToFill" @click="goLogs"></image>
|
||||
<image class="dialog" :src="webUrl+'/20220210142530967881.png'" mode="scaleToFill" v-if="newRecords.length>0">
|
||||
</image>
|
||||
<view class="dialog" v-if="newRecords.length>0">
|
||||
<swiper :indicator-dots="false" :autoplay="true" :interval="5000" :duration="1000" circular>
|
||||
<swiper-item v-for="item in newRecords" :key="item">
|
||||
<view class="acea-row row-middle">
|
||||
<image class="avatar" :src="item.avatar" mode="scaleToFill"></image>
|
||||
<text>恭喜{{ item.username }}获得{{ item.prizeName }}</text>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<!-- 大转盘抽奖 -->
|
||||
<view class="wheel-box" v-show="!isDialog">
|
||||
</view>
|
||||
|
||||
<image class="btn-tip" :src="webUrl+'/20220210142525648150.png'" mode="scaleToFill" v-if="lotteryInfo"></image>
|
||||
<view class="btn-tip acea-row row-center-wrapper" v-if="lotteryInfo">
|
||||
<view>剩余
|
||||
<text>{{ lotteryInfo.lotteryUserInfo.dayLimit }}</text>
|
||||
次抽奖机会
|
||||
</view>
|
||||
<!-- <view>剩余<text>{{parseInt(lotteryInfo.lotteryUserInfo.lotteryPoints/lotteryInfo.singleCost)}}</text>次抽奖机会</view> -->
|
||||
</view>
|
||||
|
||||
<view class="tip-box" v-html="lotteryInfo.description" v-if="lotteryInfo">
|
||||
<!-- <view>1.每天有1次幸运大转盘的抽奖机会</view>
|
||||
<view>2.每次抽奖需要消耗{{lotteryInfo.singleCost}}幸运币。</view>
|
||||
<view>3.抽中商品后可去个人中心页面查看订单详情。</view> -->
|
||||
</view>
|
||||
<image class="btn-role" :src="webUrl+'/20220210142520109834.png'" mode="scaleToFill"></image>
|
||||
|
||||
<cover-view class="result-mark" v-if="isDialog">
|
||||
<cover-view class="result-dialog flex flex-col ai-center">
|
||||
<cover-image class="icon-close" :src="webUrl+'/20220610111928963051.png'" mode="scaleToFill"
|
||||
@click="changeDialog(false)"/>
|
||||
<cover-view class="title">恭喜您,中奖啦!</cover-view>
|
||||
<cover-image class="cover" :src="result.imgs[0].src" mode="scaleToFill"/>
|
||||
<cover-view class="name">获得的是{{ result.fonts[0].text }}</cover-view>
|
||||
<button class="btn-fetch" type="default" @click="goReceive">去领取</button>
|
||||
<button class="btn-close" type="default" @click="changeDialog(false)">关闭</button>
|
||||
</cover-view>
|
||||
</cover-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {draw, getLotteryInfo, getLotteryRecordsNew} from "@/api/luck.js";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
blocks: [],
|
||||
buttons: [],
|
||||
prizes: [],
|
||||
defaultConfig: {
|
||||
stopRange: 0.5
|
||||
},
|
||||
lotteryId: null,
|
||||
newRecords: [],
|
||||
lotteryInfo: null,
|
||||
isDialog: false,
|
||||
result: {},
|
||||
lotteryRecordId: null, //抽奖记录ID
|
||||
hitIndex: 0,
|
||||
isWait: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getLuck();
|
||||
this.blocks = [{
|
||||
imgs: [{
|
||||
src: this.webUrl + '/20220210142536583482.png',
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
}]
|
||||
}]
|
||||
this.buttons = [{
|
||||
radius: '50%',
|
||||
imgs: [{
|
||||
src: this.webUrl + '/20220210142504244580.png',
|
||||
width: '177rpx',
|
||||
top: '-65%'
|
||||
}]
|
||||
}]
|
||||
|
||||
},
|
||||
methods: {
|
||||
changeDialog(state){
|
||||
this.isDialog=state
|
||||
},
|
||||
// 初始化
|
||||
getLuck() {
|
||||
getLotteryInfo().then(({
|
||||
data
|
||||
}) => {
|
||||
this.lotteryId = data.id;
|
||||
this.lotteryInfo = data;
|
||||
|
||||
// 处理奖品数据
|
||||
let len = this.lotteryInfo.prizeList.length;
|
||||
let temp;
|
||||
for (let i = 0; i < len; i++) {
|
||||
temp = {
|
||||
imgs: [{
|
||||
src: this.lotteryInfo.prizeList[i].image,
|
||||
width: "80rpx",
|
||||
height: "80rpx",
|
||||
top: "85%"
|
||||
}],
|
||||
fonts: [{
|
||||
text: this.lotteryInfo.prizeList[i].name,
|
||||
top: '50%',
|
||||
fontSize: '28rpx'
|
||||
}]
|
||||
}
|
||||
|
||||
this.$set(this.prizes, i, temp)
|
||||
}
|
||||
|
||||
getLotteryRecordsNew(this.lotteryId).then(({
|
||||
data
|
||||
}) => this.newRecords = data);
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转奖品记录
|
||||
goLogs() {
|
||||
this.$yrouter.push('/v4/views/luck/logs?id=' + this.lotteryId);
|
||||
},
|
||||
// 点击抽奖按钮触发回调
|
||||
startCallBack() {
|
||||
let that = this;
|
||||
if (this.isWait) return;
|
||||
this.isWait = true;
|
||||
|
||||
if (this.lotteryId == null) {
|
||||
uni.showToast({
|
||||
title: "无抽奖活动",
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
draw(this.lotteryId).then(res => {
|
||||
if (res.success) {
|
||||
that.lotteryRecordId = res.data.id;
|
||||
let surplus = that.lotteryInfo.lotteryUserInfo.dayLimit - 1;
|
||||
if (surplus > -1) {
|
||||
that.$set(that.lotteryInfo.lotteryUserInfo, "dayLimit", surplus)
|
||||
}
|
||||
|
||||
for (let i = 0, len = that.lotteryInfo.prizeList.length; i < len; i++) {
|
||||
if (res.data.prizeId == that.lotteryInfo.prizeList[i].id) {
|
||||
that.hitIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 先开始旋转
|
||||
that.$refs.myLucky.play()
|
||||
that.isHit = res.data.isHit;
|
||||
// 使用定时器来模拟请求接口
|
||||
setTimeout(() => {
|
||||
// 调用stop停止旋转并传递中奖索引
|
||||
if (res.data.prizeId == null) that.hitIndex = -1;
|
||||
that.$refs.myLucky.stop(that.hitIndex)
|
||||
}, 3000)
|
||||
} else {
|
||||
that.isWait = false;
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
that.isWait = false;
|
||||
uni.showToast({
|
||||
title: err.msg,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
})
|
||||
|
||||
},
|
||||
// 抽奖结束触发回调
|
||||
endCallBack(prize) {
|
||||
// 奖品详情
|
||||
console.log(prize)
|
||||
this.result = prize;
|
||||
this.isWait = false;
|
||||
|
||||
if (this.lotteryInfo.prizeList[this.hitIndex].name == "谢谢参与") {
|
||||
uni.showToast({
|
||||
title: "别灰心,好运一定会来",
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
return
|
||||
}
|
||||
this.isDialog = true;
|
||||
},
|
||||
|
||||
goReceive() {
|
||||
this.isDialog = false;
|
||||
uni.navigateTo({
|
||||
url: "receive?id=" + this.lotteryRecordId
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
image {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.luck-view {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bg-luck {
|
||||
width: 750rpx;
|
||||
height: 1523rpx;
|
||||
}
|
||||
|
||||
.btn-log {
|
||||
width: 109rpx;
|
||||
height: 49rpx;
|
||||
position: absolute;
|
||||
top: 18rpx;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
width: 521rpx;
|
||||
height: 111rpx;
|
||||
position: absolute;
|
||||
top: 240rpx;
|
||||
left: 114.5rpx;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
|
||||
.acea-row {
|
||||
margin-top: 27rpx;
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 20rpx;
|
||||
background: #FFBEBE;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.wheel-box {
|
||||
position: absolute;
|
||||
top: 352rpx;
|
||||
left: 65rpx;
|
||||
}
|
||||
|
||||
.btn-tip {
|
||||
width: 372rpx;
|
||||
height: 61rpx;
|
||||
position: absolute;
|
||||
top: 1014rpx;
|
||||
left: 189rpx;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
|
||||
text {
|
||||
font-size: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.tip-box {
|
||||
width: 670rpx;
|
||||
height: 290rpx;
|
||||
position: absolute;
|
||||
bottom: 90rpx;
|
||||
left: 40rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 46rpx 30rpx 30rpx;
|
||||
border: 4rpx solid #E69F42;
|
||||
border-radius: 32rpx;
|
||||
background: #fff;
|
||||
font-size: 30rpx;
|
||||
line-height: 1.5;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.btn-role {
|
||||
width: 156rpx;
|
||||
height: 60rpx;
|
||||
position: absolute;
|
||||
bottom: 363rpx;
|
||||
left: 92rpx;
|
||||
}
|
||||
|
||||
.result-mark {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(51, 51, 51, 0.39);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.result-dialog {
|
||||
position: absolute;
|
||||
top: 300rpx;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0);
|
||||
width: 458rpx;
|
||||
height: 560rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #FFF5DB;
|
||||
|
||||
.icon-close {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
right: 26rpx;
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-top: 40rpx;
|
||||
font-size: 34rpx;
|
||||
font-weight: bold;
|
||||
line-height: 50rpx;
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.cover {
|
||||
width: 240rpx;
|
||||
height: 240rpx;
|
||||
vertical-align: middle;
|
||||
margin: 15rpx 0;
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-fetch {
|
||||
width: 176rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 28rpx;
|
||||
border-radius: 30rpx;
|
||||
background: #FD685D;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
height: 34rpx;
|
||||
line-height: 34rpx;
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: #D6BA70;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,159 +0,0 @@
|
||||
<template>
|
||||
<view class="receive-view">
|
||||
<view class="item flex ai-center" :class="{'active':selectIndex===index}" v-for="(item,index) in list"
|
||||
@click="tapItem(index)">
|
||||
<image class="select" :src="webUrl+'/20220613104953149068.png'" mode="scaleToFill" v-if="selectIndex===index" />
|
||||
|
||||
<view class="content">
|
||||
<view class="base flex ai-center">
|
||||
<view>{{item.realName}}</view>
|
||||
<view class="phone">{{item.phone}}</view>
|
||||
</view>
|
||||
|
||||
<view class="address more-t">{{item.province}}{{item.city}}{{item.district}}{{item.detail}}</view>
|
||||
</view>
|
||||
|
||||
<image class="default" :src="webUrl+'/20220613104939432841.png'" mode="scaleToFill" v-if="item.isDefault===1" />
|
||||
</view>
|
||||
|
||||
<button class="btn-receive" type="default" @click="receive">确认领取</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getAddressList
|
||||
} from "@/api/user";
|
||||
import {
|
||||
takePrize
|
||||
} from "@/api/luck";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
id: null, //领奖记录ID
|
||||
list: [], //收货地址列表
|
||||
selectIndex: 0
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.id = option.id;
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
getAddressList({
|
||||
page: 1,
|
||||
limit: 999
|
||||
}).then(res => {
|
||||
if (res.success) {
|
||||
this.list = res.data;
|
||||
if (this.list.length) {
|
||||
for (let i = 0; i < this.list.length; i++) {
|
||||
if (this.list[i].isDefault === 1) this.selectIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
tapItem(index) {
|
||||
this.selectIndex = index;
|
||||
},
|
||||
|
||||
receive() {
|
||||
takePrize(this.id, this.list[this.selectIndex].id).then(res => {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: res.data,
|
||||
success: () => {
|
||||
if (res.success) {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
icon: "error",
|
||||
title: err.msg
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.receive-view {
|
||||
padding: 40rpx;
|
||||
|
||||
.active {
|
||||
box-shadow: 0px 6px 12px rgba(191, 189, 197, 0.6);
|
||||
}
|
||||
|
||||
.item {
|
||||
position: relative;
|
||||
height: 172rpx;
|
||||
margin-bottom: 32rpx;
|
||||
padding: 24rpx 20rpx 28rpx 0;
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
|
||||
.content {
|
||||
margin-left: 24rpx;
|
||||
|
||||
.base {
|
||||
color: #080F1A;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
font-weight: bold;
|
||||
|
||||
.phone {
|
||||
margin-left: 18rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.address {
|
||||
width: 100%;
|
||||
height: 70rpx;
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
.select {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.default {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 72rpx;
|
||||
height: 36rpx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn-receive {
|
||||
position: fixed;
|
||||
bottom: 80rpx;
|
||||
left: 0;
|
||||
width: 686rpx;
|
||||
height: 80rpx;
|
||||
margin: 0 32rpx;
|
||||
border-radius: 40rpx;
|
||||
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.16);
|
||||
background: #FF564A;
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user