diff --git a/src/app.wpy b/src/app.wpy
index f82f4b4..b557383 100644
--- a/src/app.wpy
+++ b/src/app.wpy
@@ -29,14 +29,16 @@ export default class extends wepy.app {
'pages/gameInfo',
'pages/login',
'pages/search',
- 'pages/product'
+ 'pages/product',
+ 'pages/jumppage'
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black'
- }
+ },
+ navigateToMiniProgramAppIdList: ["wx0748c95caec7c0fe"]
}
globalData = {
@@ -109,7 +111,13 @@ export default class extends wepy.app {
}
onLaunch() {
}
-
+ onShow(options) {
+ console.log('app.onShow');
+ console.log(options);
+ if (options.scene === 1038) { //从小程序返回
+ jcEvent.emit(jcEvent.events.NEED_UPDATE_SCORE, {})
+ }
+ }
getUserInfo() {
return this.globalData.userInfo
}
diff --git a/src/common/global.js b/src/common/global.js
index 0824e08..9b36249 100644
--- a/src/common/global.js
+++ b/src/common/global.js
@@ -1,6 +1,6 @@
export default {
- // apiBase: 'http://192.168.100.232',
- apiBase: 'https://ghost-test.kingsome.cn',
+ apiBase: 'http://192.168.100.232',
+ // apiBase: 'https://ghost-test.kingsome.cn',
hostBase: 'https://pay.kingsome.cn',
//游戏页面根路径
gameBase: 'http://192.168.100.232',
diff --git a/src/common/jc-event.js b/src/common/jc-event.js
index d6278ac..cf8a95c 100644
--- a/src/common/jc-event.js
+++ b/src/common/jc-event.js
@@ -28,6 +28,7 @@ export default {
BUY_GAME_SUCCESS: 'buy-game-success',
LOGIN_FINISHED : 'login-finished',
UPDATE_RECENT_GAMES: 'update-recent-games',
- UPDATE_GAME_STATUS: 'update-game-status'
+ UPDATE_GAME_STATUS: 'update-game-status',
+ NEED_UPDATE_SCORE: 'need-update-score'
}
}
diff --git a/src/pages/gameInfo.wpy b/src/pages/gameInfo.wpy
index b2a6190..f4c80a0 100644
--- a/src/pages/gameInfo.wpy
+++ b/src/pages/gameInfo.wpy
@@ -106,6 +106,7 @@
},
bottomSecondTap(e) {
console.log('bottomSecondTap');
+ this.requestAd('');
},
toggleShowMore() {
this.showMore = !this.showMore;
@@ -124,10 +125,16 @@
jcEvent.emit(jcEvent.events.UPDATE_GAME_STATUS, {gid: self.id});
self.$apply();
});
+ jcEvent.on(jcEvent.events.NEED_UPDATE_SCORE, this, data => {
+ this.getUserInfo();
+ });
this.getRecord();
+ }
+ onShow() {
this.getUserInfo();
}
async showBuyMenu() {
+ let self = this;
try {
let res = await wepy.showActionSheet({
itemList: [`金币开通(${this.record.score})`, '促销开通']
@@ -137,12 +144,7 @@
if (res.tapIndex === 0) {
console.log('点击金币开通');
if (this.score < this.record.score) {
- console.log('金币不足');
- wepy.showToast({
- title: '金币不足',
- icon: 'none',
- duration: 2000
- })
+ this.getRecord('金币不足')
} else {
this.buyGame();
}
@@ -237,6 +239,21 @@
}
onUnload() {
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);
+ }
}
}
diff --git a/src/pages/index.wpy b/src/pages/index.wpy
index 3a5a30d..bf8e77b 100644
--- a/src/pages/index.wpy
+++ b/src/pages/index.wpy
@@ -49,6 +49,7 @@
data = {
nickname: '加载中',
avatar: '',
+ score: 0,
records: [],
recent_game_list: [],
all_count: 0,
@@ -123,6 +124,9 @@
}
self.$apply();
});
+ jcEvent.on(jcEvent.events.NEED_UPDATE_SCORE, this, data => {
+ this.getUserInfo();
+ })
}
getAllData() {
this.getRecords();
@@ -133,6 +137,7 @@
jcEvent.remove(jcEvent.events.LOGIN_FINISHED, this);
jcEvent.remove(jcEvent.events.UPDATE_RECENT_GAMES, this);
jcEvent.remove(jcEvent.events.UPDATE_GAME_STATUS, this);
+ jcEvent.remove(jcEvent.events.NEED_UPDATE_SCORE, this);
}
onShow() {
let userInfo = this.$parent.getUserInfo();
@@ -161,9 +166,11 @@
try {
let res = await http.post('/api/emulated/user_info', {type: 'all'});
console.log(res);
+ this.gameSet.clear();
for(let game of res.games) {
this.gameSet.add(game.gid);
}
+ this.score = res.score;
this.$apply();
} catch (err) {
console.log('error get user info');
diff --git a/src/pages/jumppage.wpy b/src/pages/jumppage.wpy
new file mode 100644
index 0000000..e47b246
--- /dev/null
+++ b/src/pages/jumppage.wpy
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+ {{text}}是否跳转到xxxxxxxxx,获取3金币?
+
+
+ 取消
+
+
+ 领取金币
+
+
+
+
+
+
+
+