Commit 6b9f4a37 authored by AU-Pro-mac's avatar AU-Pro-mac

add new code --21

parent b806c262
......@@ -6,7 +6,7 @@
"win": true,
"userName": "xxxxxxxxxxx",
"userImgUrl": "https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png",
"isNewUser": false
"isNewUser": true
},
"success": true,
"message": "成功"
......
This diff is collapsed.
......@@ -172,6 +172,7 @@ export class Main {
console.log('resloadingList 加载完毕')
FYGE.GDispatcher.dispatchEvent("loadEnd");
// changeScene(CsdScene)
// showPanel(NoStepPanel)
//测试
......
......@@ -23,10 +23,6 @@ App({
xxlWinRate: 0.7,
// 游戏胜率 - 传送带
csdWinRate: 0.7,
// 是否是新用户 - 传送带
isNewUser_csd: true,
// 是否是新用户 - 消消乐
isNewUser_xxl: true,
// 全局数据
globalData: {},
......@@ -43,7 +39,7 @@ App({
*/
handleQuery(query) {
const { activityId } = query;
this.activityId = activityId || '5f73f1b09da6718132be23d1';
// this.activityId = activityId || '5f73f1b09da6718132be23d1';
this.activityId = activityId || '5f7a893575cfb6f3d500933c';
}
......
......@@ -155,24 +155,23 @@ Page({
console.log(`%c-----是否关注店铺:${this.isFollow}`, ConsoleStyle)
let param = { activityId: app.activityId, avatar: app.avatar, userNick: nickName, avatar, isFollow: this.isFollow, }
if (this.query.inviteId) param.inviteId = this.query.inviteId
const { success, message, data } = await API.login(param)
API.login(param)
.then(res => {
const { success, message, data } = res
this.userLogin = true
console.log('%c-----用户登陆信息\n' + '-----yd.login\n', ConsoleStyle, data)
app.openId = data.openId
this.isNewUser = data.isNewUser
// 首次进入 弹出活动规则
if (this.isNewUser) this.showNewUserModal()
// this.checkNewUserInGame()
this.getGameInfo()
this.init(data);
})
.catch(res => { commonToast(res && res.message); }) || {};
if (success) {
this.userLogin = true
console.log('%c-----用户登陆信息\n' + '-----yd.login\n', ConsoleStyle, data)
app.openId = data.openId
this.isNewUser = data.isNewUser
// 首次进入 弹出活动规则
if (this.isNewUser) this.showNewUserModal()
// 检测是否参与过 消消乐 和 传送带游戏
this.checkNewUserInGame()
this.getGameInfo()
this.init(data);
}
},
// 请求 业务接口 信息
......@@ -625,6 +624,7 @@ Page({
this.setData({ commonModalVisibleT2: false });
this.getGameInfo()
},
// 点击前 检查活动 开始结束时间
checkStartEndTime () {
let time = new Date()
......@@ -650,16 +650,7 @@ Page({
})
}
},
// 检测是否参与过 消消乐 和 传送带游戏
checkNewUserInGame () {
let resXxl = my.getStorageSync({ key: `YD11_firstInGameXxl_${app.activityId}_${app.openId}` })
if (resXxl.data && resXxl.data === 1) app.isNewUser_xxl = false
else app.isNewUser_xxl = true
let resCsd = my.getStorageSync({ key: `YD11_firstInGameCsd_${app.activityId}_${app.openId}` })
if (resCsd.data && resCsd.data === 1) app.isNewUser_csd = false
else app.isNewUser_csd = true
},
onUnload() {
// 页面被关闭
},
......
......@@ -122,19 +122,24 @@ Page({
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)
console.log(`%creceiveEnamePrize\n` + `------领取权益`, ConsoleStyle, item )
API.receiveEnamePrize({ activityId: app.activityId, id: item._id })
.then(res => {
const { success, data, message } = res
console.log('%c-----领取权益\n' + '-----yd.receiveEnamePrize\n', ConsoleStyle, success, data, message)
if (success && data) {
commonToast('领取成功')
this.getMyPrize()
}
setTimeout(() => {
flag = false
}, 500)
})
.catch(res => {
this.getMyPrize('noLoading')
commonToast(res && res.message)
}) || {};
},
// 领取实物前询问
async handleGetEntity(e) {
......@@ -154,7 +159,7 @@ Page({
// commonToast(' getUserAddress =>'+JSON.stringify( userAddress))
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
const params = {
activityId,
activityId: app.activityId,
area:countyName,
addressDetail:detailInfo,
name,
......@@ -209,7 +214,7 @@ Page({
}, (rej)=>{
commonToast(rej.message)
})
.catch(res => { console.warn(res); commonToast(res && res.message); flag = false }) || {};z
.catch(res => { console.warn(res); commonToast(res && res.message); flag = false }) || {};
},
// 积分
async handleGetIntergation(e) {
......
......@@ -39,24 +39,14 @@ Component({
if (this.props.gameType !== prevProps.gameType) {
this.setData({ gameType: this.props.gameType })
// 存储本地 用户玩游戏的信息
if (this.props.gameType === 1) {
if (this.props.gameType == 1) {
// 切换游戏场景
if (!this.main) return
this.main.changeGameSence(this.props.gameType)
my.setStorage({
key: `YD11_firstInGameCsd_${app.activityId}_${app.openId}`,
data: 1
});
app.isNewUser_csd = false
} else if (this.props.gameType === 2) {
} else if (this.props.gameType == 2) {
// 切换游戏场景
if (!this.main) return
this.main.changeGameSence(this.props.gameType)
my.setStorage({
key: `YD11_firstInGameCsd_${app.activityId}_${app.openId}`,
data: 1
});
app.isNewUser_xxl = false
}
}
},
......@@ -78,9 +68,9 @@ Component({
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;
......@@ -173,6 +163,8 @@ Component({
this.isWin = win
let fname = this.getFakeUserName()
let favatar = this.getFakeAvatar()
let firstIn = this.checkFirstInFromStorage()
this.gameData = {
win: win,
fakeUserName: fname,
......@@ -180,10 +172,11 @@ Component({
userName: app.nickName,
userImgUrl: app.avatar,
// 是否是新用户
isNewUser: this.data.gameType === 1 ? app.isNewUser_csd : app.isNewUser_xxl
isNewUser: firstIn
}
console.log('%cgameData:', ConsoleStyle, this.gameData)
this.postMessage('mine.getUserInfo', {data:this.gameData})
this.saveStorage()
} else {
commonToast(res.message)
}
......@@ -191,6 +184,34 @@ Component({
.catch(res => { console.warn(res); commonToast(res && res.message) }) || {};
},
saveStorage () {
if (this.data.gameType == 1) {
my.setStorage({
key: `YD11_firstInGameCsd_${app.activityId}_${app.openId}`,
data: 1
});
} else if (this.data.gameType == 2) {
my.setStorage({
key: `YD11_firstInGameXxl_${app.activityId}_${app.openId}`,
data: 1
});
}
},
checkFirstInFromStorage () {
if (this.data.gameType == 1) {
let resCsd = my.getStorageSync({ key: `YD11_firstInGameCsd_${app.activityId}_${app.openId}` })
console.warn('resCsd', resCsd)
if (resCsd.data && resCsd.data == 1) return false
else return true
} else if (this.data.gameType == 2) {
let resXxl = my.getStorageSync({key: `YD11_firstInGameXxl_${app.activityId}_${app.openId}` })
console.warn('resXxl', resXxl)
if (resXxl.data && resXxl.data == 1) return false
else return true
}
},
// 游戏结束 获取开奖
getGameOverPrize () {
// test - code
......@@ -239,10 +260,10 @@ Component({
let num = Math.floor(Math.random() * (100 - 1) + 1)
console.log('num: ', num)
if (type === 1) {
if (num <= parseInt(app.xxlWinRate)) win = true
if (num <= parseInt(app.csdWinRate)) win = true
else win = false
} else if (type === 2) {
if (num <= parseInt(app.csdWinRate)) win = true
if (num <= parseInt(app.xxlWinRate)) win = true
else win = false
}
console.log(`%ccountWinRange: ${win}`, ConsoleStyle)
......
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