Merge branch 'feature/wap4.3' of http://git.dev.yoho.cn/web/yohobuy into feature/wap4.3
Showing
9 changed files
with
154 additions
and
7 deletions
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | namespace LibModels\Wap\Cuxiao; | 3 | namespace LibModels\Wap\Cuxiao; |
4 | 4 | ||
5 | +use Api\Sign; | ||
5 | use Api\Yohobuy; | 6 | use Api\Yohobuy; |
6 | 7 | ||
7 | /** | 8 | /** |
@@ -127,4 +128,22 @@ class ActivityData | @@ -127,4 +128,22 @@ class ActivityData | ||
127 | )); | 128 | )); |
128 | } | 129 | } |
129 | 130 | ||
131 | + /** | ||
132 | + * 发放优惠券 | ||
133 | + * | ||
134 | + * @param int $uid 用户ID | ||
135 | + * @param string $token 发券标记 | ||
136 | + * @return mixed | ||
137 | + */ | ||
138 | + public static function couponSend($uid, $token) | ||
139 | + { | ||
140 | + $param = Yohobuy::param(); | ||
141 | + $param['method'] = 'app.coupons.couponSend'; | ||
142 | + $param['uid'] = $uid; | ||
143 | + $param['coupon_send_token'] = $token; | ||
144 | + $param['client_secret'] = Sign::getSign($param); | ||
145 | + | ||
146 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
147 | + } | ||
148 | + | ||
130 | } | 149 | } |
@@ -21,6 +21,8 @@ var $loading = $(''), | @@ -21,6 +21,8 @@ var $loading = $(''), | ||
21 | var searching = false; | 21 | var searching = false; |
22 | var mySwiper = {}; | 22 | var mySwiper = {}; |
23 | 23 | ||
24 | +var isLoading = false; | ||
25 | + | ||
24 | ellipsis.init(); | 26 | ellipsis.init(); |
25 | 27 | ||
26 | if ($loadMoreInfo.length > 0) { | 28 | if ($loadMoreInfo.length > 0) { |
@@ -82,13 +84,16 @@ function initInfosEvt($container) { | @@ -82,13 +84,16 @@ function initInfosEvt($container) { | ||
82 | 84 | ||
83 | //点赞 | 85 | //点赞 |
84 | $btn = $this.closest('.like-btn'); | 86 | $btn = $this.closest('.like-btn'); |
85 | - if ($btn.length > 0) { | 87 | + if ($btn.length > 0 && !isLoading) { |
86 | e.preventDefault(); | 88 | e.preventDefault(); |
87 | if ($btn.hasClass('like')) { | 89 | if ($btn.hasClass('like')) { |
88 | opt = 'cancel'; | 90 | opt = 'cancel'; |
89 | } | 91 | } |
90 | 92 | ||
91 | $info = $this.closest('.guang-info'); | 93 | $info = $this.closest('.guang-info'); |
94 | + | ||
95 | + isLoading = true; | ||
96 | + | ||
92 | $.ajax({ | 97 | $.ajax({ |
93 | type: 'POST', | 98 | type: 'POST', |
94 | url: '/guang/opt/praiseArticle', | 99 | url: '/guang/opt/praiseArticle', |
@@ -99,6 +104,7 @@ function initInfosEvt($container) { | @@ -99,6 +104,7 @@ function initInfosEvt($container) { | ||
99 | success: function(data) { | 104 | success: function(data) { |
100 | var code = data.code; | 105 | var code = data.code; |
101 | 106 | ||
107 | + | ||
102 | if (code === 200) { | 108 | if (code === 200) { |
103 | $btn.next('.like-count').text(data.data); | 109 | $btn.next('.like-count').text(data.data); |
104 | 110 | ||
@@ -108,6 +114,9 @@ function initInfosEvt($container) { | @@ -108,6 +114,9 @@ function initInfosEvt($container) { | ||
108 | }, | 114 | }, |
109 | error: function() { | 115 | error: function() { |
110 | tip.show('网络断开连接了~'); | 116 | tip.show('网络断开连接了~'); |
117 | + }, | ||
118 | + complete: function() { | ||
119 | + isLoading = false; | ||
111 | } | 120 | } |
112 | }); | 121 | }); |
113 | return; | 122 | return; |
@@ -233,4 +242,4 @@ exports.mySwiper = mySwiper; | @@ -233,4 +242,4 @@ exports.mySwiper = mySwiper; | ||
233 | exports.initSwiper = initSwiper; | 242 | exports.initSwiper = initSwiper; |
234 | exports.initInfosEvt = initInfosEvt; | 243 | exports.initInfosEvt = initInfosEvt; |
235 | exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis; | 244 | exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis; |
236 | -exports.loadMore = loadMore; | ||
245 | +exports.loadMore = loadMore; |
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | background-color: #ff575c; | 41 | background-color: #ff575c; |
42 | color: #fff; | 42 | color: #fff; |
43 | } | 43 | } |
44 | - .new-festival-tag { | 44 | + .running-man-tag { |
45 | width: 90rem / $pxConvertRem; | 45 | width: 90rem / $pxConvertRem; |
46 | background-color: #017df9; | 46 | background-color: #017df9; |
47 | color: #f7ed02; | 47 | color: #f7ed02; |
@@ -165,7 +165,7 @@ $basicBtnC:#eb0313; | @@ -165,7 +165,7 @@ $basicBtnC:#eb0313; | ||
165 | background-color: #ff575c; | 165 | background-color: #ff575c; |
166 | color: #fff; | 166 | color: #fff; |
167 | } | 167 | } |
168 | - .new-festival-tag { | 168 | + .running-man-tag { |
169 | background-color: #017df9; | 169 | background-color: #017df9; |
170 | color: #f7ed02; | 170 | color: #f7ed02; |
171 | } | 171 | } |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | <p class="good-tag sale-tag">SALE</p> | 13 | <p class="good-tag sale-tag">SALE</p> |
14 | {{/ is_discount}} | 14 | {{/ is_discount}} |
15 | {{# is_yohood}} | 15 | {{# is_yohood}} |
16 | - <div class="good-tag yohood-tag">跑男同款</div> | 16 | + <div class="good-tag running-man-tag">跑男同款</div> |
17 | {{/ is_yohood}} | 17 | {{/ is_yohood}} |
18 | {{# is_limited}} | 18 | {{# is_limited}} |
19 | <p class="good-tag limit-tag">限量商品</p> | 19 | <p class="good-tag limit-tag">限量商品</p> |
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | <p class="good-tag sale-tag">SALE</p> | 12 | <p class="good-tag sale-tag">SALE</p> |
13 | {{/ is_discount}} | 13 | {{/ is_discount}} |
14 | {{# is_yohoood}} | 14 | {{# is_yohoood}} |
15 | - <p class="good-tag new-festival-tag">跑男同款</p> | 15 | + <p class="good-tag running-man-tag">跑男同款</p> |
16 | {{/ is_yohoood}} | 16 | {{/ is_yohoood}} |
17 | {{# is_limited}} | 17 | {{# is_limited}} |
18 | <p class="good-tag limit-tag">限量商品</p> | 18 | <p class="good-tag limit-tag">限量商品</p> |
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | * Time: 16:31 | 7 | * Time: 16:31 |
8 | */ | 8 | */ |
9 | use Action\AbstractAction; | 9 | use Action\AbstractAction; |
10 | +use Coupon\CouponModel; | ||
10 | use LibModels\Wap\Coupon\CouponData; | 11 | use LibModels\Wap\Coupon\CouponData; |
11 | use Plugin\DataProcess\CouponFloorProcess; | 12 | use Plugin\DataProcess\CouponFloorProcess; |
12 | use Plugin\Helpers; | 13 | use Plugin\Helpers; |
@@ -93,4 +94,19 @@ class CouponController extends AbstractAction | @@ -93,4 +94,19 @@ class CouponController extends AbstractAction | ||
93 | return (null !== $this->get('app_version')); | 94 | return (null !== $this->get('app_version')); |
94 | } | 95 | } |
95 | 96 | ||
96 | -} | ||
97 | + /** | ||
98 | + * 获取优惠券 | ||
99 | + */ | ||
100 | + public function couponSendAction() | ||
101 | + { | ||
102 | + $callback = $this->get('callback'); | ||
103 | + $token = $this->get('token', ''); | ||
104 | + $uid = $this->getUid(true); | ||
105 | + $app = $this->get('app', array()); | ||
106 | + | ||
107 | + $result = CouponModel::couponSend($uid, $token, $app); | ||
108 | + | ||
109 | + $this->helpJsonCallbackResult($callback, $result['code'], $result['message'], $result['data']); | ||
110 | + } | ||
111 | + | ||
112 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace Coupon; | ||
4 | + | ||
5 | +use Api\Sign; | ||
6 | +use Api\Yohobuy; | ||
7 | +use LibModels\Wap\Cuxiao\ActivityData; | ||
8 | +use Plugin\Helpers; | ||
9 | + | ||
10 | +/** | ||
11 | + * 发券相关的数据处理模型 | ||
12 | + * | ||
13 | + * @name CouponModel | ||
14 | + * @package Models/Coupon | ||
15 | + * @copyright yoho.inc | ||
16 | + * @version 1.0 (2016-04-19 13:52:44) | ||
17 | + * @author Gtskk<2330416537@qq.com> | ||
18 | + */ | ||
19 | +class CouponModel | ||
20 | +{ | ||
21 | + /** | ||
22 | + * 发放优惠券返回的接口数据处理 | ||
23 | + * | ||
24 | + * @param int $uid 用户ID | ||
25 | + * @param string $token 发券标记 | ||
26 | + * @param array $app url中传递的app有关的参数 | ||
27 | + * @return mixed | ||
28 | + */ | ||
29 | + public static function couponSend($uid, $token, $app) | ||
30 | + { | ||
31 | + $result = array('code' => 403, 'message' => '参数错误', 'data' => ''); | ||
32 | + | ||
33 | + do { | ||
34 | + // APP时用参数中的ID | ||
35 | + if (self::checkApp($app)) { | ||
36 | + $uid = isset($app['uid']) ? $app['uid'] : 0; | ||
37 | + } | ||
38 | + | ||
39 | + // 用户ID或者发券标记为空时 | ||
40 | + if (empty($uid) || empty($token)) { | ||
41 | + break; | ||
42 | + } | ||
43 | + | ||
44 | + $couponResult = ActivityData::couponSend($uid, $token); | ||
45 | + // 接口返回错误时 | ||
46 | + if (empty($couponResult)) { | ||
47 | + $result['code'] = 404; | ||
48 | + $result['message'] = '出错啦~'; | ||
49 | + break; | ||
50 | + } | ||
51 | + | ||
52 | + $result = $couponResult; | ||
53 | + } while (false); | ||
54 | + | ||
55 | + return $result; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 校验是否为app | ||
60 | + * | ||
61 | + * @param array $app url中传递的app有关的参数 | ||
62 | + * @return bool | ||
63 | + */ | ||
64 | + private static function checkApp($app) | ||
65 | + { | ||
66 | + $isApp = false; | ||
67 | + | ||
68 | + // APP时用参数中的ID | ||
69 | + if (!empty($app) && isset($app['client_secret'])) { | ||
70 | + $params = $app; | ||
71 | + unset($params['client_secret']); | ||
72 | + $params['private_key'] = Yohobuy::$privateKeyList[$params['client_type']]; | ||
73 | + | ||
74 | + $isApp = ($app['client_secret'] === Sign::getSign($params)); | ||
75 | + } | ||
76 | + | ||
77 | + return $isApp; | ||
78 | + } | ||
79 | + | ||
80 | +} |
@@ -311,4 +311,27 @@ class LoginController extends AbstractAction | @@ -311,4 +311,27 @@ class LoginController extends AbstractAction | ||
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | + /** | ||
315 | + * jsonp获取用户uid | ||
316 | + */ | ||
317 | + public function userAction() | ||
318 | + { | ||
319 | + $result = array('code' => 403, 'message' => '未登录', 'data' => ''); | ||
320 | + | ||
321 | + do { | ||
322 | + $callback = $this->get('callback'); | ||
323 | + | ||
324 | + $uid = $this->getUid(true); | ||
325 | + if (!empty($uid)) { | ||
326 | + $result = array( | ||
327 | + 'code' => 200, | ||
328 | + 'message' => '已登录', | ||
329 | + 'data' => $uid | ||
330 | + ); | ||
331 | + } | ||
332 | + } while (false); | ||
333 | + | ||
334 | + $this->helpJsonCallbackResult($callback, $result['code'], $result['message'], $result['data']); | ||
335 | + } | ||
336 | + | ||
314 | } | 337 | } |
-
Please register or login to post a comment