Authored by Rock Zhang

Merge branch 'feature/wap/yuanxiao' into develop/wap

... ... @@ -24,17 +24,17 @@ class Yohobuy
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
//java API
const API_URL = 'http://apih5.yoho.cn/';
const API_URL2 = 'http://apih5.yoho.cn/';
const SERVICE_URL = 'http://serviceh5.yoho.cn/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://api2.open.yohobuy.com/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
/* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://test2.open.yohobuy.com/';
const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://test2.open.yohobuy.com/';
/* 预览环境 */
// const API_URL = 'http://preapi.yoho.cn/';
... ...
... ... @@ -2,7 +2,6 @@
namespace LibModels\Wap\Cuxiao;
use Api\Sign;
use Api\Yohobuy;
/**
... ... @@ -21,6 +20,8 @@ class ActivityData
const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon';
const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon';
const URI_SEND_MESSAGE = 'inbox/service/v1/inbox';
const URI_YUANXIAO_CHOUQIAN = 'union/ActivityRest/draw';
const URI_YUANXIAO_CHOUQIAN_SHARE = 'union/ActivityRest/getDrawInfo';
/**
* 用户获取某个活动指定的单个优惠券
... ... @@ -70,6 +71,8 @@ class ActivityData
}
/**
* 获取元宵抽签的结果
*
* @param int $uid 用户UID
* @param string $nickName 用户昵称
* @param string $birthday 用户生日
... ... @@ -78,15 +81,29 @@ class ActivityData
*/
public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender)
{
$param = Yohobuy::param();
$param = array();
$param['method'] = 'wap.activity.draw';
$param['uid'] = $uid;
$param['nick_name'] = $nickName;
$param['nickname'] = $nickName;
$param['birthday'] = $birthday;
$param['gender'] = $gender;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN, $param);
}
/**
* 获取分享结果页元宵抽签的结果
*
* @param int $uid 用户UID
* @return mixed 抽签的结果
*/
public static function getYuanxiaoShareInfo($uid)
{
$param = array();
$param['method'] = 'wap.activity.draw';
$param['uid'] = $uid;
return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN_SHARE, $param);
}
/**
... ...
... ... @@ -18,7 +18,7 @@
<div class="title">
生日
</div>
<input type="date" name="birthday" value="{{birthday}}">
<input type="date" name="birthday" value="{{birthday}}" min="1900-01-01" max="2016-01-01">
</div>
<div class="gender">
<div class="title">
... ...
... ... @@ -24,7 +24,7 @@
<script type="text/tmpl" id="M1">
<div class="bg-majia"></div>
<div class="bg-yifei animated slideInUp"></div>
<div class="flyman animated infinite "></div>
<div class="flyman flyIn "></div>
</script>
<script type="text/tmpl" id="M2">
<div class="bg-bamei animated slideInRight"></div>
... ...
... ... @@ -80,4 +80,30 @@ class YuanxiaoModel
return $result;
}
/**
* @param int $uid 用户UID
* @return array|mixed 抽奖的结果
*/
public static function getChoujiangShareInfo($uid)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($uid)) {
break;
}
$chouqian = ActivityData::getYuanxiaoShareInfo($uid);
if (isset($chouqian['data'])) {
$result = array(
'name' => $chouqian['data']['nickname'],
'type' => $chouqian['data']['randomCode'],
'total' => $chouqian['data']['total']
);
}
} while (false);
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -9,8 +9,8 @@ use Plugin\Helpers;
*/
class YuanxiaoController extends HuodongAction
{
// const STATIC_FILE = 'http://localhost:2222/assets/1.0.1';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.0.1';
// const STATIC_FILE = 'http://localhost:2222/assets/1.0.2';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.0.2';
const ENCRYPT_KEY = 'iamgtskkwhoareyou';
/**
... ... @@ -66,11 +66,13 @@ class YuanxiaoController extends HuodongAction
// 调用接口
$result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender);
$result['code'] = 200;
$result['data'] = array('name' => $nickName, 'type' => 'M2');
if ($result['code'] === 200) { // 处理成功就跳转到等待页
// 将返回的结果存入cookeie中15分钟
$this->setCookie('yuanxiaochouqian', json_encode($result['data']), time() + 15*60);
$cookieData = array(
'name' => $nickName,
'type' => $result['data']['randomCode']
);
$this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15*60);
$this->go(Helpers::url('/cuxiao/yuanxiao/wait'));
} else { // 不成功就显示返回的错误信息
$this->_view->display('info', array(
... ... @@ -125,19 +127,18 @@ class YuanxiaoController extends HuodongAction
$this->auditJumpLogin();
$result = $this->getCookie('yuanxiaochouqian', null);
if (empty($result)) { // 未取到信息就重新测试
$this->go(Helpers::url('/cuxiao/yuanxiao/info'));
}
// if (empty($result)) { // 未取到信息就重新测试
// $this->go(Helpers::url('/cuxiao/yuanxiao/info'));
// }
// cookie中存的结果
$result = json_decode($result, true);
$shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array(
'name' => $this->encrypt($result['name']),
'hash' => $this->encrypt($this->getUid())
));
$result['type'] = $this->get('type', 'M2');
$this->_view->display('result', array(
'staticTitle' => '元宵抽签',
'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
'staticFile' => self::STATIC_FILE,
'result' => $result,
'shareUrl' => $shareUrl,
... ... @@ -152,22 +153,23 @@ class YuanxiaoController extends HuodongAction
*/
public function shareAction()
{
// 昵称从url中解析
$name = $this->decrypt($this->get('name', ''));
// 用户UID
$uid = $this->decrypt($this->get('hash', ''));
if (empty($uid)) {
$this->go(Helpers::url('/cuxiao/yuanxiao/index'));
}
// 调用接口获取type和count
$result = array('type' => 'M1', 'count' => 9887);
$result = YuanxiaoModel::getChoujiangShareInfo($uid);
$this->_view->display('share', array(
'staticTitle' => '元宵抽签',
'staticFile' => self::STATIC_FILE,
'result' => array(
'name' => $name,
'name' => $result['name'],
'type' => $result['type']
),
'count' => $result['count'],
'count' => $result['total'],
'staticJS' => array(
'share.js'
)
... ...