Commit 3cf797be authored by AU-Pro-mac's avatar AU-Pro-mac

add new code --08

parent dac3ef34
...@@ -157,9 +157,9 @@ export class Main { ...@@ -157,9 +157,9 @@ export class Main {
await this.loadImageTexturesCsd01(resCanvasList) await this.loadImageTexturesCsd01(resCanvasList)
await this.loadImageTexturesCsd02(resCanvasList) await this.loadImageTexturesCsd02(resCanvasList)
// changeScene(OpenAni) changeScene(OpenAni)
// changeScene(CsdScene) // changeScene(CsdScene)
changeScene(XxlScene) // changeScene(XxlScene)
}) })
await InitLottie.initLottieList(resLottieList); await InitLottie.initLottieList(resLottieList);
......
...@@ -118,12 +118,14 @@ export default class Root extends FYGE.Container { ...@@ -118,12 +118,14 @@ export default class Root extends FYGE.Container {
GDispatcher.removeEventListener('MatchCompelete', this.gameStart, this) GDispatcher.removeEventListener('MatchCompelete', this.gameStart, this)
this.gameStartFlag = true this.gameStartFlag = true
this.touchArea.mouseEnable = true
} }
// 结束游戏 // 结束游戏
async gameOver () { async gameOver () {
this.time = 60 this.time = 60
this.gameStartFlag = false this.gameStartFlag = false
this.touchArea.mouseEnable = false
if (!this.userInfo.win) this.scoreBoard.scoreRight += 3 if (!this.userInfo.win) this.scoreBoard.scoreRight += 3
this.goodsContainer.removeAllGoods() this.goodsContainer.removeAllGoods()
...@@ -161,10 +163,10 @@ export default class Root extends FYGE.Container { ...@@ -161,10 +163,10 @@ export default class Root extends FYGE.Container {
// 创建 触摸层 // 创建 触摸层
createTouchRect () { createTouchRect () {
this.touchArea = Tools.getRect(750, 574, 0xff22ff, 0) this.touchArea = Tools.getRect(750, 874, 0xff22ff, 0)
this.touchArea.x = 0 this.touchArea.x = 0
this.touchArea.y = 1050 this.touchArea.y = 750
this.touchArea.mouseEnable = true this.touchArea.mouseEnable = false
this.addChild(this.touchArea) this.addChild(this.touchArea)
this.touchArea.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onMouseDownArea, this) this.touchArea.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onMouseDownArea, this)
...@@ -199,6 +201,7 @@ export default class Root extends FYGE.Container { ...@@ -199,6 +201,7 @@ export default class Root extends FYGE.Container {
this.guide.visible = false this.guide.visible = false
setTimeout(() => { setTimeout(() => {
showPanel(MatchingPanel, this.userInfo) showPanel(MatchingPanel, this.userInfo)
this.guide.removeEventListener(FYGE.MouseEvent.CLICK, this.guideFunc, this)
}, 200) }, 200)
} else { } else {
this.guide.texture = Ins.getRes(this.guideRes[i]) this.guide.texture = Ins.getRes(this.guideRes[i])
......
...@@ -11,10 +11,8 @@ export default class Catecher extends FYGE.Container { ...@@ -11,10 +11,8 @@ export default class Catecher extends FYGE.Container {
// 右用户分 // 右用户分
scoreRight; scoreRight;
// 时间 // 时间
timerNumer: 60; timerNumer = 60;
timeText; timeText;
// 倒计时函数
timerFunc;
// 左 用户板 // 左 用户板
userBoard_left; userBoard_left;
// 右 用户板 // 右 用户板
...@@ -96,8 +94,7 @@ export default class Catecher extends FYGE.Container { ...@@ -96,8 +94,7 @@ export default class Catecher extends FYGE.Container {
// 销毁 事件和循环 // 销毁 事件和循环
destroy () { destroy () {
clearInterval(this.timerFunc) this.removeEventListener(FYGE.Event.ENTER_FRAME, this.timerFunc, this)
this.timerFunc = null
} }
// 分数更新 // 分数更新
...@@ -157,8 +154,7 @@ export default class Catecher extends FYGE.Container { ...@@ -157,8 +154,7 @@ export default class Catecher extends FYGE.Container {
} }
stopTime () { stopTime () {
clearInterval(this.timerFunc) this.removeEventListener(FYGE.Event.ENTER_FRAME, this.timerFunc, this)
this.timerFunc = null
} }
start (time) { start (time) {
...@@ -166,19 +162,41 @@ export default class Catecher extends FYGE.Container { ...@@ -166,19 +162,41 @@ export default class Catecher extends FYGE.Container {
this.scoreRight = 0 this.scoreRight = 0
this.timerNumer = time this.timerNumer = time
this.updateTime(this.timerNumer) this.updateTime(this.timerNumer)
this.addEventListener(FYGE.Event.ENTER_FRAME, this.timerFunc, this)
}
this.timerFunc = setInterval(() => { lt = 0
tt = 0
// 倒计时函数
timerFunc () {
if (!this._root.gameStartFlag) return
// console.log(this.timerNumer)
// 时间消耗完毕 // 时间消耗完毕
if (this.timerNumer <= 0) { if (this.timerNumer <= 0) {
this._root.gameOver() this._root.gameOver()
clearInterval(this.timerFunc)
this.timerFunc = null
this.updateTime(0) this.updateTime(0)
this.lt = this.tt = 0
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.timerFunc, this)
return
}
if (this.lt) {
let nt = new Date().getTime()
let dt = nt - this.lt
this.tt += dt / 1000 >> 0
let ntt = 60 - this.tt
if (ntt != this.timerNumer) {
this.timerNumer = ntt
this.updateTime(this.timerNumer)
this.lt = nt
}
} else { } else {
this.updateTime(--this.timerNumer) this.lt = new Date().getTime()
} }
}, 1000)
} }
...@@ -215,7 +233,8 @@ export default class Catecher extends FYGE.Container { ...@@ -215,7 +233,8 @@ export default class Catecher extends FYGE.Container {
c.width = 120 c.width = 120
c.height = 120 c.height = 120
let a = Tools.getCircle(60, 0x000000, 1, 60, 60) let a = Tools.getCircle(60, 0x000000, 1, 60, 60)
let p = Tools.getSprite(avatar, 0, 0) let p = FYGE.Sprite.fromUrl(avatar)
p.x = p.y = 0
p.width = 120 p.width = 120
p.height = 120 p.height = 120
c['updateAvatar'] = (avatar) => { p.texture = RES.getRes(avatar) } c['updateAvatar'] = (avatar) => { p.texture = RES.getRes(avatar) }
......
...@@ -45,6 +45,9 @@ Page({ ...@@ -45,6 +45,9 @@ Page({
this.getMyPrize(); this.getMyPrize();
}, },
onShareAppMessage() { onShareAppMessage() {
// 返回自定义分享信息
SHARE_CONFIG.imageUrl = ''
SHARE_CONFIG.path = this.changeURLArg('/pages/homePage/homePage', 'inviteId', app.openId)
return SHARE_CONFIG; return SHARE_CONFIG;
}, },
// 到期时间 // 到期时间
......
...@@ -317,7 +317,7 @@ Component({ ...@@ -317,7 +317,7 @@ Component({
let fname = this.getFakeUserName() let fname = this.getFakeUserName()
let favatar = this.getFakeAvatar() let favatar = this.getFakeAvatar()
this.gameData = { this.gameData = {
win: win, win: true,
fakeUserName: fname, fakeUserName: fname,
fakeUserImgUrl: favatar, fakeUserImgUrl: favatar,
userName: app.nickName, userName: app.nickName,
......
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
width: 478rpx; width: 478rpx;
height: 237rpx; height: 237rpx;
position: absolute; position: absolute;
top: 1110rpx; top: 1080rpx;
left: calc(50% - 239rpx); left: calc(50% - 239rpx);
background: transparent background: transparent
} }
...@@ -220,12 +220,12 @@ ...@@ -220,12 +220,12 @@
padding: 0 30rpx; padding: 0 30rpx;
margin-top: 103rpx; margin-top: 103rpx;
width: 100%; width: 100%;
height: 93rpx; height: 100rpx;
} }
.bottom_btn { .bottom_btn {
flex: 1; flex: 1;
width: 206rpx; width: 204rpx;
height: 93rpx; height: 93rpx;
} }
......
...@@ -34,6 +34,15 @@ ...@@ -34,6 +34,15 @@
<image class="outside" src="{{resList['7750fff8-383d-4135-b20b-b3108d5d0845'].url}}" /> <image class="outside" src="{{resList['7750fff8-383d-4135-b20b-b3108d5d0845'].url}}" />
</view> </view>
<!-- 底座和按钮 -->
<view class="bottom">
<image class="bottom_bg" src="{{resList['738011dd-8cdc-455e-8dfa-2f17f5112bdf'].url}}" mode="aspectFill" />
<view class="bottom_btn_wrapper">
<view class="bottom_btn" onTap="gotoMyPrize"><image class="bottom_btn_image" src="{{resList['050b07b7-255a-4118-9221-0d4f1d45c296'].url}}" mode="aspectFill" /></view>
<view class="bottom_btn" onTap="handdlerStartButton"><image class="bottom_btn_image" src="{{resList['18cbbf52-1bc5-4109-b60c-59de1d06a1e7'].url}}" mode="aspectFill" /></view>
</view>
</view>
</view> </view>
<!-- 开始按钮 --> <!-- 开始按钮 -->
<view class="start_button" onTap='handdlerStartButton'> <view class="start_button" onTap='handdlerStartButton'>
...@@ -44,20 +53,12 @@ ...@@ -44,20 +53,12 @@
<!-- 顶部文案 --> <!-- 顶部文案 -->
<label class="chance">剩余抽奖次数:{{leftTimes}}次</label> <label class="chance">剩余抽奖次数:{{leftTimes}}次</label>
<!-- 底座和按钮 -->
<view class="bottom">
<image class="bottom_bg" src="{{resList['fbe88b43-5930-46e3-bd7b-f0ea0ff50d1a'].url}}" mode="aspectFill" />
<view class-"bottom_btn_wrapper">
<view class="bottom_btn" onTap=""><image class="bottom_btn_image" src="{{resList['050b07b7-255a-4118-9221-0d4f1d45c296'].url}}" mode="aspectFill" /></view>
<view class="bottom_btn" onTap=""><image class="bottom_btn_image" src="{{resList['18cbbf52-1bc5-4109-b60c-59de1d06a1e7'].url}}" mode="aspectFill" /></view>
</view>
</view>
</view> </view>
</view> </view>
<!-- 弹窗-奖品信息 --> <!-- 弹窗-奖品信息
<rewards-modal a:if='{{rewardsModalShow}}' modalData='{{rewardsModalData}}' onModalClose='onModalClose' onModalConfirm='onModalConfirm' data-modalType='rewards' /> <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-t1 a:if="{{commonModalVisibleT1}}" data="{{commonModalDataT1}}" onModalClose="closeCommonModalT1" onModalConfirm="confirmCommonModalT1" />
<common-modal-t2 a:if="{{commonModalVisibleT2}}" data="{{commonModalDataT2}}" onModalClose="closeCommonModalT2" onModalOne="onModalT2One" onModalTwo="onModalT2Two"/> <common-modal-t2 a:if="{{commonModalVisibleT2}}" data="{{commonModalDataT2}}" onModalClose="closeCommonModalT2" onModalOne="onModalT2One" onModalTwo="onModalT2Two"/>
......
...@@ -36,21 +36,19 @@ Page({ ...@@ -36,21 +36,19 @@ Page({
}, },
activityId: undefined, activityId: undefined,
onLoad(query) { async onLoad(query) {
// 页面加载 // 页面加载
// this.getAuth() // this.getAuth()
console.info(`Page onLoad with query: ${JSON.stringify(query)}`) console.info(`Page onLoad with query: ${JSON.stringify(query)}`)
let { activityId } = app let { activityId } = app
this.activityId = activityId this.activityId = activityId
this.getDataTurnTable() this.getDataTurnTable()
this.getGameInfo() await this.getGameInfo()
},
onCallBack () {
// console.log(this.data.listRange)
}, },
// 获取游戏次数
async getGameInfo () { async getGameInfo () {
return new Promise ((resolve, reject) => {
API.getGameInfo({ activityId: this.activityId }) API.getGameInfo({ activityId: this.activityId })
.then(res => { .then(res => {
const { success, message, data } = res const { success, message, data } = res
...@@ -58,19 +56,21 @@ Page({ ...@@ -58,19 +56,21 @@ Page({
else { else {
console.log('%c-----获取游戏信息\n' + '-----yd.getGameInfo\n', ConsoleStyle, data) console.log('%c-----获取游戏信息\n' + '-----yd.getGameInfo\n', ConsoleStyle, data)
this.setData({ leftTimes: data.lotteryTimes }) this.setData({ leftTimes: data.lotteryTimes })
resolve('complete')
} }
}) })
.catch(res => { console.warn(res); commonToast(res && res.message); }) || {}; .catch(res => { console.warn(res); commonToast(res && res.message); reject('fail') }) || {}
})
}, },
// 获取转盘信息
async getDataTurnTable () { async getDataTurnTable () {
let { success, data } = await API.getLotteryPrizeList({ activityId: this.activityId}).catch(res => { let { success, data } = await API.getLotteryPrizeList({ activityId: this.activityId}).catch(res => {
console.warn(res) console.warn(res)
commonToast(res && res.message) commonToast(res && res.message)
}) || {} }) || {}
if (success && data) {
// 开发用 if (success && data) {
console.log('%c-----获取转盘奖品\n' + '-----getPrizeConfigList\n', ConsoleStyle, data) console.log('%c-----获取转盘奖品\n' + '-----getPrizeConfigList\n', ConsoleStyle, data)
data.forEach((item, index) => { data.forEach((item, index) => {
...@@ -80,10 +80,7 @@ Page({ ...@@ -80,10 +80,7 @@ Page({
} }
}) })
// data.push(...data) this.setData({ listTurnTable: data })
// data.push(heartBroken)
this.setData({ listTurnTable: data, leftTimes: data.leftTimes })
} }
}, },
...@@ -97,7 +94,7 @@ Page({ ...@@ -97,7 +94,7 @@ Page({
// 开始旋转 转盘 // 开始旋转 转盘
async startDraw () { async startDraw () {
console.log('startDraw run') console.log('%cstartDraw run', ConsoleStyle)
if (this.data.rotateFlag) return if (this.data.rotateFlag) return
if (!this.data.leftTimes > 0) { if (!this.data.leftTimes > 0) {
commonToast('您还没有抽奖次数') commonToast('您还没有抽奖次数')
...@@ -109,11 +106,15 @@ Page({ ...@@ -109,11 +106,15 @@ Page({
return return
}) || {} }) || {}
// test code -
// let success = true // let success = true
// let data = { // let data = {
// id: '5f7295860cb733e8928791b6', // id: '5f7295860cb733e8928791b6',
// type: 3, // type: 3,
// name: '一碗热翔',
// image: '//yun.duiba.com.cn/spark/assets/9be08f492b1e9fb4006cd676bcf5df760856b74a.png'
// } // }
// test code -
this.setData({ rotateFlag: true }) this.setData({ rotateFlag: true })
...@@ -135,6 +136,9 @@ Page({ ...@@ -135,6 +136,9 @@ Page({
rotateT = 4 + 1 rotateT = 4 + 1
this.setData({ rewardsInfo: data }) this.setData({ rewardsInfo: data })
} }
// test code -
// rotateT = this.sum(1, 6)
// test code -
}) })
} }
...@@ -145,13 +149,47 @@ Page({ ...@@ -145,13 +149,47 @@ Page({
// 开始动画 // 开始动画
setTimeout(() => { setTimeout(() => {
this.animateRotation(360 * (++this.timerCount * 2) + rotateDeg, 1000 * (rotateDeg / 360) + 1000) this.animateRotation(360 * (++this.timerCount * 2) + rotateDeg, 1000 * (rotateDeg / 360) + 1000)
//更改 rotateFlag
setTimeout(() => { this.setData({ rotateFlag: false }) }, 1000 * (rotateDeg / 360) + 1000 + 20) // 更改 rotateFlag - 弹窗 结果弹窗
setTimeout(() => {
this.setData({ rotateFlag: false })
if (data.type !== 5) {
this.showCommonMoadalT2({
title: '恭喜你',
content: `恭喜您获得${data.name}`,
confirmCallback1: async () => {
await this.getGameInfo()
this.closeCommonModalT2()
this.gotoMyPrize()
},
confirmCallback2: async () => {
await this.getGameInfo()
this.closeCommonModalT2()
},
btnImg1: resList['240b56fa-66ce-414c-86ea-4ac13a3ac4e2'].url,
btnImg2: resList['8d3b3b51-d535-48e6-a76c-d61920da4826'].url,
rewardsImg: data.image
})
} else {
this.showCommonMoadalT1({
title: '很遗憾',
content: `奖励与你擦肩而过\n 再接再厉哦~`,
confirmCallback: async () => {
await this.getGameInfo()
this.closeCommonModalT1()
},
btnImg: resList['fd0d94ef-fe1a-4771-8ba2-ad7aadacafc0'].url
})
}
}, 1000 * (rotateDeg / 360) + 1000 + 20)
}, 300) }, 300)
this.setData({ leftTimes: --this.data.leftTimes }) let time = this.data.leftTimes - 1
this.setData({ leftTimes: time })
} }
}, },
// 旋转动画rot:旋转角度,timegap:旋转时间 // 旋转动画rot:旋转角度,timegap:旋转时间
animateRotation (rot, timegap) { animateRotation (rot, timegap) {
console.log('animateRotation run') console.log('animateRotation run')
...@@ -165,7 +203,6 @@ Page({ ...@@ -165,7 +203,6 @@ Page({
this.setData({ this.setData({
myAnimation: animation.export() myAnimation: animation.export()
}) })
}, },
onModalClose (e) { onModalClose (e) {
...@@ -186,10 +223,12 @@ Page({ ...@@ -186,10 +223,12 @@ Page({
}, },
onModalConfirm (e) { onModalConfirm (e) {
// TODO: do something
this.onModalClose(e) this.onModalClose(e)
}, },
gotoMyPrize() { my.navigateTo({url: '../myprize/myprize'}) },
init() { init() {
this.getIndex() this.getIndex()
}, },
...@@ -214,55 +253,14 @@ Page({ ...@@ -214,55 +253,14 @@ Page({
onReachBottom() { 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() { showRuleModal() {
this.setData({ this.setData({
ruleModalVisible: true ruleModalVisible: true
}) })
}, },
/** // 通用弹出确认按钮回调
* 通用弹出确认按钮回调
*/
confirmCommonModal() { confirmCommonModal() {
const { commonModalConfirm } = this.data const { commonModalConfirm } = this.data
commonModalConfirm && commonModalConfirm() commonModalConfirm && commonModalConfirm()
...@@ -295,18 +293,71 @@ Page({ ...@@ -295,18 +293,71 @@ Page({
}) })
}, },
// 通用弹层 - 关闭 - T1
closeCommonModalT1() {
this.setData({ commonModalVisibleT1: false });
},
// 通用弹层 - 关闭 - T2
closeCommonModalT2() {
this.setData({ commonModalVisibleT2: false });
},
onModalT2One () { this.data.onModalT2One() }, onModalT2One () { this.data.onModalT2One() },
onModalT2Two () { this.data.onModalT2Two() }, onModalT2Two () { this.data.onModalT2Two() },
confirmCommonModalT1 () { this.data.confirmCommonModalT1() }, confirmCommonModalT1 () { this.data.confirmCommonModalT1() },
/**
* 跳转到天猫页面
*/ // 获取用户权限
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()
}
},
// 跳转到天猫页面
goTmallPage() { goTmallPage() {
navigateToOutside(REDIRECT_URL['tmall']) navigateToOutside(REDIRECT_URL['tmall'])
}, },
onShareAppMessage() { onShareAppMessage() {
// 返回自定义分享信息 // 返回自定义分享信息
// return SHARE_CONFIG SHARE_CONFIG.imageUrl = ''
SHARE_CONFIG.path = this.changeURLArg('/pages/homePage/homePage', 'inviteId', app.openId)
return SHARE_CONFIG;
},
// 取 随机数
sum (m, n) {
var num = Math.floor(Math.random() * (m - n) + n)
return num
}, },
}) })
...@@ -652,6 +652,18 @@ const resList = { ...@@ -652,6 +652,18 @@ const resList = {
ext: '.png', ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/视频加载也.ae8ad97c68d1de7e88b311a7339b1a30c4ebc883.png', url: '//yun.duiba.com.cn/spark/assets/视频加载也.ae8ad97c68d1de7e88b311a7339b1a30c4ebc883.png',
uuid: 'fbe88b43-5930-46e3-bd7b-f0ea0ff50d1a' uuid: 'fbe88b43-5930-46e3-bd7b-f0ea0ff50d1a'
},
'240b56fa-66ce-414c-86ea-4ac13a3ac4e2': {
name: '转盘查看奖品',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/转盘查看奖品.27e49f3519d21b18a9668b9f976c8d2b2518c06b.png',
uuid: '240b56fa-66ce-414c-86ea-4ac13a3ac4e2'
},
'8d3b3b51-d535-48e6-a76c-d61920da4826': {
name: '转盘继续抽奖',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/转盘继续抽奖.fe17a5fb4ea5e033add1a857e3fd1f5b7363ac40.png',
uuid: '8d3b3b51-d535-48e6-a76c-d61920da4826'
} }
}; };
......
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