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-index: 101;
} }
.z-action-sheet { .z-action-sheet {
height: 285rpx;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
@ -53,7 +52,7 @@
<view class="z-action-sheet-back {{ config.hide ? 'hidden' : ''}}"></view> <view class="z-action-sheet-back {{ config.hide ? 'hidden' : ''}}"></view>
<view class="z-action-sheet {{ config.hide ? 'hidden' : ''}}"> <view class="z-action-sheet {{ config.hide ? 'hidden' : ''}}">
<view class="one-line" @tap="goldTap">{{config.goldTitle}}</view> <view class="one-line" @tap="goldTap">{{config.goldTitle}}</view>
<navigator class="one-line" <navigator class="one-line {{config.showBuy ? '' : 'hidden'}}"
target="miniProgram" target="miniProgram"
open-type="navigate" open-type="navigate"
app-id="wx815bf59d472c0a63" app-id="wx815bf59d472c0a63"
@ -73,7 +72,8 @@
config: { config: {
hide: true, hide: true,
goldTitle: '', goldTitle: '',
params: '' params: '',
showBuy: false
} }
} }
data = { 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 { export default class cfgMixin extends wepy.mixin {
$getShareCfg() { $getShareCfg() {
@ -10,13 +10,14 @@ export default class cfgMixin extends wepy.mixin {
return { return {
str: '怀旧经典游戏', str: '怀旧经典游戏',
image: 'https://resource.kingsome.cn/dalmatian/wapp/share.jpg' image: 'https://resource.kingsome.cn/dalmatian/wapp/share.jpg'
} };
} }
} }
$getPrice(name) {
$getExtCfg(name) {
let cfgObj = wepy.getStorageSync('cfg'); let cfgObj = wepy.getStorageSync('cfg');
let price = cfgObj.ext_json_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) { if (price) {
try { try {
obj = JSON.parse(price); obj = JSON.parse(price);
@ -24,6 +25,37 @@ export default class cfgMixin extends wepy.mixin {
console.log('parse json error'); 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: { zActionSheetCfg: {
hide: true, hide: true,
goldTitle: '金币开通', goldTitle: '金币开通',
params: '' params: '',
showBuy: false
}, },
vip: false vip: false
}; };
@ -136,7 +137,7 @@
this.zActionSheetCfg.hide = true; this.zActionSheetCfg.hide = true;
}, },
actionSheetGold() { actionSheetGold() {
if (this.score < this.$getPrice(this.record.category)) { if (this.score < this.$getExtCfg(this.record.category+'_price')) {
this.requestAd('金币不足') this.requestAd('金币不足')
} else { } else {
this.buyGame(); this.buyGame();
@ -188,11 +189,12 @@
this.showAll = !cfg ? false : !cfg.hide_main; this.showAll = !cfg ? false : !cfg.hide_main;
this.getUserInfo(); this.getUserInfo();
this.vip = this.$parent.isVip(); this.vip = this.$parent.isVip();
this.zActionSheetCfg.showBuy = this.$showBuy();
this.$apply(); this.$apply();
} }
async showBuyMenu() { async showBuyMenu() {
this.zActionSheetCfg.params = `token=${this.$parent.getGlobalDate('gameToken')}&gid=${this.id}`; 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; this.zActionSheetCfg.hide = false;
} }
playGame(multip) { playGame(multip) {

View File

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

View File

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