技术心得记录:微信小程序之图片频繁变化,几秒之后输出结果(适用于抽奖)

简介: 技术心得记录:微信小程序之图片频繁变化,几秒之后输出结果(适用于抽奖)

测试数据自己动手组建


先上效果图(动画滚动,体现在代码定时器里)


//抽奖


runLottery() {


const that = this


const {


getLuckyBoxHomepage,


classData,


numType


} = this.data


let openOneRewardFiveData = this.data.openOneRewardFiveData


//关闭确认消耗积分弹框


this.setData({


isshowpop: false,


//试玩数据清空


openOneRewardFiveData: 【】


})


//启动定时器


var inteValTime = setInterval(() => {


var result = 【】


var clickNumber = that.data.clickNumber + 1


if (clickNumber > classData.length - 1) {


clickNumber = 0


}


result.push(classData【clickNumber】)


that.setData({


//商品滚动效果


openOneRewardData: result,


clickNumber


})


// console.log(clickNumber, "clickNumber")


// console.log(this.data.openOneRewardFiveData, "openOneRewardFiveData")


// console.log(this.data.animationStatus, "animationStatus")


}, 450);


//抽奖


this.setData({


openOneRewardFiveData: 【】


})


//可以先用测试数据查看效果


common.request(api, {


luckyBoxId: getLuckyBoxHomepage.id,


//开启1次还是5连抽


counts: numType == 'one' ? 1 : 5,


periods: getLuckyBoxHomepage.periods


}, 'POST').then(res => {


console.log("抽奖", res)


if (res.code == 'SUCCESS') {


if (numType == 'one') {


setTimeout(() => {


that.setData({


openOneRewardFiveData: res.data,


clickNumber: 0,


animationStatus: true,


//显示好的按钮


showBtnStatus: true


})


console.log("openOneRewardFiveData", this.data.openOneRewardFiveData)


clearInterval(inteValTime)


}, 3200)


} else {


var fiveTime = setInterval(() => {


var clickNumber_five = that.data.clickNumber_five


clickNumber_five++


//5连抽会隔0.4秒出现抽奖结果


if (clickNumber_five == 5) {


clearInterval(inteValTime)


clearInterval(fiveTime)


that.setData({


clickNumber_five: -1,


clickNumber: 0


})


return false


}


}, 450)


setTimeout(() => {


var fiveDataTime = setInterval(() => {


var clickNumber_five_data = that.data.clickNumber_five_data


clickNumber_five_data++


if (clickNumber_five_data == 5) {


clearInterval(fiveDataTime)


that.setData({


clickNumber_five_data: -1,


showBtnStatus: true,


})


return false


}


openOneRewardFiveData.push(res.data【clickNumber_five_data】)


that.setData({


openOneRewardFiveData,


animationStatus: true,


clickNumber_five_data,


})


if (openOneRewardFiveData.length == 5) {


this.setData({


showBtnStatus: true


})


}


}, 480)


}, 2300)


}


//开奖弹框


this.setData({


runLotteryStatus: !this.data.runLotteryStatus


})


} else {


//积分不足做处理


}


})


},



[/span>view class="protocol-win { {runLotteryStatus? 'block' : 'none'}}" catchtouchmove="touchmove"

[/span>view class="protocol-content-runLottery"

[/span>view class="market_specialEffects"

[/span>view style="position: relative;top: 17.5%;"

[/span>view class="market_rewardDialog"

[/span>view wx:if="{ {!animationStatus}}" class="runLotteryTitle_five"

[/span>view wx:else class="runLotteryTitle_five"


[/span>view wx:if="{ {numType=='one'}}"

[/span>view wx:if="{ {animationStatus}}" class="{ {animationStatus?'animation':''}}"

[/span>view wx:for="{ {openOneRewardFiveData}}" wx:key="index"

[/span>view class="runLotteryFlex"


[/span>view wx:if="{ {item.level==0 && animationStatus}}"


style="background-image: url('');background-size: 100% 100%;width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;"

[/span>image src="{ {item.image}}" />



[/span>view wx:else

[/span>image src="{ {item.image}}" />




[/span>view class="prizeTitle" wx:if="{ {item.commodityName}}"



[/span>view class="prizeTitle" wx:if="{ {item.prizeName}}"


[/span>view class="prizeTitle" wx:if="{ {item.integral>0}}"

[/span>view class="prizeMoney" wx:if="{ {item.price>0}}"

[/span>text style="font-size: 26rpx;"

//代码效果参考:http://www.lyjsj.net.cn/wx/art_23689.html

[/span>text style="font-size: 48rpx;"


[/span>view class="prizeMoney" wx:if="{ {item.integral>0}}"

[/span>text style="font-size: 26rpx;"

[/span>text style="font-size: 48rpx;"





[/span>view wx:else

[/span>view wx:for="{ {openOneRewardData}}" wx:key="index"

[/span>view class="runLotteryFlex"

[/span>view wx:if="{ {item.level==0 && animationStatus}}"


style="background-image: url('');background-size: 100% 100%;width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;"

[/span>image src="{ {item.image}}" />



[/span>view wx:else

[/span>image src="{ {item.image}}" />




[/span>view class="prizeTitle"

[/span>view class="prizeMoney" wx:if="{ {item.price>0}}"

[/span>text style="font-size: 26rpx;"

[/span>text style="font-size: 48rpx;"


[/span>view class="prizeMoney" wx:if="{ {item.integral>0}}"

[/span>text style="font-size: 26rpx;"

[/span>text style="font-size: 48rpx;"






[/span>view wx:else

[/span>view wx:if="{ {animationStatus}}" class="{ {animationStatus?'animation':''}}"

[/span>view class="runLotteryFlex_five_flex_row"

[/span>view class="runLotteryFlex_five_flex" wx:for="{ {openOneRewardFiveData}}"


wx:key="index"

[/span>view class="runLotteryFlex_five"

[/span>view wx:if="{ {item.level==0 && animationStatus}}"


style="background-image: url('');background-size: 100% 100%;width: 100%;height: 100%;

相关文章
|
2天前
|
JSON 小程序 JavaScript
技术心得记录:小爱童鞋@你,一起来撸个小程序吧
技术心得记录:小爱童鞋@你,一起来撸个小程序吧
|
2天前
|
XML 小程序 前端开发
技术心得记录:微信小程序开发的基本流程
技术心得记录:微信小程序开发的基本流程
|
3天前
|
移动开发 小程序 前端开发
技术经验解读:一个简单抓取糗事百科糗事的小程序
技术经验解读:一个简单抓取糗事百科糗事的小程序
|
2天前
|
JSON 缓存 小程序
技术笔记:uniapp微信小程序支付
技术笔记:uniapp微信小程序支付
|
3天前
|
小程序 API PHP
技术经验分享:hinkPHP5.0+小程序商城
技术经验分享:hinkPHP5.0+小程序商城
|
10天前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的小程序疫苗预约网站系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的小程序疫苗预约网站系统的详细设计和实现(源码+lw+部署文档+讲解等)
|
5天前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的智慧农业小程序的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的智慧农业小程序的详细设计和实现(源码+lw+部署文档+讲解等)
20 6
|
5天前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的在线答题微信小程序的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的在线答题微信小程序的详细设计和实现(源码+lw+部署文档+讲解等)
19 3
|
5天前
|
小程序 定位技术
uniapp微信小程序地图全屏显示配送范围
uniapp微信小程序地图全屏显示配送范围
11 1
|
9天前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的校园导航微信小程序的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的校园导航微信小程序的详细设计和实现(源码+lw+部署文档+讲解等)
24 4