Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
23 changed files
with
425 additions
and
50 deletions
@@ -32,4 +32,58 @@ class CartData | @@ -32,4 +32,58 @@ class CartData | ||
32 | return Yohobuy::get(Yohobuy::API_URL, $param); | 32 | return Yohobuy::get(Yohobuy::API_URL, $param); |
33 | } | 33 | } |
34 | 34 | ||
35 | + /** | ||
36 | + * 移出购物车 | ||
37 | + * | ||
38 | + * @param int $uid 用户ID | ||
39 | + * @param string $sku 商品sku列表 | ||
40 | + * @return array 接口返回的数据 | ||
41 | + */ | ||
42 | + public static function removeFromCart($uid, $sku) | ||
43 | + { | ||
44 | + $param = Yohobuy::param(); | ||
45 | + $param['method'] = 'app.Shopping.remove'; | ||
46 | + $param['product_sku_list'] = $sku; | ||
47 | + $param['uid'] = $uid; | ||
48 | + $param['client_secret'] = Sign::getSign($param); | ||
49 | + | ||
50 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * 修改购物车商品数据 | ||
55 | + * | ||
56 | + * @param int $uid 用户ID | ||
57 | + * @param string $swapData 商品数据 | ||
58 | + * @return array 接口返回的数据 | ||
59 | + */ | ||
60 | + public static function modifyCartProduct($uid, $swapData) | ||
61 | + { | ||
62 | + $param = Yohobuy::param(); | ||
63 | + $param['method'] = 'app.Shopping.swap'; | ||
64 | + $param['swap_data'] = $swapData; | ||
65 | + $param['uid'] = $uid; | ||
66 | + $param['client_secret'] = Sign::getSign($param); | ||
67 | + | ||
68 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * 移入收藏夹 | ||
73 | + * | ||
74 | + * @param int $uid 用户ID | ||
75 | + * @param string $sku 商品sku列表 | ||
76 | + * @return array 接口返回的数据 | ||
77 | + */ | ||
78 | + public static function addToFav($uid, $sku) | ||
79 | + { | ||
80 | + $param = Yohobuy::param(); | ||
81 | + $param['method'] = 'app.Shopping.addfavorite'; | ||
82 | + $param['product_sku_list'] = $sku; | ||
83 | + $param['uid'] = $uid; | ||
84 | + $param['client_secret'] = Sign::getSign($param); | ||
85 | + | ||
86 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
87 | + } | ||
88 | + | ||
35 | } | 89 | } |
@@ -22,15 +22,16 @@ class BrandData | @@ -22,15 +22,16 @@ class BrandData | ||
22 | * | 22 | * |
23 | * @param int $id 品牌ID | 23 | * @param int $id 品牌ID |
24 | * @param int $uid 用户ID | 24 | * @param int $uid 用户ID |
25 | + * @param bool $isBrand 是品牌还是商品 | ||
25 | * @return array | 26 | * @return array |
26 | */ | 27 | */ |
27 | - public static function favorite($id, $uid) | 28 | + public static function favorite($id, $uid, $isBrand = true) |
28 | { | 29 | { |
29 | $param = Yohobuy::param(); | 30 | $param = Yohobuy::param(); |
30 | $param['method'] = 'app.favorite.add'; | 31 | $param['method'] = 'app.favorite.add'; |
31 | $param['id'] = $id; | 32 | $param['id'] = $id; |
32 | $param['uid'] = $uid; | 33 | $param['uid'] = $uid; |
33 | - $param['type'] = 'brand'; | 34 | + $param['type'] = $isBrand ? 'brand' : 'product'; |
34 | $param['client_secret'] = Sign::getSign($param); | 35 | $param['client_secret'] = Sign::getSign($param); |
35 | 36 | ||
36 | return Yohobuy::post(Yohobuy::API_URL, $param); | 37 | return Yohobuy::post(Yohobuy::API_URL, $param); |
@@ -41,15 +42,16 @@ class BrandData | @@ -41,15 +42,16 @@ class BrandData | ||
41 | * | 42 | * |
42 | * @param int $id 品牌ID | 43 | * @param int $id 品牌ID |
43 | * @param int $uid 用户ID | 44 | * @param int $uid 用户ID |
45 | + * @param bool $isBrand 是品牌还是商品 | ||
44 | * @return array | 46 | * @return array |
45 | */ | 47 | */ |
46 | - public static function favoriteCancel($id, $uid) | 48 | + public static function favoriteCancel($id, $uid, $isBrand = true) |
47 | { | 49 | { |
48 | $param = Yohobuy::param(); | 50 | $param = Yohobuy::param(); |
49 | $param['method'] = 'app.favorite.cancel'; | 51 | $param['method'] = 'app.favorite.cancel'; |
50 | $param['fav_id'] = $id; | 52 | $param['fav_id'] = $id; |
51 | $param['uid'] = $uid; | 53 | $param['uid'] = $uid; |
52 | - $param['type'] = 'brand'; | 54 | + $param['type'] = $isBrand ? 'brand' : 'product'; |
53 | $param['client_secret'] = Sign::getSign($param); | 55 | $param['client_secret'] = Sign::getSign($param); |
54 | 56 | ||
55 | return Yohobuy::post(Yohobuy::API_URL, $param); | 57 | return Yohobuy::post(Yohobuy::API_URL, $param); |
@@ -205,14 +205,14 @@ class Helpers | @@ -205,14 +205,14 @@ class Helpers | ||
205 | $result['name'] = $productData['product_name']; | 205 | $result['name'] = $productData['product_name']; |
206 | $result['price'] = empty($productData['market_price']) ? false : $productData['market_price']; | 206 | $result['price'] = empty($productData['market_price']) ? false : $productData['market_price']; |
207 | $result['salePrice'] = $productData['sales_price']; | 207 | $result['salePrice'] = $productData['sales_price']; |
208 | - if ($showPoint) { | ||
209 | - $result['price'] && $result['price'] .= '.00'; | ||
210 | - $result['salePrice'] && $result['salePrice'] .= '.00'; | ||
211 | - } | 208 | + if ($showPoint) { |
209 | + $result['price'] && $result['price'] .= '.00'; | ||
210 | + $result['salePrice'] && $result['salePrice'] .= '.00'; | ||
211 | + } | ||
212 | $result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y'); | 212 | $result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y'); |
213 | $result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_' | 213 | $result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_' |
214 | - . $productData['goods_list'][0]['goods_id'] | ||
215 | - . '/' . $productData['cn_alphabet'] . '.html'; | 214 | + . $productData['goods_list'][0]['goods_id'] |
215 | + . '/' . $productData['cn_alphabet'] . '.html'; | ||
216 | // APP访问需要加附加的参数 | 216 | // APP访问需要加附加的参数 |
217 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 | 217 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 |
218 | if ($isApp) { | 218 | if ($isApp) { |
@@ -9,4 +9,5 @@ require('./order-detail'); | @@ -9,4 +9,5 @@ require('./order-detail'); | ||
9 | require('./fav'); | 9 | require('./fav'); |
10 | require('./index'); | 10 | require('./index'); |
11 | require('./coupons'); | 11 | require('./coupons'); |
12 | -require('./online-service'); | ||
12 | +require('./online-service'); | ||
13 | +require('./address'); |
@@ -4,7 +4,8 @@ | @@ -4,7 +4,8 @@ | ||
4 | * @date: 2015/11/12 | 4 | * @date: 2015/11/12 |
5 | */ | 5 | */ |
6 | var $ = require('jquery'); | 6 | var $ = require('jquery'); |
7 | -var $userAvatar = $('.user-avatar'); | 7 | +var $userAvatar = $('.user-avatar'), |
8 | + $listItem = $('.list-item'); | ||
8 | var myImage = new Image(); | 9 | var myImage = new Image(); |
9 | 10 | ||
10 | require('../product/recommend-for-you.js'); | 11 | require('../product/recommend-for-you.js'); |
@@ -12,3 +13,10 @@ myImage.src = $userAvatar.attr('src'); | @@ -12,3 +13,10 @@ myImage.src = $userAvatar.attr('src'); | ||
12 | myImage.onerror = function() { | 13 | myImage.onerror = function() { |
13 | $userAvatar.attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); | 14 | $userAvatar.attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); |
14 | }; | 15 | }; |
16 | + | ||
17 | +$('.yoho-page').on('touchstart', '.list-item, .type-item', function() { | ||
18 | + $listItem.removeClass('highlight'); | ||
19 | + $(this).addClass('highlight'); | ||
20 | +}).on('touchend touchcancel', '.list-item, .type-item', function() { | ||
21 | + $(this).removeClass('highlight'); | ||
22 | +}); |
@@ -5,9 +5,8 @@ | @@ -5,9 +5,8 @@ | ||
5 | */ | 5 | */ |
6 | var $ = require('jquery'), | 6 | var $ = require('jquery'), |
7 | lazyLoad = require('yoho.lazyload'), | 7 | lazyLoad = require('yoho.lazyload'), |
8 | - Swiper = require('yoho.iswiper'); | ||
9 | - | ||
10 | -var loading = require('../../plugin/loading'), | 8 | + Swiper = require('yoho.iswiper'), |
9 | + loading = require('../../plugin/loading'), | ||
11 | tip = require('../../plugin/tip'); | 10 | tip = require('../../plugin/tip'); |
12 | 11 | ||
13 | var introUrl = $('#introUrl').val(), | 12 | var introUrl = $('#introUrl').val(), |
@@ -11,6 +11,7 @@ var goodsSwiper; | @@ -11,6 +11,7 @@ var goodsSwiper; | ||
11 | 11 | ||
12 | require('./desc'); | 12 | require('./desc'); |
13 | require('./comments-consults'); | 13 | require('./comments-consults'); |
14 | +require('./like'); | ||
14 | require('../recommend-for-you.js'); | 15 | require('../recommend-for-you.js'); |
15 | 16 | ||
16 | lazyLoad($('img.lazy')); | 17 | lazyLoad($('img.lazy')); |
@@ -49,6 +50,4 @@ $('.goodsDiscount .dropdown').on('click', function() { | @@ -49,6 +50,4 @@ $('.goodsDiscount .dropdown').on('click', function() { | ||
49 | $('.goodsDiscount .first-item span').html(''); | 50 | $('.goodsDiscount .first-item span').html(''); |
50 | $('.goodsDiscount .discount-folder').slideUp(); | 51 | $('.goodsDiscount .discount-folder').slideUp(); |
51 | } | 52 | } |
52 | -}); | ||
53 | - | ||
54 | - | 53 | +}); |
static/js/product/detail/like.js
0 → 100644
1 | +/** | ||
2 | + * 商品详情 | ||
3 | + * @author: Lynnic | ||
4 | + * @date: 2015/11/24 | ||
5 | + */ | ||
6 | +var $ = require('jquery'), | ||
7 | + Hammer = require('yoho.hammer'), | ||
8 | + tip = require('../../plugin/tip'); | ||
9 | + | ||
10 | +var likeHammer = new Hammer(document.getElementById('likeBtn')); | ||
11 | + | ||
12 | +likeHammer.on('tap', function(e) { | ||
13 | + var productId = $('#productId').val(), | ||
14 | + opt; | ||
15 | + var $this = $(this); | ||
16 | + | ||
17 | + if ($this.hasClass('liked')) { | ||
18 | + opt = 'cancel'; | ||
19 | + } else { | ||
20 | + opt = 'ok'; | ||
21 | + } | ||
22 | + | ||
23 | + $.ajax({ | ||
24 | + type: 'POST', | ||
25 | + url: '/product/opt/favoriteProduct', | ||
26 | + data: { | ||
27 | + id: productId, | ||
28 | + opt: opt | ||
29 | + }, | ||
30 | + success: function(data) { | ||
31 | + if (data.code === 200) { | ||
32 | + $this.toggleClass('liked'); | ||
33 | + } else if (data.code === 400) { | ||
34 | + location.href = data.data;//未登录跳转登录页 | ||
35 | + } else { | ||
36 | + tip.show(data.message); | ||
37 | + } | ||
38 | + }, | ||
39 | + error: function() { | ||
40 | + tip.show('网络断开连接了~'); | ||
41 | + } | ||
42 | + }); | ||
43 | + | ||
44 | +}); | ||
45 | + | ||
46 | +$('#likeBtn').on('click', function(e) { | ||
47 | + return false; | ||
48 | +}); |
@@ -64,7 +64,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -64,7 +64,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
64 | id = $this.closest('.shopping-cart-good').data('id'), | 64 | id = $this.closest('.shopping-cart-good').data('id'), |
65 | url; | 65 | url; |
66 | 66 | ||
67 | - if ($this.closest('.put-in-favorite')) { | 67 | + if ($this.closest('.put-in-favorite').length > 0) { |
68 | 68 | ||
69 | //移入收藏夹 | 69 | //移入收藏夹 |
70 | url = '/shoppingCart/col'; | 70 | url = '/shoppingCart/col'; |
@@ -138,6 +138,10 @@ | @@ -138,6 +138,10 @@ | ||
138 | font-size: pxToRem(28px); | 138 | font-size: pxToRem(28px); |
139 | line-height: 1.5; | 139 | line-height: 1.5; |
140 | width: pxToRem(193px); | 140 | width: pxToRem(193px); |
141 | + | ||
142 | + &.highlight { | ||
143 | + background: #eee; | ||
144 | + } | ||
141 | } | 145 | } |
142 | 146 | ||
143 | .iconfont { | 147 | .iconfont { |
@@ -158,6 +162,11 @@ | @@ -158,6 +162,11 @@ | ||
158 | padding: 0 pxToRem(30px); | 162 | padding: 0 pxToRem(30px); |
159 | font-size: pxToRem(32px); | 163 | font-size: pxToRem(32px); |
160 | line-height: pxToRem(88px); | 164 | line-height: pxToRem(88px); |
165 | + | ||
166 | + &.highlight { | ||
167 | + background: #eee; | ||
168 | + } | ||
169 | + | ||
161 | &:after { | 170 | &:after { |
162 | content: ''; | 171 | content: ''; |
163 | position: absolute; | 172 | position: absolute; |
@@ -346,14 +346,14 @@ $basicBtnC:#eb0313; | @@ -346,14 +346,14 @@ $basicBtnC:#eb0313; | ||
346 | font-size: pxToRem(47px); | 346 | font-size: pxToRem(47px); |
347 | color: #444; | 347 | color: #444; |
348 | } | 348 | } |
349 | - &.unfavorite{ | ||
350 | - font-size: pxToRem(34px); | ||
351 | - color:#ccc; | ||
352 | - } | ||
353 | &.favorite { | 349 | &.favorite { |
354 | font-size: pxToRem(34px); | 350 | font-size: pxToRem(34px); |
355 | - color: $basicBtnC; | 351 | + color: #ccc |
356 | } | 352 | } |
353 | + &.favorite.liked{ | ||
354 | + color:$basicBtnC;; | ||
355 | + } | ||
356 | + | ||
357 | &.addto-cart, | 357 | &.addto-cart, |
358 | &.sold-out { | 358 | &.sold-out { |
359 | height: pxToRem(80px); | 359 | height: pxToRem(80px); |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <div class="good-detail-page yoho-page"> | 2 | <div class="good-detail-page yoho-page"> |
3 | <div class="banner-container"> | 3 | <div class="banner-container"> |
4 | <div class="tag-container"> | 4 | <div class="tag-container"> |
5 | - <p class="good-tag soonSoldOut-tag">即将售罄</p> | 5 | + <!-- <p class="good-tag soonSoldOut-tag">即将售罄</p> --> |
6 | {{# tags}} | 6 | {{# tags}} |
7 | {{# is_new}} | 7 | {{# is_new}} |
8 | <p class="good-tag new-tag">NEW</p> | 8 | <p class="good-tag new-tag">NEW</p> |
@@ -118,10 +118,10 @@ | @@ -118,10 +118,10 @@ | ||
118 | {{else}} | 118 | {{else}} |
119 | <a href="" class="sold-out">已售罄</a> | 119 | <a href="" class="sold-out">已售罄</a> |
120 | {{/if}} | 120 | {{/if}} |
121 | - {{#if favorite}} | ||
122 | - <a href="" class="favorite iconfont "></a> | 121 | + {{#if isCollect}} |
122 | + <a href="#" id="likeBtn" class="favorite iconfont liked"></a> | ||
123 | {{else}} | 123 | {{else}} |
124 | - <a href="" class="unfavorite iconfont "></a> | 124 | + <a href="" id="likeBtn" class="favorite iconfont"></a> |
125 | {{/if}} | 125 | {{/if}} |
126 | </div> | 126 | </div> |
127 | {{/cartInfo}} | 127 | {{/cartInfo}} |
@@ -129,6 +129,10 @@ | @@ -129,6 +129,10 @@ | ||
129 | {{#if introUrl}} | 129 | {{#if introUrl}} |
130 | <input id="introUrl" type="hidden" value={{introUrl}}> | 130 | <input id="introUrl" type="hidden" value={{introUrl}}> |
131 | {{/if}} | 131 | {{/if}} |
132 | + | ||
133 | + {{#if id}} | ||
134 | + <input id="productId" type="hidden" value={{id}}> | ||
135 | + {{/if}} | ||
132 | 136 | ||
133 | </div> | 137 | </div> |
134 | {{> layout/footer}} | 138 | {{> layout/footer}} |
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | <div class="question"> | 38 | <div class="question"> |
39 | <span class="iconfont"></span> | 39 | <span class="iconfont"></span> |
40 | <p> | 40 | <p> |
41 | - {{question}} | 41 | + {{question}}<br> |
42 | <span class="time">{{time}}</span> | 42 | <span class="time">{{time}}</span> |
43 | </p> | 43 | </p> |
44 | </div> | 44 | </div> |
@@ -14,7 +14,6 @@ use Index\UserModel as UserModel; | @@ -14,7 +14,6 @@ use Index\UserModel as UserModel; | ||
14 | * @package | 14 | * @package |
15 | * @copyright yoho.inc | 15 | * @copyright yoho.inc |
16 | * @version 1.0 (2015-10-28 16:28:32) | 16 | * @version 1.0 (2015-10-28 16:28:32) |
17 | - * @author fei.hong <fei.hong@yoho.cn> | ||
18 | */ | 17 | */ |
19 | class HomeController extends AbstractAction | 18 | class HomeController extends AbstractAction |
20 | { | 19 | { |
@@ -27,7 +26,12 @@ class HomeController extends AbstractAction | @@ -27,7 +26,12 @@ class HomeController extends AbstractAction | ||
27 | public function init() | 26 | public function init() |
28 | { | 27 | { |
29 | // 检查用户是否登录, 未登录则跳转到登录页 | 28 | // 检查用户是否登录, 未登录则跳转到登录页 |
30 | - $uid = 8826435; //$this->getUid(true); | 29 | + // @todo 为了方便测试,支持传uid参数 |
30 | + $uid = $this->getUid(); | ||
31 | + if (!$uid) { | ||
32 | + $uid = $this->_uid = $this->get('uid', 8826435); //$this->getUid(true); | ||
33 | + } | ||
34 | + | ||
31 | $action = $this->getRequest()->getActionName(); | 35 | $action = $this->getRequest()->getActionName(); |
32 | if (!$uid && $action !== 'index') { | 36 | if (!$uid && $action !== 'index') { |
33 | $this->go(Helpers::url('/signin.html')); | 37 | $this->go(Helpers::url('/signin.html')); |
@@ -678,4 +682,4 @@ class HomeController extends AbstractAction | @@ -678,4 +682,4 @@ class HomeController extends AbstractAction | ||
678 | ); | 682 | ); |
679 | $this->_view->display('i-help', $data); | 683 | $this->_view->display('i-help', $data); |
680 | } | 684 | } |
681 | -} | ||
685 | +} |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use Index\CartModel; | ||
5 | +use Plugin\Helpers; | ||
4 | 6 | ||
5 | /** | 7 | /** |
6 | * 购物车 | 8 | * 购物车 |
7 | */ | 9 | */ |
8 | class ShoppingCartController extends AbstractAction | 10 | class ShoppingCartController extends AbstractAction |
9 | { | 11 | { |
12 | + protected $_uid; | ||
13 | + | ||
14 | + /** | ||
15 | + * 初始化 | ||
16 | + */ | ||
17 | + public function init() | ||
18 | + { | ||
19 | + // 检查用户是否登录, 未登录则跳转到登录页 | ||
20 | + $this->_uid = $this->getUid(); | ||
21 | + if (!$this->_uid) { | ||
22 | + $this->go(Helpers::url('/signin.html')); | ||
23 | + } | ||
24 | + | ||
25 | + parent::init(); | ||
26 | + } | ||
27 | + | ||
28 | + /* | ||
29 | + * 首页 | ||
30 | + */ | ||
10 | public function indexAction() | 31 | public function indexAction() |
11 | { | 32 | { |
12 | $this->setTitle('购物车'); | 33 | $this->setTitle('购物车'); |
13 | $this->setNavHeader('购物车'); | 34 | $this->setNavHeader('购物车'); |
14 | 35 | ||
15 | - $uid = $this->getUid(); | ||
16 | $data = array( | 36 | $data = array( |
17 | 'shoppingCartPage' => true, | 37 | 'shoppingCartPage' => true, |
18 | - 'shoppingCart' => \Index\CartModel::getCartData($uid) | 38 | + 'shoppingCart' => CartModel::getCartData($this->_uid) |
19 | ); | 39 | ); |
20 | 40 | ||
21 | // 渲染模板 | 41 | // 渲染模板 |
22 | $this->_view->display('index', $data); | 42 | $this->_view->display('index', $data); |
23 | } | 43 | } |
24 | 44 | ||
45 | + /** | ||
46 | + * 移出购物车 | ||
47 | + */ | ||
48 | + public function delAction() | ||
49 | + { | ||
50 | + $result = array(); | ||
51 | + | ||
52 | + if ($this->isAjax()) { | ||
53 | + $productId = $this->post('id', 0); | ||
54 | + $result = CartModel::removeFromCart($this->_uid, $productId); | ||
55 | + } | ||
56 | + | ||
57 | + if (empty($result)) { | ||
58 | + echo ' '; | ||
59 | + } else { | ||
60 | + $this->echoJson($result); | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * 移入收藏夹 | ||
66 | + */ | ||
67 | + public function colAction() | ||
68 | + { | ||
69 | + $result = array(); | ||
70 | + | ||
71 | + if ($this->isAjax()) { | ||
72 | + $productId = $this->post('id', 0); | ||
73 | + $result = CartModel::addToFav($this->_uid, $productId); | ||
74 | + } | ||
75 | + | ||
76 | + if (empty($result)) { | ||
77 | + echo ' '; | ||
78 | + } else { | ||
79 | + $this->echoJson($result); | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * 修改购物车商品数据 | ||
85 | + */ | ||
86 | + public function modifyAction() | ||
87 | + { | ||
88 | + $result = array(); | ||
89 | + | ||
90 | + if ($this->isAjax()) { | ||
91 | + | ||
92 | + $params = array(); | ||
93 | + $params['old_product_sku']= $this->post('old_product_sku', 0); | ||
94 | + $params['new_product_sku']= $this->post('new_product_sku', 0); | ||
95 | + $params['buy_number']= $this->post('buy_number', 0); | ||
96 | + $params['selected']= $this->post('selected', null); | ||
97 | + $result = CartModel::modifyCartProduct($this->_uid, $params); | ||
98 | + } | ||
99 | + | ||
100 | + if (empty($result)) { | ||
101 | + echo ' '; | ||
102 | + } else { | ||
103 | + $this->echoJson($result); | ||
104 | + } | ||
105 | + } | ||
106 | + | ||
25 | public function giftAdvanceAction() | 107 | public function giftAdvanceAction() |
26 | { | 108 | { |
27 | $data = array( | 109 | $data = array( |
@@ -51,6 +51,75 @@ class CartModel | @@ -51,6 +51,75 @@ class CartModel | ||
51 | return $result; | 51 | return $result; |
52 | } | 52 | } |
53 | 53 | ||
54 | + /** | ||
55 | + * 移出购物车 | ||
56 | + * | ||
57 | + * @param int $uid 用户ID | ||
58 | + * @param string $sku 商品sku列表 | ||
59 | + * @return array 接口返回的数据 | ||
60 | + */ | ||
61 | + public static function removeFromCart($uid, $sku) | ||
62 | + { | ||
63 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
64 | + | ||
65 | + // 处理sku | ||
66 | + $sku_list = json_encode(array($sku => 1)); | ||
67 | + | ||
68 | + $remove = CartData::removeFromCart($uid, $sku_list); | ||
69 | + if ($remove && isset($remove['code'])) { | ||
70 | + $result['code'] = $remove['code']; | ||
71 | + $result['message'] = $remove['message']; | ||
72 | + } | ||
73 | + | ||
74 | + return $result; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * 移入收藏夹 | ||
79 | + * | ||
80 | + * @param int $uid 用户ID | ||
81 | + * @param string $sku 商品sku列表 | ||
82 | + * @return array 接口返回的数据 | ||
83 | + */ | ||
84 | + public static function addToFav($uid, $sku) | ||
85 | + { | ||
86 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
87 | + | ||
88 | + // 处理sku | ||
89 | + $sku_list = json_encode(array($sku => 1)); | ||
90 | + | ||
91 | + $add = CartData::addToFav($uid, $sku_list); | ||
92 | + if ($add && isset($add['code'])) { | ||
93 | + $result['code'] = $add['code']; | ||
94 | + $result['message'] = $add['message']; | ||
95 | + } | ||
96 | + | ||
97 | + return $result; | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * 修改购物车商品数据 | ||
102 | + * | ||
103 | + * @param int $uid 用户ID | ||
104 | + * @param string $param 要更改的数据 | ||
105 | + * @return array 接口返回的数据 | ||
106 | + */ | ||
107 | + public static function modifyCartProduct($uid, $param) | ||
108 | + { | ||
109 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
110 | + | ||
111 | + // 处理要更改的数据 | ||
112 | + $swapData = json_encode(array($param)); | ||
113 | + | ||
114 | + $modify = CartData::addToFav($uid, $swapData); | ||
115 | + if ($modify && isset($modify['code'])) { | ||
116 | + $result['code'] = $modify['code']; | ||
117 | + $result['message'] = $modify['message']; | ||
118 | + } | ||
119 | + | ||
120 | + return $result; | ||
121 | + } | ||
122 | + | ||
54 | 123 | ||
55 | /** | 124 | /** |
56 | * 处理不同类型的购物车数据 | 125 | * 处理不同类型的购物车数据 |
@@ -65,7 +134,7 @@ class CartModel | @@ -65,7 +134,7 @@ class CartModel | ||
65 | $oneGoods = array(); | 134 | $oneGoods = array(); |
66 | // 购买的商品列表 | 135 | // 购买的商品列表 |
67 | foreach ($data['goods_list'] as $value) { | 136 | foreach ($data['goods_list'] as $value) { |
68 | - $oneGoods['id'] = $value['product_id']; | 137 | + $oneGoods['id'] = $value['product_sku']; |
69 | $oneGoods['name'] = $value['product_name']; | 138 | $oneGoods['name'] = $value['product_name']; |
70 | $oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120); | 139 | $oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120); |
71 | $oneGoods['color'] = $value['color_name']; | 140 | $oneGoods['color'] = $value['color_name']; |
@@ -31,15 +31,44 @@ class DetailModel | @@ -31,15 +31,44 @@ class DetailModel | ||
31 | 31 | ||
32 | if (is_numeric($productId) && is_numeric($goodsId)) { | 32 | if (is_numeric($productId) && is_numeric($goodsId)) { |
33 | // 调用服务 | 33 | // 调用服务 |
34 | - $baseInfo = DetailData::baseInfo($productId, $uid); | 34 | + $baseInfo = DetailData::baseInfo($productId, $uid); |
35 | + | ||
36 | + // 判断商品是否在架 | ||
37 | + if (empty($baseInfo['status'])) { | ||
38 | + return $result; | ||
39 | + } | ||
35 | 40 | ||
36 | // 商品名称 | 41 | // 商品名称 |
37 | if (isset($baseInfo['productName'])) { | 42 | if (isset($baseInfo['productName'])) { |
38 | $result['goodsName'] = $baseInfo['productName']; | 43 | $result['goodsName'] = $baseInfo['productName']; |
39 | - } else { | ||
40 | - return $result; | ||
41 | - } | 44 | + } |
42 | 45 | ||
46 | + // 商品标签 | ||
47 | + if (!empty($baseInfo['productTagBoList'])) { | ||
48 | + foreach ($baseInfo['productTagBoList'] as $value) { | ||
49 | + switch ($value['tagLabel']) { | ||
50 | + case 'is_soon_sold_out': // 即将售磬 | ||
51 | + $result['tags']['is_soon_sold_out'] = true; | ||
52 | + break; | ||
53 | + case 'is_new': // 新品 | ||
54 | + $result['tags']['is_new'] = true; | ||
55 | + break; | ||
56 | + case 'is_discount': // 在售 | ||
57 | + $result['tags']['is_discount'] = true; | ||
58 | + break; | ||
59 | + case 'is_limited': // 限量 | ||
60 | + $result['tags']['is_limited'] = true; | ||
61 | + break; | ||
62 | + case 'is_yohood': // YOHOOD | ||
63 | + $result['tags']['is_yohood'] = true; | ||
64 | + break; | ||
65 | + case 'is_advance': // 再到着 | ||
66 | + $result['tags']['is_advance'] = true; | ||
67 | + break; | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
43 | // 商品价格 | 72 | // 商品价格 |
44 | if (isset($baseInfo['productPriceBo'])) { | 73 | if (isset($baseInfo['productPriceBo'])) { |
45 | $result['goodsPrice'] = array(); | 74 | $result['goodsPrice'] = array(); |
@@ -174,8 +203,15 @@ class DetailModel | @@ -174,8 +203,15 @@ class DetailModel | ||
174 | 'goodsInstore' => $baseInfo['storage'], | 203 | 'goodsInstore' => $baseInfo['storage'], |
175 | ); | 204 | ); |
176 | 205 | ||
206 | + // 是否收藏 | ||
207 | + $result['isCollect'] = false; | ||
208 | + if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') { | ||
209 | + $result['isCollect'] = true; | ||
210 | + } | ||
211 | + | ||
177 | // 底部简介的URL链接 | 212 | // 底部简介的URL链接 |
178 | $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html'); | 213 | $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html'); |
214 | + $result['id'] = $productId; | ||
179 | } | 215 | } |
180 | 216 | ||
181 | return $result; | 217 | return $result; |
@@ -17,12 +17,10 @@ class DetailController extends AbstractAction | @@ -17,12 +17,10 @@ class DetailController extends AbstractAction | ||
17 | public function indexAction() | 17 | public function indexAction() |
18 | { | 18 | { |
19 | $productId = $this->param('productId'); | 19 | $productId = $this->param('productId'); |
20 | - $productId = 22399; | ||
21 | if (!is_numeric($productId)) { | 20 | if (!is_numeric($productId)) { |
22 | $this->error(); | 21 | $this->error(); |
23 | } | 22 | } |
24 | $goodsId = $this->param('goodsId'); | 23 | $goodsId = $this->param('goodsId'); |
25 | - $goodsId = 32443; | ||
26 | if (!is_numeric($goodsId)) { | 24 | if (!is_numeric($goodsId)) { |
27 | $this->error(); | 25 | $this->error(); |
28 | } | 26 | } |
@@ -60,7 +60,55 @@ class OptController extends AbstractAction | @@ -60,7 +60,55 @@ class OptController extends AbstractAction | ||
60 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | 60 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); |
61 | break; | 61 | break; |
62 | } | 62 | } |
63 | + } while (false); | ||
64 | + | ||
65 | + $this->echoJson($result); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * 商品收藏/取消收藏 | ||
70 | + * | ||
71 | + * @param int id 商品ID | ||
72 | + * @param string opt 操作标识("ok":表示收藏,"cancel":表示取消收藏) | ||
73 | + * @return json | ||
74 | + */ | ||
75 | + public function favoriteProductAction() | ||
76 | + { | ||
77 | + $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | ||
63 | 78 | ||
79 | + do { | ||
80 | + /* 判断是否是AJAX请求 */ | ||
81 | + if (!$this->isAjax()) { | ||
82 | + break; | ||
83 | + } | ||
84 | + | ||
85 | + /* 判断品牌ID是否有效 */ | ||
86 | + $id = $this->post('id'); | ||
87 | + if (!is_numeric($id)) { | ||
88 | + break; | ||
89 | + } | ||
90 | + | ||
91 | + /* 判断用户是否登录 */ | ||
92 | + $uid = $this->getUid(); | ||
93 | + if (!$uid) { | ||
94 | + $referer = $this->server('HTTP_REFERER', SITE_MAIN); | ||
95 | + $result = array('code' => 400, 'message' => '未登录', 'data' => Helpers::url('/signin.html', array('refer' => $referer))); | ||
96 | + break; | ||
97 | + } | ||
98 | + | ||
99 | + /* 取消收藏 */ | ||
100 | + $opt = $this->post('opt', 'ok'); | ||
101 | + if ($opt !== 'ok') { | ||
102 | + $result = BrandData::favoriteCancel($id, $uid, false); | ||
103 | + break; | ||
104 | + } | ||
105 | + | ||
106 | + /* 收藏 */ | ||
107 | + $result = BrandData::favorite($id, $uid, false); | ||
108 | + if (!isset($result['code'])) { | ||
109 | + $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | ||
110 | + break; | ||
111 | + } | ||
64 | } while (false); | 112 | } while (false); |
65 | 113 | ||
66 | $this->echoJson($result); | 114 | $this->echoJson($result); |
@@ -33,12 +33,12 @@ application.debug = False | @@ -33,12 +33,12 @@ application.debug = False | ||
33 | application.servers.config = APPLICATION_PATH "/configs/core" | 33 | application.servers.config = APPLICATION_PATH "/configs/core" |
34 | 34 | ||
35 | ;出错的时候是否抛出异常 | 35 | ;出错的时候是否抛出异常 |
36 | -application.dispatcher.throwException = False | 36 | +application.dispatcher.throwException = True |
37 | 37 | ||
38 | ;是否使用默认的异常 捕获Controller, 如果开启, 在有未捕获的异常的时候, | 38 | ;是否使用默认的异常 捕获Controller, 如果开启, 在有未捕获的异常的时候, |
39 | ;控制权会交给ErrorController的errorAction 方法, | 39 | ;控制权会交给ErrorController的errorAction 方法, |
40 | ;可以通过$request->getException()获得此异常对象 | 40 | ;可以通过$request->getException()获得此异常对象 |
41 | -application.dispatcher.catchException = False | 41 | +application.dispatcher.catchException = True |
42 | 42 | ||
43 | ;模板预编译目录,该目录需要有读写权限 | 43 | ;模板预编译目录,该目录需要有读写权限 |
44 | application.template.compile = ROOT_PATH "/compile/m.yohobuy.com" | 44 | application.template.compile = ROOT_PATH "/compile/m.yohobuy.com" |
@@ -126,10 +126,10 @@ routes.product.route.action = Index | @@ -126,10 +126,10 @@ routes.product.route.action = Index | ||
126 | routes.product.map.1 = productId | 126 | routes.product.map.1 = productId |
127 | routes.product.map.2 = goodsId | 127 | routes.product.map.2 = goodsId |
128 | 128 | ||
129 | -routes.buy.type = "regex" | ||
130 | -routes.buy.match = "#/product/intro_([0-9]+)/(.*).html#" | ||
131 | -routes.buy.route.module = Product | ||
132 | -routes.buy.route.controller = Detail | ||
133 | -routes.buy.route.action = Intro | ||
134 | -routes.buy.map.1 = productSkn | 129 | +routes.productintro.type = "regex" |
130 | +routes.productintro.match = "#/product/intro_([0-9]+)/(.*).html#" | ||
131 | +routes.productintro.route.module = Product | ||
132 | +routes.productintro.route.controller = Detail | ||
133 | +routes.productintro.route.action = Intro | ||
134 | +routes.productintro.map.1 = productSkn | ||
135 | 135 |
yohobuy/m.yohobuy.com/public/index-pre.php
0 → 100644
1 | +<?php | ||
2 | +use Yaf\Application; | ||
3 | + | ||
4 | +define('SITE_MAIN', 'http://m.yohobuy.com'); // 网站主域名 | ||
5 | +define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名 | ||
6 | +define('COOKIE_DOMAIN', '.m.yohobuy.com'); // COOKIE作用域 | ||
7 | +define('SUB_DOMAIN', '.m.yohobuy.com'); // 子域名后缀 | ||
8 | +define('USE_CACHE', false); // 缓存的开关 | ||
9 | +define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录 | ||
10 | +define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录 | ||
11 | +defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'preview'); | ||
12 | + | ||
13 | +$application = new Application(APPLICATION_PATH . '/configs/application.preview.ini'); | ||
14 | +$application->bootstrap()->run(); |
-
Please register or login to post a comment