根据配置显示隐藏相关组件

This commit is contained in:
zhl 2019-02-21 17:09:05 +08:00
parent d44c39db63
commit 70387ac8cd
6 changed files with 39 additions and 6 deletions

View File

@ -12,6 +12,9 @@
width: 749rpx;
overflow-x: hidden;
}
.hidden{
display: none!important;
}
</style>
<script>
@ -55,6 +58,7 @@ export default class extends wepy.app {
let account = wepy.getStorageSync('account');
console.log('finish parse jcfw');
console.log(account);
jcEvent.emit(jcEvent.events.NEED_UPDATE_CFG, {});
if (this.checkClientLogin()) {
this.login();
}
@ -167,5 +171,8 @@ export default class extends wepy.app {
console.info(`[${obj ? 'UPDATE' : 'GET'} GlobalData ${name}]:`, this.globalData[name]);
return this.globalData[name];
}
showAll() {
return this.globalData.showAll;
}
}
</script>

View File

@ -29,6 +29,7 @@ export default {
LOGIN_FINISHED : 'login-finished',
UPDATE_RECENT_GAMES: 'update-recent-games',
UPDATE_GAME_STATUS: 'update-game-status',
NEED_UPDATE_SCORE: 'need-update-score'
NEED_UPDATE_SCORE: 'need-update-score',
NEED_UPDATE_CFG: 'need-update-cfg'
}
}

View File

@ -11,7 +11,7 @@
<view class="title">{{item.name}}</view>
<view class="content">{{item.introduce}}</view>
</view>
<view class="left-btn">
<view class="left-btn {{showAll ? '' : 'hidden'}}">
<view wx:if="{{item.owned}}" class="zan-btn zan-btn--mini zan-btn--plain zan-btn--primary ">
去玩
</view>
@ -28,7 +28,11 @@
props = {
item: {
type: Object,
defalut: null
default: null
},
showAll: {
type: Boolean,
default: false
}
}
data = {

View File

@ -71,6 +71,8 @@ var SDKManage = function() {
var cb = function(res) {
console.log('getGameConfig');
console.log(res);
wx.setStorageSync('cfg', res);
setTimeout(() => {
self.doLogin();
}, 10);

View File

@ -51,7 +51,7 @@
</view>
</view>
</view>
<gameBottomBar :config.sync="bottomActionCfg" @bottomMainTap.user="bottomMainTap"
<gameBottomBar class="{{showAll? '' : 'hidden'}}" :config.sync="bottomActionCfg" @bottomMainTap.user="bottomMainTap"
@bottomSecondTap.user="bottomSecondTap"/>
</template>
@ -77,6 +77,7 @@
typeStr: '其他',
tagList: [],
score: 0,
showAll: false,
bottomActionCfg: {
hide: false,
mainBtnIconClass: 'icon-cart',
@ -115,6 +116,7 @@
onLoad(params) {
this.id = decodeURIComponent(params.id);
this.showAll = this.$parent.showAll();
console.log(this.id);
let self = this;
jcEvent.on(jcEvent.events.BUY_GAME_SUCCESS, this, data => {
@ -128,9 +130,16 @@
jcEvent.on(jcEvent.events.NEED_UPDATE_SCORE, this, data => {
this.getUserInfo();
});
jcEvent.on(jcEvent.events.NEED_UPDATE_CFG, this, data => {
let cfg = wepy.getStorageSync('cfg');
this.showAll = !cfg ? false : !cfg.hide_main;
this.$apply();
})
this.getRecord();
}
onShow() {
let cfg = wepy.getStorageSync('cfg');
this.showAll = !cfg ? false : !cfg.hide_main;
this.getUserInfo();
}
async showBuyMenu() {
@ -240,6 +249,7 @@
onUnload() {
jcEvent.remove(jcEvent.events.BUY_GAME_SUCCESS, this);
jcEvent.remove(jcEvent.events.NEED_UPDATE_SCORE, this);
jcEvent.remove(jcEvent.events.NEED_UPDATE_CFG, this);
}
async requestAd(text) {
try {

View File

@ -18,7 +18,7 @@
<view class="right" @tap="toSearch"><i class="icon-search"></i> 搜索</view>
</view>
<repeat for="{{records}}" item="item" >
<recordCell :item="item" @gameCellTap.user="gameTap"/>
<recordCell :item="item" @gameCellTap.user="gameTap" :showAll.sync = 'showAll'/>
</repeat>
<zanLoadmore :loading.sync="loading" :nodata.sync="noData" :nomore.sync="noMore" nodata_str="暂无数据"></zanLoadmore>
<toast/>
@ -60,7 +60,8 @@
loading: false,
noData: true,
noMore: false,
gameSet: new Set()
gameSet: new Set(),
showAll: false
};
methods = {
@ -130,6 +131,11 @@
jcEvent.on(jcEvent.events.NEED_UPDATE_SCORE, this, data => {
this.getUserInfo();
})
jcEvent.on(jcEvent.events.NEED_UPDATE_CFG, this, data => {
let cfg = wepy.getStorageSync('cfg');
this.showAll = !cfg ? false : !cfg.hide_main;
this.$apply();
})
}
getAllData() {
this.getRecords();
@ -141,8 +147,11 @@
jcEvent.remove(jcEvent.events.UPDATE_RECENT_GAMES, this);
jcEvent.remove(jcEvent.events.UPDATE_GAME_STATUS, this);
jcEvent.remove(jcEvent.events.NEED_UPDATE_SCORE, this);
jcEvent.remove(jcEvent.events.NEED_UPDATE_CFG, this);
}
onShow() {
let cfg = wepy.getStorageSync('cfg');
this.showAll = !cfg ? false : !cfg.hide_main;
let userInfo = this.$parent.getUserInfo();
console.log(userInfo);
if (userInfo) {