点击联机分享链接进入游戏后,由首页跳转至游戏页面

This commit is contained in:
zhl 2019-03-05 20:40:24 +08:00
parent f3f3935096
commit 37c486486d
6 changed files with 103 additions and 33 deletions

View File

@ -29,7 +29,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 0, "current": 1,
"list": [ "list": [
{ {
"id": 0, "id": 0,
@ -41,6 +41,13 @@
"appId": "wxbf333d56b4de3905", "appId": "wxbf333d56b4de3905",
"extraData": "{ \"type\": \"item\", \"event_type\": \"pay_result\", \"success\": true, \"gid\": 1100309 }" "extraData": "{ \"type\": \"item\", \"event_type\": \"pay_result\", \"success\": true, \"gid\": 1100309 }"
} }
},
{
"id": 1,
"name": "分享游戏",
"pathName": "pages/index",
"query": "roomId=1100309&gid=7000006&togame=1",
"scene": null
} }
] ]
} }

View File

@ -1,7 +1,7 @@
export default { export default {
// apiBase: 'http://192.168.100.226', // apiBase: 'http://192.168.100.226',
apiBase: 'https://ghost-test.kingsome.cn', apiBase: 'https://ghost-test.kingsome.cn',
cdnBase: 'https://resource.kingsome.cn/emulator/v1.0.0/', cdnBase: 'http://h5games-al.kingsome.cn/emulator-static/',
version: '1.0.0', version: '1.0.0',
gameTypes: ['射击','格斗', '角色扮演','动作角色扮演', gameTypes: ['射击','格斗', '角色扮演','动作角色扮演',
'赛车', '动作游戏','策略战棋', '其他', '赛车', '动作游戏','策略战棋', '其他',

View File

@ -99,29 +99,29 @@ var httpcli = function(){
cbRes && cbRes(restext); cbRes && cbRes(restext);
}else{ }else{
cbErr && cbErr(res.statusCode, res.msg); cbErr && cbErr(res.statusCode, res.msg);
} }
}, },
fail: function(res){ fail: function(res){
console.log("[wx]request fail!"+ JSON.stringify(res)); console.log("[wx]request fail!"+ JSON.stringify(res));
if(!isretry && this._needretry){ if(!isretry && self._needretry){
let obj = { let obj = {
u: url, u: url,
v: urldata, v: urldata,
successcb: cbRes, successcb: cbRes,
errcb: cbErr errcb: cbErr
}; };
this.cachemsg.push(obj); self.cachemsg.push(obj);
}else{ }else{
cbErr && cbErr(-1, res.msg); cbErr && cbErr(-1, res.msg);
} }
// cbErr && cbErr(-1, res.msg); // cbErr && cbErr(-1, res.msg);
}, },
complete: function(){ complete: function(){
this._runningcount--; self._runningcount--;
console.log("[wx]request complete!"); console.log("[wx]request complete!");
} }
}); });
return xhr; return xhr;
} }
return null; return null;
}; };
@ -140,7 +140,7 @@ var httpcli = function(){
} }
obj.passtime += this._retryms; obj.passtime += this._retryms;
bneedretry = (obj.passtime >= obj.retry_count * this._retryms); bneedretry = (obj.passtime >= obj.retry_count * this._retryms);
if(bneedretry && !obj.retrying){ if(bneedretry && !obj.retrying){
obj.retrying = true; obj.retrying = true;
let method = obj.v? 'POST': 'GET'; let method = obj.v? 'POST': 'GET';

View File

@ -2,7 +2,7 @@
</style> </style>
<template> <template>
<view class="container"> <view class="container">
<web-view src="{{link}}"></web-view> <web-view src="{{link}}" @load="webloaded" @error="webloaderror" @message="onMessage"></web-view>
</view> </view>
</template> </template>
@ -13,14 +13,56 @@
export default class GameWebPage extends wepy.page { export default class GameWebPage extends wepy.page {
components = {}; components = {};
data = { data = {
link: '' link: '',
roomId: '',
gid: ''
};
methods = {
webloaded: function(e) {
console.log('page load finished');
console.log(e);
},
webloaderror: function(e) {
console.log('page load error');
console.log(e);
},
onMessage: function(e) {
if (e.detail.data) {
let data = e.detail.data;
this.roomId = data[0];
}
}
}; };
methods = {};
onLoad(params) { onLoad(params) {
this.gid = params.gid;
this.link = decodeURIComponent(params.link); this.link = decodeURIComponent(params.link);
console.log(this.link); console.log('load page: ' + this.link);
this.$apply(); this.$apply();
} }
onShareAppMessage() {
let self = this;
let account = wepy.getStorageSync('account');
return {
title: '来玩啊',
path: `/pages/index?isShare=1&inviter_id=${account.account_id}&roomId=${this.roomId}&gid=${this.gid}&togame=1`,
imageUrl: 'https://resource.kingsome.cn/dalmatian/wapp/share.jpg',
success: function (res) {
wepy.getShareInfo({
shareTicket: res.shareTickets[0]
})
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err)
})
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
}
} }
</script> </script>

View File

@ -113,7 +113,11 @@
bottomMainTap(e) { bottomMainTap(e) {
console.log('bottomMainTap'); console.log('bottomMainTap');
if (this.record.owned || this.vip) { if (this.record.owned || this.vip) {
this.playGame(); if (this.record.category === 'fc') {
this.openPlayMenu();
} else {
this.playGame();
}
} else { } else {
//显示购买游戏界面 //显示购买游戏界面
this.showBuyMenu(); this.showBuyMenu();
@ -187,22 +191,25 @@
this.zActionSheetCfg.goldTitle = `金币开通(${this.record.score})`; this.zActionSheetCfg.goldTitle = `金币开通(${this.record.score})`;
this.zActionSheetCfg.hide = false; this.zActionSheetCfg.hide = false;
} }
playGame() { playGame(multip) {
http.post('/api/emulated/play_game', { gid: this.id }) http.post('/api/emulated/play_game', { gid: this.id })
.then(res => { .then(res => {
console.log('success update game history'); console.log('success update game history');
jcEvent.emit(jcEvent.events.UPDATE_RECENT_GAMES, {}); jcEvent.emit(jcEvent.events.UPDATE_RECENT_GAMES, {});
let url; let url;
if (this.record.category === 'fc') { if (this.record.category === 'fc') {
url = `${this.fcUrl}/id=${this.id}`; url = `${this.fcUrl}?id=${this.id}`;
if (multip) {
url += '&roomId=0';
}
} else { } else {
url = `${this.gbaUrl1}/id=${this.id}`; url = `${this.gbaUrl1}?id=${this.id}`;
if (this.record.fixed) { if (this.record.fixed) {
url = `${this.gbaUrl2}/id=${this.id}`; url = `${this.gbaUrl2}?id=${this.id}`;
} }
} }
wepy.navigateTo({ wepy.navigateTo({
url: '/pages/game?link=' + url url: '/pages/game?link=' + encodeURIComponent(url) + '&gid=' + this.id
}); });
}) })
.catch(err => { .catch(err => {
@ -290,5 +297,15 @@
console.log(err); console.log(err);
} }
} }
async openPlayMenu () {
let res = await wepy.showActionSheet({
itemList: ['单人', '联机']
});
if (!res.cancel) {
console.log(res.tapIndex);
this.playGame(res.tapIndex)
}
}
} }
</script> </script>

View File

@ -119,18 +119,7 @@
} }
async onLoad(options) { async onLoad(options) {
let userInfo = this.$parent.getUserInfo();
let self = this; let self = this;
if (userInfo) {
this.nickname = userInfo.nickName;
this.avatar = userInfo.avatarUrl;
this.$apply();
}
if (this.$parent.checkAuthorize()) {
wepy.navigateTo({
url: '/pages/login'
})
}
if (!this.$parent.checkClientLogin()) { if (!this.$parent.checkClientLogin()) {
this.getAllData(); this.getAllData();
this.vip_params = `token=${this.$parent.getGlobalDate('gameToken')}`; this.vip_params = `token=${this.$parent.getGlobalDate('gameToken')}`;
@ -169,6 +158,16 @@
this.showToast('购买失败', 2000); this.showToast('购买失败', 2000);
} }
}) })
if (options.togame) {
let cfg = wepy.getStorageSync('cfg');
let fcUrl = cfg.fcurl;
let roomId = options.roomId;
let gid = options.gid;
let link = `${fcUrl}?id=${gid}&roomId=${roomId}`;
wepy.navigateTo({
url: '/pages/game?link=' + encodeURIComponent(link) + '&gid=' + gid
});
}
} }
getAllData() { getAllData() {
this.getRecords(); this.getRecords();
@ -194,6 +193,11 @@
this.avatar = userInfo.avatarUrl; this.avatar = userInfo.avatarUrl;
this.$apply(); this.$apply();
} }
if (this.$parent.checkAuthorize()) {
wepy.navigateTo({
url: '/pages/login'
})
}
} }
initPageParam() { initPageParam() {
this.all_count = 999; this.all_count = 999;