Merge branch 'develop/wap' of http://git.dev.yoho.cn/web/yohobuy into develop/wap
Showing
15 changed files
with
662 additions
and
36 deletions
@@ -42,6 +42,13 @@ class HuodongAction extends Controller_Abstract | @@ -42,6 +42,13 @@ class HuodongAction extends Controller_Abstract | ||
42 | protected $_data; | 42 | protected $_data; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | + * 是否是应用访问标志位 | ||
46 | + * | ||
47 | + * @var boolean | ||
48 | + */ | ||
49 | + protected $_isApp; | ||
50 | + | ||
51 | + /** | ||
45 | * 初始化 | 52 | * 初始化 |
46 | */ | 53 | */ |
47 | public function init() | 54 | public function init() |
@@ -58,6 +65,9 @@ class HuodongAction extends Controller_Abstract | @@ -58,6 +65,9 @@ class HuodongAction extends Controller_Abstract | ||
58 | if (isset($config->css->url)) { | 65 | if (isset($config->css->url)) { |
59 | $this->_view->assign('imgUrl', $config->img->url); | 66 | $this->_view->assign('imgUrl', $config->img->url); |
60 | } | 67 | } |
68 | + | ||
69 | + // 判断是否是应用访问, 拼接APP需要的URL参数 | ||
70 | + $this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid')); | ||
61 | } | 71 | } |
62 | 72 | ||
63 | /** | 73 | /** |
@@ -196,7 +206,7 @@ class HuodongAction extends Controller_Abstract | @@ -196,7 +206,7 @@ class HuodongAction extends Controller_Abstract | ||
196 | * @param string $name cookie的名字 | 206 | * @param string $name cookie的名字 |
197 | * @param string $value cookie的值 | 207 | * @param string $value cookie的值 |
198 | * @param integer $expire cookie过期时间 | 208 | * @param integer $expire cookie过期时间 |
199 | - * @param integer $path cookie可用的路径 | 209 | + * @param string $path cookie可用的路径 |
200 | * @param string $domain cookie可用域名 | 210 | * @param string $domain cookie可用域名 |
201 | */ | 211 | */ |
202 | protected function setCookie($name, $value, $expire = 0, $path = '/', $domain = '.yohobuy.com') | 212 | protected function setCookie($name, $value, $expire = 0, $path = '/', $domain = '.yohobuy.com') |
@@ -24,17 +24,17 @@ class Yohobuy | @@ -24,17 +24,17 @@ 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/' | ||
35 | -// const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; | ||
36 | -// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
37 | -// const API_OLD = 'http://test2.open.yohobuy.com/'; | 34 | + const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/' |
35 | + const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; | ||
36 | + const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
37 | + const API_OLD = 'http://test2.open.yohobuy.com/'; | ||
38 | 38 | ||
39 | /* 预览环境 */ | 39 | /* 预览环境 */ |
40 | // const API_URL = 'http://preapi.yoho.cn/'; | 40 | // const API_URL = 'http://preapi.yoho.cn/'; |
@@ -20,6 +20,8 @@ class ActivityData | @@ -20,6 +20,8 @@ class ActivityData | ||
20 | const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon'; | 20 | const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon'; |
21 | const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon'; | 21 | const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon'; |
22 | 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'; | ||
23 | 25 | ||
24 | /** | 26 | /** |
25 | * 用户获取某个活动指定的单个优惠券 | 27 | * 用户获取某个活动指定的单个优惠券 |
@@ -69,9 +71,51 @@ class ActivityData | @@ -69,9 +71,51 @@ class ActivityData | ||
69 | } | 71 | } |
70 | 72 | ||
71 | /** | 73 | /** |
74 | + * 获取元宵抽签的结果 | ||
75 | + * | ||
76 | + * @param int $uid 用户UID | ||
77 | + * @param string $nickName 用户昵称 | ||
78 | + * @param string $birthday 用户生日 | ||
79 | + * @param int $gender 用户性别 | ||
80 | + * @return mixed 抽签的结果 | ||
81 | + */ | ||
82 | + public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender) | ||
83 | + { | ||
84 | + $param = array(); | ||
85 | + $param['method'] = 'wap.activity.draw'; | ||
86 | + $param['uid'] = $uid; | ||
87 | + $param['nickname'] = $nickName; | ||
88 | + $param['birthday'] = $birthday; | ||
89 | + $param['gender'] = $gender; | ||
90 | + | ||
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); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
72 | * 发送站内信 | 110 | * 发送站内信 |
73 | - * | ||
74 | - * @param int $activityId 活动ID | 111 | + * |
112 | + * @param int $uid | ||
113 | + * @param string $title | ||
114 | + * @param int $content | ||
115 | + * @param int $type | ||
116 | + * @param string $verify_key | ||
117 | + * @param int $send_uid | ||
118 | + * @param string $call_back | ||
75 | * @return array | 119 | * @return array |
76 | */ | 120 | */ |
77 | public static function message($uid, $title, $content, $type = 1, $verify_key = '', $send_uid = 0, $call_back = '') | 121 | public static function message($uid, $title, $content, $type = 1, $verify_key = '', $send_uid = 0, $call_back = '') |
@@ -21,7 +21,6 @@ class UserData | @@ -21,7 +21,6 @@ class UserData | ||
21 | * 个人详情数据 | 21 | * 个人详情数据 |
22 | * | 22 | * |
23 | * @param int $uid 用户ID | 23 | * @param int $uid 用户ID |
24 | - * @param int $udid 客户端唯一标识 | ||
25 | * @return array 个人详情接口返回的数据 | 24 | * @return array 个人详情接口返回的数据 |
26 | */ | 25 | */ |
27 | public static function userData($uid) | 26 | public static function userData($uid) |
1 | -<!DOCTYPE html> | ||
2 | -<html> | ||
3 | -<head> | ||
4 | - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
5 | - <meta charset="utf-8"> | ||
6 | - <title>{{staticTitle}}</title> | ||
7 | - <!-- <meta name="apple-mobile-web-app-title" content="SUMMER SALE"> --> | ||
8 | - <meta name="format-detection" content="telephone=no"> | ||
9 | - <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui"> | ||
10 | - <meta name="apple-mobile-web-app-capable" content="yes"> | ||
11 | - <meta name="apple-mobile-web-app-status-bar-style" content="grey"> | ||
12 | - <script> | ||
13 | - (function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="80px"}else{e.style.fontSize=80*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window); | ||
14 | - </script> | ||
15 | -</head> | ||
16 | -<body> | ||
17 | - <div class="main-wrap"> | ||
18 | - 元宵节抽签 | 1 | +{{> cuxiao/yuanxiao/header}} |
2 | + <div class="main-wrap home"> | ||
3 | + <div class="header"></div> | ||
4 | + <div class="people"> | ||
5 | + <div class="flower flower-l"></div> | ||
6 | + <div class="flower flower-r"></div> | ||
7 | + </div> | ||
8 | + <a class="start" href="/cuxiao/yuanxiao/info"></a> | ||
9 | + <div class="footer"> | ||
10 | + <a class="arrow animated infinite pulse" href="/cuxiao/yuanxiao/info"></a> | ||
11 | + <div class="yohobuy"></div> | ||
12 | + </div> | ||
19 | </div> | 13 | </div> |
20 | -</body> | 14 | +{{> cuxiao/yuanxiao/footer}} |
1 | +{{> cuxiao/yuanxiao/header}} | ||
2 | + <div class="main-wrap info"> | ||
3 | + <div class="header"> | ||
4 | + <span class="title chao">潮</span> | ||
5 | + <span class="title liu">流</span> | ||
6 | + | ||
7 | + <div class="sub-title"> 开运测试</div> | ||
8 | + </div> | ||
9 | + | ||
10 | + <form class="user" method="POST"> | ||
11 | + <div class="user-info nick"> | ||
12 | + <div class="title"> | ||
13 | + 昵称 | ||
14 | + </div> | ||
15 | + <input type="text" name="nick" placeholder="请输入您帅气的名字!" value="" maxlength="5"> | ||
16 | + </div> | ||
17 | + <div class="user-info birthday"> | ||
18 | + <div class="title"> | ||
19 | + 生日 | ||
20 | + </div> | ||
21 | + <input type="date" name="birthday" value="{{birthday}}" min="1900-01-01" max="2016-01-01"> | ||
22 | + </div> | ||
23 | + <div class="gender"> | ||
24 | + <div class="title"> | ||
25 | + 性<br>别 | ||
26 | + </div> | ||
27 | + <div class="icon boy"> | ||
28 | + <span class="check {{#if gender}}checked{{/if}}" data-gender="{{#if gender}}1{{/if}}"></span> | ||
29 | + </div> | ||
30 | + <div class="icon girl"> | ||
31 | + <span class="check {{#unless gender}}checked{{/if}}" data-gender="{{#if gender}}2{{/if}}"></span> | ||
32 | + </div> | ||
33 | + <input type="hidden" name="gender" id="gender" value="{{gender}}"> | ||
34 | + </div> | ||
35 | + </form> | ||
36 | + | ||
37 | + <div class="footer"> | ||
38 | + <div class="submit"> | ||
39 | + 开始测试 | ||
40 | + </div> | ||
41 | + </div> | ||
42 | + | ||
43 | + <div class="mask hide"> | ||
44 | + <div class="modal"> | ||
45 | + <div class="icon close"></div> | ||
46 | + <div class="text"> | ||
47 | + 你还没有<br>完善信息哦 | ||
48 | + </div> | ||
49 | + <div class="btn close"> | ||
50 | + 现在就完善 | ||
51 | + </div> | ||
52 | + </div> | ||
53 | + </div> | ||
54 | + </div> | ||
55 | +{{> cuxiao/yuanxiao/footer}} |
1 | +{{> cuxiao/yuanxiao/header}} | ||
2 | + <div class="main-wrap result"> | ||
3 | + <div class="flower flower-l"></div> | ||
4 | + <div class="flower flower-r"></div> | ||
5 | + | ||
6 | + <div class="title"> | ||
7 | + <p> | ||
8 | + {{result.name}} | ||
9 | + </p> | ||
10 | + 2016年的潮流运势是 | ||
11 | + </div> | ||
12 | + | ||
13 | + <div class="hr"> | ||
14 | + </div> | ||
15 | + | ||
16 | + <div class="type {{result.type}}" data-type="{{result.type}}"> | ||
17 | + | ||
18 | + </div> | ||
19 | + | ||
20 | + <div class="footer"> | ||
21 | + <div class="share"> | ||
22 | + 分享2016年潮流运势 | ||
23 | + </div> | ||
24 | + </div> | ||
25 | + </div> | ||
26 | +{{> cuxiao/yuanxiao/type}} | ||
27 | +{{> cuxiao/yuanxiao/footer}} |
1 | +{{> cuxiao/yuanxiao/header}} | ||
2 | + <div class="main-wrap share"> | ||
3 | + <div class="header"></div> | ||
4 | + <div class="flower flower-l"></div> | ||
5 | + <div class="flower flower-r"></div> | ||
6 | + | ||
7 | + <div class="title"> | ||
8 | + <p> | ||
9 | + {{result.name}} | ||
10 | + </p> | ||
11 | + 2016年的潮流运势是 | ||
12 | + </div> | ||
13 | + | ||
14 | + <div class="type {{result.type}}" data-type="{{result.type}}"> | ||
15 | + | ||
16 | + </div> | ||
17 | + | ||
18 | + <div class="count"> | ||
19 | + 已有{{count}}人参与 | ||
20 | + </div> | ||
21 | + | ||
22 | + <div class="footer"> | ||
23 | + <a class="entry" href="/cuxiao/yuanxiao/index"> | ||
24 | + 我也要测 | ||
25 | + </a> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | +{{> cuxiao/yuanxiao/type}} | ||
29 | +{{> cuxiao/yuanxiao/footer}} |
1 | +{{> cuxiao/yuanxiao/header}} | ||
2 | + <div class="main-wrap wait"> | ||
3 | + <div class="flower flower-l"></div> | ||
4 | + <div class="flower flower-r"></div> | ||
5 | + | ||
6 | + <div class="tip"> | ||
7 | + 正在分析你的<br>潮流运势<br>… … | ||
8 | + </div> | ||
9 | + | ||
10 | + <div class="loading animated infinite rotateIn"> | ||
11 | + </div> | ||
12 | + <div class="hat"> | ||
13 | + </div> | ||
14 | + | ||
15 | + <div class="footer"> | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + <script type="text/javascript"> | ||
19 | + setTimeout(function (){ | ||
20 | + location.href = "/cuxiao/yuanxiao/result"; | ||
21 | + }, 2000); | ||
22 | + </script> | ||
23 | +{{> cuxiao/yuanxiao/footer}} |
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | +<head> | ||
4 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
5 | + <meta charset="utf-8"> | ||
6 | + <title>{{staticTitle}}</title> | ||
7 | + <!-- <meta name="apple-mobile-web-app-title" content="SUMMER SALE"> --> | ||
8 | + <meta name="format-detection" content="telephone=no"> | ||
9 | + <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui"> | ||
10 | + <meta name="apple-mobile-web-app-capable" content="yes"> | ||
11 | + <meta name="apple-mobile-web-app-status-bar-style" content="grey"> | ||
12 | + <script type="text/javascript"> | ||
13 | + (function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window); | ||
14 | + </script> | ||
15 | + <link rel="stylesheet" href="{{staticFile}}/css/style.css"> | ||
16 | +</head> | ||
17 | +<body> |
1 | +<script type="text/tmpl" id="P1"> | ||
2 | + <div class="bg-guang"></div> | ||
3 | + <div class="bg-yuan"></div> | ||
4 | + <div class="title">成为一个大写加粗的</div> | ||
5 | + <div class="chaoren animated infinite pulse"></div> | ||
6 | +</script> | ||
7 | +<script type="text/tmpl" id="P2"> | ||
8 | + <div class="bg-bige animated zoomIn"></div> | ||
9 | + <div class="bg-manzai animated zoomIn"></div> | ||
10 | + <div class="bg-ren"></div> | ||
11 | + <div class="title animated infinite pulse"></div> | ||
12 | + <div class="yzbb animated slideInDown"></div> | ||
13 | +</script> | ||
14 | +<script type="text/tmpl" id="P3"> | ||
15 | + <div class="bg-yunqi animated zoomIn"></div> | ||
16 | + <div class="shoes animated infinite swing"></div> | ||
17 | + <div class="yeezy animated slideInDown"></div> | ||
18 | +</script> | ||
19 | +<script type="text/tmpl" id="P4"> | ||
20 | + <div class="bg-car"></div> | ||
21 | + <div class="hands animated infinite swing"></div> | ||
22 | + <div class="wanghong animated slideInRight"></div> | ||
23 | +</script> | ||
24 | +<script type="text/tmpl" id="M1"> | ||
25 | + <div class="bg-majia"></div> | ||
26 | + <div class="bg-yifei animated slideInUp"></div> | ||
27 | + <div class="flyman flyIn "></div> | ||
28 | +</script> | ||
29 | +<script type="text/tmpl" id="M2"> | ||
30 | + <div class="bg-bamei animated slideInRight"></div> | ||
31 | + <div class="meizi animated infinite swing"></div> | ||
32 | + <div class="shoes"></div> | ||
33 | +</script> | ||
34 | +<script type="text/tmpl" id="M3"> | ||
35 | + <div class="bg-cloud1 animated slideInRight"></div> | ||
36 | + <div class="bg-chuanzhe animated slideInLeft"></div> | ||
37 | + <div class="shan"></div> | ||
38 | + <div class="rensheng"></div> | ||
39 | + <div class="cloud2 animated slideInRight"></div> | ||
40 | + <div class="shoes animated infinite swing"></div> | ||
41 | +</script> | ||
42 | +<script type="text/tmpl" id="M4"> | ||
43 | + <div class="bg-guang"></div> | ||
44 | + <div class="bg-jin1 animated slideInright"></div> | ||
45 | + <div class="ren"></div> | ||
46 | + <div class="jin2 animated slideInDown"></div> | ||
47 | + <div class="jin3 animated slideInDown"></div> | ||
48 | + <div class="shuaiqi animated slideInDown"></div> | ||
49 | +</script> | ||
50 | +<script type="text/tmpl" id="F1"> | ||
51 | + <div class="bg-hezi1 animated slideInLeft"></div> | ||
52 | + <div class="bg-hezi2 animated slideInDown"></div> | ||
53 | + <div class="bg-hezi3 animated slideInRight"></div> | ||
54 | + <div class="sun animated infinite zoomIn"></div> | ||
55 | + <div class="kuaidi animated slideInDown"></div> | ||
56 | +</script> | ||
57 | +<script type="text/tmpl" id="F2"> | ||
58 | + <div class="bg-love1 animated infinite zoomIn"></div> | ||
59 | + <div class="bg-love2"></div> | ||
60 | + <div class="boy animated slideInRight"></div> | ||
61 | + <div class="girl animated slideInLeft"></div> | ||
62 | + <div class="bidong animated slideInRight"></div> | ||
63 | +</script> | ||
64 | +<script type="text/tmpl" id="F3"> | ||
65 | + <div class="bg-bra animated infinite pulse"></div> | ||
66 | + <div class="xiongda animated zoomIn"></div> | ||
67 | +</script> | ||
68 | +<script type="text/tmpl" id="F4"> | ||
69 | + <div class="bg-guang animated infinite zoomIn"></div> | ||
70 | + <div class="bg-shoes1 animated slideInLeft"></div> | ||
71 | + <div class="bg-shoes2 animated slideInRight"></div> | ||
72 | + <div class="bg-shoes3 animated slideInDown"></div> | ||
73 | + <div class="style animated slideInUp"></div> | ||
74 | +</script> |
1 | +<?php | ||
2 | + | ||
3 | +namespace Cuxiao; | ||
4 | +use LibModels\Wap\Cuxiao\ActivityData; | ||
5 | +use LibModels\Wap\Home\UserData; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by PhpStorm. | ||
9 | + * User: Gtskk | ||
10 | + * Date: 2016/2/18 | ||
11 | + * Time: 16:26 | ||
12 | + * | ||
13 | + * @name YuanxiaoModel | ||
14 | + * @package models/Cuxiao | ||
15 | + * @author Gtskk(tttt6399998@126.com) | ||
16 | + */ | ||
17 | +class YuanxiaoModel | ||
18 | +{ | ||
19 | + /** | ||
20 | + * 处理用户详情数据 | ||
21 | + * | ||
22 | + * @param int $uid 用户ID | ||
23 | + * @return array|mixed 处理之后的个人详情数据 | ||
24 | + */ | ||
25 | + public static function getUserProfileData($uid) | ||
26 | + { | ||
27 | + $result = array( | ||
28 | + 'birthday' => '2000-01-01', | ||
29 | + 'gender' => 2 | ||
30 | + ); | ||
31 | + | ||
32 | + // 调用接口获取个人详情 | ||
33 | + $userData = UserData::userData($uid); | ||
34 | + | ||
35 | + // 处理个人详情数 | ||
36 | + if (isset($userData['data']) && !empty($userData['data'])) { | ||
37 | + $result['birthday'] = $userData['data']['birthday'] ?: '2000-01-01'; | ||
38 | + $result['gender'] = $userData['data']['gender'] == 1 ? '男' : '女'; | ||
39 | + } | ||
40 | + | ||
41 | + return $result; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * @param int $uid 用户UID | ||
46 | + * @param sring $nickName 用户昵称 | ||
47 | + * @param string $birthday 用户生日 | ||
48 | + * @param int $gender 用户性别 | ||
49 | + * @return array 处理之后抽签的结果 | ||
50 | + */ | ||
51 | + public static function getChouqianInfo($uid, $nickName, $birthday, $gender) | ||
52 | + { | ||
53 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
54 | + | ||
55 | + do { | ||
56 | + if (empty($uid)) { | ||
57 | + break; | ||
58 | + } | ||
59 | + | ||
60 | + if (empty($nickName)) { | ||
61 | + $result['message'] = '昵称不能为空'; | ||
62 | + break; | ||
63 | + } | ||
64 | + | ||
65 | + if (empty($birthday)) { | ||
66 | + $result['message'] = '生日不能为空'; | ||
67 | + break; | ||
68 | + } | ||
69 | + | ||
70 | + if (empty($gender)) { | ||
71 | + $result['message'] = '性别不能为空'; | ||
72 | + break; | ||
73 | + } | ||
74 | + | ||
75 | + $chouqian = ActivityData::getYuanxiaoInfo($uid, $nickName, $birthday, $gender); | ||
76 | + if ($chouqian) { | ||
77 | + $result = $chouqian; | ||
78 | + } | ||
79 | + } while (false); | ||
80 | + | ||
81 | + return $result; | ||
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 | + } | ||
109 | +} |
@@ -11,7 +11,7 @@ use LibModels\Wap\Cuxiao\ActivityData; | @@ -11,7 +11,7 @@ use LibModels\Wap\Cuxiao\ActivityData; | ||
11 | class ChristmasController extends HuodongAction | 11 | class ChristmasController extends HuodongAction |
12 | { | 12 | { |
13 | 13 | ||
14 | - private $_isApp = false; | 14 | +// private $_isApp = false; |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * 备注:2015年12月11号上线 | 17 | * 备注:2015年12月11号上线 |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\HuodongAction; | 3 | use Action\HuodongAction; |
4 | +use Cuxiao\YuanxiaoModel; | ||
4 | use Plugin\Helpers; | 5 | use Plugin\Helpers; |
5 | -use LibModels\Wap\Cuxiao\ActivityData; | ||
6 | -use Api\Yohobuy; | ||
7 | 6 | ||
8 | /** | 7 | /** |
9 | * 元宵抽签活动 | 8 | * 元宵抽签活动 |
10 | */ | 9 | */ |
11 | class YuanxiaoController extends HuodongAction | 10 | class YuanxiaoController extends HuodongAction |
12 | { | 11 | { |
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'; | ||
15 | + | ||
16 | + /** | ||
17 | + * 通过当前用户审判是否跳到登录页 | ||
18 | + * | ||
19 | + */ | ||
20 | + private function auditJumpLogin() | ||
21 | + { | ||
22 | + $uid = $this->getLoggedUid(); | ||
23 | + if (!$uid || !is_numeric($uid)) { | ||
24 | + $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/yuanxiao/info')), 'default')); | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
13 | /** | 28 | /** |
14 | * 元宵抽签 | 29 | * 元宵抽签 |
15 | */ | 30 | */ |
16 | public function indexAction() | 31 | public function indexAction() |
17 | { | 32 | { |
33 | + // 该变量用来控制和显示页面的弹出提示 | ||
34 | + $showPopupFlag = '0'; | ||
35 | + | ||
18 | $this->_view->display('index', array( | 36 | $this->_view->display('index', array( |
19 | - 'staticTitle' => '元宵抽签' | 37 | + 'staticTitle' => '元宵抽签', |
38 | + 'staticFile' => self::STATIC_FILE, | ||
39 | + 'staticJS' => array( | ||
40 | + 'home.js' | ||
41 | + ), | ||
42 | + 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享 | ||
43 | + 'shareLink' => 'http://feature.yoho.cn/2016lishifeng/index.html', | ||
44 | + 'shareTitle' => 'YOHO!BUY有货新年寻宝大作战,千元利是等你赢!', | ||
45 | + 'shareDesc' => 'YOHO!BUY有货,全球800+潮流品牌每日上新!', | ||
46 | + 'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/12/30/12/02008a9724b898dee56852de9f1a3978bf.jpg', | ||
47 | + 'showPopupFlag' => $showPopupFlag, | ||
48 | + )); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * 元宵抽签 信息 | ||
53 | + */ | ||
54 | + public function infoAction() | ||
55 | + { | ||
56 | + // 审判跳转登录页 | ||
57 | + $this->auditJumpLogin(); | ||
58 | + | ||
59 | + $uid = $this->getUid(); | ||
60 | + // POST提交请求 | ||
61 | + $posts = $this->post(); | ||
62 | + if (!empty($posts)) { | ||
63 | + $nickName = $this->post('nick', ''); | ||
64 | + $birthday = $this->post('birthday', ''); | ||
65 | + $gender = $this->post('gender', 0); | ||
66 | + | ||
67 | + // 调用接口 | ||
68 | + $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender); | ||
69 | + if ($result['code'] === 200) { // 处理成功就跳转到等待页 | ||
70 | + // 将返回的结果存入cookeie中15分钟 | ||
71 | + $cookieData = array( | ||
72 | + 'name' => $nickName, | ||
73 | + 'type' => $result['data']['randomCode'] | ||
74 | + ); | ||
75 | + $this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15*60); | ||
76 | + $this->go(Helpers::url('/cuxiao/yuanxiao/wait')); | ||
77 | + } else { // 不成功就显示返回的错误信息 | ||
78 | + $this->_view->display('info', array( | ||
79 | + 'staticTitle' => '元宵抽签', | ||
80 | + 'staticFile' => self::STATIC_FILE, | ||
81 | + 'staticJS' => array( | ||
82 | + 'info.js' | ||
83 | + ), | ||
84 | + 'birthday' => $birthday, | ||
85 | + 'gender' => $gender, | ||
86 | + 'message' => $result['message'] | ||
87 | + )); | ||
88 | + } | ||
89 | + } else { | ||
90 | + $userData = YuanxiaoModel::getUserProfileData($uid); | ||
91 | + | ||
92 | + $this->_view->display('info', array( | ||
93 | + 'staticTitle' => '元宵抽签', | ||
94 | + 'staticFile' => self::STATIC_FILE, | ||
95 | + 'staticJS' => array( | ||
96 | + 'info.js' | ||
97 | + ), | ||
98 | + 'birthday' => $userData['birthday'], | ||
99 | + 'gender' => $userData['gender'], | ||
100 | + )); | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * 元宵抽签 等待 | ||
106 | + */ | ||
107 | + public function waitAction() | ||
108 | + { | ||
109 | + // 审判跳转登录页 | ||
110 | + $this->auditJumpLogin(); | ||
111 | + | ||
112 | + $this->_view->display('wait', array( | ||
113 | + 'staticTitle' => '元宵抽签', | ||
114 | + 'staticFile' => self::STATIC_FILE, | ||
115 | + 'staticJS' => array( | ||
116 | + 'wait.js' | ||
117 | + ), | ||
118 | + )); | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * 元宵抽签 结果 | ||
123 | + */ | ||
124 | + public function resultAction() | ||
125 | + { | ||
126 | + // 审判跳转登录页 | ||
127 | + $this->auditJumpLogin(); | ||
128 | + | ||
129 | + $result = $this->getCookie('yuanxiaochouqian', null); | ||
130 | + // if (empty($result)) { // 未取到信息就重新测试 | ||
131 | + // $this->go(Helpers::url('/cuxiao/yuanxiao/info')); | ||
132 | + // } | ||
133 | + // cookie中存的结果 | ||
134 | + $result = json_decode($result, true); | ||
135 | + $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array( | ||
136 | + 'hash' => $this->encrypt($this->getUid()) | ||
137 | + )); | ||
138 | + | ||
139 | + $this->_view->display('result', array( | ||
140 | + 'staticTitle' => '元宵抽签', | ||
141 | + 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享 | ||
142 | + 'staticFile' => self::STATIC_FILE, | ||
143 | + 'result' => $result, | ||
144 | + 'shareUrl' => $shareUrl, | ||
145 | + 'staticJS' => array( | ||
146 | + 'result.js' | ||
147 | + ) | ||
20 | )); | 148 | )); |
21 | } | 149 | } |
150 | + | ||
151 | + /** | ||
152 | + * 元宵抽签 分享 | ||
153 | + */ | ||
154 | + public function shareAction() | ||
155 | + { | ||
156 | + // 用户UID | ||
157 | + $uid = $this->decrypt($this->get('hash', '')); | ||
158 | + if (empty($uid)) { | ||
159 | + $this->go(Helpers::url('/cuxiao/yuanxiao/index')); | ||
160 | + } | ||
161 | + | ||
162 | + // 调用接口获取type和count | ||
163 | + $result = YuanxiaoModel::getChoujiangShareInfo($uid); | ||
164 | + | ||
165 | + $this->_view->display('share', array( | ||
166 | + 'staticTitle' => '元宵抽签', | ||
167 | + 'staticFile' => self::STATIC_FILE, | ||
168 | + 'result' => array( | ||
169 | + 'name' => $result['name'], | ||
170 | + 'type' => $result['type'] | ||
171 | + ), | ||
172 | + 'count' => $result['total'], | ||
173 | + 'staticJS' => array( | ||
174 | + 'share.js' | ||
175 | + ) | ||
176 | + )); | ||
177 | + } | ||
178 | + | ||
179 | + /** | ||
180 | + * 检测登录状态 | ||
181 | + * | ||
182 | + * @return int | ||
183 | + */ | ||
184 | + private function getLoggedUid() | ||
185 | + { | ||
186 | + if ($this->_isApp) { | ||
187 | + $uid = $this->get('uid'); | ||
188 | + } else { | ||
189 | + $uid = $this->getUid(); | ||
190 | + } | ||
191 | + | ||
192 | + return $uid; | ||
193 | + } | ||
194 | + | ||
195 | + /** | ||
196 | + * 加密字符串 | ||
197 | + * | ||
198 | + * @param string $data 需要加密的字符串 | ||
199 | + * @return string 加密之后的字符串 | ||
200 | + */ | ||
201 | + private function encrypt($data) | ||
202 | + { | ||
203 | + $data = strval($data); | ||
204 | + $key = md5(self::ENCRYPT_KEY); | ||
205 | + $x = 0; | ||
206 | + $len = strlen($data); | ||
207 | + $l = strlen($key); | ||
208 | + $char = ''; | ||
209 | + $str = ''; | ||
210 | + | ||
211 | + for ($i = 0; $i < $len; $i++) { | ||
212 | + if ($x == $l) | ||
213 | + { | ||
214 | + $x = 0; | ||
215 | + } | ||
216 | + $char .= $key{$x}; | ||
217 | + $x++; | ||
218 | + } | ||
219 | + | ||
220 | + for ($i = 0; $i < $len; $i++) { | ||
221 | + $str .= chr(ord($data{$i}) + (ord($char{$i})) % 256); | ||
222 | + } | ||
223 | + | ||
224 | + return base64_encode($str); | ||
225 | + } | ||
226 | + | ||
227 | + /** | ||
228 | + * 解密字符串 | ||
229 | + * | ||
230 | + * @param string $data 需要解密的字符串 | ||
231 | + * @return string 解密之后的字符串 | ||
232 | + */ | ||
233 | + private function decrypt($data) | ||
234 | + { | ||
235 | + $key = md5(self::ENCRYPT_KEY); | ||
236 | + $x = 0; | ||
237 | + $data = base64_decode($data); | ||
238 | + $len = strlen($data); | ||
239 | + $l = strlen($key); | ||
240 | + $char = ''; | ||
241 | + $str = ''; | ||
242 | + | ||
243 | + for ($i = 0; $i < $len; $i++) { | ||
244 | + if ($x == $l) | ||
245 | + { | ||
246 | + $x = 0; | ||
247 | + } | ||
248 | + $char .= substr($key, $x, 1); | ||
249 | + $x++; | ||
250 | + } | ||
251 | + | ||
252 | + for ($i = 0; $i < $len; $i++) { | ||
253 | + if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) { | ||
254 | + $str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1))); | ||
255 | + } else { | ||
256 | + $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1))); | ||
257 | + } | ||
258 | + } | ||
259 | + | ||
260 | + return $str; | ||
261 | + } | ||
22 | } | 262 | } |
-
Please register or login to post a comment