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

add new code --21

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