Commit 8800b354 authored by AU-Pro-mac's avatar AU-Pro-mac

add new code --02

parent 7aa323bf
......@@ -21,7 +21,10 @@ App({
xxlWinRate: 0.7,
// 游戏胜率 - 传送带
csdWinRate: 0.7,
// 是否是新用户 - 传送带
isNewUser_csd: true,
// 是否是新用户 - 消消乐
isNewUser_xxl: true,
// 全局数据
globalData: {},
......
......@@ -14,10 +14,10 @@
<image class="mission_icon" src="{{item.iconUrl}}" />
<view class="mission_content">
<view class="mission_title">{{item.taskNameActiv}}</view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+{{item.waitReceive}}</text></view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+{{item.rewards}}</text></view>
</view>
<view class="mission_btn {{ item.status === 1 ? 'mission_btn_active' : '' }}"
data-type="{{item.taskType}}" data-status="{{item.status}}" data-itemIds="{{item.itemIds}}" onTap="doTaskByType">
data-type="{{item.taskType}}" data-status="{{item.status}}" data-itemIds="{{item.itemIds}}" data-info="{{item}}" onTap="doTaskByType">
<text a:if="{{item.status === 1}}" class="mission_btn_text">{{item.btnText}}</text>
<text a:if="{{item.status === 2}}" class="mission_btn_text">待领取</text>
<text a:if="{{item.status === 3}}" class="mission_btn_text">已完成</text>
......
......@@ -142,6 +142,11 @@ Component({
if (!success) { console.warn(res); commonToast(res && res.message) }
else {
console.log('%c--------领取成功\n' + '-----yd.receiveTaskRewards\n', ConsoleStyle, data)
if (ds.type === 'invites') {
commonToast(`已有${ds.info.todayCompleteTimes}位还有为你助力,获得次数,乐园门票+${Number(ds.info.todayCompleteTimes) * Number(ds.info.rewards)}`)
} else {
commonToast('领取成功')
}
this.getMissionList()
this.onRefreshGameInfo()
}
......
......@@ -48,7 +48,7 @@ Component({
if(!this.timer) {
this.setData({ usePercent: this.data.percent })
this.browseGoodsTimes()
console.log(30 - this.usePercent)
console.log(15 - this.usePercent)
}
}
},
......@@ -87,7 +87,7 @@ Component({
this.setData({
usePercent: this.data.usePercent + 1
}, () => {
if (this.data.usePercent >= 30) {
if (this.data.usePercent >= 15) {
console.log(this.data.usePercent)
this.props.onCompleteTask(taskType)
clearInterval(this.timer)
......
......@@ -78,11 +78,11 @@
<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 class="bottom_ydgame_block_coin">抽奖次数 X{{drawNum}}</view>
</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">
......@@ -93,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="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}}" />
<image data-gameType='1' onTap="handleClickGame" class="gamechoose_block_sc {{ ticketNum ? '' : 'opciaty05' }}" src="{{resList['b23ce750-11e2-45f9-b3af-a0a7dedddcfd'].url}}" />
<image data-gameType='2' onTap="handleClickGame" class="gamechoose_block_xxl {{ ticketNum ? '' : 'opciaty05' }}" src="{{resList['ffe6b4b2-3401-44b6-b090-11005d2fd5d7'].url}}" />
<view class="gameChoose_mask" onTap="closeShowChooseGame"></view>
</view>
</view>
......@@ -108,8 +108,6 @@
class="homepage_pagecanvas"
onBackPage="backToPage"
gameType="{{ gameType }}"
gameData="{{ gameData }}"
gamePrize="{{ gamePrize }}"
>
</pagecanvas>
......
......@@ -42,12 +42,6 @@ Page({
// 用户是否登陆
userLogin: false,
data: {
// 游戏数据
gameData: null,
// 游戏抽奖
gamePrize: null,
resList: resList,
title: '',
content: '',
......@@ -106,13 +100,12 @@ Page({
// 开场动画
this.openAnimation().then(async res_ => {
this.backToPage()
this.init()
this.getAuth()
})
// test - 打点
// clickStat(1, '2')
this.getAuth()
},
// 获取用户授权信息
......@@ -304,10 +297,10 @@ Page({
return new Promise ((resolve, reject) => {
API.getGameInfo({ activityId: app.activityId })
.then(res => {
console.log('%c-----获取游戏信息\n' + '-----yd.getGameInfo\n', ConsoleStyle, data)
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({
ticketNum: data.gameTimes,
drawNum: data.lotteryTimes,
......@@ -336,31 +329,7 @@ Page({
// 切换到游戏
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 (e.currentTarget.dataset.gameType != 3) await this.getGameInfo()
if (this.data.ticketNum == 0 && e.currentTarget.dataset.gameType != 3) {
this.showCommonMoadalT1({
title: '门票不足',
......@@ -372,109 +341,22 @@ Page({
return
} else {
let type = Number(e.currentTarget.dataset.gameType)
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
}
})
}
this.setData({
gameShow: true,
gameType: type
})
.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, gamePrize: null, gameData: null })
this.setData({ gameShow_timeout: false, gameType: 0 })
this.getGameInfo()
setTimeout(() => { this.setData({ gameShow: false }) }, 350)
},
// 去转盘
gotoTurnTable () {
my.navigateTo({url: '../turnTablePage/turnTablePage'})
},
gotoTurnTable () { my.navigateTo({url: '../turnTablePage/turnTablePage'}) },
// video - turn left
videoTurnLeft () {
......@@ -562,12 +444,17 @@ Page({
videoHideFunc() {
this.videoRecord(this.data.videoActiveIndex)
console.log('videoHideFunc', this.videoSrcArr)
this.setData({ videoShow: false })
this.setData({
videoShow: false
})
// 观看超过 15000ms 15s
if (this.videoSrcArr[this.data.videoActiveIndex].timeStamp >= 15000 && !this.videoSrcArr[this.data.videoActiveIndex].completed) {
this.videoSrcArr[this.data.videoActiveIndex].completed = true
this.getWatchRewards()
}
this.videoSrcArr.forEach((item) => {
item.timeStamp = 0
})
},
// video - 观看视频领奖
......@@ -575,9 +462,11 @@ Page({
API.sendCoinsByWatch({activityId: app.activityId, videoIndex: this.data.videoActiveIndex})
.then(res => {
const {success, data} = res
console.log('%c-----观看视频领奖\n' + '-----yd.sendCoinsByWatch\n', ConsoleStyle, data)
if (success) {
let num = this.data.drawNum
this.setData({drawNum: num + data.lotteryTimes})
if (!data.lotteryTimes) return
this.showCommonMoadalT2({
title: '看视频奖励',
content: `抽奖次数+${data.lotteryTimes}`,
......
......@@ -2,7 +2,7 @@ import { Main } from './output';
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside, getSystemInfo } = tbcc.tb;
const { commonToast, getAuthUserInfo, navigateToOutside, getSystemInfo, ConsoleStyle } = tbcc.tb;
const checkSystem = async () => {
const { version } = await getSystemInfo();
......@@ -20,6 +20,8 @@ Component({
messageMadalData: {},
messageMadalVisble: false,
},
isWin: false,
gamePrize: null,
gameData: null,
didMount() {
......@@ -36,20 +38,10 @@ 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() },
init() {
console.log('do init');
this.spark_startEngine();
......@@ -82,12 +74,6 @@ Component({
onCanvasReady() {
console.log('onCanvasReady')
this.changeGameSence(this.props.gameType)
// 授权和登录先搞
checkSystem().then(r => {
if (r) {
this.getAuth();
}
});
},
postMessage(netName, data) {
......@@ -102,61 +88,123 @@ Component({
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;
switch (netName) {
// 获取信息
case "mine.getUserInfo":
// 开始游戏
this.gameStartInfo()
break;
case "mine.backToPage":
this.back()
break;
case 'mine.getPrizeInfo':
// 游戏结束开奖 -- 提前
this.getGameOverPrize()
break;
default:
console.warn('监听时间名 没有对应处理函数')
break;
}
},
// 从游戏中返回
back () {
this.props.onBackPage()
this.gameData = null
this.gamePrize = null
},
// 游戏开始 获取用户信息
gameStartInfo () {
API.doJoin({activityId: app.activityId, type: this.data.gameType === 1 ? 'slide' : 'timeline'})
.then(res => {
const { data, success } = res
if (success) {
// 计算胜负
let win = this.countWinRange()
this.isWin = win
let fname = this.getFakeUserName()
let favatar = this.getFakeAvatar()
this.gameData = {
win: win,
fakeUserName: fname,
fakeUserImgUrl: favatar,
userName: app.nickName,
userImgUrl: app.avatar,
// 是否是新用户
isNewUser: this.data.gameType === 1 ? app.isNewUser_csd : app.isNewUser_xxl
}
this.postMessage('mine.getUserInfo', this.gameData)
// this.postMessage('csdGameData', this.gameData)
} else {
commonToast(res.message)
}
})
.catch(res => { console.warn(res); commonToast(res && res.message) }) || {};
},
// 游戏结束 获取开奖
getGameOverPrize () {
API.gameOver({activityId: app.activityId, type: this.data.gameType === 1 ? 'slide' : 'timeline', isWin: this.win})
.then(res => {
const { data, success} = res
if (success) {
this.gamePrize = {
name: data.prize.name,
image: data.prize.image,
type: data.prize.type
}
this.postMessage('mine.getPrizeInfo', this.gamePrize)
} else {
this.gamePrize ={
name: '谢谢参与',
image: '',
type: 5
}
this.postMessage('mine.getPrizeInfo', this.gamePrize)
}
})
.catch(err => {
console.warn(err)
this.gamePrize = {
name: '谢谢参与',
image: '',
type: 5
}
this.postMessage('mine.getPrizeInfo', this.gamePrize)
})
},
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);
});
// 游戏胜率计算
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 () {
var _rsl1 = '',
_rsl2 = ''
var _randomUniCode = Math.floor(Math.random() * (40870 - 19968) + 19968).toString(16);
eval("_rsl1=" + '"\\u' + _randomUniCode + '"')
eval("_rsl2=" + '"\\u' + _randomUniCode + '"')
return _rsl1 + 'XXXXXX' + _rsl2
},
// 生成假用户头像
getFakeAvatar () {
return 'FakeAvatar'
},
//鼠标事件
......
......@@ -610,6 +610,18 @@ const resList = {
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/我也要赢大奖.a22bebbd5be4a6e557ee4ef611216ba73b729d10.png',
uuid: 'fd8a805e-e2e3-49c6-8236-1f181177a313'
},
'ffe6b4b2-3401-44b6-b090-11005d2fd5d7': {
name: '胶囊消消',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/胶囊消消.898555668d65ae277a2db5f6541615e4ed6336be.png',
uuid: 'ffe6b4b2-3401-44b6-b090-11005d2fd5d7'
},
'b23ce750-11e2-45f9-b3af-a0a7dedddcfd': {
name: '时空传送',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/时空传送.53c4af1a66a461812b8f3a502b14cddf4daed9b3.png',
uuid: 'b23ce750-11e2-45f9-b3af-a0a7dedddcfd'
}
};
export default resList;
\ 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