You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
9.2 KiB
PHTML

5 years ago
<?php
namespace Sdk\Controller;
use Think\Controller;
5 years ago
class GameController extends BaseController{
5 years ago
/**
* 读取游戏客服qq
* @param int $game_id 游戏ID
* @return mixed
* 小纯洁
*/
public function get_game_ccustom_service_qq(){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
$gameModel = new \Admin\Model\GameModel();
$result = $gameModel->get_table_fields("ccustom_service_qq",$request['game_id']);
$qq = empty($result)?"":$result;
if($request['promote_id']!=0){
$res=M('site_base','tab_')->field('site_qq')->where(['promote_id'=>$request['promote_id']])->find();
if($res['site_qq']){
$data = array(
"status"=>200,
"ccustom_service_qq"=>$res['site_qq'],
);
echo base64_encode(json_encode($data));die;
}
}
$data = array(
"status"=>200,
"ccustom_service_qq"=>C(APP_QQ),
);
echo base64_encode(json_encode($data));
}
5 years ago
/**
5 years ago
* 初始化SDK接口
5 years ago
*/
public function init_sdk() {
$data = json_decode(base64_decode(file_get_contents("php://input")), true);
if (I('debug') == 1) {
$data['user_id'] = 1;
$data['sdk_version'] = 2;
}
$contact_cs = M('tool','tab_')->where(['name' => 'contact_cs'])->find();
5 years ago
$contact_cs = json_decode($contact_cs['config'],true);
5 years ago
foreach($contact_cs as $k => &$v) {
$contact_cs[$k]['icon'] = C('ADMIN_DOMAIN') . $contact_cs[$k]['icon'];
//
if (substr($contact_cs[$k]['url'], 0, 7) == "http://" || substr($contact_cs[$k]['url'], 0, 8) == "https://") {
$contact_cs[$k]['url'] = $contact_cs[$k]['url'] . "/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
} else {
$contact_cs[$k]['url'] = C('H5_DOMAIN') . $v['url'] . "/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
}
if ($contact_cs[$k]['type'] == 1) {// 原生
$contact_cs[$k]['ios_url'] = "?action=".$contact_cs[$k]['name'];
} else if ($contact_cs[$k]['type'] == 0) { // H5
$contact_cs[$k]['ios_url'] = $contact_cs[$k]['url']."?action=push";
if ($data['sdk_version'] == 1 && $contact_cs[$k]['name'] == 'suppersign')
unset($contact_cs[$k]);
} else if ($contact_cs[$k]['type'] == 2) { // 外部链接
if (strpos($contact_cs[$k]['ios_url'], "?") === false) {
$gap = "?";
} else {
$gap = "&";
}
$contact_cs[$k]['ios_url'] = $contact_cs[$k]['ios_url']."{$gap}action=openurl";
5 years ago
}
}
array_multisort(array_column($contact_cs,'sort'),SORT_ASC,$menus);
$ret = [
5 years ago
'contact_cs' => $contact_cs[$k],
5 years ago
];
if (I('debug') == 1)
pp(($ret));
re_msg(200,'获取成功',$ret);
}
5 years ago
/**
* 获取渠道悬浮球图
* @param int $game_id 游戏ID
* @return mixed
* 小纯洁
*/
public function get_suspend(){
5 years ago
$data = json_decode(base64_decode(file_get_contents("php://input")), true);
5 years ago
if (I('debug') == 1) {
$data['user_id'] = 1;
5 years ago
$data['sdk_version'] = 2;
5 years ago
}
5 years ago
5 years ago
if(empty($data['user_id'])) {
re_msg(1004, 'fail', '用户不存在');
}
5 years ago
$userToken = M('user','tab_')->where(['id' => $data['user_id']])->getField('user_token');
if (!$userToken) {
5 years ago
re_msg(1004, 'fail', '数据有误');
}
5 years ago
$sdkMenus = M('tool','tab_')->where(['name' => 'sdk_menu'])->find();
$menus = json_decode($sdkMenus['config'],true);
5 years ago
foreach($menus as $k => &$v) {
$menus[$k]['icon'] = C('ADMIN_DOMAIN') . $menus[$k]['icon'];
// die;
if (substr($menus[$k]['url'], 0, 7) == "http://" || substr($menus[$k]['url'], 0, 8) == "https://") {
$menus[$k]['url'] = $menus[$k]['url'] . '/user_token/' . $userToken."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
} else {
$menus[$k]['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $userToken."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
}
//$menus[$k]['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $userToken."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
5 years ago
if ($menus[$k]['type'] == 1) {// 原生
5 years ago
$menus[$k]['ios_url'] = "?action=".$menus[$k]['name'];
5 years ago
} else if ($menus[$k]['type'] == 0) { // H5
$menus[$k]['ios_url'] = $menus[$k]['url']."?action=push";
if ($data['sdk_version'] == 1 && $menus[$k]['name'] == 'suppersign')
5 years ago
unset($menus[$k]);
5 years ago
} else if ($menus[$k]['type'] == 2) { // 外部链接
$menus[$k]['ios_url'] = $menus[$k]['ios_url']."?action=openurl";
5 years ago
}
5 years ago
5 years ago
}
$personalMenu = M('tool','tab_')->where(['name' => 'personal_menu'])->getField('config');
$personalMenu = json_decode($personalMenu, true);
foreach($personalMenu as &$v) {
$v['icon'] = C('ADMIN_DOMAIN') . $v['icon'];
5 years ago
if (substr($v['url'], 7) == "http://" || substr($v['url'], 8) == "https://") {
$v['url'] = $v['url'] . '/user_token/' . $userToken."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
} else {
$v['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $userToken."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
}
5 years ago
if ($v['type'] == 1) {// 原生
5 years ago
$v['ios_url'] = "?action=".$v['name'];
5 years ago
} else if ($menus[$k]['type'] == 0) { // H5
$v['ios_url'] = $v['url']."?action=push";
if ($data['sdk_version'] == 1 && $v['name'] == 'suppersign')
5 years ago
unset($v);
5 years ago
} else if ($menus[$k]['type'] == 2) { // 外部链接
$v['ios_url'] = $v['ios_url']."?action=openurl";
5 years ago
}
5 years ago
5 years ago
}
5 years ago
// 2456623.96
5 years ago
array_multisort(array_column($menus,'sort'),SORT_ASC,$menus);
5 years ago
array_multisort(array_column($personalMenu,'sort'),SORT_ASC,$personalMenu);
5 years ago
$ball_status = M('config','sys_')->where(['name' => 'WAP_SUSPEND_SHWO_STATUS'])->getField('value');
$sites_ball_logo = M('config','sys_')->where(['name' => 'WAP_SUSPEND_ICON'])->getField('value');
5 years ago
$sites_ball_logo = get_cover( $sites_ball_logo ,'path');
if(strpos($sites_ball_logo, 'http')!==false){
$sites_ball_logo = $sites_ball_logo;
}else{
5 years ago
$sites_ball_logo = C('ADMIN_DOMAIN').$sites_ball_logo;
5 years ago
}
5 years ago
$ret = [
'sites_ball_logo' => $sites_ball_logo,
'ball_status' => $ball_status,
'menus' => $menus,
5 years ago
'mine_features' => $personalMenu,
5 years ago
];
5 years ago
if (I('debug') == 1)
pp(($ret));
5 years ago
re_msg(200,'获取成功',$ret);
5 years ago
}
5 years ago
5 years ago
//获取游戏域名
//yyh 2018 10 23
public function get_game_domain(){
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
$game_id = $request['game_id'];
$list = M('Game','tab_')
->field('tab_game.id,login_notify_url')
->where(['tab_game.id'=>$game_id])
->join('tab_game_set on game_id = tab_game.id')
->find();
$login_notify_url = $list['login_notify_url'];
if(empty($login_notify_url)){
$url = $_SERVER['HTTP_HOST'];
}else{
$arr = parse_url($login_notify_url);
$scheme = $arr['scheme']?:'http';
$host = $arr['host'];
$url = $host;
}
$this->new_set_message(200,"成功",['url'=>$url]);
}
//获取sdk分享链接
public function get_sdk_share_url(){
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
$game_id = $request['game_id'];
$user_id = $request['user_id'];
$user_data = M('User','tab_')->field('account')->find($user_id);
if (empty($user_data)) {
$this->new_set_message(1001, "用户数据不存在", []);
}
$param = M('param','tab_')->field('openid,wx_appid,type')->where(['game_id'=>$game_id])->select();
$qqappid = '';
$wxappid = '';
if(is_array($param)) {
foreach($param as $k=>$v) {
if($v['type']==2) {
$wxappid = $v['wx_appid'];
}elseif($v['type']==1) {
$qqappid = $v['openid'];
}
}
}
$logo = get_cover(C('WAP_APP_ICON'),'path');
$pointtype = M('point_type','tab_')->field('title,description')->where(['key'=>'invite_friend'])->find();
$url = 'http://'.$_SERVER['HTTP_HOST'].'/app.php/Share/register/invite_account/'.$user_data['account'].'/game_id/'.$game_id;
$title = $pointtype['title']?$pointtype['title']:'邀请好友注册得奖励';
$content = $pointtype['description']?$pointtype['description']:'邀请好友注册可获得积分奖励,还有机会获得平台币奖励哦~';
$logo = $logo?$logo:'/Uploads/Picture/yaoqing.png';
if(strpos($logo,'http')===false){
$logo = 'http://'.$_SERVER['HTTP_HOST'].$logo;
}
$data = ['url'=>$url,'title'=>$title,'logo'=>$logo,'content'=>$content,'qqAPPid'=>$qqappid,'wxAPPid'=>$wxappid];
$this->new_set_message(200, "success", $data);
}
}