master
ELF 5 years ago
parent 4a1ffd2955
commit a0cfee5466

@ -130,7 +130,7 @@ class ApplyService {
$decryptStr = openssl_decrypt(base64_decode($code), self::ENCRYPT_METHOD, self::ENCRYPT_KEY);
$result = json_decode($decryptStr, true);
if (is_null($result)) {
$items = explode('|', $result);
$items = explode('|', $decryptStr);
if (count($items) != 5) {
return null;
}

@ -827,6 +827,9 @@ class PromoteService {
*/
public function getTopPromote($promote)
{
/* if ($promote['level'] == 1) {
return $promote;
} */
$chain = trim($promote['chain'], '/');
if ($chain == '') {
return $promote;
@ -1093,4 +1096,24 @@ class PromoteService {
}
return $groupName;
}
public function getVisibleGameIds($promote)
{
$gameIds = M('game', 'tab_')->getField('id', true);
$selfGameIds = $promote['game_ids'] == '' ? $gameIds : explode(',', $promote['game_ids']);
if ($promote['level'] == 1) {
return $selfGameIds;
}
$topPromote = $this->getTopPromote($promote);
if ($topPromote['child_game_permission'] == 0) {
$gameIds = M('apply', 'tab_')->where(['offline_status' => 0, 'promote_id' => $topPromote['id']])->getField('game_id', true);
if (empty($gameIds)) {
return [];
}
return array_intersect($selfGameIds, $gameIds);
} else {
return $selfGameIds;
}
}
}

File diff suppressed because one or more lines are too long

@ -1,6 +1,8 @@
<?php
namespace Base\Tool;
use Base\Tool\MobileDetect;
/**
* @author elf<360197197@qq.com>
*/
@ -8,6 +10,7 @@ class Request {
private $serverInfo;
private $scheme;
private $mobileDetect;
public function __construct()
{
@ -29,43 +32,45 @@ class Request {
return $this->serverInfo['HTTP_USER_AGENT'] ?? '';
}
public function isMobile()
public function getMobileDetect()
{
$isMobile = false;
$userAgent = $this->getUserAgent();
$mobileAgents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
foreach ($mobileAgents as $mobileAgent) {
if (stripos($userAgent, $mobileAgent) !== false) {
$isMobile = true;
}
if (!$this->mobileDetect) {
$this->mobileDetect = new MobileDetect($this->serverInfo);
}
return $isMobile;
return $this->mobileDetect;
}
public function isMobile()
{
return $this->getMobileDetect()->isMobile();
}
public function isTablet()
{
return $this->getMobileDetect()->isTablet();
}
public function isIOS()
{
$userAgent = $this->getUserAgent();
if(stripos($userAgent, 'iphone') !== false || stripos($userAgent, 'ipad') !== false || stripos($userAgent, 'ipod') !== false) {
return true;
}
return false;
return $this->getMobileDetect()->isIOS();
}
public function isAndroid()
{
$userAgent = $this->getUserAgent();
if(stripos($userAgent, 'android')) {
return true;
}
return false;
return $this->getMobileDetect()->isAndroidOS();
}
public function isIPadOS()
{
return $this->getMobileDetect()->isIPadOS();
}
public function isIOS13()
{
$userAgent = $this->getUserAgent();
// if (preg_match('/OS [1][3-9]_[1-9][_\d]* like Mac OS X/i', $userAgent)) {
if (preg_match('/OS.*[1][3-9]_[1-9][_\d]*.*like.*Mac.*OS.*X/i', $userAgent)) {
return true;
$version = $this->getMobileDetect()->version('iPhone');
if ($version) {
$versionItems = explode('_', $version);
return isset($versionItems[0]) && intval($versionItems[0]) == 13;
}
return false;
}
@ -121,4 +126,9 @@ class Request {
}
return $this->scheme;
}
public function getServerInfo()
{
return $this->serverInfo;
}
}

@ -1818,17 +1818,7 @@ class ApplyController extends BaseController
]
]);
}
$applyService = new ApplyService();
if (!$applyService->checkSociatyPerm($promote, $game)) {
$this->ajaxReturn([
'status' => 0,
'message' => '该游戏未授权',
'data' => [
]
]);
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
$this->ajaxReturn([
@ -1841,6 +1831,7 @@ class ApplyController extends BaseController
$icon = Request::getHost() . '/' . get_cover($game['icon'], 'path');
$applyService = new ApplyService();
$result = $applyService->checkApplyStatus($apply);
if (!$result['status']) {
$this->ajaxReturn([
@ -1881,16 +1872,6 @@ class ApplyController extends BaseController
]);
}
$applyService = new ApplyService();
if (!$applyService->checkSociatyPerm($promote, $game)) {
$this->ajaxReturn([
'status' => 0,
'message' => '该游戏未授权',
'data' => [
]
]);
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
$this->ajaxReturn([
@ -1903,6 +1884,7 @@ class ApplyController extends BaseController
$icon = Request::getHost() . '/' . get_cover($game['icon'], 'path');
$applyService = new ApplyService();
$result = $applyService->checkApplyStatus($apply);
if (!$result['status']) {
$this->ajaxReturn([

@ -32,7 +32,7 @@ class GameController extends BaseController
$promoteId = I('promote_id', 0);
$promoteLevel = I('promote_level', 0);
$loginPromote = $this->getLoginPromote();
$baseGameId = I('base_game_id', 0);
$baseGameId = I('game_id', 0);
$isMine = I('is_mine', 0);
if ($promoteLevel != 0 && $promoteId == 0) {
@ -46,9 +46,11 @@ class GameController extends BaseController
$promoteId = $loginPromote['id'];
}
$gameIds = [];
$promoteService = new PromoteService();
$gameIds = $promoteService->getVisibleGameIds($loginPromote);
if ($baseGameId > 0) {
$baseGame = M('base_game', 'tab_')->where('id', $baseGameId)->find();
$baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find();
$gameIds = [];
if ($baseGame['android_game_id'] > 0) {
$gameIds[] = $baseGame['android_game_id'];
}
@ -56,10 +58,9 @@ class GameController extends BaseController
$gameIds[] = $baseGame['ios_game_id'];
}
}
if ($isMine) {
$applyGameIds = M('apply', 'tab_')->where(['offline_status' => 0, 'promote_id' => $promoteId])->getField('game_id', true);
$gameIds = (count($gameIds) == 0 ? $applyGameIds : array_intersect($applyGameIds, $gameIds));
$gameIds = array_intersect($applyGameIds, $gameIds);
}
$columns = ['id', 'icon', 'game_name', 'features', 'sdk_version', 'game_size', 'game_type_name'];
@ -70,9 +71,7 @@ class GameController extends BaseController
}
$conditions['server_type'] = $serverType;
if (count($gameIds) > 0) {
$conditions['id'] = ['in', $gameIds];
}
$conditions['id'] = ['in', $gameIds];
$query = M('game', 'tab_')->field($columns)->where($conditions)->order('relation_game_id desc');
list($games, $pagination, $count) = $this->paginate($query);
@ -267,11 +266,16 @@ class GameController extends BaseController
public function getMineBaseGames()
{
$gameIds = M('apply', 'tab_')->where(['promote_id' => $promoteId])->getField('game_id', true);
$games = [];
if (count($gameIds) > 0) {
$games = M('base_game', 'tab_')->where(['_logic' => 'or', 'android_game_id' => ['in', $gameIds], 'ios_game_id' => ['in', $gameIds]])->select();
$loginPromote = $this->getLoginPromote();
$promoteService = new PromoteService();
$gameIds = $promoteService->getVisibleGameIds($loginPromote);
$conditions = [];
if ($gameIds !== true) {
$conditions = ['_logic' => 'or', 'android_game_id' => ['in', $gameIds], 'ios_game_id' => ['in', $gameIds]];
} else {
$conditions = '1=1';
}
$games = M('base_game', 'tab_')->where($conditions)->select();
return $this->ajaxReturn([
'status' => true,
@ -1986,16 +1990,6 @@ class GameController extends BaseController
]);
}
$applyService = new ApplyService();
if (!$applyService->checkSociatyPerm($promote, $game)) {
$this->ajaxReturn([
'status' => 0,
'message' => '该游戏未授权',
'data' => [
]
]);
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
$this->ajaxReturn([
@ -2008,6 +2002,7 @@ class GameController extends BaseController
$icon = Request::getHost() . '/' . get_cover($game['icon'], 'path');
$applyService = new ApplyService();
$result = $applyService->checkApplyStatus($apply);
if (!$result['status']) {
$this->ajaxReturn([
@ -2048,16 +2043,6 @@ class GameController extends BaseController
]);
}
$applyService = new ApplyService();
if (!$applyService->checkSociatyPerm($promote, $game)) {
$this->ajaxReturn([
'status' => 0,
'message' => '该游戏未授权',
'data' => [
]
]);
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
$this->ajaxReturn([
@ -2070,6 +2055,7 @@ class GameController extends BaseController
$icon = Request::getHost() . '/' . get_cover($game['icon'], 'path');
$applyService = new ApplyService();
$result = $applyService->checkApplyStatus($apply);
if (!$result['status']) {
$this->ajaxReturn([

@ -6,6 +6,7 @@ use User\Api\MemberApi;
use Base\Facade\Request;
use Base\Service\ApplyService;
use Base\Service\PackageDownloadLogService;
use Base\Tool\MobileDetect;
/**
* 前台公共控制器
@ -159,6 +160,7 @@ class HomeController extends Controller
$applyService = new ApplyService();
if ($code != '') {
$data = $applyService->decodeApplyCode($code);
$result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_LANDING_PAGE);
if (!$result['status']) {
$this->error($result['message']);
@ -169,7 +171,7 @@ class HomeController extends Controller
}
$isWechat = Request::isWechat();
$isIOS = Request::isIOS();
$isIOS = Request::isIOS() || Request::isIPadOS();
$isAndroid = Request::isAndroid();
$isIOS13 = Request::isIOS13();
@ -207,9 +209,6 @@ class HomeController extends Controller
$game = M('game', 'tab_')->field($columns)->where($map)->find();
$promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find();
if (!$applyService->checkSociatyPerm($promote, $game)) {
$this->error('该链接已经失效');
}
if ($game['sdk_version'] == 1 && $isIOS) {
$map = [];

@ -67,25 +67,20 @@ class PackageController extends Controller
$promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find();
$game = M('game','tab_')->field(['id', 'game_name', 'sdk_version', 'apply_auth'])->where(['id' => $apply['game_id']])->find();
if (!$applyService->checkSociatyPerm($promote, $game)) {
$this->redirect("package/downloadError", ['message' => '该链接已经失效']);
}
if (Request::isMobile()) {
if (Request::isMobile() || Request::isTablet()) {
if (!Request::isAndroid() && $game['sdk_version'] == 1) {
$this->redirect("package/downloadError", ['message' => '请使用安卓浏览器下载']);
}
if (!Request::isIOS() && $game['sdk_version'] == 2) {
if (!(Request::isIOS() || Request::isIPadOS()) && $game['sdk_version'] == 2) {
$this->redirect("package/downloadError", ['message' => '请使用ios浏览器下载']);
}
}
$packageUrl = $game['sdk_version'] == 1 ? $apply['pack_url'] : $apply['plist_url'];
M('game','tab_')->where(['id' => $game['id']])->setInc('dow_num');
if (Request::isAndroid()) {
$this->gotoPkgUrl($packageUrl);
} else if (Request::isIOS()) {
if (Request::isIOS() || Request::isIPadOS()) {
$packageDownloadLogService = new PackageDownloadLogService();
$packageDownloadLogService->add([
'user_id' => 0,

@ -311,39 +311,18 @@
</div>
</div>
<div class="game-window-box" id="game_link">
<div class="game-window-title">
<p style="width: calc(80% - 20px)">复制结果</p>
<p class="add-game-close" style="width: calc(20% - 20px);text-align: right;"><i class="iconfont iconguanbi"></i></p>
</div>
<div class="game-window-content" style="text-align: center;width: auto;padding-bottom: 0px;">
<div class="game-window-content-eveyone" style="display: block;color: #3A97FF;font-size: 1.1rem;">
<label style="margin-right: 20px;">下载地址:</label>
<span id="game_link_address" style="word-wrap: break-word;white-space: normal;"></span>
</div>
</div>
<div class="game-window-content" style="text-align: center;width: auto;padding-top: 5px;">
<div class="game-window-content-eveyone" style="display: block;color: #999;font-size: 1.1rem;">
<span id="copy_msg">复制成功,ctrl+v粘贴即可</span>
<button class="clipboard-btn" id="clipboard-btn" style="display: none;" data-text="">复制</button>
</div>
</div>
<div class="game-window-content" style="text-align: center;width: auto;padding-bottom: 5px;">
<div id="game_link_ercode" class="game-window-content-eveyone" style="display: block;color: #999;font-size: 1.1rem;">
<!-- <img id="game_link_ercode" style="width: 200px;height: 200px;"> -->
</div>
</div>
<div class="game-window-bg"></div>
<div class="game-window-content" style="text-align: center;width: auto;padding-top: 5px;">
<div class="game-window-content-eveyone" style="display: block;color: #999;font-size: 1.1rem;">
<span>下载地址二维码</span>
</div>
<div id="game-link-box" class="layer-box" style="display: none;">
<span class="game-link-title" style="font-size: 87.5%; color: #212529; font-weight: 700;"></span>
<span id="game_link_address" style="font-size: 87.5%; color: #212529; word-wrap: break-word;white-space: normal;"></span>
<p class="work-mark"style="font-size: 12px; text-align: center; margin-bottom: 30px; margin-top: 5px">复制成功,ctrl+v粘贴即可</p>
<button class="clipboard-btn" id="clipboard-btn" style="display: none;">复制</button>
<div id="game_link_ercode" class="game-window-content-eveyone" style="text-align:center;">
</div>
<p class="game-link-qrcode-mark" class="work-mark"style="font-size: 12px; text-align: center;"></p>
</div>
<div class="game-window-bg"></div>
<div id="apply-child-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data">
@ -378,7 +357,7 @@
</div>
</block>
<block name="script">
<script src="__STATIC__/zeroclipboard/jquery.zclip.min.js"></script>
<script src="__STATIC__/clipboard.min.js"></script>
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script src="__STATIC__/clipboard.min.js"></script>
<script type="text/javascript" src="__JS__/jquery.qrcode.min.js"></script>
@ -498,6 +477,22 @@
$('.game-window-bg').hide();
});
var clipboard = new ClipboardJS('#clipboard-btn', {
text: function(trigger) {
return trigger.getAttribute('data-text');
}
})
clipboard.on('success', function (e) {
$('#copy_msg').text('复制成功,ctrl+v粘贴即可');
$('#clipboard-btn').hide();
});
clipboard.on('error', function (e) {
$('#copy_msg').text('自动复制失败,请点击复制按钮');
$('#clipboard-btn').show();
});
highlight_subnav('{:U($curUri)}');
})
@ -577,7 +572,7 @@
if (response.status == 1) {
var logo = getGameLogo(obj)
drawQrcode(response.data.url, logo)
showLinkDialog(response.data.url)
showLinkDialog(response.data.url, type)
} else {
layer.alert(response.message, {icon: 7});
}
@ -591,15 +586,13 @@
function isImg(src) {
var img = new Image();
img.src = src;
if (img.width > 0 || img.height > 0) {
return true;
}
return false;
return true;
}
function getGameLogo(obj) {
var logo = null;
var logoSrc = $(obj).parents('.game-li').eq(0).find('.img-box').children('img').attr('src');
console.log(isImg(logoSrc))
if (isImg(logoSrc)) {
logo = $(obj).parents('.game-li').eq(0).find('.img-box').children('img')[0]
} else {
@ -641,18 +634,37 @@
label: 'jQuery.qrcode',
fontname: 'Ubuntu',
fontcolor: '#ff9818',
};
}
$('#game_link_ercode').empty().qrcode(options);
$("#game_link_ercode canvas")[0].getContext('2d').drawImage(logo, (qrcodeWidth - logoWidth) / 2, (qrcodeHeight - logoHeight) / 2, logoWidth, logoHeight);
}
function showLinkDialog(url) {
function showLinkDialog(url, type) {
$('#clipboard-btn').attr('data-text', url)
$('#clipboard-btn').click()
$('#game_link_address').text(url);
var typeName = ''
if (type == 'landing-page') {
typeName = '落地页链接'
} else {
typeName = '下载链接'
}
var box = $('#game-link-box')
$('#game_link_address').text(url)
box.find('.game-link-title').html(typeName + '')
box.find('.game-link-qrcode-mark').html(typeName + '二维码')
layer.open({
title: typeName,
type: 1,
content: box,
area: ['400px', '450px'],
zIndex: 250,
})
/* $('#game_link_address').text(url);
$('#game_link').show();
$('.game-window-bg').show();
$('.game-window-bg').show(); */
}
function batchApplyGame(gameId, promoteIds, successCallback) {
@ -676,13 +688,13 @@
var games = response.data.games;
var html = '<option value="">请选择游戏</option>';
if (games.length > 0) {
$.each(promotes, function (index, item) {
$.each(games, function (index, item) {
var selected = ''
if (curGameId == item.id) {
selected = 'selected'
}
html += '<option value="' + item.id + '" title="' + item.name + '"' + selected + '>';
html += promoteTitle;
html += item.name;
html += '</option>';
});
}

Loading…
Cancel
Save