Commit a7923cce authored by spc's avatar spc

Merge branch 'yd11_20200922' of gitlab2.dui88.com:wanghongyuan/new_taobao into yd11_20200922

parents a13386be 7aa323bf
......@@ -33,7 +33,7 @@ const apiList = {
},
// 大转盘抽奖
lottery: {
drawLotteryPrize: {
handle: 'lottery',
method: 'get',
isShowLoading: true
......
......@@ -17,6 +17,10 @@ App({
vipUrl: '',
// 直播间页面
liveUrl: '',
// 游戏胜率 - 消消乐
xxlWinRate: 0.7,
// 游戏胜率 - 传送带
csdWinRate: 0.7,
// 全局数据
globalData: {},
......
......@@ -22,6 +22,11 @@
<text a:if="{{item.status === 2}}" class="mission_btn_text">待领取</text>
<text a:if="{{item.status === 3}}" class="mission_btn_text">已完成</text>
<!-- 如果测试 这里 关注店铺 任务有bug
<text a:if="{{item.status === 2 && item.type === 'follow'}}" class="mission_btn_text">待领取</text>
<text a:if="{{item.status === 3 && item.type !== 'follow'}}" class="mission_btn_text">已完成</text>
-->
<view a:if="{{item.taskType === 'invites'}}" class="mission_invite_tips">{{item.completeTimes}}个好友为你助力成功</view>
</view>
</view>
......
......@@ -95,6 +95,11 @@ Component({
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {};
},
onRefreshGameInfo () {
const { onRefreshGameInfo } = this.props;
onRefreshGameInfo && onRefreshGameInfo();
},
onModalClose() {
const { onModalClose } = this.props;
onModalClose && onModalClose();
......@@ -129,6 +134,8 @@ Component({
break;
}
} else if (ds.status === 2) {
// 如果测试 这里 关注店铺 任务有bug
// } else if (ds.status === 2 || (ds.status === 3 && ds.type === 'follow')) {
API.receiveTaskRewards({activityId: app.activityId, taskType: ds.type})
.then(res => {
const { success, message, data } = res
......@@ -136,12 +143,14 @@ Component({
else {
console.log('%c--------领取成功\n' + '-----yd.receiveTaskRewards\n', ConsoleStyle, data)
this.getMissionList()
this.onRefreshGameInfo()
}
})
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {};
} else if (ds.status === 3) {
commonToast('该任务您已经完成了哦')
this.onRefreshGameInfo()
}
},
......
......@@ -3,5 +3,5 @@
isBackFlag="{{isBackFlag}}"
goodsList="{{goodsList}}"
task="{{task}}"
onCompleteTask="onCompleteTask" />
onCompleteTask="onCompleteTaskHandle" />
</view>
\ No newline at end of file
......@@ -18,6 +18,7 @@ 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: {
......@@ -84,6 +85,13 @@ Page({
// this.setData({ goodsList: data || [] })
// }
},
// 完成任务 防抖
onCompleteTaskHandle (taskType,itemId) {
debounce(this.onCompleteTask(taskType,itemId), 300)
},
//任务完成
async onCompleteTask(taskType,itemId) {
console.log(taskType,itemId)
......
......@@ -267,15 +267,25 @@
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
position: relative;
box-shadow: 0 0 24rpx rgba(159, 87, 85, .46);
}
.an_niu {
.video_block_wrapper_playicon {
width: 95rpx;
height: 94rpx;
opacity: 1;
left: 170rpx;
top: 87rpx;
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%;
......
......@@ -48,8 +48,10 @@
<!-- 视频部分 -->
<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">
<image src="{{videoImgSrcSmall}}" mode="aspectFill" />
<view>观看XXXXX视频</view>
<view>赢惊喜抽奖次数</view>
</view>
......@@ -80,7 +82,7 @@
<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 class="bottom_mission_block_freenum">抽奖次数 X{{drawNum}}</view>
</view>
<view class="bottom_mission_block" onTap="showMissionModal">
......@@ -91,8 +93,8 @@
<!-- 选择游戏 -->
<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="changeGameOrPage" class="gamechoose_block_sc {{ ticketNum ? '' : 'opciaty05' }}" src="{{resList['f2915694-4e09-4776-8f38-9ddb285e4d17'].url}}" />
<image data-gameType='2' onTap="changeGameOrPage" class="gamechoose_block_xxl {{ ticketNum ? '' : 'opciaty05' }}" src="{{resList['7aafb158-7fec-4ae1-a83e-496779c4a107'].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>
......@@ -106,6 +108,8 @@
class="homepage_pagecanvas"
onBackPage="backToPage"
gameType="{{ gameType }}"
gameData="{{ gameData }}"
gamePrize="{{ gamePrize }}"
>
</pagecanvas>
......@@ -117,4 +121,4 @@
<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"></mission-modal>
<mission-modal a:if="{{missionModalVisible}}" onModalClose="closeMissionModal" onRefreshGameInfo="getGameInfo"></mission-modal>
......@@ -4,7 +4,7 @@ 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 } = tbcc.tb;
const { commonToast, getAuthUserInfo, navigateToOutside, ConsoleStyle, checkShopFavoredStatus, debounce } = tbcc.tb;
Page({
doExchange: () => {
......@@ -42,14 +42,16 @@ Page({
// 用户是否登陆
userLogin: false,
data: {
// 游戏数据
gameData: null,
// 游戏抽奖
gamePrize: null,
resList: resList,
title: '',
content: '',
rule: '',
commonModalData: {
content: '',
btnText: ''
},
// 视频收起 - flag
videoBottom: false,
// 具有延迟的 视频收起 - flag
......@@ -98,19 +100,14 @@ Page({
async onLoad (query) {
console.info(`%cPage onLoad with query: ${JSON.stringify(query)}`, ConsoleStyle)
if (query.inviteId) {
app.inviteId = query.inviteId
this.inviteId = query.inviteId
console.log('%c该用户是 通过邀请链接 进入', 'color:green; font-size:16px; font-weight:bold;')
}
this.query = query
// 页面加载
// 开场动画
// this.openAnimation().then(async res_ => {
// this.backToPage()
// let res = await this.getAuth()
// this.init()
// })
this.openAnimation().then(async res_ => {
this.backToPage()
this.init()
})
// test - 打点
// clickStat(1, '2')
......@@ -163,12 +160,18 @@ Page({
if (!success) { console.warn(res); commonToast(res && res.message) }
else {
console.log('%c-----活动基本信息\n' + '-----yd.getActivityBaseInfoById\n', ConsoleStyle, data)
app.liveUrl = data.liveUrl
// 游戏胜率 - 消消乐
app.xxlWinRate = data.timeChangeWinRate
// 游戏胜率 - 传送带
app.csdWinRate = data.conveyBeltWinRate
data.videoUrlArr.forEach((item, index) => {
// // 获取视频 视频封面 视频小封面
// this.videoSrcArr[index] = {
// url: item, timeStamp: 0, totalTime: 0, completed: false
// }
// this.posterSrcArr
// this.videoImgSrcSmallArr = data.videoImgSrcSmallArr
// this.posterSrcArr = data.
// this.videoImgSrcSmallArr = data.
})
this.setData({
rule: data.rule,
......@@ -179,25 +182,58 @@ Page({
}
})
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {};
// this.checkDohelp();
// 助力逻辑
if (this.checkDohelpReturnMark()) {
// TODO: 若是助力返回信息,直接调用 this.checkDohelp()
this.checkDohelp()
} else if (this.query.inviteId) {
console.log('%c该用户是 通过邀请链接 进入', 'color:green; font-size:16px; font-weight:bold;')
app.inviteId = this.query.inviteId
this.inviteId = this.query.inviteId
}
},
// 检查助力标记
checkDohelpReturnMark () {
console.warn('检查助力返回标记!!', this.query)
return false
},
// 助力
checkDohelp(){
if (this.inviteId) {
//是分享落地页,可以助力
//todo 需要判断是不是会员
commonToast('准备5秒后给邀请者助力~');
setTimeout(() => {
API.doHelp({activityId: app.activityId,inviteId:this.inviteId}).then(res=>{
commonToast('助力成功~');
}).catch(err=>{
const { data, success } = res
console.log('%c-----助力接口\n' + '-----yd.doHelp\n', ConsoleStyle, res)
if (success) {
this.showCommonMoadalT1({
title: '恭喜您',
content: '助力成功~',
confirmCallback: () => {
this.closeCommonModalT1()
},
btnImg: '//yun.duiba.com.cn/spark/assets/我也要赢大奖.a22bebbd5be4a6e557ee4ef611216ba73b729d10.png' })
} else {
if (!data.isVip) {
app.vipUrl = data.url
this.showCommonMoadalT1({
title: '温馨提示',
content: '成为会员 才能为他助力哦~',
confirmCallback: () => {
navigateToOutside(data.url)
},
btnImg: '//yun.duiba.com.cn/spark/assets/一秒成为会员.10be8a8ede8f6c62eadb005744dc54ae182911d9.png' })
}
commonToast(JSON.stringify(err));
}
}).catch(err=>{
console.log(err)
commonToast(err.message);
});
}, 5000);
} else {
commonToast('不是分享落地页,不需要走助力~')
console.log('不是分享落地页,不需要走助力~')
}
},
......@@ -220,13 +256,7 @@ Page({
// 新用户 助力链接
if (this.isNewUser && this.inviteId) {
this.showCommonMoadalT1({
title: '温馨提示',
content: '成为会员 才能为他助力哦~',
confirmCallback: () => {
navigateToOutside(app.vipUrl)
},
btnImg: '//yun.duiba.com.cn/spark/assets/一秒成为会员.10be8a8ede8f6c62eadb005744dc54ae182911d9.png' })
this.checkDohelp()
// //yun.duiba.com.cn/spark/assets/为他助力.bc57a24aecb04934067712c76186d800343dabd5.png
}
// 新用户 不是助力链接
......@@ -271,6 +301,7 @@ Page({
// 获取 游戏门票 抽奖次数 今日是否首次登陆
getGameInfo () {
return new Promise ((resolve, reject) => {
API.getGameInfo({ activityId: app.activityId })
.then(res => {
const { success, message, data } = res
......@@ -284,8 +315,10 @@ Page({
})
if (this.data.todayFirstLogin) this.userFirstInToday()
}
resolve('complete')
})
.catch(res => { console.warn(res); commonToast(res && res.message); reject('fail') }) || {};
})
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {};
},
// 开场动画
......@@ -298,8 +331,36 @@ Page({
})
},
// 去游戏 防抖
handleClickGame (e) { debounce(this.changeGameOrPage(e), 300) },
// 切换到游戏
changeGameOrPage (e) {
async changeGameOrPage (e) {
// 测试
this.setData({
gameShow: true,
gameType: 1,
gameData: {
win: true,
fakeUserName: 'xxxxxxxx',
fakeUserImgUrl: '//yun.duiba.com.cn/spark/assets/赚门票.21d8c2fd01dffd454116bb6c1189ba6bb74306f4.png',
userName: app.nickName,
userImgUrl: app.avatar
}
})
setTimeout(() => { this.setData({ gameShow_timeout: true }) }, 350)
this.setData({
gamePrize: {
name: '一碗热翔',
image: '//yun.duiba.com.cn/spark/assets/赚门票.21d8c2fd01dffd454116bb6c1189ba6bb74306f4.png',
type: 1
}
})
// 测试
return
if (this.data.ticketNum == 0 && e.currentTarget.dataset.gameType != 3) {
this.showCommonMoadalT1({
title: '门票不足',
......@@ -311,15 +372,102 @@ Page({
return
} else {
let type = Number(e.currentTarget.dataset.gameType)
this.videoCtx.pause()
this.setData({ gameShow: true, gameType: type })
API.doJoin({activityId: app.activityId, type: type === 1 ? 'slide' : 'timeline'})
.then(res => {
const { data, success } = res
if (success) {
// 计算胜负
let win = this.countWinRange()
let fname = this.getFakeUserName()
let favatar = this.getFakeAvatar()
this.setData({
gameShow: true,
gameType: type,
gameData: {
win: win,
fakeUserName: fname,
fakeUserImgUrl: favatar,
userName: app.nickName,
userImgUrl: app.avatar
}
})
setTimeout(() => { this.setData({ gameShow_timeout: true }) }, 350)
// 游戏结束开奖 -- 提前
this.getGameOverPrize()
} else {
commonToast(res.message)
}
})
.catch(res => { console.warn(res); commonToast(res && res.message) }) || {};
}
},
// 游戏结束 获取开奖
getGameOverPrize () {
API.gameOver({activityId: app.activityId, type: type === 1 ? 'slide' : 'timeline', isWin: win})
.then(res => {
const { data, success} = res
if (success) {
this.setData({
gamePrize: {
name: data.prize.name,
image: data.prize.image,
type: data.prize.type
}
})
} else {
this.setData({
gamePrize: {
name: '谢谢参与',
image: '',
type: 5
}
})
}
})
.catch(err => {
console.warn(err)
this.setData({
gamePrize: {
name: '谢谢参与',
image: '',
type: 5
}
})
})
},
// 游戏胜率计算
countWinRange (type) {
let win = false
let num = Math.floor(Math.random() * (100 - 1) + 1)
if (type === 1) {
if (num <= app.xxlWinRate * 100) win = true
else win = false
} else if (type === 2) {
if (num <= app.csdWinRate * 100) win = true
else win = false
}
return win
},
// 生成假用户名
getFakeUserName () {
},
// 生成假用户头像
getFakeAvatar () {
},
// 从游戏 返回 到 主页
backToPage () {
this.setData({ gameShow_timeout: false, gameType: 0 })
this.setData({ gameShow_timeout: false, gameType: 0, gamePrize: null, gameData: null })
this.getGameInfo()
setTimeout(() => { this.setData({ gameShow: false }) }, 350)
},
......@@ -422,12 +570,14 @@ Page({
}
},
// 观看视频领奖
// video - 观看视频领奖
getWatchRewards() {
API.sendCoinsByWatch({activityId: app.activityId, videoIndex: this.data.videoActiveIndex})
.then(res => {
const {success, data} = res
if (success) {
let num = this.data.drawNum
this.setData({drawNum: num + data.lotteryTimes})
this.showCommonMoadalT2({
title: '看视频奖励',
content: `抽奖次数+${data.lotteryTimes}`,
......@@ -447,6 +597,7 @@ Page({
})
},
// video - 展示视频
videoShowFunc() {
this.setData({ videoShow: true })
setTimeout(() => {
......@@ -542,18 +693,6 @@ Page({
}
},
/**
* 显示通用弹层
* @param {object} options content: 通用弹层内容 btnText:按钮文案 confirmCallback: 按钮确认回调
*/
showCommonModal({ content, btnText, confirmCallback }) {
this.setData({
commonModalConfirm: confirmCallback || null,
commonModalVisible: true,
commonModalData: { content, btnText }
});
},
changeURLArg(url, arg, arg_val) {
var pattern = arg + '=([^&]*)';
var replaceText = arg + '=' + arg_val;
......
......@@ -20,6 +20,7 @@ Component({
messageMadalData: {},
messageMadalVisble: false,
},
gameData: null,
didMount() {
this.setData({
......@@ -35,13 +36,19 @@ Component({
// 切换游戏场景
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()
},
back () { this.props.onBackPage() },
init() {
console.log('do init');
......@@ -75,7 +82,7 @@ Component({
onCanvasReady() {
console.log('onCanvasReady')
this.changeGameSence(this.props.gameType)
//授权和登录先搞
// 授权和登录先搞
checkSystem().then(r => {
if (r) {
this.getAuth();
......@@ -173,9 +180,6 @@ Component({
}
},
/**
* 获取用户授权信息
*/
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
......@@ -188,9 +192,7 @@ Component({
this.login();
}
},
/**
* 登录接口
*/
async login() {
const { nickName, avatar } = app;
const { success } = await API.login({ userNick: nickName, avatar }).catch(res => {
......@@ -201,11 +203,10 @@ Component({
this.init();
}
},
closeRuleModal() {
this.setData({
ruleModalVisible: false
});
}
this.setData({ ruleModalVisible: false })
},
}
......
......@@ -49,7 +49,10 @@
<!-- 弹窗-奖品信息 -->
<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' /> -->
......@@ -8,6 +8,18 @@ const { commonToast, getAuthUserInfo, navigateToOutside, ConsoleStyle, checkShop
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: [], // 转盘奖品信息
......@@ -253,54 +265,46 @@ Page({
const { commonModalConfirm } = this.data
commonModalConfirm && commonModalConfirm()
},
/**
* 执行开始
*/
doStart() {
this.showCommonModal({
content: '活动还未开始\n请稍后',
btnText: '我知道了',
commonModalVisible: true,
confirmCallback: () => {
this.closeCommonModal()
// 显示通用弹层
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()
}
})
},
/**
* 显示通用弹层
* @param {object} options content: 通用弹层内容 btnText:按钮文案 confirmCallback: 按钮确认回调
*/
showCommonModal({ content, btnText, confirmCallback }) {
// 显示通用弹层
showCommonMoadalT2 (obj) {
let { title, content, confirmCallback1, confirmCallback2, btnImg1, btnImg2, rewardsImg } = obj
this.setData({
commonModalConfirm: confirmCallback || null,
commonModalVisible: true,
commonModalData: { content, btnText }
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'])
},
/**
* 关闭通用弹层
*/
closeCommonModal() {
this.setData({
commonModalVisible: false
})
},
/**
* 关闭活动规则弹层
*/
closeRuleModal() {
this.setData({
ruleModalVisible: false
})
},
onShareAppMessage() {
// 返回自定义分享信息
return SHARE_CONFIG
// 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