iOS上增加是否显示购买的功能

This commit is contained in:
zhl 2019-03-07 13:10:51 +08:00
parent 398d744fc8
commit 68f76cd2a8
6 changed files with 59 additions and 18 deletions

View File

@ -12,7 +12,6 @@
z-index: 101;
}
.z-action-sheet {
height: 285rpx;
bottom: 0;
left: 0;
right: 0;
@ -53,7 +52,7 @@
<view class="z-action-sheet-back {{ config.hide ? 'hidden' : ''}}"></view>
<view class="z-action-sheet {{ config.hide ? 'hidden' : ''}}">
<view class="one-line" @tap="goldTap">{{config.goldTitle}}</view>
<navigator class="one-line"
<navigator class="one-line {{config.showBuy ? '' : 'hidden'}}"
target="miniProgram"
open-type="navigate"
app-id="wx815bf59d472c0a63"
@ -73,7 +72,8 @@
config: {
hide: true,
goldTitle: '',
params: ''
params: '',
showBuy: false
}
}
data = {

View File

@ -165,4 +165,9 @@ export default class baseMixin extends wepy.mixin {
}
}
}
$isIos() {
let info = wepy.getSystemInfoSync();
console.log(info);
return (info.platform && (/^ios/.test(info.platform.toLowerCase()) || /^devtools/.test(info.platform.toLowerCase())));
}
}

View File

@ -1,4 +1,4 @@
import wepy from 'wepy'
import wepy from 'wepy';
export default class cfgMixin extends wepy.mixin {
$getShareCfg() {
@ -10,13 +10,14 @@ export default class cfgMixin extends wepy.mixin {
return {
str: '怀旧经典游戏',
image: 'https://resource.kingsome.cn/dalmatian/wapp/share.jpg'
}
};
}
}
$getPrice(name) {
$getExtCfg(name) {
let cfgObj = wepy.getStorageSync('cfg');
let price = cfgObj.ext_json_cfg;
let obj = {fc_price: 5, gba_price: 10, ad_price: 3};
let obj = { fc_price: 5, gba_price: 10, ad_price: 3 };
if (price) {
try {
obj = JSON.parse(price);
@ -24,6 +25,37 @@ export default class cfgMixin extends wepy.mixin {
console.log('parse json error');
}
}
return obj[name+'_price'];
return obj[name];
}
//是否显示vip购买游戏页面等信息
$showAll() {
let cfg = wepy.getStorageSync('cfg');
return !cfg ? false : !cfg.hide_main;
}
/**
* 是否显示vip和产品的购买
* 1. 如果开启了审核开关(hide_main = true) 则隐藏所有购买按钮
* 2. 如果关闭了审核开关
* a. 如果当前系统为android则显示购买
* b. ios则根据ios_buy是否开启开启的情况下显示购买
* c. 未开启ios_buy的情况下如果已有游戏达到show_count, 则也显示购买
* */
$showBuy() {
if (this.$showAll()) {
if (this.$isIos()) {
let result = !!this.$getExtCfg('ios_buy');
if (!result) {
let count = wepy.getStorageSync('game_count') || 0;
let countCfg = this.$getExtCfg('show_count') || 0;
result = count >= countCfg;
}
return result;
} else {
return true;
}
} else {
return false;
}
}
}

View File

@ -99,7 +99,8 @@
zActionSheetCfg: {
hide: true,
goldTitle: '金币开通',
params: ''
params: '',
showBuy: false
},
vip: false
};
@ -136,7 +137,7 @@
this.zActionSheetCfg.hide = true;
},
actionSheetGold() {
if (this.score < this.$getPrice(this.record.category)) {
if (this.score < this.$getExtCfg(this.record.category+'_price')) {
this.requestAd('金币不足')
} else {
this.buyGame();
@ -188,11 +189,12 @@
this.showAll = !cfg ? false : !cfg.hide_main;
this.getUserInfo();
this.vip = this.$parent.isVip();
this.zActionSheetCfg.showBuy = this.$showBuy();
this.$apply();
}
async showBuyMenu() {
this.zActionSheetCfg.params = `token=${this.$parent.getGlobalDate('gameToken')}&gid=${this.id}`;
this.zActionSheetCfg.goldTitle = `金币开通(${this.$getPrice(this.record.category)})`;
this.zActionSheetCfg.goldTitle = `金币开通(${this.$getExtCfg(this.record.category + '_price')})`;
this.zActionSheetCfg.hide = false;
}
playGame(multip) {

View File

@ -11,7 +11,7 @@
<view class="vip-view {{showAll? '' : 'hidden'}}">
<image src="{{vipImg}}"></image>
<text class="vip-expire-txt">{{expire_str}}</text>
<navigator class="vip-btn zan-btn zan-btn--mini zan-btn--primary zan-btn--plain button-hover {{vip_btn_title ? '' : 'hidden'}}"
<navigator class="vip-btn zan-btn zan-btn--mini zan-btn--primary zan-btn--plain button-hover {{showBuy ? '' : 'hidden'}}"
target="miniProgram"
open-type="navigate"
app-id="wx815bf59d472c0a63"
@ -87,7 +87,8 @@
expire_str: '',
vipImg: image.vip_s,
vip_btn_title: '激活',
vip_params: ''
vip_params: '',
showBuy: false
};
methods = {
@ -147,8 +148,8 @@
this.getUserInfo();
})
jcEvent.on(jcEvent.events.NEED_UPDATE_CFG, this, data => {
let cfg = wepy.getStorageSync('cfg');
this.showAll = !cfg ? false : !cfg.hide_main;
this.showAll = this.$showAll();
this.showBuy = !!this.vip_btn_title && this.$showBuy();
this.$apply();
})
jcEvent.on(jcEvent.events.BUY_VIP_RESULT, this, data => {
@ -200,7 +201,7 @@
if (!cfg._getrewardtype) {
wepy.hideShareMenu();
}
this.showAll = !cfg ? false : !cfg.hide_main;
this.showAll = this.$showAll();
let userInfo = this.$parent.getUserInfo();
console.log(userInfo);
if (userInfo) {
@ -241,6 +242,7 @@
this.my_game_list = res.records;
this.showMyGame = this.my_game_list.length > 0;
this.$apply();
wepy.setStorageSync('game_count', this.my_game_list.length);
} catch (err) {
console.log('error get recent games');
}
@ -271,7 +273,7 @@
this.vip_btn_title = '激活';
this.vipImg = image.vip_s;
}
this.showBuy = !!this.vip_btn_title && this.$showBuy();
}
this.$apply();

View File

@ -107,7 +107,7 @@
onLoad(params) {
this.text = decodeURIComponent(params.text);
this.aid = decodeURIComponent(params.aid);
this.ad_price = this.$getPrice('ad');
this.ad_price = this.$getExtCfg('ad_price');
console.log(`aid : ${this.aid}`);
let self = this;
this.$parent.getShareCount(count => {