Commit 3776f989 authored by wildfirecode13's avatar wildfirecode13

1

parent 6a35ca75
<view class="goodsPage">
<goods-modal
isBackFlag="{{isBackFlag}}"
goodsList="{{goodsList}}"
task="{{task}}"
onCompleteTask="onCompleteTaskHandle" />
</view>
\ No newline at end of file
/**
* 任务类型(taskType):collectGoods、orderGoods、browseGoods、exchangeCredits
* task: {
* itemId: //商品ID
* taskType: //任务类型
* type: //头部样式(02——banner,01——标题)
* image: {//图片
* bg: //集合页背景
* banner: //头部banner
* title: //头部title
* collect: //商品以收藏
* no_collect: //商品未收藏
* }
* color: //商品名称:文字颜色
* }
*/
const app = getApp();
const { tbcc } = app;
const { openDetail, collectGoods, checkGoodsCollectedStatus, commonToast, ConsoleStyle } = tbcc.tb;
import API from '../../api';
import { debounce } from '../../tbcc-sdk/lib/tb';
Page({
data: {
query: {},
task: {},
isBackFlag: 1,
goodsList: [],
taskType: ''
},
onLoad(query) {
this.query = query || {}
// query: frontOrderGoods, browseGoods, orderGoods
if (!query) query = 'browseGoods'
this.setData({ taskType: query })
this.init()
},
onShow() {
//重新回到页面开启倒计时
this.setData({ isBackFlag: Math.floor((Math.random() * 100)) == this.data.isBackFlag ? 101 : Math.floor((Math.random() * 100)) })
},
init() {
let { itemId, taskType } = this.query
taskType = taskType ? taskType : 'browseGoods'
let banner
if (taskType === 'frontOrderGoods') banner = '//yun.duiba.com.cn/spark/assets/yd_title支付定金.ca58631100ce3b73a4a8b1cff3c1bad2c060fc3a.png'
else if (taskType === 'browseGoods') banner = '//yun.duiba.com.cn/spark/assets/yd_title浏览商品.78d3155ae8b60786d793b8c44fe898dc8bbbc4ea.png'
else if (taskType === 'orderGoods') banner = '//yun.duiba.com.cn/spark/assets/yd_title购买商品.b0548da1dc653c283a8c12de2767c7c7d9a789d8.png'
this.setData({
task: {
itemId,
taskType: taskType,
image: {
bg: '//yun.duiba.com.cn/spark/assets/bg1.d818f787351875b0982937d8bb68b0655febec3c.png',
banner: banner,
// title: '//yun.dui88.com/taobaomini/clientCTest/goods_title@2x.png',
collect: '//yun.dui88.com/taobaomini/clientCTest/goods_collection@2x.png',
no_collect: '//yun.dui88.com/taobaomini/clientCTest/collection_no_collect@2x.png',
img: '//yun.dui88.com/taobaomini/clientCTest/goods_img@2x.png',
},
color: '#181818'
}
})
this.initPage()
},
async initPage() {
const { activityId } = app
const { taskType, itemIds } = this.query
API.getItemListByItemIds({activityId: app.activityId, itemIds: itemIds})
.then(res => {
const { success, message, data } = res
if (!success) { console.warn(res); commonToast(res && res.message) }
else {
console.log('%c--------获取商品列表\n' + '-----yd.getItemListByItemIds\n', ConsoleStyle, data)
this.setData({ goodsList: data })
}
})
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {};
// let handel = taskType == 'collectGoods' ? 'getCollectItemList' : 'getItemListByItemIds'
// const { success, data } = await API[handel]({ activityId, itemIds }).catch(res => {
// res && commonToast(res)
// }) || {}
// if(success) {
// this.setData({ goodsList: data || [] })
// }
},
// 完成任务 防抖
onCompleteTaskHandle (taskType,itemId) {
debounce(this.onCompleteTask(taskType,itemId), 300)
},
//任务完成
async onCompleteTask(taskType,itemId) {
console.log(taskType,itemId)
const { activityId } = app
switch(taskType) {
case 'collectGoods':
let { success, data } = await API.doCollectGoodsTask({ activityId, taskType, itemId }).catch(res => {
res && commonToast(res)
}) || {}
if(success) {
this.initPage()
}
break;
// 完成浏览任务
case 'browseGoods':
let browsResult = await API.doBrowseGoodsTask({ activityId, itemId }).catch(res => {
res && commonToast(res)
}) || {}
console.log(browsResult)
if(browsResult.success) {
commonToast('任务完成')
}
break;
}
}
});
{
"usingComponents": {
"goods-modal": "/components/goodsModal/goodsModal"
}
}
\ No newline at end of file
.homepage_wrapper {
width: 100%;
height: 100%;
top: 0;
left: 0rpx;
position: absolute;
z-index: 2;
background: white;
}
.homepage_animation {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
z-index: 30;
}
.homepage_animation_canvas {
width:100%;
height:100%;
}
.homepage_pagecanvas {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
}
.homepage_mian {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
}
.homepage_back {
width: 100%;
height: 1624rpx;
left: 0rpx;
top: calc(50% - 812rpx);
position: absolute;
}
.bei_jing80 {
width: 750rpx;
height: 1624rpx;
left: 0;
top: 0;
position: absolute;
}
.head {
width: 100%;
height: 60rpx;
top: 28rpx;
left: 0;
flex-direction: row;
justify-content: space-between;
display: flex;
position: absolute;
}
.head_ruler {
width: 141rpx;
height: 60rpx;
}
.head_rewards {
width: 141rpx;
height: 60rpx;
}
.bottom {
width: 667rpx;
height: 310rpx;
opacity: 1;
left: 42rpx;
bottom: 22rpx;
position: absolute;
z-index: 5;
}
.bottom_turntable_block {
width: 194rpx;
height: 211rpx;
opacity: 1;
left: 473rpx;
top: 67rpx;
position: absolute;
}
.bottom_turntable_block_image {
width: 194rpx;
height: 211rpx;
opacity: 1;
position: absolute;
}
.gamechoose_block {
width: 409rpx;
height: 200rpx;
opacity: 1;
left: 130.5rpx;
top: -202rpx;
position: absolute;
z-index: 1;
}
.gamechoose_block_back {
width: 409rpx;
height: 200rpx;
opacity: 1;
position: absolute;
z-index: 1;
}
.gamechoose_block_sc {
width: 126rpx;
height: 126rpx;
opacity: 1;
left: 41rpx;
top: 31rpx;
position: absolute;
z-index: 1;
}
.gamechoose_block_xxl {
width: 126rpx;
height: 126rpx;
opacity: 1;
left: 239rpx;
top: 31rpx;
position: absolute;
z-index: 1;
}
.gameChoose_mask {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: transparent;
z-index: 0;
}
.opciaty05 {
opacity: 0.5;
}
.bottom_ydgame_block {
width: 267rpx;
height: 312rpx;
opacity: 1;
left: 200rpx;
position: absolute;
}
.bottom_ydgame_block_image {
width: 267rpx;
height: 260rpx;
opacity: 1;
position: absolute;
}
.bottom_ydgame_block_coin {
width: 194rpx;
height: 40rpx;
line-height: 40rpx;
left: 0;
top: 214rpx;
background-color: #f7cbcf;
border-radius: 21rpx;
text-align: center;
position: absolute;
font-size: 23.8rpx;
font-weight: 500;
color: rgba(200, 82, 73, 1);
}
.bottom_mission_block {
width: 194rpx;
height: 235rpx;
opacity: 1;
top: 67rpx;
position: absolute;
}
.bottom_mission_block_freenum {
width: 224rpx;
height: 40rpx;
line-height: 40rpx;
opacity: 1;
left: 20rpx;
top: 266rpx;
position: absolute;
font-size: 23.8rpx;
font-weight: 500;
color: rgba(200, 82, 73, 1);
border-radius: 20rpx;
background-color: #f7cbcf;
text-align: center;
}
.bottom_mission_block_image {
width: 194rpx;
height: 211rpx;
opacity: 1;
position: absolute;
}
.video_wrapper{
position: absolute;
z-index: 30;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
background: black;
}
.video_wrapper_mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: 20;
}
.video {
position: absolute;
width: 100%;
height: 100%;
background: black;
/* margin: 16rpx auto; */
}
.video_hide {
position: absolute;
z-index: 40;
width: 140rpx;
height: 100rpx;
top: 0;
left: 100rpx;
background: rgba(255, 255, 255, .9);
color: rgb(0, 0, 0);
font-size: 22rpx;
overflow: hidden;
text-align: center;
line-height: 100rpx;
}
.video_block {
width: 430rpx;
height: 408rpx;
opacity: 1;
left: 160rpx;
top: calc(632rpx + (50% - 812rpx));
position: absolute;
z-index: 3;
}
.video_block_wrapper {
width: 100%;
height: 100%;
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
position: relative;
box-shadow: 0 0 24rpx rgba(159, 87, 85, .46);
}
.video_block_wrapper_playicon {
width: 95rpx;
height: 94rpx;
opacity: 1;
left: 170rpx;
top: 84rpx;
position: absolute;
z-index: 10;
}
.video_block_wrapper_postersmall {
width: 400rpx;
height: 180rpx;
left: 15rpx;
top: 15rpx;
position: absolute;
z-index: 8;
}
.video_block_text {
width: 100%;
height: 64rpx;
line-height: 32rpx;
text-align: center;
left: 0;
top: 280rpx;
position: absolute;
font-size: 26rpx;
font-weight: 500;
color: rgba(200, 82, 73, 1);
}
.video_block_up {
width: 100%;
height: 20rpx;
line-height: 20rpx;
text-align: center;
left: 0;
top: 365rpx;
position: absolute;
font-size: 18.3rpx;
color: rgba(203, 165, 112, 1);
text-decoration: underline;
}
.video_btn_left {
width: 83rpx;
height: 84rpx;
opacity: 1;
top: 158rpx;
left: -93rpx;
position: absolute;
}
.video_btn_right {
width: 83rpx;
height: 84rpx;
opacity: 1;
top: 158rpx;
right: -93rpx;
position: absolute;
}
.block_opciaty0 {
opacity: 0;
transition: opacity .2s linear;
}
.block_opciaty1 {
opacity: 1;
transition: opacity .2s linear;
}
.video_block_s {
width: 168rpx;
height: 136rpx;
opacity: 1;
right: 24rpx;
top: calc(930rpx + (50% - 812rpx));
box-shadow: 0 0 8rpx rgba(159, 87, 85, .36);
position: absolute;
border-radius: 6rpx;
z-index: 6;
background: #fff;
}
.video_s {
width: 156rpx;
height: 90rpx;
opacity: 1;
margin: 6rpx auto;
background-color: rgba(0, 0, 0, 0.5);
}
.video_block_tips {
width: 100%;
height: 30rpx;
line-height: 30rpx;
left: 0rpx;
bottom: 4rpx;
text-align: center;
position: absolute;
font-size: 24rpx;
font-weight: 500;
color: rgba(200, 82, 73, 1);
}
.bo_fang_an_niu {
width: 40rpx;
height: 40rpx;
opacity: 1;
left: 68rpx;
top: 30rpx;
position: absolute;
}
.biao_ti75 {
width: 632rpx;
height: 260rpx;
opacity: 1;
left: 110rpx;
top: 279rpx;
position: absolute;
}
<!-- 业务页面部分 -->
<view class="homepage_wrapper {{ gameShow ? 'block_opciaty0' : '' }}" hidden="{{ gameShow_timeout }}">
<!-- 主页 -->
<view class="homepage_mian">
<view class="homepage_back">
<image class="bei_jing80" src="{{resList['abe2084e-ff0b-454d-ad6e-a9117e44bdaa'].url}}" />
<image class="biao_ti75" src="{{resList['3e2471e2-f271-4931-8665-0c2d7fe332b4'].url}}" />
</view>
<!-- 头部 规则-奖品 按钮 -->
<view class="head">
<image class="head_ruler" onTap="showRuleModal" src="{{resList['ee8882be-4b1d-43eb-bad7-8d96318c5022'].url}}" />
<!-- <image class="head_ruler" onTap="showCommonMoadalT1" src="{{resList['ee8882be-4b1d-43eb-bad7-8d96318c5022'].url}}" /> -->
<image class="head_rewards" onTap="gotoMyPrizePage" src="{{resList['74a63fd3-6776-44a2-990e-fadac00fb757'].url}}" />
</view>
<view class="video_wrapper" a:if="{{videoShow}}">
<view class="video_wrapper_mask"></view>
<video
id="videoCtx"
class="video"
src="{{videoSrc}}"
poster="{{posterSrc}}"
controls="{{false}}"
loop="{{isLooping}}"
muted="{{muteWhenPlaying}}"
show-mute-btn="{{showMuteButton}}"
show-fullscreen-btn="{{showFullScreenButton}}"
object-fit="{{objectFit}}"
autoplay="{{autoPlay}}"
direction="{{directionWhenFullScreen}}"
initial-time="{{initTime}}"
mobilenetHintType="{{mobilenetHintType}}"
onPlay="onPlay"
onPause="onPause"
onEnded="onEnded"
onError="onPlayError"
onTimeUpdate="onTimeUpdate"
onLoading="onLoading"
/>
</view>
<view class="video_hide" onTap="videoHideFunc"> 缩小视频 </view>
<!-- 视频部分 -->
<view hidden="{{videoBottom_timeout}}" class="video_block {{ videoBottom ? 'block_opciaty0' : ''}}">
<view class="video_block_wrapper" onTap="videoShowFunc" >
<!-- 视频播放按钮 -->
<image class="video_block_wrapper_playicon" src="" mode="aspectFill" />
<image class="video_block_wrapper_postersmall" src="{{videoImgSrcSmall}}" mode="aspectFill" />
<view class="video_block_text">
<view>观看XXXXX视频</view>
<view>赢惊喜抽奖次数</view>
</view>
<!--
<view class="video_block_up" onTap="onVideoTurnSmall">收起视频</view>
-->
</view>
<!-- 按钮组 左-右 -->
<image class="video_btn_left" onTap="videoTurnLeft" src="{{resList['70006ad9-e7aa-4121-8493-c3c0afa94608'].url}}" />
<image class="video_btn_right" onTap="videoTurnRight" src="{{resList['cf73af84-5751-4aee-a754-9106162786d9'].url}}" />
</view>
<!--
<view hidden="{{!videoBottom_timeout}}" onTap="onVideoTurnBig" class="video_block_s {{ !videoBottom ? 'block_opciaty0' : ''}}" >
<view class='video_s'></view>
<image class="bo_fang_an_niu" src="{{resList['8d5b83a6-59d9-484c-a74e-99f13ba20b02'].url}}" />
<view class="video_block_tips">看视频 赢金币</view>
</view>
-->
<!-- 底部 门票-乐园-抽奖 -->
<view class="bottom">
<view class="bottom_turntable_block" onTap="gotoTurnTable">
<image class="bottom_turntable_block_image" src="{{resList['44b8923b-c9f9-4246-a4ff-4093ff97ca33'].url}}" />
</view>
<view class="bottom_ydgame_block" onTap="openShowChooseGame">
<image class="bottom_ydgame_block_image" src="{{resList['81a085b2-ce9c-4a8f-bdcc-d08f10083134'].url}}" />
<view class="bottom_mission_block_freenum">抽奖次数 X{{drawNum}}</view>
</view>
<view class="bottom_mission_block" onTap="showMissionModal">
<image class="bottom_mission_block_image" src="{{resList['db8bff60-3223-428b-81a8-27c4742a6469'].url}}" />
<view a:if="{{ticketNum}}" class="bottom_ydgame_block_coin"> 免费门票 X{{ticketNum}}</view>
</view>
<!-- 选择游戏 -->
<view class="gamechoose_block" a:if='{{ showChooseGame }}'>
<image class="gamechoose_block_back" src="{{resList['22c949b8-84af-4a22-bb21-70088d1eafad'].url}}" />
<image data-gameType='1' onTap="handleClickGame" class="gamechoose_block_sc {{ ticketNum ? '' : 'opciaty05' }}" src="{{resList['f2915694-4e09-4776-8f38-9ddb285e4d17'].url}}" />
<image data-gameType='2' onTap="handleClickGame" class="gamechoose_block_xxl {{ ticketNum ? '' : 'opciaty05' }}" src="{{resList['7aafb158-7fec-4ae1-a83e-496779c4a107'].url}}" />
<view class="gameChoose_mask" onTap="closeShowChooseGame"></view>
</view>
</view>
</view>
</view>
<!-- 动画 - 游戏部分 -->
<pagecanvas
class="homepage_pagecanvas"
onBackPage="backToPage"
gameType="{{ gameType }}"
gameData="{{ gameData }}"
gamePrize="{{ gamePrize }}"
>
</pagecanvas>
<!-- 弹窗部分 -->
<common-modal-t1 a:if="{{commonModalVisibleT1}}" data="{{commonModalDataT1}}" onModalClose="closeCommonModalT1" onModalConfirm="confirmCommonModalT1" />
<common-modal-t2 a:if="{{commonModalVisibleT2}}" data="{{commonModalDataT2}}" onModalClose="closeCommonModalT2" onModalOne="onModalT2One" onModalTwo="onModalT2Two"/>
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal" text="{{rule}}"></rule-modal>
<rewards-modal a:if="{{rewardsModalVisible}}" onModalClose="closeRewardsModal"></rewards-modal>
<prizes-modal a:if="{{prizesModalVisible}}" onModalClose="closePrizesModal"></prizes-modal>
<mission-modal a:if="{{missionModalVisible}}" onModalClose="closeMissionModal" onRefreshGameInfo="getGameInfo"></mission-modal>
This diff is collapsed.
{
"usingComponents": {
"pagecanvas": "/pages/pagecanvas/pagecanvas",
"rule-modal": "/components/ruleModal/ruleModal",
"rewards-modal": "/components/comRewardsModal/comRewardsModal",
"prizes-modal": "/components/comPrizesModal/comPrizesModal",
"common-modal-t1": "/components/commonModalT1/commonModalT1",
"common-modal-t2": "/components/commonModalT2/commonModalT2",
"mission-modal": "/components/comMissionModal/comMissionModal",
"end-modal": "/components/endModal/endModal"
}
}
\ No newline at end of file
const app = getApp(); const app = getApp();
const { tbcc } = app; const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb; const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb;
import API from '../../api';
Page({ Page({
data: { data: {
}, },
init() {
console.log('do init');
//单独的落地页
//todo 后台新增可配置助力页奖品图,展示区域在球内
},
onLoad(query) { onLoad(query) {
// 页面加载 // 页面加载
console.info(`Page onLoad with query: ${JSON.stringify(query)}`); this.getAuth();
console.info(`Invite Page onLoad with query: ${JSON.stringify(query)}`);
this.inviteId = query.inviteId;
},
/**
* 获取用户授权信息
*/
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
});
if (userInfo) {
console.log('userInfo', userInfo);
const { nickName, avatar } = userInfo;
app.nickName = nickName;
app.avatar = avatar;
this.login();
}
},
/**
* 登录接口
*/
async login() {
const { nickName, avatar, isFollow } = app;
const { success, data } = await API.login({ userNick: nickName, avatar, isFollow: true }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
const { openId } = data;
app.openId = openId;
this.init();
}
} }
}); });
<view class="my-prize">
<prize-modal
myPrizeList="{{myPrizeList}}"
task="{{task}}"
endTime="{{endTime}}"
onHandleClick="handleClick"/>
</view>
\ No newline at end of file
'use strict';
import API from "/api";
import { SHARE_CONFIG } from '/tbcc-sdk/lib/constants';
const app = getApp();
const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard, ConsoleStyle } = tbcc.tb;
const { PRIZE_TYPE_MAP, PRIZE_DRAW_STATUS_MAP } = tbcc.constants;
let flag = false;
Page({
data: {
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP,
myPrizeList: null, //我的奖品
endTime: null,//到期时间
task: {
image: {
bg: '//yun.duiba.com.cn/spark/assets/bg1.d818f787351875b0982937d8bb68b0655febec3c.png', //背景图
copyIcon: '//yun.duiba.com.cn/spark/assets/copyicon.4017db37e6be807f8b864c962beafdfeeaeb26f0.png', //复制
logisticsBth: '//yun.duiba.com.cn/spark/assets/mybtn查看物流.03ea3cdd889c8f09885b24a56dc99460734bc8a6.png', //查看物流
useBtn: '//yun.duiba.com.cn/spark/assets/mybtn去使用.c0276af13ecf949f4624244458dad57128641a54.png', //去使用(除实物奖品外)
addressBth: '//yun.duiba.com.cn/spark/assets/mybtn填写地址.ca58f849aea9c78e0290060624e1dd987ca988ae.png', //填写地址(实物奖品)
addressPriceBth: '//yun.duiba.com.cn/spark/assets/mybtn付邮费领取.dc12fb67b913ba8dd444e800b70f4fd54d377692.png', //填写地址(实物奖品)
jj: '//yun.duiba.com.cn/spark/assets/mybtn立即领取.3b85dd66efc6c18549868f543d48c9e6152d2432.png', //立即领取(除实物奖品外)
hasGetBtn: '//yun.duiba.com.cn/spark/assets/mybtn已领取.e342f48a85fbf9421a45cab37a3eb12eec091705.png', //已领取(优惠券)
getAgainBtn: '//yun.duiba.com.cn/spark/assets/mybtn重新领取.aba2a7e3d9f7724bb6f1aed8ccb50cea0268d0fb.png', //重新领取
invalidBtn: '//yun.duiba.com.cn/spark/assets/mybtn已失效.2fc529b912383145770f97a6c9dd7c413e528172.png', //已失效
failBth: '//yun.duiba.com.cn/spark/assets/mybtn领取失败.3fd23d113a41180b24da14e071772e167ce13b1a.png', //领取失败
doOptions: '//yun.duiba.com.cn/spark/assets/mybtn处理中.2b580c9a13cbaf0f905461d05f7f9a567c63f340.png', //处理中
},
logisticsImage: {
shipped: '//yun.duiba.com.cn/aurora/assets/3a7b68ec171ee339ce619d19f6ae3f9c1e6d801a.png', // 已发货物流弹窗
notShipped: '//yun.duiba.com.cn/aurora/assets/ee0300d7b472c555ecf0b7b8d582fcf9189c2d19.png', // 待发货物流弹窗
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
},
btnStyle: { // 按钮自定义样式
width: '150rpx',
height: '41rpx',
}
}
},
onShow() {
flag = false
this.getMyPrize();
},
onShareAppMessage() {
return SHARE_CONFIG;
},
// 到期时间
getEndTime(prizeList = []) {
if (!prizeList || !prizeList.length) return null
prizeList.forEach(item => {
// + 8 * 60 * 60 * 1000
const endTime = item.expiredTime
if (!endTime) return null;
const yy = new Date(endTime).getFullYear();
const mm = new Date(endTime).getMonth() + 1;
const dd = new Date(endTime).getDate();
const t1 = `${yy}${mm}${dd}日`;
// console.log(new Date(endTime).toLocaleDateString())
// const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日
const t2 = new Date(endTime).getHours() + '';//获取时
const t3 = new Date(endTime).getMinutes() + '';//获取分
const t4 = new Date(endTime).getMilliseconds() + '';//获取秒
item.endTime = t1 + ' ' + t2 + ':' + t3
console.log('endTime', endTime, t1 + ' ' + t2 + ':' + t3);
})
this.setData({
myPrizeList: prizeList
})
},
/**
* 获取奖品列表
* @param {string} type 是否展示loading
*/
async getMyPrize(type) {
const { activityId } = app;
if (type != 'noLoading') {
my.showLoading();
}
API.getMyPrizeList({ activityId })
.then(res => {
const { success, data, message } = res
if (!success) { console.warn(res); commonToast(res && res.message) }
else {
console.log('%c-----获取我的奖品\n' + '-----yd.getMyPrizeList\n', ConsoleStyle, data)
this.setData({ myPrizeList: data })
this.getEndTime(data.list)
}
if (type != 'noLoading') { my.hideLoading() }
})
.catch(res => {
console.warn(res); commonToast(res && res.message);
if (type != 'noLoading') { my.hideLoading() } }) || {};
},
// 领取奖品
async handleClick(e) {
console.log(e)
const { item } = e.target.dataset;
// 领取权益
if (item.type === PRIZE_TYPE_MAP.EQUITY) return this.handleGetEquity(e)
// 领取实物
if (item.type === PRIZE_TYPE_MAP.ENTITY) return this.handleGetEntity(e)
// 领取积分
if (item.type === PRIZE_TYPE_MAP.INTEGRATION) return this.handleGetIntergation(e)
},
// 优惠券
async handleGetEquity(e) {
if (flag) {
return
}
flag = true;
const { activityId } = app;
const { item } = e.target.dataset;
console.log(item, '领取权益')
const { success, data, message } = await API.receiveEnamePrize({ activityId, _id: item._id }).catch(res => {
this.getMyPrize('noLoading')
commonToast(res && res.message)
}) || {};
if (success && data) {
console.log('%c-----领取权益\n' + '-----yd.receiveEnamePrize\n', ConsoleStyle, data)
commonToast('领取成功')
this.getMyPrize()
}
setTimeout(() => {
flag = false
}, 500)
},
// 领取实物前询问
async handleGetEntity(e) {
if (flag) {
return
}
my.showLoading();
flag = true;
const { activityId } = app;
const { item } = e.target.dataset;
const userAddress = await getUserAddress({ joinTag: " " }).catch((data)=>{
flag = false
console.log('getUserAddress出错了,错误信息是',data);
})
my.hideLoading();
if (!userAddress) return
// commonToast(' getUserAddress =>'+JSON.stringify( userAddress))
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
const params = {
activityId,
area:countyName,
addressDetail:detailInfo,
name,
phone: telNumber,
detailInfo,
cityCode,
cityName,
city:cityName,
province:provinceName,
provinceName,
countyName,
streetName,
id:item._id,
_id: item._id
}
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
console.log(result)
const { confirm } = result;
if (confirm) {
this.receiveObjectPrize(params);
}
},
});
flag = false
},
// 领取实物
async receiveObjectPrize(params) {
// commonToast('正在调用receiveObjectPrize'+JSON.stringify(params))
API.receiveObjectPrize(params)
.then((res) => {
// setTimeout(() => {
// commonToast(JSON.stringify(res))
// }, 5000);
const { success, data, message } = res;
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
this.getMyPrize()
}, (rej)=>{
commonToast(rej.message)
})
.catch(res => { console.warn(res); commonToast(res && res.message); flag = false }) || {};z
},
// 积分
async handleGetIntergation(e) {
if (flag) {
return
}
flag = true;
// 判断是否为会员
await this.getUserInfo()
const { isVip, vipUrl } = app;
if (!isVip) {
commonToast('立即加入会员,即可领取奖品', 2000);
setTimeout(() => {
navigateToOutside(vipUrl)
}, 1000)
flag = false
return
}
const { activityId } = app;
const { item } = e.target.dataset;
console.log(item, '领取积分')
API.receiveEnamePrize({ activityId, _id: item._id })
.then(res => {
const { success, data, message } = res
if (success && data) {
console.log('%c-----领取积分\n' + '-----yd.receiveEnamePrize\n', ConsoleStyle, data)
commonToast('领取成功')
flag = false
this.getMyPrize()
} else {
commonToast(message)
flag = false
}
})
.catch(res => { console.warn(res); commonToast(res && res.message); flag = false }) || {};
},
//获取用户vip信息
async getUserInfo() {
const { activityId, inviteId } = app;
API.getVipInfo({ activityId, inviteId })
.then(res => {
const { success, data, message } = res
console.log('%c-----用户vip信息\n' + '-----yd.getVipInfo\n', ConsoleStyle, data)
if (success && data) {
app.isVip = (data && data.isVip) || false;
app.vipUrl = (data && data.url) || '';
flag = false
this.getMyPrize()
} else {
commonToast(message)
flag = false
}
})
.catch(res => { console.warn(res); commonToast(res && res.message); flag = false }) || {};
},
});
\ No newline at end of file
{
"usingComponents": {
"prize-modal": "/components/prizeModal/prizeModal"
}
}
\ No newline at end of file
This diff is collapsed.
.canvas {
width:100%;
height:100%;
}
.page-game {
/* position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
min-height: 100vh; */
background: #fff;
width:100%;
height:100vh;
flex: 1;
display: flex;
flex-direction: column;
}
<view disable-scroll="true" class="page-game">
<canvas disable-scroll="true" id="canvas" type="2d" class="canvas" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady">
</canvas>
</view>
<!-- <rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal> -->
\ No newline at end of file
import { Main } from './output';
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside, getSystemInfo } = tbcc.tb;
const checkSystem = async () => {
const { version } = await getSystemInfo();
console.log('version', version);
return tbcc.utils.versionCompare(version, '9.8.0');
}
Component({
data: {
// 当前正在进行的游戏
gameType: 0,
// 规则弹窗
ruleModalVisible: false,
// 消息弹窗
messageMadalData: {},
messageMadalVisble: false,
},
gameData: null,
didMount() {
this.setData({
gameType: this.props.gameType
})
this.init()
},
didUpdate(prevProps, prevData) {
console.warn('gameType', this.props.gameType)
if (this.props.gameType !== prevProps.gameType) {
this.setData({ gameType: this.props.gameType })
// 切换游戏场景
if (!this.main) return
this.main.changeGameSence(this.props.gameType)
setTimeout(() => {
if (this.props.gameType === 2) this.postMessage('xxlGameData', this.props.gameData)
else if (this.props.gameType === 1) this.postMessage('csdGameData', this.props.gameData)
}, 60)
}
if (this.props.gamePrize !== prevProps.gamePrize && this.props.gamePrize !== null) {
if (this.props.gameType === 2) this.postMessage('xxlGamePrize', this.props.gamePrize)
else if (this.props.gameType === 1) this.postMessage('csdGamePrize', this.props.gamePrize)
}
},
methods: {
back () { this.props.onBackPage() },
init() {
console.log('do init');
this.spark_startEngine();
},
spark_startEngine() {
console.log('spark_startEngine')
var self = this;
my.createCanvas({
id: 'canvas',
success: ccc => {
console.log('cccs')
const dpr = my.getSystemInfoSync().pixelRatio;
const windowWidth = my.getSystemInfoSync().windowWidth;
const windowHeight = my.getSystemInfoSync().windowHeight;
ccc.width = windowWidth * dpr + dpr; //重新修改会有误差
ccc.height = windowHeight * dpr + dpr;
if (!this.main) {
this.main = new Main(ccc); //添加事件,为了和main里的通信
app.canvasMain = this.main;
this.main.addGlobalEvent("onMessage", self.onMessage, self);
}
}
});
},
onCanvasReady() {
console.log('onCanvasReady')
this.changeGameSence(this.props.gameType)
// 授权和登录先搞
checkSystem().then(r => {
if (r) {
this.getAuth();
}
});
},
postMessage(netName, data) {
this.main.dispatchGlobalEvent({
type: netName
}, data); //以防复用事件event串了,就用这种方式
},
//和main通信的方法,接收main的信息
onMessage(e) {
//接口名字
let netName = e.data.netName; //接口参数
let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口
//定制的授权
if (netName.indexOf("mine") == 0) {
var data = {
success: true
};
switch (netName) {
case "mine.getAppData":
//获取信息
data = {
success: true,
data: {
activityId: app.activityId,
nickName: app.nickName,
avatar: app.avatar,
openId: app.openId
}
};
break;
case "mine.navigateToPage": // 切换page
data = { success: true, data: {} };
my.navigateTo({
url: `/pages/${parameter.name}/${parameter.name}`
});
break;
case "mine.backToPage":
this.back()
break;
case "mine.showModal": // 展示弹窗
data = { success: true, data: {} };
const key = `${parameter.name}Visible`;
const dataKey = `${parameter.name}Data`;
const toSetData = {};
toSetData[key] = true;
toSetData[dataKey] = parameter.data;
this.setData(toSetData);
break;
case 'test':
console.log('测试一下', parameter.hint);
break;
}
this.postMessage(netName, data);
} else {
const {
function: fc
} = app.cloud;
const [myCloudName, handler] = netName.split("."); //待写,
parameter.activityId = app.activityId;
fc.invoke(myCloudName, parameter, handler).then(res => {
this.postMessage(netName, res);
});
}
},
//鼠标事件
onMouseEvent(e) {
if (this.main) this.main.stage.onMouseEvent(e);
},
onShow() {
// 页面显示
if (this.main) {
this.main.run();
this.main.dispatchGlobalEvent("onShow");
}
},
onHide() {
// 页面隐藏
if (this.main) {
this.main.pause();
this.main.dispatchGlobalEvent("onHide");
}
},
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
});
if (userInfo) {
console.log('userInfo', userInfo);
const { nickName, avatar } = userInfo;
app.nickName = nickName;
app.avatar = avatar;
this.login();
}
},
async login() {
const { nickName, avatar } = app;
const { success } = await API.login({ userNick: nickName, avatar }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
this.init();
}
},
closeRuleModal() {
this.setData({ ruleModalVisible: false })
},
}
});
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
.shop {
}
.shop-page {
width: 100vw;
height: 100vh;
opacity: 1;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
/* background: url('') no-repeat center top/cover; */
}
.shop .shopbg {
width: 750rpx;
height: 1624rpx;
opacity: 1;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
.shop .shopitem {
width: 309rpx;
height: 324rpx;
opacity: 1;
left: 54rpx;
top: 254rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
.shop .shopitem .shopitem_bg2 {
width: 309rpx;
height: 324rpx;
opacity: 1;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
.shop .shopitem .shopitem_bg1 {
width: 224rpx;
height: 161rpx;
opacity: 1;
left: 45rpx;
top: 29rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
.shop .shopitem .shopitem_disabledbtn {
width: 209rpx;
height: 60rpx;
opacity: 1;
left: 49rpx;
top: 241rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
.shop .shopitem .shopitem_buybtn {
width: 217rpx;
height: 68rpx;
opacity: 1;
left: 45rpx;
top: 237rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
.shop .shopitem .shopitem_txt {
width: 88rpx;
height: 20rpx;
opacity: 1;
left: 136rpx;
top: 261rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
font-size: 21.79723rpx;
color: #474543;
}
.shop .shopitem .shopitem_name {
width: 209rpx;
height: 23rpx;
opacity: 1;
left: 51rpx;
top: 203rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
font-size: 20.12052rpx;
color: #474543;
}
.shop .shop_gold {
width: 98rpx;
height: 21rpx;
opacity: 1;
left: 348rpx;
top: 151rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
font-size: 23.47394rpx;
color: #7b644e;
}
.shop .shop_backbtn {
width: 67rpx;
height: 67rpx;
opacity: 1;
left: 48rpx;
top: 41rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
<view class="shop">
<view class="shop-page" style="{{{'background':`url(${resList['da6bc001-768a-4b1c-95af-a9a8853ef6f9'].url}) no-repeat center top/cover`}}}">
<!-- <image class="shopbg" src={{resList['da6bc001-768a-4b1c-95af-a9a8853ef6f9'].url}} /> -->
<view class="shopitem">
<image class="shopitem_bg2" src={{resList['a5230993-3870-4a91-bdd1-ffc4782770d0'].url}} />
<image class="shopitem_bg1" src={{resList['dd4ee407-16e4-4cb7-9eba-365b33f466a3'].url}} />
<image class="shopitem_disabledbtn" src={{resList['8d08152f-311a-446a-a15a-ff02ebed0139'].url}} />
<image class="shopitem_buybtn" src={{resList['dd8ea96e-e33f-4f5d-b31f-29f332c3c867'].url}} />
<label class="shopitem_txt">101010</label>
<label class="shopitem_name">商品名商品名商品名</label>
</view>
<label class="shop_gold">101010</label>
<image a:if={{false}} class="shop_backbtn" src={{resList['bdab9777-8a4d-4659-ba23-66aaddb7fa5b'].url}} />
</view>
</view>
\ No newline at end of file
'use strict';
import resList from '../../resconfig/resList'; //import API from '../../api';
Page({
data: {},
onLoad(props) {
this.setData( {
resList: resList
});
}
});
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
.turntable_wrapper {
top: 0rpx;
left: 0rpx;
width: 750rpx;
height: 1624rpx;
position: fixed;
top: calc(50% - 812rpx);
left: 0;
}
.turntable_wrapper .bg1 {
width: 750rpx;
height: 1624rpx;
opacity: 1;
position: absolute;
z-index: 0;
}
.zhuang_shi_kao_bei {
width: 750rpx;
height: 1178rpx;
opacity: 1;
position: absolute;
z-index: 1;
}
.turntable_wrapper .turntable_block {
width: 750rpx;
height: 1559rpx;
opacity: 1;
position: relative;
z-index: 2;
}
.turntable {
width: 750rpx;
/* height: auto; */
opacity: 1;
top: 40rpx;
position: absolute;
}
.turntable .turntable_rotate {
width: 750rpx;
height: 1519rpx;
opacity: 1;
position: absolute;
}
.turntable .turntable_rotate .rotate_block {
width: 750rpx;
height: 1519rpx;
opacity: 1;
position: absolute;
}
.rotate {
width: 578rpx;
height: 578rpx;
opacity: 1;
left: 85rpx;
top: 527rpx;
position: absolute;
z-index: 10;
transform-origin: center center;
}
/* .rotate_start {
animation: rotate_infinite 1s linear infinite;
}
@keyframes rotate_infinite {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
} */
.backboard {
width: 100%;
height: 100%;
/* left: 142rpx;
top: 526rpx;
position: absolute; */
}
.backboard image {
width: 100%;
height: 100%;
}
.rewards {
width: 464rpx;
height: 464rpx;
opacity: 1;
left: 57rpx;
top: 57rpx;
position: absolute;
z-index: 2;
/* background: yellowgreen; */
}
.rewards_item {
width: 130rpx;
height: 160rpx;
position: absolute;
opacity: 1;
/* background-color: black; */
transform-origin: center center;
padding-top: 10rpx;
}
.rewards_item_name {
display: block;
width: 100%;
line-height: 2em;
font-size: 26rpx;
color: #bb3346;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.rewards_item_image {
display: block;
width: 96rpx;
height: 96rpx;
margin: 10rpx auto 0;
}
.rewards_item_0{
left: 76rpx;
top: -10rpx;
}
.rewards_item_1{
left: -20rpx;
top: 154rpx;
}
.rewards_item_2{
left: 76rpx;
bottom: -14rpx;
}
.rewards_item_3{
right: 76rpx;
bottom: -14rpx;
}
.rewards_item_4{
right: -20rpx;
top: 154rpx;
}
.rewards_item_5{
right: 76rpx;
top: -10rpx;
}
.rotate_block .outside {
width: 620rpx;
height: 620rpx;
opacity: 1;
left: 64rpx;
top: 505rpx;
position: absolute;
}
.turntable .start_button {
width: 210rpx;
height: 228rpx;
opacity: 1;
left: 274rpx;
top: 700rpx;
position: absolute;
z-index: 10;
}
.start_button .start_button_image {
width: 210rpx;
height: 228rpx;
opacity: 1;
position: absolute;
}
.wen_an01 {
width: 607rpx;
height: 194rpx;
opacity: 1;
left: 73rpx;
top: 218rpx;
position: absolute;
}
.wen_an_biao_ti {
width: 607rpx;
height: 194rpx;
opacity: 1;
position: absolute;
}
.yao_qing_hao_you_zanc_wei_zhi {
width: 100%;
height: 71rpx;
opacity: 1;
left: 0;
top: 10rpx;
position: absolute;
text-align: center;
font-size: 74rpx;
font-weight: 500;
color: rgba(0, 0, 0, 1);
}
.zu2 {
width: 307rpx;
height: 66rpx;
opacity: 1;
left: 148rpx;
top: 128rpx;
position: absolute;
}
.xing_zhuang1 {
width: 307rpx;
height: 4rpx;
opacity: 1;
top: 62rpx;
position: absolute;
}
.xing_zhuang1_kao_bei {
width: 307rpx;
height: 4rpx;
opacity: 1;
position: absolute;
}
.chou_liang_xi_hao_li {
width: 100%;
height: 60rpx;
opacity: 1;
left: 0;
top: 122rpx;
text-align: center;
position: absolute;
font-size: 42rpx;
color: rgba(21, 24, 29, 1);
}
.tu_ceng27 {
width: 20rpx;
height: 15rpx;
opacity: 1;
position: absolute;
font-size: 41.84353rpx;
color: rgba(0, 0, 0, 1);
}
.tu_ceng26 {
width: 20rpx;
height: 15rpx;
opacity: 1;
left: 587rpx;
top: 104rpx;
position: absolute;
font-size: 41.84353rpx;
color: rgba(0, 0, 0, 1);
}
.chance {
width: 100%;
height: 24rpx;
opacity: 1;
left: 0;
top: 498rpx;
position: absolute;
font-size: 24rpx;
text-align: center;
color: #d95477;
}
.logo25 {
width: 295rpx;
height: 196rpx;
opacity: 1;
left: 228rpx;
position: absolute;
}
.myVideo_wrapper {
position: absolute;
top: 100rpx;
left: 100rpx;
width: 500rpx;
height: 400rpx;
transform: translate3d(0, 0, 0);
}
.myVideo_wrapper_after {
transition: transform 1.5s ease-in-out;
position: absolute;
transform: translate3d(300, 400, 0);
transform: translate3d(300, 400, 0);
width: 300rpx;
height: 200rpx;
}
.myVideo {
width: 100%;
height: 100%;
}
<view class="turntable_wrapper">
<!-- 背景 -->
<image class="bg1" src="{{resList['a6341ace-cb10-4143-8763-1a7234e80d7a'].url}}" />
<!-- MAIN BLOCK -->
<view class="turntable_block">
<!-- 旋转转盘 -->
<view class="turntable">
<view class="turntable_rotate">
<view class="rotate_block">
<!-- 旋转部分 -->
<view class="rotate" animation="{{myAnimation}}">
<view class='backboard'>
<image src="{{resList['b36c6a57-a96b-407d-b1a1-7745e3880ab2'].url}}" mode="aspectFill" />
</view>
<view class="rewards">
<view a:for='{{listTurnTable}}' a:key='*this' data-itemIdx='{{index}}'
class='rewards_item {{`rewards_item_${index}`}}' style='transform: rotate({{-(index) * 60 - 30}}deg);'>
<label class='rewards_item_name' style='color: {{ ((index + 1) % 2) ? "rgba(239, 43, 31, 1)" : "#ffffff" }}'>{{item.name}}</label>
<image class='rewards_item_image' src='{{item.image}}' mode='{{aspectFill}}' style='height:{{item.type == 5 ? 72 : 96}}rpx' />
<!-- <label class='rewards_item_name' style='color: {{ ((index + 1) % 2) ? "rgba(239, 43, 31, 1)" : "#ffffff" }}'>ysl 唇膏</label> -->
<!-- <image class='rewards_item_image' src='//yun.duiba.com.cn/spark-dev/assets/79bd22b20d0633d716c45292b79faab3714ae0ac.png' /> -->
</view>
</view>
</view>
<!-- 外层不动 -->
<image class="outside" src="{{resList['7750fff8-383d-4135-b20b-b3108d5d0845'].url}}" />
</view>
</view>
<!-- 开始按钮 -->
<view class="start_button" onTap='handdlerStartButton'>
<image class="start_button_image" src="{{resList['9ac2fe27-618d-444d-9548-6cab5e1c76dd'].url}}" />
</view>
</view>
<!-- 顶部文案 -->
<label class="chance">剩余抽奖次数:{{leftTimes}}次</label>
</view>
</view>
<!-- 弹窗-奖品信息 -->
<rewards-modal a:if='{{rewardsModalShow}}' modalData='{{rewardsModalData}}' onModalClose='onModalClose' onModalConfirm='onModalConfirm' data-modalType='rewards' />
<!-- 弹窗部分 -->
<common-modal-t1 a:if="{{commonModalVisibleT1}}" data="{{commonModalDataT1}}" onModalClose="closeCommonModalT1" onModalConfirm="confirmCommonModalT1" />
<common-modal-t2 a:if="{{commonModalVisibleT2}}" data="{{commonModalDataT2}}" onModalClose="closeCommonModalT2" onModalOne="onModalT2One" onModalTwo="onModalT2Two"/>
<!-- 抽奖次数不足,快去雅顿乐园玩游戏赢抽奖次数吧 -->
<!-- 弹窗-抽奖结果 -->
<!-- <draw-modal a:if='{{drawModalShow}}' modalData='{{drawModalData}}' onModalClose='onModalClose' onModalConfirm='onModalConfirm' data-modalType='draw' /> -->
const app = getApp();
import API from '../../api';
import { clickStat } from '../../md';
import resList from '../../resconfig/resList.js'
const { tbcc } = app;
const { SHARE_CONFIG, REDIRECT_URL } = tbcc.constants;
const { commonToast, getAuthUserInfo, navigateToOutside, ConsoleStyle, checkShopFavoredStatus, debounce } = tbcc.tb;
Page({
data: {
commonModalConfirmT1: null,
commonModalVisibleT1: false,
onModalT2One: null,
onModalT2Two: null,
commonModalVisibleT2: false,
ruleModalVisible: false,
rewardsModalVisible: false,
prizesModalVisible: false,
missionModalVisible: false,
resList: resList,
listTurnTable_test: [1, 2, 3, 4, 5], // 转盘奖品信息_测试
listTurnTable: [], // 转盘奖品信息
prizeList: [], // props中获取到的奖品信息
tempStyle: { // 转盘旋转
transform: ''
},
myAnimation: '', // 旋转动画
rotateFlag: false, // 是否在旋转中
rewardsInfo: {}, // 获奖的奖品信息
leftTimes: 0, // 剩余抽奖次数
rewardsModalShow: false, // 弹窗控制-奖品信息
drawModalShow: true, // 弹窗控制-抽奖结果
},
activityId: undefined,
onLoad(query) {
// 页面加载
// this.getAuth()
console.info(`Page onLoad with query: ${JSON.stringify(query)}`)
let { activityId } = app
this.activityId = activityId
this.getDataTurnTable()
this.getGameInfo()
},
onCallBack () {
// console.log(this.data.listRange)
},
async getGameInfo () {
API.getGameInfo({ activityId: this.activityId })
.then(res => {
const { success, message, data } = res
if (!success) { console.warn(res); commonToast(res && res.message) }
else {
console.log('%c-----获取游戏信息\n' + '-----yd.getGameInfo\n', ConsoleStyle, data)
this.setData({ leftTimes: data.lotteryTimes })
}
})
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {};
},
async getDataTurnTable () {
let { success, data } = await API.getLotteryPrizeList({ activityId: this.activityId}).catch(res => {
console.warn(res)
commonToast(res && res.message)
}) || {}
if (success && data) {
// 开发用
console.log('%c-----获取转盘奖品\n' + '-----getPrizeConfigList\n', ConsoleStyle, data)
let heartBroken = {
image: resList['2a5c22ac-2449-4e2a-af33-8e3a837e20fe'].url,
name: '谢谢参与',
type: 5
}
data.push(...data)
data.push(heartBroken)
this.setData({ listTurnTable: data, leftTimes: data.leftTimes })
}
},
// 点击防抖
handdlerStartButton () {
debounce (this.startDraw(), 300)
},
timer: null,
timerCount: 0,
// 开始旋转 转盘
async startDraw () {
console.log('startDraw run')
if (this.data.rotateFlag) return
if (!this.data.leftTimes > 0) {
commonToast('您还没有抽奖次数')
return
}
const { success, data } = await API.drawLotteryPrize({ activityId: this.activityId, prizeDataType: 3 }).catch(res => {
commonToast(res && res.message)
return
}) || {}
// let success = true
// let data = {
// id: '5f7295860cb733e8928791b6',
// type: 3,
// }
this.setData({ rotateFlag: true })
if (success && data) {
let rotateT // 旋转扇面
let rotateDeg // 选装角度
// 5:谢谢参与
if (data.type == 5) {
this.data.listTurnTable.forEach((item, index) => {
if (item.type == 5) rotateT = index + 1
})
// 1:权益(优惠券),2:积分,3:实物
} else if (data.type == 1 || data.type == 2 || data.type == 3) {
this.data.listTurnTable.forEach((item, index) => {
if (item._id == data.id) {
rotateT = index + 1
rotateT = 4 + 1
this.setData({ rewardsInfo: data })
}
})
}
// 调整位置-归零
this.animateRotation(this.timerCount ? 360 * (++this.timerCount * 2) : 0, 1)
rotateDeg = rotateT * 60 - 30
// 开始动画
setTimeout(() => {
this.animateRotation(360 * (++this.timerCount * 2) + rotateDeg, 1000 * (rotateDeg / 360) + 1000)
//更改 rotateFlag
setTimeout(() => { this.setData({ rotateFlag: false }) }, 1000 * (rotateDeg / 360) + 1000 + 20)
}, 300)
this.setData({ leftTimes: --this.data.leftTimes })
}
},
// 旋转动画rot:旋转角度,timegap:旋转时间
animateRotation (rot, timegap) {
console.log('animateRotation run')
let animation = my.createAnimation({
transformOrigin: 'center center',
duration: timegap,
timeFunction: 'ease-out',
delay: 0
})
animation.rotate(rot).step()
this.setData({
myAnimation: animation.export()
})
},
onModalClose (e) {
// console.log(e)
let fn = () => {
switch (e.currentTarget.dataset.modalType) {
case 'draw':
this.setData({ drawModalShow: false })
break;
case 'rewards':
this.setData({ rewardsModalShow: false })
break;
default:
break;
}
}
debounce( fn() , 300)
},
onModalConfirm (e) {
// TODO: do something
this.onModalClose(e)
},
init() {
this.getIndex()
},
onReady() {
// 页面加载完成
},
onShow() {
// 页面显示
},
onHide() {
// 页面隐藏
},
onUnload() {
// 页面被关闭
},
onTitleClick() {
// 标题被点击
},
onPullDownRefresh() {
// 页面被下拉
},
onReachBottom() {
// 页面被拉到底部
},
/**
* 获取用户权限
*/
async getAuth() {
const userInfo = await getAuthUserInfo()
if (!userInfo) return
const { nickName, avatar } = userInfo
app.nickName = nickName
app.avatar = avatar
this.login()
},
/**
* 获取主接口
*/
async getIndex() {
const { activityId } = app
const { success, data } = await API.getIndex({ activityId }).catch(res => {
commonToast(res && res.message)
}) || {}
if (success && data) {
const { title, content, rule } = data
this.setData({ title, content, rule })
}
},
/**
* 登录接口
*/
async login() {
const { activityId, nickName, avatar } = app
const { success } = await API.login({ activityId, nickName, avatar }).catch(res => {
commonToast(res && res.message)
}) || {}
if (success) {
this.init()
}
},
/**
* 显示规则弹层
*/
showRuleModal() {
this.setData({
ruleModalVisible: true
})
},
/**
* 通用弹出确认按钮回调
*/
confirmCommonModal() {
const { commonModalConfirm } = this.data
commonModalConfirm && commonModalConfirm()
},
// 显示通用弹层
showCommonMoadalT1 ({
title = 'test- title',
content = 'test- content',
confirmCallback = () => {},
btnImg = '//yun.duiba.com.cn/spark/assets/32d8536184c3539c0d9655d03c1b60f3d5e1f60a.png' }) {
this.setData({
commonModalVisibleT1: true,
commonModalDataT1: { title, content, btnImg },
confirmCommonModalT1: () => {
confirmCallback()
this.closeCommonModalT1()
}
})
},
// 显示通用弹层
showCommonMoadalT2 (obj) {
let { title, content, confirmCallback1, confirmCallback2, btnImg1, btnImg2, rewardsImg } = obj
this.setData({
commonModalVisibleT2: true,
commonModalDataT2: { title, content, btnImg1, btnImg2, rewardsImg },
onModalT2One: () => { confirmCallback1() },
onModalT2Two: () => { confirmCallback2() }
})
},
onModalT2One () { this.data.onModalT2One() },
onModalT2Two () { this.data.onModalT2Two() },
confirmCommonModalT1 () { this.data.confirmCommonModalT1() },
/**
* 跳转到天猫页面
*/
goTmallPage() {
navigateToOutside(REDIRECT_URL['tmall'])
},
onShareAppMessage() {
// 返回自定义分享信息
// return SHARE_CONFIG
},
})
{
"usingComponents": {
"common-modal-t1": "/components/commonModalT1/commonModalT1",
"common-modal-t2": "/components/commonModalT2/commonModalT2"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment