增加小游戏跳转界面
This commit is contained in:
parent
b465ec3f73
commit
6ddd02ad6d
14
src/app.wpy
14
src/app.wpy
@ -29,14 +29,16 @@ export default class extends wepy.app {
|
|||||||
'pages/gameInfo',
|
'pages/gameInfo',
|
||||||
'pages/login',
|
'pages/login',
|
||||||
'pages/search',
|
'pages/search',
|
||||||
'pages/product'
|
'pages/product',
|
||||||
|
'pages/jumppage'
|
||||||
],
|
],
|
||||||
window: {
|
window: {
|
||||||
backgroundTextStyle: 'light',
|
backgroundTextStyle: 'light',
|
||||||
navigationBarBackgroundColor: '#fff',
|
navigationBarBackgroundColor: '#fff',
|
||||||
navigationBarTitleText: 'WeChat',
|
navigationBarTitleText: 'WeChat',
|
||||||
navigationBarTextStyle: 'black'
|
navigationBarTextStyle: 'black'
|
||||||
}
|
},
|
||||||
|
navigateToMiniProgramAppIdList: ["wx0748c95caec7c0fe"]
|
||||||
}
|
}
|
||||||
|
|
||||||
globalData = {
|
globalData = {
|
||||||
@ -109,7 +111,13 @@ export default class extends wepy.app {
|
|||||||
}
|
}
|
||||||
onLaunch() {
|
onLaunch() {
|
||||||
}
|
}
|
||||||
|
onShow(options) {
|
||||||
|
console.log('app.onShow');
|
||||||
|
console.log(options);
|
||||||
|
if (options.scene === 1038) { //从小程序返回
|
||||||
|
jcEvent.emit(jcEvent.events.NEED_UPDATE_SCORE, {})
|
||||||
|
}
|
||||||
|
}
|
||||||
getUserInfo() {
|
getUserInfo() {
|
||||||
return this.globalData.userInfo
|
return this.globalData.userInfo
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
// apiBase: 'http://192.168.100.232',
|
apiBase: 'http://192.168.100.232',
|
||||||
apiBase: 'https://ghost-test.kingsome.cn',
|
// apiBase: 'https://ghost-test.kingsome.cn',
|
||||||
hostBase: 'https://pay.kingsome.cn',
|
hostBase: 'https://pay.kingsome.cn',
|
||||||
//游戏页面根路径
|
//游戏页面根路径
|
||||||
gameBase: 'http://192.168.100.232',
|
gameBase: 'http://192.168.100.232',
|
||||||
|
@ -28,6 +28,7 @@ export default {
|
|||||||
BUY_GAME_SUCCESS: 'buy-game-success',
|
BUY_GAME_SUCCESS: 'buy-game-success',
|
||||||
LOGIN_FINISHED : 'login-finished',
|
LOGIN_FINISHED : 'login-finished',
|
||||||
UPDATE_RECENT_GAMES: 'update-recent-games',
|
UPDATE_RECENT_GAMES: 'update-recent-games',
|
||||||
UPDATE_GAME_STATUS: 'update-game-status'
|
UPDATE_GAME_STATUS: 'update-game-status',
|
||||||
|
NEED_UPDATE_SCORE: 'need-update-score'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
},
|
},
|
||||||
bottomSecondTap(e) {
|
bottomSecondTap(e) {
|
||||||
console.log('bottomSecondTap');
|
console.log('bottomSecondTap');
|
||||||
|
this.requestAd('');
|
||||||
},
|
},
|
||||||
toggleShowMore() {
|
toggleShowMore() {
|
||||||
this.showMore = !this.showMore;
|
this.showMore = !this.showMore;
|
||||||
@ -124,10 +125,16 @@
|
|||||||
jcEvent.emit(jcEvent.events.UPDATE_GAME_STATUS, {gid: self.id});
|
jcEvent.emit(jcEvent.events.UPDATE_GAME_STATUS, {gid: self.id});
|
||||||
self.$apply();
|
self.$apply();
|
||||||
});
|
});
|
||||||
|
jcEvent.on(jcEvent.events.NEED_UPDATE_SCORE, this, data => {
|
||||||
|
this.getUserInfo();
|
||||||
|
});
|
||||||
this.getRecord();
|
this.getRecord();
|
||||||
|
}
|
||||||
|
onShow() {
|
||||||
this.getUserInfo();
|
this.getUserInfo();
|
||||||
}
|
}
|
||||||
async showBuyMenu() {
|
async showBuyMenu() {
|
||||||
|
let self = this;
|
||||||
try {
|
try {
|
||||||
let res = await wepy.showActionSheet({
|
let res = await wepy.showActionSheet({
|
||||||
itemList: [`金币开通(${this.record.score})`, '促销开通']
|
itemList: [`金币开通(${this.record.score})`, '促销开通']
|
||||||
@ -137,12 +144,7 @@
|
|||||||
if (res.tapIndex === 0) {
|
if (res.tapIndex === 0) {
|
||||||
console.log('点击金币开通');
|
console.log('点击金币开通');
|
||||||
if (this.score < this.record.score) {
|
if (this.score < this.record.score) {
|
||||||
console.log('金币不足');
|
this.getRecord('金币不足')
|
||||||
wepy.showToast({
|
|
||||||
title: '金币不足',
|
|
||||||
icon: 'none',
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
this.buyGame();
|
this.buyGame();
|
||||||
}
|
}
|
||||||
@ -237,6 +239,21 @@
|
|||||||
}
|
}
|
||||||
onUnload() {
|
onUnload() {
|
||||||
jcEvent.remove(jcEvent.events.BUY_GAME_SUCCESS, this);
|
jcEvent.remove(jcEvent.events.BUY_GAME_SUCCESS, this);
|
||||||
|
jcEvent.remove(jcEvent.events.NEED_UPDATE_SCORE, this);
|
||||||
|
}
|
||||||
|
async requestAd(text) {
|
||||||
|
try {
|
||||||
|
let res = await http.post('/api/emulated/request_ad', {});
|
||||||
|
if (res.errcode === 0) {
|
||||||
|
wepy.navigateTo({
|
||||||
|
url: `/pages/jumppage?text=${text}&aid=${res.aid}, `
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('request ad with errmsg: ' + res.errmsg);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
data = {
|
data = {
|
||||||
nickname: '加载中',
|
nickname: '加载中',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
|
score: 0,
|
||||||
records: [],
|
records: [],
|
||||||
recent_game_list: [],
|
recent_game_list: [],
|
||||||
all_count: 0,
|
all_count: 0,
|
||||||
@ -123,6 +124,9 @@
|
|||||||
}
|
}
|
||||||
self.$apply();
|
self.$apply();
|
||||||
});
|
});
|
||||||
|
jcEvent.on(jcEvent.events.NEED_UPDATE_SCORE, this, data => {
|
||||||
|
this.getUserInfo();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
getAllData() {
|
getAllData() {
|
||||||
this.getRecords();
|
this.getRecords();
|
||||||
@ -133,6 +137,7 @@
|
|||||||
jcEvent.remove(jcEvent.events.LOGIN_FINISHED, this);
|
jcEvent.remove(jcEvent.events.LOGIN_FINISHED, this);
|
||||||
jcEvent.remove(jcEvent.events.UPDATE_RECENT_GAMES, this);
|
jcEvent.remove(jcEvent.events.UPDATE_RECENT_GAMES, this);
|
||||||
jcEvent.remove(jcEvent.events.UPDATE_GAME_STATUS, this);
|
jcEvent.remove(jcEvent.events.UPDATE_GAME_STATUS, this);
|
||||||
|
jcEvent.remove(jcEvent.events.NEED_UPDATE_SCORE, this);
|
||||||
}
|
}
|
||||||
onShow() {
|
onShow() {
|
||||||
let userInfo = this.$parent.getUserInfo();
|
let userInfo = this.$parent.getUserInfo();
|
||||||
@ -161,9 +166,11 @@
|
|||||||
try {
|
try {
|
||||||
let res = await http.post('/api/emulated/user_info', {type: 'all'});
|
let res = await http.post('/api/emulated/user_info', {type: 'all'});
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
this.gameSet.clear();
|
||||||
for(let game of res.games) {
|
for(let game of res.games) {
|
||||||
this.gameSet.add(game.gid);
|
this.gameSet.add(game.gid);
|
||||||
}
|
}
|
||||||
|
this.score = res.score;
|
||||||
this.$apply();
|
this.$apply();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('error get user info');
|
console.log('error get user info');
|
||||||
|
106
src/pages/jumppage.wpy
Normal file
106
src/pages/jumppage.wpy
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<style lang="less">
|
||||||
|
.background-view {
|
||||||
|
background-color: #666666;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.msg-box{
|
||||||
|
position: absolute;
|
||||||
|
width: 600rpx;
|
||||||
|
height: 300rpx;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
margin: -200rpx -300rpx;
|
||||||
|
border-radius:5px;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
}
|
||||||
|
.msg-title {
|
||||||
|
height: 200rpx;
|
||||||
|
widht: 600rpx;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
padding: 10px;
|
||||||
|
font-size:18px;
|
||||||
|
color:#777;
|
||||||
|
|
||||||
|
}
|
||||||
|
.msg-action-bar {
|
||||||
|
height: 80rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
border-top: 1rpx solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.msg-action-bar .msg-action-btn {
|
||||||
|
width: 300rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
.msg-action-bar .msg-action-btn:first-child {
|
||||||
|
border-right: 1rpx solid #e5e5e5 ;
|
||||||
|
}
|
||||||
|
.msg-action-bar .msg-action-btn:last-child {
|
||||||
|
color: #3283fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<view class="background-view"></view>
|
||||||
|
<view class="msg-box">
|
||||||
|
<view class="msg-title">
|
||||||
|
<text>{{text}}是否跳转到xxxxxxxxx,获取3金币?</text>
|
||||||
|
</view>
|
||||||
|
<view class="msg-action-bar">
|
||||||
|
<view class="msg-action-btn" @tap="cancel"><text>取消</text></view>
|
||||||
|
<view class="msg-action-btn">
|
||||||
|
<navigator
|
||||||
|
target="miniProgram"
|
||||||
|
open-type="navigate"
|
||||||
|
app-id="wx0748c95caec7c0fe"
|
||||||
|
path="?aid={{aid}}"
|
||||||
|
extra-data=""
|
||||||
|
version="develop"
|
||||||
|
>
|
||||||
|
领取金币
|
||||||
|
</navigator>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import wepy from 'wepy'
|
||||||
|
import http from '../utils/http';
|
||||||
|
|
||||||
|
export default class JumpPage extends wepy.page {
|
||||||
|
components = {};
|
||||||
|
data = {
|
||||||
|
text: '',
|
||||||
|
aid: '11'
|
||||||
|
};
|
||||||
|
methods = {
|
||||||
|
cancel: function() {
|
||||||
|
wepy.navigateBack()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad(params) {
|
||||||
|
this.text = decodeURIComponent(params.text);
|
||||||
|
this.aid = decodeURIComponent(params.aid);
|
||||||
|
console.log(`aid : ${this.aid}`);
|
||||||
|
this.$apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user