Authored by 王水玲

Merge branch 'feature/wap4.3' of http://git.dev.yoho.cn/web/yohobuy into feature/wap4.3

... ... @@ -2,6 +2,7 @@
namespace LibModels\Wap\Cuxiao;
use Api\Sign;
use Api\Yohobuy;
/**
... ... @@ -127,4 +128,22 @@ class ActivityData
));
}
/**
* 发放优惠券
*
* @param int $uid 用户ID
* @param string $token 发券标记
* @return mixed
*/
public static function couponSend($uid, $token)
{
$param = Yohobuy::param();
$param['method'] = 'app.coupons.couponSend';
$param['uid'] = $uid;
$param['coupon_send_token'] = $token;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -21,6 +21,8 @@ var $loading = $(''),
var searching = false;
var mySwiper = {};
var isLoading = false;
ellipsis.init();
if ($loadMoreInfo.length > 0) {
... ... @@ -82,13 +84,16 @@ function initInfosEvt($container) {
//点赞
$btn = $this.closest('.like-btn');
if ($btn.length > 0) {
if ($btn.length > 0 && !isLoading) {
e.preventDefault();
if ($btn.hasClass('like')) {
opt = 'cancel';
}
$info = $this.closest('.guang-info');
isLoading = true;
$.ajax({
type: 'POST',
url: '/guang/opt/praiseArticle',
... ... @@ -99,6 +104,7 @@ function initInfosEvt($container) {
success: function(data) {
var code = data.code;
if (code === 200) {
$btn.next('.like-count').text(data.data);
... ... @@ -108,6 +114,9 @@ function initInfosEvt($container) {
},
error: function() {
tip.show('网络断开连接了~');
},
complete: function() {
isLoading = false;
}
});
return;
... ... @@ -233,4 +242,4 @@ exports.mySwiper = mySwiper;
exports.initSwiper = initSwiper;
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
\ No newline at end of file
exports.loadMore = loadMore;
... ...
... ... @@ -41,7 +41,7 @@
background-color: #ff575c;
color: #fff;
}
.new-festival-tag {
.running-man-tag {
width: 90rem / $pxConvertRem;
background-color: #017df9;
color: #f7ed02;
... ...
... ... @@ -165,7 +165,7 @@ $basicBtnC:#eb0313;
background-color: #ff575c;
color: #fff;
}
.new-festival-tag {
.running-man-tag {
background-color: #017df9;
color: #f7ed02;
}
... ...
... ... @@ -13,7 +13,7 @@
<p class="good-tag sale-tag">SALE</p>
{{/ is_discount}}
{{# is_yohood}}
<div class="good-tag yohood-tag">跑男同款</div>
<div class="good-tag running-man-tag">跑男同款</div>
{{/ is_yohood}}
{{# is_limited}}
<p class="good-tag limit-tag">限量商品</p>
... ...
... ... @@ -12,7 +12,7 @@
<p class="good-tag sale-tag">SALE</p>
{{/ is_discount}}
{{# is_yohoood}}
<p class="good-tag new-festival-tag">跑男同款</p>
<p class="good-tag running-man-tag">跑男同款</p>
{{/ is_yohoood}}
{{# is_limited}}
<p class="good-tag limit-tag">限量商品</p>
... ...
... ... @@ -7,6 +7,7 @@
* Time: 16:31
*/
use Action\AbstractAction;
use Coupon\CouponModel;
use LibModels\Wap\Coupon\CouponData;
use Plugin\DataProcess\CouponFloorProcess;
use Plugin\Helpers;
... ... @@ -93,4 +94,19 @@ class CouponController extends AbstractAction
return (null !== $this->get('app_version'));
}
}
\ No newline at end of file
/**
* 获取优惠券
*/
public function couponSendAction()
{
$callback = $this->get('callback');
$token = $this->get('token', '');
$uid = $this->getUid(true);
$app = $this->get('app', array());
$result = CouponModel::couponSend($uid, $token, $app);
$this->helpJsonCallbackResult($callback, $result['code'], $result['message'], $result['data']);
}
}
... ...
<?php
namespace Coupon;
use Api\Sign;
use Api\Yohobuy;
use LibModels\Wap\Cuxiao\ActivityData;
use Plugin\Helpers;
/**
* 发券相关的数据处理模型
*
* @name CouponModel
* @package Models/Coupon
* @copyright yoho.inc
* @version 1.0 (2016-04-19 13:52:44)
* @author Gtskk<2330416537@qq.com>
*/
class CouponModel
{
/**
* 发放优惠券返回的接口数据处理
*
* @param int $uid 用户ID
* @param string $token 发券标记
* @param array $app url中传递的app有关的参数
* @return mixed
*/
public static function couponSend($uid, $token, $app)
{
$result = array('code' => 403, 'message' => '参数错误', 'data' => '');
do {
// APP时用参数中的ID
if (self::checkApp($app)) {
$uid = isset($app['uid']) ? $app['uid'] : 0;
}
// 用户ID或者发券标记为空时
if (empty($uid) || empty($token)) {
break;
}
$couponResult = ActivityData::couponSend($uid, $token);
// 接口返回错误时
if (empty($couponResult)) {
$result['code'] = 404;
$result['message'] = '出错啦~';
break;
}
$result = $couponResult;
} while (false);
return $result;
}
/**
* 校验是否为app
*
* @param array $app url中传递的app有关的参数
* @return bool
*/
private static function checkApp($app)
{
$isApp = false;
// APP时用参数中的ID
if (!empty($app) && isset($app['client_secret'])) {
$params = $app;
unset($params['client_secret']);
$params['private_key'] = Yohobuy::$privateKeyList[$params['client_type']];
$isApp = ($app['client_secret'] === Sign::getSign($params));
}
return $isApp;
}
}
... ...
... ... @@ -311,4 +311,27 @@ class LoginController extends AbstractAction
}
}
/**
* jsonp获取用户uid
*/
public function userAction()
{
$result = array('code' => 403, 'message' => '未登录', 'data' => '');
do {
$callback = $this->get('callback');
$uid = $this->getUid(true);
if (!empty($uid)) {
$result = array(
'code' => 200,
'message' => '已登录',
'data' => $uid
);
}
} while (false);
$this->helpJsonCallbackResult($callback, $result['code'], $result['message'], $result['data']);
}
}
... ...