|
@@ -2,21 +2,20 @@
|
|
|
<view class="luckyDraw">
|
|
|
<image src="../../static/backImg.png" class="back" mode="widthFix"></image>
|
|
|
<view class="luckyDrawContent">
|
|
|
-
|
|
|
<!-- 个人信息模块 -->
|
|
|
<view class="luckyDrawTop">
|
|
|
<view class="left">
|
|
|
- <view class="avatarView">
|
|
|
+ <view class="avatarView" @click="startAni(3)">
|
|
|
<open-data type="userAvatarUrl" class="avatar"></open-data>
|
|
|
</view>
|
|
|
<view class="userInfo">
|
|
|
- <view class="account">{{mpName}}</view>
|
|
|
+ <view class="account" v-if="mpName">{{mpName}}</view>
|
|
|
<view class="ID">ID:{{userId}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="right" @click="jumpSign">
|
|
|
- <text>签到有礼</text>
|
|
|
- </view>
|
|
|
+ <navigator :url="'../checkInRecord/checkInRecord' + getSerialize({...mpData, openId})" class="right" hover-class="none">
|
|
|
+ <text>中奖记录</text>
|
|
|
+ </navigator>
|
|
|
</view>
|
|
|
|
|
|
<!-- 滚动通知 -->
|
|
@@ -27,6 +26,12 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
+
|
|
|
+ <!-- 去抽奖路口 -->
|
|
|
+ <view class="qLuckDraw" @click="jumpSign">
|
|
|
+ <image src="../../static/redEnv.png" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+
|
|
|
<!-- 大转盘 -->
|
|
|
<view class="turntable">
|
|
|
<view class="decorate">
|
|
@@ -34,32 +39,35 @@
|
|
|
<image src="../../static/chassis.png" class="decorateChassis" mode="widthFix"></image>
|
|
|
</view>
|
|
|
<view class="turntableContent">
|
|
|
- <almost-lottery
|
|
|
- :canvasId="canvasConfig.canvasId"
|
|
|
- :canvasWidth="canvasConfig.width"
|
|
|
- :canvasHeight="canvasConfig.height"
|
|
|
- :outerWidth="canvasConfig.outerWidth"
|
|
|
- :outerHeight="canvasConfig.outerHeight"
|
|
|
- :colors="canvasConfig.colors"
|
|
|
- :ringCount="8"
|
|
|
- :duration="5"
|
|
|
- :prizeList="prizeList"
|
|
|
- :prizeIndex="prizeIndex"
|
|
|
- @reset-index="prizeIndex = -1"
|
|
|
- @draw-start="handleDrawStart"
|
|
|
- @draw-end="handleDrawEnd"
|
|
|
- @finish="handleDrawFinish"
|
|
|
- v-if="prizeList.length"
|
|
|
- />
|
|
|
+ <view class="al">
|
|
|
+ <almost-lottery
|
|
|
+ :canvasId="canvasConfig.canvasId"
|
|
|
+ :canvasWidth="canvasConfig.width"
|
|
|
+ :canvasHeight="canvasConfig.height"
|
|
|
+ :outerWidth="canvasConfig.outerWidth"
|
|
|
+ :outerHeight="canvasConfig.outerHeight"
|
|
|
+ :colors="canvasConfig.colors"
|
|
|
+ :ringCount="8"
|
|
|
+ :duration="5"
|
|
|
+ :prizeList="prizeList"
|
|
|
+ :prizeIndex="prizeIndex"
|
|
|
+ @reset-index="prizeIndex = -1"
|
|
|
+ @draw-start="handleDrawStart"
|
|
|
+ @draw-end="handleDrawEnd"
|
|
|
+ @finish="handleDrawFinish"
|
|
|
+ v-if="prizeList.length"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
<view class="bottom">
|
|
|
<view class="cont">今日剩余抽奖次数:<text>{{freeNum}}</text></view>
|
|
|
- <navigator :url="'../checkInRecord/checkInRecord' + getSerialize({...mpData, openId})" class="record" hover-class="none">
|
|
|
- <text>中奖记录</text>
|
|
|
- </navigator>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
+ <view style="margin: 0 30rpx;">
|
|
|
+ <ad-view :unitId="adConfig.bannerAd" adIntervals="200"></ad-view>
|
|
|
+ </view>
|
|
|
+
|
|
|
<!-- 我的奖品 -->
|
|
|
<view class="myPrize">
|
|
|
<view class="title">我的奖品</view>
|
|
@@ -119,7 +127,7 @@
|
|
|
<view class="againLuckDrawBt btVip" @click="againLuckDraw('vip');startAni(2)" :style="{transform: `scale(${scale})`}">再次抽奖</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <image src="../../static/close.png" class="close" mode="widthFix" @click="popupVIPShow = false;startAni(2)"></image>
|
|
|
+ <image src="../../static/close.png" class="close" mode="widthFix" @click="popupVIPShow = false;startAni(2); showCpAd()"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 弹窗12 -->
|
|
@@ -131,7 +139,7 @@
|
|
|
<view class="againLuckDrawBt" @click="againLuckDraw('12'); startAni(3)" :style="{transform: `scale(${scale})`, marginBottom: 0}">再次抽奖</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <image src="../../static/close.png" class="close" mode="widthFix" @click="popup12Show = false; startAni(3)"></image>
|
|
|
+ <image src="../../static/close.png" class="close" mode="widthFix" @click="popup12Show = false; startAni(3); showCpAd()"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 弹窗金币 -->
|
|
@@ -145,7 +153,7 @@
|
|
|
<view class="againLuckDrawBt btGold" @click="againLuckDraw('gold'); startGold(false)" :style="{transform: `translateX(12rpx) scale(${scale})`}">再次抽奖</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <image src="../../static/close.png" class="close" mode="widthFix" @click="popupGoldShow = false; startGold(false)"></image>
|
|
|
+ <image src="../../static/close.png" class="close" mode="widthFix" @click="popupGoldShow = false; startGold(false); showCpAd()"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
@@ -161,23 +169,37 @@
|
|
|
<view class="receiveTs" :animation="animationDataTs">
|
|
|
{{tsTitle}}
|
|
|
</view>
|
|
|
+
|
|
|
+ <!-- 格子广告 -->
|
|
|
+ <view class="singleLattice">
|
|
|
+ <ad-custom-view :unit-id="adConfig.singleLatticeAd" adIntervals="200"></ad-custom-view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- let timer = null
|
|
|
+ let timer = null, powerOnTimer = null, adTimer = null, lqTimer = null;
|
|
|
import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue'
|
|
|
- import { config, getHome, getOpenId, getBanner, setDrawGain, getPond, setReceive } from '@/api/api.js'
|
|
|
+ import { config, getHome, getOpenId, getBanner, setDrawGain, getPond, setReceive, getVersion } from '@/api/api.js'
|
|
|
import { clearCacheFile } from '@/uni_modules/almost-lottery/utils/almost-utils.js'
|
|
|
-
|
|
|
+ import { bannerAd, urgeVideoAd, insertScreenAd, singleLatticeAd } from '@/utils/ad_config.js'
|
|
|
+ import adView from '@/components/ad-view/ad-view.vue'
|
|
|
+ import adCustomView from '@/components/ad-custom-view/ad-custom-view.vue'
|
|
|
+ const systemInfo = uni.getSystemInfoSync()
|
|
|
export default {
|
|
|
components: {
|
|
|
- AlmostLottery
|
|
|
+ AlmostLottery,
|
|
|
+ adView,
|
|
|
+ adCustomView
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
title: 'Hello',
|
|
|
+ adConfig: {
|
|
|
+ bannerAd,
|
|
|
+ singleLatticeAd
|
|
|
+ },
|
|
|
list: [
|
|
|
'恭喜用户 “9016” 成功提现 2000书币',
|
|
|
'恭喜用户 “9017” 成功提现 10书币',
|
|
@@ -187,10 +209,10 @@
|
|
|
// canvas id、宽、高
|
|
|
canvasConfig: {
|
|
|
canvasId: 'almostLotteryCanvas',
|
|
|
- width: 300,
|
|
|
- height: 300,
|
|
|
- outerWidth: 325,
|
|
|
- outerHeight: 325,
|
|
|
+ width: 280,
|
|
|
+ height: 280,
|
|
|
+ outerWidth: 305,
|
|
|
+ outerHeight: 305,
|
|
|
colors: [
|
|
|
'#FEE3C6',
|
|
|
'#FFFFFF'
|
|
@@ -199,8 +221,6 @@
|
|
|
// 以下是奖品配置数据
|
|
|
// 奖品数据
|
|
|
prizeList: [],
|
|
|
- // 奖品是否设有库存
|
|
|
- onStock: false,
|
|
|
// 中奖下标
|
|
|
prizeIndex: -1,
|
|
|
// 是否正在抽奖中,避免重复触发
|
|
@@ -226,7 +246,7 @@
|
|
|
mpData: {},
|
|
|
prizeCountDtoList: [], // 碎片列表
|
|
|
mpName: null, // 渠道号
|
|
|
- userId: null, //
|
|
|
+ userId: 91874, //
|
|
|
luckyDay: {}, // 中奖信息
|
|
|
doubleKey: "", // 领取key
|
|
|
clearTime: "", // 碎片有效期
|
|
@@ -250,6 +270,17 @@
|
|
|
{top: '474rpx', left: '294rpx'}
|
|
|
],
|
|
|
tsTitle: '', //提示信息
|
|
|
+ remoteVersion: null,
|
|
|
+ loading: false,
|
|
|
+ _isLoaded: false,
|
|
|
+ powerOnCount: 0, // 记录开机秒数
|
|
|
+ powerOnTimer: new Date().getTime(), // 保存当前进入页面的时间挫
|
|
|
+ videoType: null, // 1 前面两次看视频翻倍 2 后面8次看视频抽奖
|
|
|
+
|
|
|
+ // 本地
|
|
|
+ weightTotal: 0,
|
|
|
+ // 权重数组
|
|
|
+ weightArr: [],
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -262,6 +293,9 @@
|
|
|
this.mpData = options
|
|
|
this.getData()
|
|
|
this.animation = uni.createAnimation({ timingFunction: 'ease' })
|
|
|
+ getVersion({appId: config.appid}).then(res => {
|
|
|
+ this.remoteVersion = res.data
|
|
|
+ })
|
|
|
},
|
|
|
onUnload() {
|
|
|
uni.hideLoading()
|
|
@@ -289,6 +323,10 @@
|
|
|
await this.getList()
|
|
|
uni.stopPullDownRefresh();
|
|
|
},
|
|
|
+ onReady() {
|
|
|
+ this.createInterstitialAd()
|
|
|
+ this.powerOnShowAd()
|
|
|
+ },
|
|
|
watch: {
|
|
|
// 监听获奖序号的变动
|
|
|
popupShow(newVal, oldVal) {
|
|
@@ -305,6 +343,148 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ powerOnShowAd() {
|
|
|
+ // 开机25秒调取弹窗广告 以后没5分钟调取
|
|
|
+ powerOnTimer = setInterval(() => {
|
|
|
+ this.powerOnCount += 1
|
|
|
+ if(this.powerOnCount === 25 || this.powerOnCount % 325 === 0) {
|
|
|
+ this.showInterstitialAd()
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ // 创建插屏广告 激励视频广告
|
|
|
+ createInterstitialAd() {
|
|
|
+ // 创建插屏广告
|
|
|
+ let interstitialAd = this.interstitialAd = uni.createInterstitialAd({adUnitId: insertScreenAd});
|
|
|
+ interstitialAd.onLoad(() => {
|
|
|
+ // 插屏 广告加载成功
|
|
|
+ console.log("插屏 广告加载成功");
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ interstitialAd.onClose(() => {
|
|
|
+ // 用户点击了关闭或返回键(仅Android有返回键)
|
|
|
+ console.log("插屏 广告关闭");
|
|
|
+ });
|
|
|
+ interstitialAd.onError((err) => {
|
|
|
+ // 插屏 广告加载失败
|
|
|
+ console.log("插屏 广告加载失败", err);
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ // 广告实例创建成功后默认会执行一次 load,加载广告数据
|
|
|
+ // 如果界面有 "显示广告" 按钮,需要先禁用掉,防止用户点击,等待广告数据加载成功后在放开
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ // 激励视频广告
|
|
|
+ this._isLoaded = false
|
|
|
+ let rewardedVideoAd = this._rewardedVideoAd = uni.createRewardedVideoAd({ adUnitId: urgeVideoAd })
|
|
|
+ rewardedVideoAd.onLoad(() => {
|
|
|
+ this._isLoaded = true
|
|
|
+ console.log('onLoad event')
|
|
|
+ // 加载激励视频成功
|
|
|
+ // 当激励视频被关闭时,默认预载下一条数据,加载完成时仍然触发 `onLoad` 事件
|
|
|
+ })
|
|
|
+ rewardedVideoAd.onError((err) => {
|
|
|
+ // 加载激励视频失败
|
|
|
+ this._isLoaded = false
|
|
|
+ console.log('onError event', err)
|
|
|
+ })
|
|
|
+ rewardedVideoAd.onClose((res) => {
|
|
|
+ // 用户点击了【关闭广告】按钮
|
|
|
+ console.log('==============>', res)
|
|
|
+ if (res && res.isEnded) {
|
|
|
+ // 正常播放结束
|
|
|
+ if(this.videoType === 1){ // 看视频翻倍领取
|
|
|
+ this.receiveGold(true)
|
|
|
+ } else if (this.videoType === 2) { // 看视频抽奖
|
|
|
+ if (!this.mpName) { // 首次没有重公众号进入
|
|
|
+ this.localGetPrizeIndex()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.remoteGetPrizeIndex()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 播放中途退出
|
|
|
+ this.prizeing = false
|
|
|
+ this.freeNum++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 抽完奖显示插屏广告
|
|
|
+ showCpAd () {
|
|
|
+ lqTimer && clearTimeout(lqTimer)
|
|
|
+ setTimeout(() => {
|
|
|
+ this.showInterstitialAd()
|
|
|
+ }, 10000)
|
|
|
+ },
|
|
|
+ // 显示插屏广告广告
|
|
|
+ showInterstitialAd() {
|
|
|
+ // 调用 interstitialAd.show(),如果数据正在加载中不会显示广告,加载成功后才显示
|
|
|
+ // 在数据没有加载成功时,需要防止用户频繁点击显示广告
|
|
|
+ if(adTimer) {
|
|
|
+ clearTimeout(adTimer)
|
|
|
+ }
|
|
|
+ let newT = new Date().getTime()
|
|
|
+ if (((newT / 1000) - (this.powerOnTimer / 1000)) < 15) { // 判断是否开机15秒
|
|
|
+ adTimer = setTimeout(() => {
|
|
|
+ if (this.loading == true) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ this.interstitialAd.show().then((res) => {
|
|
|
+ console.log('插屏广告成功---》', res)
|
|
|
+ this.loading = false;
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('插屏广告错误---》', err)
|
|
|
+ });
|
|
|
+ clearTimeout(adTimer)
|
|
|
+ }, newT - this.powerOnTimer + 1000)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.loading == true) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log(11111)
|
|
|
+ this.loading = true;
|
|
|
+ this.interstitialAd.show().then((res) => {
|
|
|
+ console.log('插屏广告成功---》', res)
|
|
|
+ this.loading = false;
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('插屏广告错误---》', err)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 显示激励视频广告
|
|
|
+ showVideoAd(type) {
|
|
|
+ console.log('显示激励视频广告')
|
|
|
+ this.videoType = type
|
|
|
+ if (this._isLoaded) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在拉取~~',
|
|
|
+ })
|
|
|
+ this._rewardedVideoAd.show().then(()=>{
|
|
|
+ uni.hideLoading()
|
|
|
+ console.log('拉取视频then')
|
|
|
+ }).catch((err) => {
|
|
|
+ console.log('拉取视频catch', err)
|
|
|
+ uni.hideLoading()
|
|
|
+ this._rewardedVideoAd && this._rewardedVideoAd.load().then(() => this._rewardedVideoAd && this._rewardedVideoAd.show()).catch(err => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '当前无视频广告',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if(this.videoType === 1){ // 看视频翻倍领取
|
|
|
+ this.receiveGold(true)
|
|
|
+ } else if (this.videoType === 2) { // 看视频抽奖
|
|
|
+ if (!this.mpName) { // 首次没有重公众号进入
|
|
|
+ this.localGetPrizeIndex()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.remoteGetPrizeIndex()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// 是否开始呼吸开关动画
|
|
|
openAniBt(val) {
|
|
|
if(val) {
|
|
@@ -332,7 +512,8 @@
|
|
|
} else {
|
|
|
this.durationMath = this.durationMath + 1
|
|
|
}
|
|
|
- this.animation.top('1300rpx').left(left).step({ duration: 1200, delay: 100 })
|
|
|
+ // this.animation.top('1300rpx').left(left).step({ duration: 1200, delay: 100 })
|
|
|
+ this.animation.top('76rpx').left('60rpx').step({ duration: 1000, delay: 100 })
|
|
|
this.animation.opacity(0).top('453rpx').left('331rpx').step({ duration: 0 })
|
|
|
this.animationData = this.animation.export()
|
|
|
}
|
|
@@ -387,16 +568,26 @@
|
|
|
},
|
|
|
// 看视频双倍
|
|
|
lookVideo() {
|
|
|
- this.receiveGold(true)
|
|
|
+ this.showVideoAd(1)
|
|
|
},
|
|
|
// 领取金币
|
|
|
receiveGold(watchVideos = false) {
|
|
|
+ if (!this.mpName) { // 首次没有重公众号进入
|
|
|
+ this.startGold(watchVideos)
|
|
|
+ this.popupShow = false
|
|
|
+ return
|
|
|
+ }
|
|
|
if(this.doubleKey) {
|
|
|
setReceive({appId: config.appid, doubleKey: this.doubleKey, openId: this.openId, watchVideos, ...this.mpData }).then(res => {
|
|
|
this.startGold(watchVideos)
|
|
|
this.popupShow = false
|
|
|
this.doubleKey = ""
|
|
|
this.getList()
|
|
|
+ if(watchVideos) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.showInterstitialAd()
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
},
|
|
@@ -414,8 +605,19 @@
|
|
|
this.list = res.data
|
|
|
})
|
|
|
} else {
|
|
|
- this.prizeList = [{"prizeId":1,"name":"100书币","stock":100,"weight":10,"prizeImage":"/static/turntable_golds.png"},{"prizeId":2,"name":"书城VIP碎片","stock":100,"weight":10,"prizeImage":"/static/turntable_VIP.png"},{"prizeId":3,"name":"30书币","stock":100,"weight":10,"prizeImage":"/static/turntable_gold.png"},{"prizeId":4,"name":"书城VIP碎片","stock":100,"weight":10,"prizeImage":"/static/turntable_VIP.png"},{"prizeId":5,"name":"10书币","stock":100,"weight":10,"prizeImage":"/static/turntable_gold.png"},{"prizeId":6,"name":"50书币","stock":100,"weight":10,"prizeImage":"/static/turntable_golds.png"},{"prizeId":7,"name":"iPhone12碎片","stock":100,"weight":10,"prizeImage":"/static/turntable_iPhone12.png"},{"prizeId":8,"name":"20书币","stock":100,"weight":10,"prizeImage":"/static/turntable_gold.png"}]
|
|
|
+ this.prizeList = [
|
|
|
+ {"prizeId":1,"name":"100书币","stock":100,"prizeCount": 100,"prizeName": '书币',"weight":0.1,"prizeType": 1,"prizeImage":"/static/turntable_golds.png"},
|
|
|
+ {"prizeId":2,"name":"书城VIP碎片","stock":100,"weight":5,"prizeType": 2,"prizeImage":"/static/turntable_VIP.png"},
|
|
|
+ {"prizeId":3,"name":"30书币","stock":100,"prizeCount": 30,"prizeName": '书币',"weight":1,"prizeType": 1,"prizeImage":"/static/turntable_gold.png"},
|
|
|
+ {"prizeId":4,"name":"书城VIP碎片","stock":100,"weight":5,"prizeType": 2,"prizeImage":"/static/turntable_VIP.png"},
|
|
|
+ {"prizeId":5,"name":"10书币","stock":100,"prizeCount": 10,"prizeName": '书币',"weight":10000,"prizeType": 1,"prizeImage":"/static/turntable_gold.png"},
|
|
|
+ {"prizeId":6,"name":"50书币","stock":100,"weight":1,"prizeCount": 50,"prizeName": '书币',"prizeType": 1,"prizeImage":"/static/turntable_golds.png"},
|
|
|
+ {"prizeId":7,"name":"iPhone12碎片","stock":100,"weight":5,"prizeType": 3,"prizeImage":"/static/turntable_iPhone12.png"},
|
|
|
+ {"prizeId":8,"name":"20书币","stock":100,"prizeCount": 20,"prizeName": '书币',"weight":10000,"prizeType": 1,"prizeImage":"/static/turntable_gold.png"}]
|
|
|
this.prizeCountDtoList = [{"prizeType":2,"prizeCount":0,"prizeName":"书城VIP碎片","maxCount":30},{"prizeType":3,"prizeCount":0,"prizeName":"iPhone12碎片","maxCount":50}]
|
|
|
+
|
|
|
+ this.prizeList.forEach((item) => this.weightTotal += item.weight)
|
|
|
+ this.weightArr = this.prizeList.map((item) => item.weight)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -540,11 +742,39 @@
|
|
|
// 本次抽奖开始
|
|
|
handleDrawStart() {
|
|
|
console.log('触发抽奖按钮')
|
|
|
- if (!this.mpName) { // 首次没有重公众号进入
|
|
|
- uni.navigateTo({
|
|
|
- url: '../officialAccount/officialAccount'
|
|
|
+ if (systemInfo.system.includes('indows')) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请到手机端抽奖!',
|
|
|
+ icon: 'error',
|
|
|
+ duration: 4000
|
|
|
})
|
|
|
return
|
|
|
+ }
|
|
|
+ if (!this.mpName) { // 首次没有重公众号进入
|
|
|
+ if(this.remoteVersion !== config.version) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请先关注公众号~~',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // uni.navigateTo({
|
|
|
+ // url: '../officialAccount/officialAccount'
|
|
|
+ // })
|
|
|
+ // 没有公众号本地抽奖
|
|
|
+ if (this.freeNum > 0) {
|
|
|
+ // 更新免费次数或金币余额
|
|
|
+ if (this.freeNum > 0) {
|
|
|
+ this.freeNum--
|
|
|
+ }
|
|
|
+ if(this.freeNum < 8) {
|
|
|
+ // 看视频
|
|
|
+ this.showVideoAd(2)
|
|
|
+ } else {
|
|
|
+ // 发起抽奖
|
|
|
+ this.localGetPrizeIndex()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
if (this.prizeing) return
|
|
|
this.prizeing = true
|
|
@@ -555,8 +785,14 @@
|
|
|
if (this.freeNum > 0) {
|
|
|
this.freeNum--
|
|
|
}
|
|
|
- // 发起抽奖
|
|
|
- this.remoteGetPrizeIndex()
|
|
|
+ lqTimer && clearTimeout(lqTimer)
|
|
|
+ if(this.freeNum < 8) {
|
|
|
+ // 看视频
|
|
|
+ this.showVideoAd(2)
|
|
|
+ } else {
|
|
|
+ // 发起抽奖
|
|
|
+ this.remoteGetPrizeIndex()
|
|
|
+ }
|
|
|
} else {
|
|
|
this.prizeing = false
|
|
|
uni.showToast({
|
|
@@ -582,6 +818,72 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 没有公众号模拟抽奖
|
|
|
+ // 本地获取中奖下标
|
|
|
+ localGetPrizeIndex() {
|
|
|
+ console.warn('###当前处于前端控制中奖概率,安全起见,强烈建议由后端控制###')
|
|
|
+ // 前端控制概率的情况下,需要拿到最接近随机权重且大于随机权重的值
|
|
|
+ // 后端控制概率的情况下,通常会直接返回 prizeId
|
|
|
+ if (!this.weightTotal) {
|
|
|
+ console.warn('###当前已开启前端控制中奖概率,但是奖品数据列表中的 weight 参数似乎配置不正确###')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log('当前权重总和为 =>', this.weightTotal)
|
|
|
+
|
|
|
+ // 注意这里使用了 Math.ceil,如果某个权重的值为 0,则始终无法中奖
|
|
|
+ let weight = Math.ceil(Math.random() * this.weightTotal)
|
|
|
+ console.log('本次权重随机数 =>', weight)
|
|
|
+
|
|
|
+ let list = [...this.prizeList]
|
|
|
+
|
|
|
+ // 生成大于等于随机权重的数组
|
|
|
+ let tempMaxArrs = []
|
|
|
+ list.forEach((item) => {
|
|
|
+ if (item.weight >= weight) {
|
|
|
+ tempMaxArrs.push(item.weight)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 如果大于随机权重的数组有值,先对这个数组排序然后取值
|
|
|
+ // 反之新建一个临时的包含所有权重的已排序数组,然后取值
|
|
|
+ let tempMaxArrsLen = tempMaxArrs.length
|
|
|
+ if (tempMaxArrsLen) {
|
|
|
+ tempMaxArrs.sort((a, b) => a - b)
|
|
|
+ // 取值时,如果存在多个值,分两种情况
|
|
|
+ if (tempMaxArrsLen > 1) {
|
|
|
+ // 值不相等的情况下取最接近的值,也就是第1个值
|
|
|
+ let sumWeight = tempMaxArrs.reduce((a, b) => a + b)
|
|
|
+ if ((sumWeight / tempMaxArrsLen) !== tempMaxArrs[0]) {
|
|
|
+ this.prizeIndex = this.weightArr.indexOf(tempMaxArrs[0])
|
|
|
+ } else {
|
|
|
+ // 值相等时,随机取值,当然这里你可以自己决定是否随机取值
|
|
|
+ let sameWeight = tempMaxArrs[0]
|
|
|
+ let sameWeightArr = []
|
|
|
+ let sameWeightItem = {}
|
|
|
+ this.weightArr.forEach((item, index) => {
|
|
|
+ if (item === sameWeight) {
|
|
|
+ sameWeightArr.push({
|
|
|
+ weight: item,
|
|
|
+ index
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log('sameWeightArr', sameWeightArr)
|
|
|
+ sameWeightItem = sameWeightArr[Math.floor(Math.random() * sameWeightArr.length)]
|
|
|
+ console.log('sameWeightItem', sameWeightItem)
|
|
|
+ this.prizeIndex = sameWeightItem.index
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.prizeIndex = this.weightArr.indexOf(tempMaxArrs[0])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let tempWeightArr = [...this.weightArr]
|
|
|
+ tempWeightArr.sort((a, b) => a - b)
|
|
|
+ this.prizeIndex = this.weightArr.indexOf(tempWeightArr[tempWeightArr.length - 1])
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].name)
|
|
|
+ },
|
|
|
// 本次抽奖结束
|
|
|
handleDrawEnd() {
|
|
|
console.log('旋转结束,执行拿到结果后到逻辑')
|
|
@@ -589,28 +891,28 @@
|
|
|
this.prizeing = false
|
|
|
let prizeName = this.prizeList[this.prizeIndex].name
|
|
|
let { prizeType, prizeCount } = this.prizeList[this.prizeIndex]
|
|
|
+
|
|
|
+ console.log('1111->', this.prizeList[this.prizeIndex])
|
|
|
this.luckyDay = this.prizeList[this.prizeIndex]
|
|
|
- let tipContent = ''
|
|
|
+
|
|
|
if (prizeName === '谢谢参与') {
|
|
|
- tipContent = '很遗憾,没有中奖,请再接再厉!'
|
|
|
} else if (prizeName.indexOf('碎片') === -1 && this.freeNum >= 8) {
|
|
|
this.popupShow = true
|
|
|
return
|
|
|
} else {
|
|
|
- // 如果奖品设有库存
|
|
|
- if (this.onStock) {
|
|
|
- let prizeStock = this.prizeList[this.prizeIndex].stock
|
|
|
- tipContent = prizeStock ? `恭喜您,获得 ${prizeName}` : `很抱歉,您来晚了,当前奖品 ${prizeName} 已无库存`
|
|
|
- } else {
|
|
|
- if (prizeType === 1) {
|
|
|
- this.popupGoldShow = true
|
|
|
- } else if (prizeType === 2) {
|
|
|
- this.popupVIPShow = true
|
|
|
- } else if (prizeType === 3) {
|
|
|
- this.popup12Show = true
|
|
|
- }
|
|
|
+ if (prizeType === 1) {
|
|
|
+ this.popupGoldShow = true
|
|
|
+ } else if (prizeType === 2) {
|
|
|
+ this.popupVIPShow = true
|
|
|
+ } else if (prizeType === 3) {
|
|
|
+ this.popup12Show = true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (!this.mpName) { // 首次没有重公众号进入
|
|
|
+ console.log("首次没有重公众号进入")
|
|
|
+ return
|
|
|
+ }
|
|
|
this.getList()
|
|
|
},
|
|
|
// 抽奖转盘绘制完成
|
|
@@ -643,7 +945,7 @@
|
|
|
position: absolute;
|
|
|
top: 0;
|
|
|
width: 100%;
|
|
|
- padding: 40rpx 0;
|
|
|
+ padding: 28rpx 0;
|
|
|
margin-bottom: 20rpx;
|
|
|
font-family: PingFangSC-Medium, PingFang SC;
|
|
|
|
|
@@ -692,10 +994,10 @@
|
|
|
}
|
|
|
}
|
|
|
.right{
|
|
|
- width: 212rpx;
|
|
|
- height: 76rpx;
|
|
|
- background: #FEC435;
|
|
|
- border-radius: 40rpx;
|
|
|
+ width: 180rpx;
|
|
|
+ height: 64rpx;
|
|
|
+ background: #BA3A11;
|
|
|
+ border-radius: 30rpx;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
@@ -703,7 +1005,6 @@
|
|
|
font-size: 28rpx;
|
|
|
font-weight: 400;
|
|
|
color: #FFFFFF;
|
|
|
- margin-left: 18rpx;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -711,12 +1012,12 @@
|
|
|
// 滚动通知
|
|
|
.notice {
|
|
|
width: 656rpx;
|
|
|
- height: 68rpx;
|
|
|
+ height: 60rpx;
|
|
|
background: #C7322C;
|
|
|
box-shadow: 0px 4rpx 8rpx 0rpx rgba(49, 49, 49, 0.08);
|
|
|
border-radius: 38rpx;
|
|
|
opacity: 0.53;
|
|
|
- margin: 58rpx auto 0;
|
|
|
+ margin: 38rpx auto 0;
|
|
|
padding: 0 30rpx;
|
|
|
box-sizing: border-box;
|
|
|
display: flex;
|
|
@@ -733,15 +1034,28 @@
|
|
|
width: 600rpx;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 去签到
|
|
|
+ .qLuckDraw {
|
|
|
+ position: absolute;
|
|
|
+ top: 180rpx;
|
|
|
+ right: 10rpx;
|
|
|
+ z-index: 200;
|
|
|
+ animation: lanimation 1.3s linear infinite;
|
|
|
+ &>image {
|
|
|
+ width: 120rpx;
|
|
|
+ height: 120rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 大转盘
|
|
|
.turntable {
|
|
|
position: relative;
|
|
|
- margin-top: 40rpx;
|
|
|
+ margin-top: 20rpx;
|
|
|
.decorate{
|
|
|
position: relative;
|
|
|
width: 100%;
|
|
|
- height: 890rpx;
|
|
|
+ height: 880rpx;
|
|
|
&>image {
|
|
|
width: 100%;
|
|
|
position: absolute;
|
|
@@ -767,43 +1081,45 @@
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
z-index: 20;
|
|
|
- padding-top: 20rpx;
|
|
|
+ .al {
|
|
|
+ width: 100%;
|
|
|
+ height: 804rpx;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ padding-bottom: 40rpx;
|
|
|
+ }
|
|
|
|
|
|
.bottom {
|
|
|
- margin-top: 20rpx;
|
|
|
+ margin-top: 30rpx;
|
|
|
text-align: center;
|
|
|
position: absolute;
|
|
|
- bottom: 35rpx;
|
|
|
+ bottom: 25rpx;
|
|
|
left: 50%;
|
|
|
transform: translateX(-50%);
|
|
|
.cont{
|
|
|
font-size: 28rpx;
|
|
|
font-weight: 400;
|
|
|
color: #FFFFFF;
|
|
|
- margin-bottom: 22rpx;
|
|
|
+ margin-bottom: 12rpx;
|
|
|
text {
|
|
|
font-size: 36rpx;
|
|
|
color: #FEED22;
|
|
|
font-weight: 500;
|
|
|
}
|
|
|
}
|
|
|
- .record{
|
|
|
- font-size: 28rpx;
|
|
|
- font-weight: 500;
|
|
|
- color: #FFFFFF;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 我的奖品
|
|
|
.myPrize {
|
|
|
- margin: 40rpx 26rpx 0;
|
|
|
+ margin: 30rpx 26rpx 0;
|
|
|
min-height: 352rpx;
|
|
|
background: #F4E2CA;
|
|
|
border-radius: 20rpx;
|
|
|
position: relative;
|
|
|
- padding: 58rpx 0 20rpx;
|
|
|
+ padding: 40rpx 0 20rpx;
|
|
|
.title {
|
|
|
position: absolute;
|
|
|
width: 232rpx;
|
|
@@ -830,8 +1146,8 @@
|
|
|
align-items: center;
|
|
|
width: 50%;
|
|
|
&>image {
|
|
|
- width: 208rpx;
|
|
|
- height: 160rpx;
|
|
|
+ width: 180rpx;
|
|
|
+ height: 140rpx;
|
|
|
}
|
|
|
.text{
|
|
|
font-size: 32rpx;
|
|
@@ -843,7 +1159,7 @@
|
|
|
.progress{
|
|
|
position: relative;
|
|
|
width: 200rpx;
|
|
|
- height: 40rpx;
|
|
|
+ height: 38rpx;
|
|
|
margin-top: 12rpx;
|
|
|
background: #FFFCF7;
|
|
|
border-radius: 26rpx;
|
|
@@ -880,7 +1196,7 @@
|
|
|
|
|
|
// 活动规则
|
|
|
.activityRules {
|
|
|
- margin: 40rpx 28rpx 0;
|
|
|
+ margin: 28rpx 28rpx 0;
|
|
|
background: #F4E2CA;
|
|
|
border-radius: 20rpx;
|
|
|
color: #F33938;
|
|
@@ -921,7 +1237,7 @@
|
|
|
left: 0;
|
|
|
right: 0;
|
|
|
bottom: 0;
|
|
|
- z-index: 100;
|
|
|
+ z-index: 201;
|
|
|
.popupContent {
|
|
|
width: 632rpx;
|
|
|
|
|
@@ -1029,7 +1345,7 @@
|
|
|
// 碎片飞行初始样式 // 金币飞行
|
|
|
.fragmentAni, .fragmentGold {
|
|
|
position: absolute;
|
|
|
- z-index: 100;
|
|
|
+ z-index: 201;
|
|
|
top: 453rpx;
|
|
|
left: 330rpx;
|
|
|
opacity: 0;
|
|
@@ -1046,7 +1362,7 @@
|
|
|
position: absolute;
|
|
|
border: 2rpx solid rgb(242, 69, 69);
|
|
|
top: 450rpx;
|
|
|
- z-index: 100;
|
|
|
+ z-index: 201;
|
|
|
color: #FFFFFF;
|
|
|
left: 50%;
|
|
|
transform: translateX(-50%);
|
|
@@ -1055,5 +1371,33 @@
|
|
|
border-radius: 5rpx;
|
|
|
opacity: 0;
|
|
|
}
|
|
|
+
|
|
|
+ .singleLattice {
|
|
|
+ position: absolute;
|
|
|
+ top: 900rpx;
|
|
|
+ right: 8rpx;
|
|
|
+ z-index: 201;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @-webkit-keyframes lanimation {
|
|
|
+ 0% {
|
|
|
+ transform: rotate(0deg);
|
|
|
+ }
|
|
|
+ 8% {
|
|
|
+ transform: rotate(12deg);
|
|
|
+ }
|
|
|
+ 16% {
|
|
|
+ transform: rotate(0deg);
|
|
|
+ }
|
|
|
+ 24% {
|
|
|
+ transform: rotate(-12deg);
|
|
|
+ }
|
|
|
+ 32% {
|
|
|
+ transform: rotate(0deg);
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ transform: rotate(0deg);
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|