123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796 |
- <template>
- <view>
- <!-- #ifdef MP-ALIPAY -->
- <!-- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票开启" v-if="rollingShow"
- leftIconSize="0"></u-navbar> -->
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="抽奖中" v-if="rollingShow"
- leftIconSize="0"></u-navbar>
- <!-- #endif -->
- <!-- #ifndef MP-ALIPAY -->
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="抽奖中" v-if="rollingShow">
- </u-navbar>
- <!-- #endif -->
- <view class="rolling" v-if="rollingShow">
- <!-- 奖品滚动 -->
- <view class="rolling-prize">
- <view ref="rolling" class="rolling-prize-list" :animation="animationData">
- <view class="rolling-prize-list-item flex" v-for="(item, index) in list" :key="index">
- <view class="rolling-prize-list-item__items flex">
- <view class="content flex" v-for="(items, indexs) in item" :key="indexs">
- <image :src="items.picUrl" mode="aspectFit"></image>
- <view class="content-title ells-one"
- v-if="items.prizeType && items.prizeType.value != 'coin'">{{ items.title }}</view>
- <view class="content-title ells-one" v-else>盲豆</view>
- <view class="content-price" v-if="items.prizeType && items.prizeType.value != 'coin'">
- ¥{{ $numberFormat(items.value) }}</view>
- <view class="content-price" v-else>{{ items.value }}个</view>
- </view>
- </view>
- </view>
- </view>
- <view class="rolling-prize-list" :animation="animationData">
- <view class="rolling-prize-list-item flex" v-for="(item, index) in list" :key="index">
- <view class="rolling-prize-list-item__items flex">
- <view class="content flex" v-for="(items, indexs) in item" :key="indexs">
- <image :src="items.picUrl" mode="aspectFit"></image>
- <view class="content-title ells-one"
- v-if="items.prizeType && items.prizeType.value != 'coin'">{{ items.title }}</view>
- <view class="content-title ells-one" v-else>盲豆</view>
- <view class="content-price" v-if="items.prizeType && items.prizeType.value != 'coin'">
- ¥{{ $numberFormat(items.value) }}</view>
- <view class="content-price" v-else>{{ items.value }}个</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 按钮 -->
- <view class="rolling-btn flex">
- <view class="rolling-btn-content flex" :class="{ 'btn-stop': btnIng }" @click="stop" v-show="btnShow">
- <image src="../../static/ticketBox/ticket_btn_center.png" mode="scaleToFill"></image>
- <view class="rolling-btn-content-title">停止滚动</view>
- </view>
- </view>
- <!-- 倒计时 -->
- <view class="rolling-time flex">
- <view class="num">{{ num }}</view>
- </view>
- </view>
- <!-- 奖品显示 -->
- <view class="prize" v-else>
- <!-- #ifndef MP-ALIPAY -->
- <view class="prize-navLeft flex" :style="{ top: statusHeight + 'px' }" @click="back">
- <u-icon size="19" color="#fff" name="arrow-left"></u-icon>
- </view>
- <!-- #endif -->
- <view class="prize-title flex">
- <image src="../../packagePrize/static/rolling_title.png" mode="scaleToFill"></image>
- </view>
- <view class="prize-box flex">
- <view class="prize-box-popup flex">
- <view class="prize-box-popup__image flex">
- <image :src="prizeInfo.picUrl" mode="aspectFit"></image>
- </view>
- <image class="prize-box-popup__rotate" src="../static/rolling_bg1.png" mode="scaleToFill"
- v-if="rotateShow" />
- <image class="prize-box-popup__circular" src="../static/rolling_bg2.png" mode="scaleToFill"
- v-if="circularShow" />
- </view>
- </view>
- <view class="prize-info flex">
- <view class="prize-info-content">
- <view class="prize-info-content-price"
- v-if="prizeInfo.prizeType && prizeInfo.prizeType.value != 'coin'">
- <text>¥</text>{{ $numberFormat(prizeInfo.value) }}</view>
- <view class="prize-info-content-price" v-else>{{ prizeInfo.value }}个</view>
- <!-- #ifdef MP-ALIPAY -->
- <view class="prize-info-content-titletwo"
- v-if="prizeInfo.prizeType && prizeInfo.prizeType.value != 'coin'">{{ prizeInfo.title }}</view>
- <view class="prize-info-content-titletwo" v-else>盲豆</view>
- <!-- #endif -->
- <!-- #ifndef MP-ALIPAY -->
- <view class="prize-info-content-title ells-one"
- v-if="prizeInfo.prizeType && prizeInfo.prizeType.value != 'coin'">{{ prizeInfo.title }}</view>
- <view class="prize-info-content-title" v-else>盲豆</view>
- <!-- #endif -->
- <view class="prize-info-content-btn flex">
- <view class="prize-info-content-btn-content flex" v-if="isTry == 0">
- <image src="../../packagePrize/static/rolling_btn.png" mode="aspectFit"></image>
- <view class="prize-info-content-btn-content-txt" @click="toPrize(prizeInfo.prizeType)"
- v-if="prizeInfo.prizeType && prizeInfo.prizeType.value != 'coin'">去查看我的奖品</view>
- <view class="prize-info-content-btn-content-txt" @click="toPrize(prizeInfo.prizeType)"
- v-else>去商城兑换商品</view>
- </view>
- <view class="prize-info-content-btn-content flex" v-else @click="back">
- <image src="../../packagePrize/static/rolling_btn.png" mode="aspectFit"></image>
- <view class="prize-info-content-btn-content-txt">来把真的</view>
- </view>
- </view>
- </view>
- </view>
- <view class="prize-tip flex" v-if="isTry == 0" @click="back">
- <view class="txt">返回首页</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- export default {
- data() {
- return {
- animationData: {}, // 动画信息
- num: 8, // 动画倒计时
- num2: 0, // 动画持续时间
- time: null, // 定时器
- stopTime: null, //自动停止
- list: [],
- prizeInfo: {},
- btnIng: false,
- rollingShow: true,
- statusHeight: 30,
- btnShow: false,
- boxId: null,
- isTry: null,
- orderId: '',
- ticketId: '',
- rotateShow: true,
- circularShow: true
- }
- },
- onLoad(options) {
- if (options) {
- this.boxId = options.boxId
- this.isTry = Number(options.isTry)
- this.orderId = options.orderId
- this.ticketId = options.ticketId
- this.getList()
- }
- // 创建动画实例
- this.animation = uni.createAnimation()
- // #ifdef MP-WEIXIN
- const res = uni.getMenuButtonBoundingClientRect()
- this.statusHeight = res.top //胶囊距离顶部
- // #endif
-
- },
- onUnload() {
- // 移除动画
- this.animationData = {}
- },
- methods: {
- getList() {
- let _this = this
- let data = {
- boxId: _this.boxId,
- isTry: _this.isTry,
- orderId: _this.orderId,
- ticketId: _this.ticketId
- }
- let num = 0
- let time = setInterval(() => {
- num++
- uni.showLoading({
- title: '加载中'
- });
- $http.post('/api/v1/mp/user/ticket/autoCashPrize', data).then(res => {
- if (res.code == 0) {
- clearInterval(time)
- _this.list = res.data.ticketAwardsPrizeList
- _this.list.forEach(item => {
- item.forEach(ele => {
- ele.picUrl = env.filePublic + ele.picUrl.split(',')[
- 0] + '?imageView2/2/w/170'
- ele.prizeType = JSON.parse(ele.prizeType)
- })
- })
- _this.prizeInfo = {
- ...res.data,
- picUrl: env.filePublic + res.data.picUrl.split(',')[0] +
- '?imageView2/2/w/340',
- prizeType: JSON.parse(res.data.prizeType)
- }
- setTimeout(() => {
- uni.hideLoading();
- _this.btnShow = true
- _this.running()
- }, 500)
- } else if (res.code == 401) {
- uni.hideLoading();
- clearInterval(time)
- uni.navigateBack({
- delta: 2
- })
- } else if (res.code == 500) {
- uni.hideLoading();
- clearInterval(time)
- uni.navigateBack({
- delta: 1
- })
- }
- if (num == 10) {
- uni.hideLoading();
- clearInterval(time)
- }
- }).catch(() => {
- uni.hideLoading();
- clearInterval(time)
- uni.navigateBack({
- delta: 1
- })
- })
- }, 1000)
- },
- // 动画开始
- running() {
- // #ifdef H5
- // 获取滚动奖品列表长度
- this.data = this.$refs.rolling.$el.clientWidth
- // 调用 step() 来表示一组动画完成
- this.animation.translateX(-this.data).step({
- duration: 8000,
- timingFunction: 'linear'
- })
- // export方法导出动画数据
- this.animationData = this.animation.export()
- // 倒计时
- this.time = setInterval(() => {
- // 开奖倒计时、页面显示
- this.num--
- // 记录动画执行时间,停止动画计算移动距离时使用
- this.num2++
- if (this.num == 0) {
- clearInterval(this.time)
- }
- }, 1000)
- // 不手动停止动画,自动停止
- this.stopTime = setTimeout(() => {
- this.stop()
- }, 8000);
- // #endif
- // #ifdef MP-ALIPAY
- my.createSelectorQuery().select('.rolling-prize-list').boundingClientRect().exec(info => {
- this.data = info[0].width
- // 调用 step() 来表示一组动画完成
- this.animation.translateX(-this.data).step({
- duration: 8000,
- timingFunction: 'linear'
- })
- // export方法导出动画数据
- this.animationData = this.animation.export()
- // 倒计时
- this.time = setInterval(() => {
- // 开奖倒计时、页面显示
- this.num--
- // 记录动画执行时间,停止动画计算移动距离时使用
- this.num2++
- if (this.num == 0) {
- clearInterval(this.time)
- }
- }, 1000)
- })
- // 不手动停止动画,自动停止
- this.stopTime = setTimeout(() => {
- this.num = 0
- this.stop()
- }, 8000);
- // #endif
- // #ifdef MP-WEIXIN
- // 元素详细信息
- uni.createSelectorQuery().in(this).select(".rolling-prize-list").boundingClientRect(info => {
- this.data = info.width
- // 调用 step() 来表示一组动画完成
- this.animation.translateX(-this.data).step({
- duration: 8000,
- timingFunction: 'linear'
- })
- // export方法导出动画数据
- this.animationData = this.animation.export()
- // 倒计时
- this.time = setInterval(() => {
- // 开奖倒计时、页面显示
- this.num--
- // 记录动画执行时间,停止动画计算移动距离时使用
- this.num2++
- if (this.num == 0) {
- clearInterval(this.time)
- }
- }, 1000)
- }).exec();
- // 不手动停止动画,自动停止
- this.stopTime = setTimeout(() => {
- this.num = 0
- this.stop()
- }, 8000);
- // #endif
- },
- // 停止动画
- stop() {
- if (this.btnIng) return
- this.btnIng = true
- // 获取屏幕距离,用于计算停止动画移动距离计算
- // #ifndef MP-ALIPAY
- let screenWidth = null
- uni.getSystemInfo({
- success: function(res) {
- screenWidth = res.screenWidth;
- }
- });
- // #endif
-
- /**
- * 0秒:下标4
- * 1秒:下标6
- * 2秒:下标8
- * 3秒:下标10
- * 4秒:下标12
- * 5秒:下标14
- * 6秒:下标16
- * 7秒:下标2
- * 8秒:下标2
- * */
- clearInterval(this.time)
- clearTimeout(this.stopTime)
- this.animationData = {}
- // #ifdef MP-ALIPAY
- this.list[3][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- // #endif
- // #ifndef MP-ALIPAY
- if (this.num2 == 0) {
- this.list[3][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 1) {
- this.list[5][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 2) {
- this.list[7][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 3) {
- this.list[9][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 4) {
- this.list[11][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 5) {
- this.list[13][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 6) {
- this.list[15][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 7) {
- this.list[1][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- } else if (this.num2 == 8) {
- // #ifdef MP-WEIXIN
- this.list[1][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- // #endif
- // #ifdef H5
- this.list[3][1] = JSON.parse(JSON.stringify(this.prizeInfo))
- // #endif
- }
- // #endif
- // #ifdef H5
- /**
- * 根据动画时间移动到指定位置
- * this.data / 8 :动画平均移动距离
- * this.num2 : 动画执行时间
- * screenWidth * 3 :移动3个屏幕距离
- */
- this.animation.translateX(-(this.data / 8 * this.num2 + screenWidth * 3)).step({
- duration: 4000,
- timingFunction: 'ease'
- })
- this.animationData = this.animation.export()
- setTimeout(() => {
- this.rollingShow = false
- }, 4500)
- setTimeout(() => {
- this.circularShow = false
- }, 5100)
- setTimeout(() => {
- this.rotateShow = false
- }, 7500)
- // #endif
- // #ifdef MP-ALIPAY
- let _this = this
- uni.getSystemInfo({
- success: (res) => {
- let windowWidth = res.windowWidth;
- my.createSelectorQuery().select('.rolling-prize-list').boundingClientRect().exec(
- info => {
- _this.data = info[0].width //动画移动距离
- _this.animation.translateX(-(_this.data + windowWidth * 3)).step({
- duration: 4000,
- timingFunction: 'ease'
- })
- _this.animationData = _this.animation.export()
- })
- setTimeout(() => {
- _this.rollingShow = false
- }, 4500)
- setTimeout(() => {
- _this.circularShow = false
- }, 5100)
- setTimeout(() => {
- _this.rotateShow = false
- }, 7500)
- }
- });
- // #endif
- // #ifdef MP-WEIXIN
- uni.createSelectorQuery().in(this).select(".rolling-prize-list").boundingClientRect(info => {
- this.data = info.width
- this.animation.translateX(-(this.data / 8 * this.num2 + screenWidth * 3)).step({
- duration: 4000,
- timingFunction: 'ease'
- })
- this.animationData = this.animation.export()
- }).exec();
- setTimeout(() => {
- this.rollingShow = false
- }, 4500)
- setTimeout(() => {
- this.circularShow = false
- }, 5100)
- setTimeout(() => {
- this.rotateShow = false
- }, 7500)
- // #endif
- },
- back() {
- uni.switchTab({
- url:'/pages/index/index'
- })
- },
- toPrize(data) {
- if (data.value == 'goods') {
- uni.redirectTo({
- url: '/packagePrize/prize/index'
- })
- }
- if (data.value == 'coupon') {
- uni.redirectTo({
- url: '/packagePrize/prize/index?coupon=1'
- })
- }
- if (data.value == 'coupon_pkg') {
- uni.redirectTo({
- url: '/packagePrize/prize/index?coupon=1'
- })
- }
- if (data.value == 'coin') {
- uni.switchTab({
- url: '/pages/core/index'
- })
- }
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .rolling {
- width: 100%;
- height: calc(100vh - 44px);
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/prize_bkg1.png) center center no-repeat;
- background-size: 100vw calc(100vh - 44px);
- overflow: hidden;
- // 奖品滚动
- &-prize {
- display: flex;
- margin-top: 28vh;
- height: 28vh;
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/prize_bkg2.png) center center no-repeat;
- background-size: 100vw 28vh;
- margin-bottom: 82rpx;
- &-list {
- display: flex;
- margin-top: 76rpx;
- height: calc(100% - 76rpx);
- &-item {
- width: 100vw;
- height: 100%;
- &__items {
- align-items: flex-start;
- justify-content: space-evenly;
- width: 100vw;
- height: 100%;
- .content {
- flex-direction: column;
- width: 30%;
- height: 85%;
- image {
- width: 100%;
- height: 60%;
- margin-bottom: 16rpx;
- }
- &-title {
- width: 100%;
- line-height: 34rpx;
- font-size: 26rpx;
- text-align: center;
- margin-bottom: 20rpx;
- }
- &-price {
- width: 100%;
- line-height: 26rpx;
- font-size: 26rpx;
- text-align: center;
- }
- }
- // .content:nth-child(2) {
- // justify-content: flex-start;
- // color: #333;
- // image {
- // width: 100%;
- // height: 60%;
- // }
- // .content-title {
- // font-weight: bold;
- // }
- // .content-price {
- // font-weight: bold;
- // }
- // }
- }
- }
- }
- }
- // 按钮
- &-btn {
- height: 160rpx;
- margin-bottom: 36rpx;
- &-content {
- position: relative;
- height: 100%;
- image {
- width: 486rpx;
- height: 100%;
- }
- &-title {
- position: absolute;
- top: 30rpx;
- font-size: 72rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #FFFFFF;
- line-height: 72rpx;
- opacity: 0.99;
- }
- }
- .btn-stop {
- animation: scaleBtn 0.2s linear;
- }
- // 放大缩小动画
- @keyframes scaleBtn {
- from {
- transform: scale(0.9);
- }
- to {
- transform: scale(1);
- }
- }
- }
- // 倒计时
- &-time {
- .num {
- font-size: 110rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #FFFFFF;
- line-height: 110rpx;
- }
- }
- }
- // 奖品显示
- .prize {
- position: relative;
- width: 100%;
- height: 100vh;
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/hit_bkg.png) center center no-repeat;
- background-size: 100vw 100vh;
- overflow: hidden;
- &-navLeft {
- position: absolute;
- left: 34rpx;
- width: 66rpx;
- height: 66rpx;
- background-color: rgba(255, 255, 255, .36);
- border-radius: 50%;
- }
- &-title {
- padding-top: 15vh;
- margin-bottom: 120rpx;
- image {
- width: 484rpx;
- height: 108rpx;
- }
- }
- &-box {
- margin-bottom: 34rpx;
- &-popup {
- position: relative;
- flex-direction: column;
- width: 75vw;
- height: 38vh;
- background-color: #FFFFFF;
- border-radius: 22rpx;
- &__image {
- position: relative;
- z-index: 10;
- width: 65%;
- height: 65%;
- image {
- width: 100%;
- height: 100%;
- }
- }
- &__rotate {
- position: absolute;
- width: 100%;
- height: 100%;
- z-index: 5;
- animation: rotateBg 3s linear;
- }
- &__circular {
- position: absolute;
- width: 600rpx;
- height: 600rpx;
- z-index: 5;
- animation: scaleBg 0.7s linear;
- }
- // 旋转动画
- @keyframes rotateBg {
- from {
- transform: rotate(0);
- }
- to {
- transform: rotate(360deg);
- }
- }
- // 放大动画
- @keyframes scaleBg {
- from {
- transform: scale(0.8);
- }
- to {
- transform: scale(1.8);
- }
- }
- }
- }
- &-info {
- margin-bottom: 40rpx;
- &-content {
- width: 70vw;
- &-price {
- text-align: center;
- font-size: 40rpx;
- line-height: 40rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- margin-bottom: 20rpx;
- text {
- font-size: 28rpx;
- }
- }
- &-title {
- height: 36rpx;
- overflow: hidden;
- text-align: center;
- font-size: 36rpx;
- line-height: 36rpx;
- color: #FFFFFF;
- margin-bottom: 50rpx;
- }
- &-titletwo {
- height: 36rpx;
- text-align: center;
- font-size: 36rpx;
- line-height: 36rpx;
- color: #FFFFFF;
- margin-bottom: 50rpx;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- &-btn {
- &-content {
- position: relative;
- width: 70vw;
- image {
- width: 70vw;
- height: 112rpx;
- }
- &-txt {
- position: absolute;
- top: 0;
- height: 112rpx;
- line-height: 112rpx;
- font-size: 30rpx;
- text-align: center;
- color: #FFFFFF;
- }
- }
- }
- }
- }
- &-tip {
- .txt {
- width: 332rpx;
- height: 66rpx;
- line-height: 66rpx;
- text-align: center;
- background: rgba(255, 211, 157, .3);
- border-radius: 34rpx;
- font-size: 34rpx;
- font-weight: 500;
- color: #FB930D;
- }
- }
- }
- </style>
|