点击联机分享链接进入游戏后,由首页跳转至游戏页面
This commit is contained in:
parent
f3f3935096
commit
37c486486d
@ -29,7 +29,7 @@
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": 0,
|
||||
"current": 1,
|
||||
"list": [
|
||||
{
|
||||
"id": 0,
|
||||
@ -41,6 +41,13 @@
|
||||
"appId": "wxbf333d56b4de3905",
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
export default {
|
||||
// apiBase: 'http://192.168.100.226',
|
||||
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',
|
||||
gameTypes: ['射击','格斗', '角色扮演','动作角色扮演',
|
||||
'赛车', '动作游戏','策略战棋', '其他',
|
||||
|
@ -103,21 +103,21 @@ var httpcli = function(){
|
||||
},
|
||||
fail: function(res){
|
||||
console.log("[wx]request fail!"+ JSON.stringify(res));
|
||||
if(!isretry && this._needretry){
|
||||
if(!isretry && self._needretry){
|
||||
let obj = {
|
||||
u: url,
|
||||
v: urldata,
|
||||
successcb: cbRes,
|
||||
errcb: cbErr
|
||||
};
|
||||
this.cachemsg.push(obj);
|
||||
self.cachemsg.push(obj);
|
||||
}else{
|
||||
cbErr && cbErr(-1, res.msg);
|
||||
}
|
||||
// cbErr && cbErr(-1, res.msg);
|
||||
},
|
||||
complete: function(){
|
||||
this._runningcount--;
|
||||
self._runningcount--;
|
||||
console.log("[wx]request complete!");
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
</style>
|
||||
<template>
|
||||
<view class="container">
|
||||
<web-view src="{{link}}"></web-view>
|
||||
<web-view src="{{link}}" @load="webloaded" @error="webloaderror" @message="onMessage"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -13,14 +13,56 @@
|
||||
export default class GameWebPage extends wepy.page {
|
||||
components = {};
|
||||
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) {
|
||||
this.gid = params.gid;
|
||||
this.link = decodeURIComponent(params.link);
|
||||
console.log(this.link);
|
||||
console.log('load page: ' + this.link);
|
||||
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>
|
||||
|
@ -113,7 +113,11 @@
|
||||
bottomMainTap(e) {
|
||||
console.log('bottomMainTap');
|
||||
if (this.record.owned || this.vip) {
|
||||
if (this.record.category === 'fc') {
|
||||
this.openPlayMenu();
|
||||
} else {
|
||||
this.playGame();
|
||||
}
|
||||
} else {
|
||||
//显示购买游戏界面
|
||||
this.showBuyMenu();
|
||||
@ -187,22 +191,25 @@
|
||||
this.zActionSheetCfg.goldTitle = `金币开通(${this.record.score})`;
|
||||
this.zActionSheetCfg.hide = false;
|
||||
}
|
||||
playGame() {
|
||||
playGame(multip) {
|
||||
http.post('/api/emulated/play_game', { gid: this.id })
|
||||
.then(res => {
|
||||
console.log('success update game history');
|
||||
jcEvent.emit(jcEvent.events.UPDATE_RECENT_GAMES, {});
|
||||
let url;
|
||||
if (this.record.category === 'fc') {
|
||||
url = `${this.fcUrl}/id=${this.id}`;
|
||||
url = `${this.fcUrl}?id=${this.id}`;
|
||||
if (multip) {
|
||||
url += '&roomId=0';
|
||||
}
|
||||
} else {
|
||||
url = `${this.gbaUrl1}/id=${this.id}`;
|
||||
url = `${this.gbaUrl1}?id=${this.id}`;
|
||||
if (this.record.fixed) {
|
||||
url = `${this.gbaUrl2}/id=${this.id}`;
|
||||
url = `${this.gbaUrl2}?id=${this.id}`;
|
||||
}
|
||||
}
|
||||
wepy.navigateTo({
|
||||
url: '/pages/game?link=' + url
|
||||
url: '/pages/game?link=' + encodeURIComponent(url) + '&gid=' + this.id
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
@ -290,5 +297,15 @@
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
async openPlayMenu () {
|
||||
let res = await wepy.showActionSheet({
|
||||
itemList: ['单人', '联机']
|
||||
});
|
||||
|
||||
if (!res.cancel) {
|
||||
console.log(res.tapIndex);
|
||||
this.playGame(res.tapIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -119,18 +119,7 @@
|
||||
}
|
||||
|
||||
async onLoad(options) {
|
||||
let userInfo = this.$parent.getUserInfo();
|
||||
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()) {
|
||||
this.getAllData();
|
||||
this.vip_params = `token=${this.$parent.getGlobalDate('gameToken')}`;
|
||||
@ -169,6 +158,16 @@
|
||||
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() {
|
||||
this.getRecords();
|
||||
@ -194,6 +193,11 @@
|
||||
this.avatar = userInfo.avatarUrl;
|
||||
this.$apply();
|
||||
}
|
||||
if (this.$parent.checkAuthorize()) {
|
||||
wepy.navigateTo({
|
||||
url: '/pages/login'
|
||||
})
|
||||
}
|
||||
}
|
||||
initPageParam() {
|
||||
this.all_count = 999;
|
||||
|
Loading…
x
Reference in New Issue
Block a user