Authored by Rock Zhang

Merge branch 'develop/wap' into beta/wap

Conflicts:
	library/Api/Yohobuy.php
@@ -24,11 +24,11 @@ class Yohobuy @@ -24,11 +24,11 @@ class Yohobuy
24 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 24 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
25 25
26 //java API 26 //java API
27 - /*const API_URL = 'http://apih5.yoho.cn/';  
28 - const API_URL2 = 'http://apih5.yoho.cn/';  
29 - const SERVICE_URL = 'http://serviceh5.yoho.cn/';  
30 - const YOHOBUY_URL = 'http://www.yohobuy.com/';  
31 - const API_OLD = 'http://api2.open.yohobuy.com/';*/ 27 +// const API_URL = 'http://apih5.yoho.cn/';
  28 +// const API_URL2 = 'http://apih5.yoho.cn/';
  29 +// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
  30 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  31 +// const API_OLD = 'http://api2.open.yohobuy.com/';
32 32
33 /* 测试环境 */ 33 /* 测试环境 */
34 const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/' 34 const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 namespace LibModels\Wap\Cuxiao; 3 namespace LibModels\Wap\Cuxiao;
4 4
5 -use Api\Sign;  
6 use Api\Yohobuy; 5 use Api\Yohobuy;
7 6
8 /** 7 /**
@@ -21,6 +20,8 @@ class ActivityData @@ -21,6 +20,8 @@ class ActivityData
21 const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon'; 20 const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon';
22 const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon'; 21 const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon';
23 const URI_SEND_MESSAGE = 'inbox/service/v1/inbox'; 22 const URI_SEND_MESSAGE = 'inbox/service/v1/inbox';
  23 + const URI_YUANXIAO_CHOUQIAN = 'union/ActivityRest/draw';
  24 + const URI_YUANXIAO_CHOUQIAN_SHARE = 'union/ActivityRest/getDrawInfo';
24 25
25 /** 26 /**
26 * 用户获取某个活动指定的单个优惠券 27 * 用户获取某个活动指定的单个优惠券
@@ -70,6 +71,8 @@ class ActivityData @@ -70,6 +71,8 @@ class ActivityData
70 } 71 }
71 72
72 /** 73 /**
  74 + * 获取元宵抽签的结果
  75 + *
73 * @param int $uid 用户UID 76 * @param int $uid 用户UID
74 * @param string $nickName 用户昵称 77 * @param string $nickName 用户昵称
75 * @param string $birthday 用户生日 78 * @param string $birthday 用户生日
@@ -78,15 +81,29 @@ class ActivityData @@ -78,15 +81,29 @@ class ActivityData
78 */ 81 */
79 public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender) 82 public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender)
80 { 83 {
81 - $param = Yohobuy::param(); 84 + $param = array();
82 $param['method'] = 'wap.activity.draw'; 85 $param['method'] = 'wap.activity.draw';
83 $param['uid'] = $uid; 86 $param['uid'] = $uid;
84 - $param['nick_name'] = $nickName; 87 + $param['nickname'] = $nickName;
85 $param['birthday'] = $birthday; 88 $param['birthday'] = $birthday;
86 $param['gender'] = $gender; 89 $param['gender'] = $gender;
87 - $param['client_secret'] = Sign::getSign($param);  
88 90
89 - return Yohobuy::get(Yohobuy::API_URL, $param); 91 + return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN, $param);
  92 + }
  93 +
  94 + /**
  95 + * 获取分享结果页元宵抽签的结果
  96 + *
  97 + * @param int $uid 用户UID
  98 + * @return mixed 抽签的结果
  99 + */
  100 + public static function getYuanxiaoShareInfo($uid)
  101 + {
  102 + $param = array();
  103 + $param['method'] = 'wap.activity.draw';
  104 + $param['uid'] = $uid;
  105 +
  106 + return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN_SHARE, $param);
90 } 107 }
91 108
92 /** 109 /**
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <div class="title"> 18 <div class="title">
19 生日 19 生日
20 </div> 20 </div>
21 - <input type="date" name="birthday" value="{{birthday}}"> 21 + <input type="date" name="birthday" value="{{birthday}}" min="1900-01-01" max="2016-01-01">
22 </div> 22 </div>
23 <div class="gender"> 23 <div class="gender">
24 <div class="title"> 24 <div class="title">
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <script type="text/tmpl" id="M1"> 24 <script type="text/tmpl" id="M1">
25 <div class="bg-majia"></div> 25 <div class="bg-majia"></div>
26 <div class="bg-yifei animated slideInUp"></div> 26 <div class="bg-yifei animated slideInUp"></div>
27 - <div class="flyman animated infinite "></div> 27 + <div class="flyman flyIn "></div>
28 </script> 28 </script>
29 <script type="text/tmpl" id="M2"> 29 <script type="text/tmpl" id="M2">
30 <div class="bg-bamei animated slideInRight"></div> 30 <div class="bg-bamei animated slideInRight"></div>
@@ -80,4 +80,30 @@ class YuanxiaoModel @@ -80,4 +80,30 @@ class YuanxiaoModel
80 80
81 return $result; 81 return $result;
82 } 82 }
  83 +
  84 + /**
  85 + * @param int $uid 用户UID
  86 + * @return array|mixed 抽奖的结果
  87 + */
  88 + public static function getChoujiangShareInfo($uid)
  89 + {
  90 + $result = array('code' => 400, 'message' => '出错啦~');
  91 +
  92 + do {
  93 + if (empty($uid)) {
  94 + break;
  95 + }
  96 +
  97 + $chouqian = ActivityData::getYuanxiaoShareInfo($uid);
  98 + if (isset($chouqian['data'])) {
  99 + $result = array(
  100 + 'name' => $chouqian['data']['nickname'],
  101 + 'type' => $chouqian['data']['randomCode'],
  102 + 'total' => $chouqian['data']['total']
  103 + );
  104 + }
  105 + } while (false);
  106 +
  107 + return $result;
  108 + }
