Authored by hf

code review by fei.hong: do test yuanxiao huodong redirect

... ... @@ -17,9 +17,7 @@
</div>
<script type="text/javascript">
setTimeout(function (){
location.href = '{{activityUrl}}';
// location.href = '{{activityUrl}}?openby:yohobuy={"action":"go.h5","params":{"title":"元宵抽签","url":"{{activityUrl}}","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"1"},"param":{"share_id":"1"}}}';
location.href = '{{{activityUrl}}}';
}, 2000);
</script>
{{> cuxiao/yuanxiao/footer}}
... ...
... ... @@ -9,23 +9,11 @@ use Plugin\Helpers;
*/
class YuanxiaoController extends HuodongAction
{
// const STATIC_FILE = 'http://localhost:2222/assets/1.1.4';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.1.4';
// const STATIC_FILE = 'http://localhost:2222/assets/1.1.3';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.1.5';
const ENCRYPT_KEY = 'iamgtskkwhoareyou';
/**
* 通过当前用户审判是否跳到登录页
*
*/
private function auditJumpLogin()
{
$uid = $this->getLoggedUid();
if (!$uid || !is_numeric($uid)) {
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/yuanxiao/info')), 'default'));
}
}
/**
* 元宵抽签
*/
public function indexAction()
... ... @@ -34,12 +22,12 @@ class YuanxiaoController extends HuodongAction
$playUrlEncode = strtr($playUrl, array('/' => '\\/'));
$this->_view->display('index', array(
'staticTitle' => '2016潮流运势测试',
'staticTitle' => '2016潮流运势测试',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'home.js'
),
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/02/19/16/02dbd38c84eccf1097b7e240452f0de856.png',
'shareUrl' => Helpers::url('/cuxiao/yuanxiao/index'),
'playUrl' => $this->isApp() ? $playUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}': $playUrl,
... ... @@ -56,7 +44,8 @@ class YuanxiaoController extends HuodongAction
if (!$this->_isApp) {
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/yuanxiao/info')), 'default'));
} else {
exit();
$playUrl = Helpers::url('/cuxiao/yuanxiao/index');
$this->go($playUrl . '?yohobuy={"action":"go.h5","params":{"islogin":"N","type":0,"url":"' . $playUrl . '","param":{}}}');
}
}
... ... @@ -72,6 +61,7 @@ class YuanxiaoController extends HuodongAction
// 调用接口
$result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $FormatBirthday, $gender);
if ($result['code'] === 200) { // 处理成功就跳转到等待页
// 将返回的结果存入cookeie中15分钟
$cookieData = array(
... ... @@ -79,15 +69,19 @@ class YuanxiaoController extends HuodongAction
'type' => $result['data']['randomCode']
);
$this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15 * 60);
$this->go(Helpers::url('/cuxiao/yuanxiao/wait'));
$waitUrl = Helpers::url('/cuxiao/yuanxiao/wait');
$this->go(!$this->isWeixin() ? $waitUrl . '?openby:yohobuy={"action":"go.h5","params":{"url":"' . $waitUrl . '","islogin":"N","param":{"from":"app"}}}' : $waitUrl);
} else { // 不成功就显示返回的错误信息
$this->_view->display('info', array(
'staticTitle' => '2016潮流运势测试',
'staticTitle' => '2016潮流运势测试',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'info.js'
),
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/02/19/16/02dbd38c84eccf1097b7e240452f0de856.png',
'shareUrl' => Helpers::url('/cuxiao/yuanxiao/index'),
'birthday' => $birthday,
... ... @@ -99,21 +93,14 @@ class YuanxiaoController extends HuodongAction
}
} else {
$userData = YuanxiaoModel::getUserProfileData($uid);
// 接口返回空数据时,设置默认值
if (empty($userData['birthday']) || $userData['birthday'] === '0000-00-00') {
$userData = array(
'birthday' => '1990-01-01',
'gender' => '3',
);
}
$this->_view->display('info', array(
'staticTitle' => '2016潮流运势测试',
'staticTitle' => '2016潮流运势测试',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'info.js'
),
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/02/19/16/02dbd38c84eccf1097b7e240452f0de856.png',
'shareUrl' => Helpers::url('/cuxiao/yuanxiao/index'),
'birthday' => date_format(date_create($userData['birthday']), 'Y年m月d日'),
... ... @@ -129,17 +116,17 @@ class YuanxiaoController extends HuodongAction
*/
public function waitAction()
{
// 审判跳转登录页
// $this->auditJumpLogin();
$activityUrl = Helpers::url('/cuxiao/yuanxiao/result');
$activityUrlEncode = strtr($activityUrl, array('/' => '\\/'));
$this->_view->display('wait', array(
'staticTitle' => '2016潮流运势测试',
'staticTitle' => '2016潮流运势测试',
'staticFile' => self::STATIC_FILE,
'activityUrl' => Helpers::url('/cuxiao/yuanxiao/result'),
'activityUrl' => !$this->isWeixin() ? $activityUrl . '?openby:yohobuy={"action":"go.h5","params":{"url":"' . $activityUrlEncode . '","islogin":"N","param":{"share_id":"19"},"share":"'.$activityUrlEncode.'","shareparam":{"share_id":"19"}}}' : $activityUrl,
'staticJS' => array(
'wait.js'
),
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/02/19/16/02dbd38c84eccf1097b7e240452f0de856.png',
'shareUrl' => Helpers::url('/cuxiao/yuanxiao/index'),
));
... ... @@ -150,9 +137,6 @@ class YuanxiaoController extends HuodongAction
*/
public function resultAction()
{
// 审判跳转登录页
//$this->auditJumpLogin();
$result = $this->getCookie('yuanxiaochouqian', null);
if (empty($result)) { // 未取到信息就重新测试
$this->go(Helpers::url('/cuxiao/yuanxiao/info'));
... ... @@ -162,16 +146,17 @@ class YuanxiaoController extends HuodongAction
$result = json_decode($result, true);
$shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array(
'hash' => $this->encrypt($this->getUid()),
'type' => $this->encrypt($result['type'])
'type' => $this->encrypt($result['type']),
'name' => $this->encrypt($result['name'])
));
$this->_view->display('result', array(
'staticTitle' => '2016潮流运势测试!',
'needShare' => $this->checkNeedShare(), // 是否需要微信分享
'staticTitle' => '2016潮流运势测试',
'needShare' => true, // 是否需要微信分享
'staticFile' => self::STATIC_FILE,
'result' => $result,
'shareTitle' => $result['name'] . '的2016年潮流运势是' . $this->getChouqianTitle($result['type']),
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/02/19/16/02dbd38c84eccf1097b7e240452f0de856.png',
'shareUrl' => $shareUrl,
'staticJS' => array(
... ... @@ -192,22 +177,23 @@ class YuanxiaoController extends HuodongAction
}
// 抽签结果
$type = $this->decrypt($this->get('type', ''));
$name = $this->decrypt($this->get('name', ''));
// 调用接口获取type和count
$result = YuanxiaoModel::getChoujiangShareInfo($uid);
$this->_view->display('share', array(
'staticTitle' => '2016潮流运势测试',
'staticTitle' => '2016潮流运势测试',
'staticFile' => self::STATIC_FILE,
'result' => array(
'name' => $result['name'],
'name' => $name ?: $result['name'],
'type' => $type ?: $result['type']
),
'count' => $result['total'],
'staticJS' => array(
'share.js'
),
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareDesc' => '元宵快乐!一起来YOHO!BUY有货玩2016年潮流开运测试!',
'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/02/19/16/02dbd38c84eccf1097b7e240452f0de856.png'
));
}
... ... @@ -268,7 +254,16 @@ class YuanxiaoController extends HuodongAction
*/
private function checkNeedShare()
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false || $this->_isApp) {
// Android
if ($this->_isApp) {
return true;
}
// IPhone
elseif (null !== $this->get('openby:yohobuy', null)) {
return true;
}
// 微信
elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
return true;
}
... ... @@ -276,6 +271,14 @@ class YuanxiaoController extends HuodongAction
}
/**
* 判断是否是微信访问
*/
private function isWeixin()
{
return (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false);
}
/**
* 加密字符串
*
* @param string $data 需要加密的字符串
... ...