83 } 109 }
@@ -9,8 +9,8 @@ use Plugin\Helpers; @@ -9,8 +9,8 @@ use Plugin\Helpers;
9 */ 9 */
10 class YuanxiaoController extends HuodongAction 10 class YuanxiaoController extends HuodongAction
11 { 11 {
12 - // const STATIC_FILE = 'http://localhost:2222/assets/1.0.1';  
13 - const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.0.1'; 12 + // const STATIC_FILE = 'http://localhost:2222/assets/1.0.2';
  13 + const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.0.2';
14 const ENCRYPT_KEY = 'iamgtskkwhoareyou'; 14 const ENCRYPT_KEY = 'iamgtskkwhoareyou';
15 15
16 /** 16 /**
@@ -66,11 +66,13 @@ class YuanxiaoController extends HuodongAction @@ -66,11 +66,13 @@ class YuanxiaoController extends HuodongAction
66 66
67 // 调用接口 67 // 调用接口
68 $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender); 68 $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender);
69 - $result['code'] = 200;  
70 - $result['data'] = array('name' => $nickName, 'type' => 'M2');  
71 if ($result['code'] === 200) { // 处理成功就跳转到等待页 69 if ($result['code'] === 200) { // 处理成功就跳转到等待页
72 // 将返回的结果存入cookeie中15分钟 70 // 将返回的结果存入cookeie中15分钟
73 - $this->setCookie('yuanxiaochouqian', json_encode($result['data']), time() + 15*60); 71 + $cookieData = array(
  72 + 'name' => $nickName,
  73 + 'type' => $result['data']['randomCode']
  74 + );
  75 + $this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15*60);
74 $this->go(Helpers::url('/cuxiao/yuanxiao/wait')); 76 $this->go(Helpers::url('/cuxiao/yuanxiao/wait'));
75 } else { // 不成功就显示返回的错误信息 77 } else { // 不成功就显示返回的错误信息
76 $this->_view->display('info', array( 78 $this->_view->display('info', array(
@@ -125,19 +127,18 @@ class YuanxiaoController extends HuodongAction @@ -125,19 +127,18 @@ class YuanxiaoController extends HuodongAction
125 $this->auditJumpLogin(); 127 $this->auditJumpLogin();
126 128
127 $result = $this->getCookie('yuanxiaochouqian', null); 129 $result = $this->getCookie('yuanxiaochouqian', null);
128 - if (empty($result)) { // 未取到信息就重新测试  
129 - $this->go(Helpers::url('/cuxiao/yuanxiao/info'));  
130 - } 130 + // if (empty($result)) { // 未取到信息就重新测试
  131 + // $this->go(Helpers::url('/cuxiao/yuanxiao/info'));
  132 + // }
131 // cookie中存的结果 133 // cookie中存的结果
132 $result = json_decode($result, true); 134 $result = json_decode($result, true);
133 $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array( 135 $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array(
134 - 'name' => $this->encrypt($result['name']),  
135 'hash' => $this->encrypt($this->getUid()) 136 'hash' => $this->encrypt($this->getUid())
136 )); 137 ));
137 - $result['type'] = $this->get('type', 'M2');  
138 138
139 $this->_view->display('result', array( 139 $this->_view->display('result', array(
140 'staticTitle' => '元宵抽签', 140 'staticTitle' => '元宵抽签',
  141 + 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
141 'staticFile' => self::STATIC_FILE, 142 'staticFile' => self::STATIC_FILE,
142 'result' => $result, 143 'result' => $result,
143 'shareUrl' => $shareUrl, 144 'shareUrl' => $shareUrl,
@@ -152,22 +153,23 @@ class YuanxiaoController extends HuodongAction @@ -152,22 +153,23 @@ class YuanxiaoController extends HuodongAction
152 */ 153 */
153 public function shareAction() 154 public function shareAction()
154 { 155 {
155 - // 昵称从url中解析  
156 - $name = $this->decrypt($this->get('name', ''));  
157 // 用户UID 156 // 用户UID
158 $uid = $this->decrypt($this->get('hash', '')); 157 $uid = $this->decrypt($this->get('hash', ''));
  158 + if (empty($uid)) {
  159 + $this->go(Helpers::url('/cuxiao/yuanxiao/index'));
  160 + }
159 161
160 // 调用接口获取type和count 162 // 调用接口获取type和count
161 - $result = array('type' => 'M1', 'count' => 9887); 163 + $result = YuanxiaoModel::getChoujiangShareInfo($uid);
162 164
163 $this->_view->display('share', array( 165 $this->_view->display('share', array(
164 'staticTitle' => '元宵抽签', 166 'staticTitle' => '元宵抽签',
165 'staticFile' => self::STATIC_FILE, 167 'staticFile' => self::STATIC_FILE,
166 'result' => array( 168 'result' => array(
167 - 'name' => $name, 169 + 'name' => $result['name'],
168 'type' => $result['type'] 170 'type' => $result['type']
169 ), 171 ),
170 - 'count' => $result['count'], 172 + 'count' => $result['total'],
171 'staticJS' => array( 173 'staticJS' => array(
172 'share.js' 174 'share.js'
173 ) 175 )