Authored by Lynnic

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

... ... @@ -32,4 +32,58 @@ class CartData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.remove';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $swapData)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.swap';
$param['swap_data'] = $swapData;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.addfavorite';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -22,15 +22,16 @@ class BrandData
*
* @param int $id 品牌ID
* @param int $uid 用户ID
* @param bool $isBrand 是品牌还是商品
* @return array
*/
public static function favorite($id, $uid)
public static function favorite($id, $uid, $isBrand = true)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.add';
$param['id'] = $id;
$param['uid'] = $uid;
$param['type'] = 'brand';
$param['type'] = $isBrand ? 'brand' : 'product';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
... ... @@ -41,15 +42,16 @@ class BrandData
*
* @param int $id 品牌ID
* @param int $uid 用户ID
* @param bool $isBrand 是品牌还是商品
* @return array
*/
public static function favoriteCancel($id, $uid)
public static function favoriteCancel($id, $uid, $isBrand = true)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['fav_id'] = $id;
$param['uid'] = $uid;
$param['type'] = 'brand';
$param['type'] = $isBrand ? 'brand' : 'product';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
... ...
... ... @@ -205,14 +205,14 @@ class Helpers
$result['name'] = $productData['product_name'];
$result['price'] = empty($productData['market_price']) ? false : $productData['market_price'];
$result['salePrice'] = $productData['sales_price'];
if ($showPoint) {
$result['price'] && $result['price'] .= '.00';
$result['salePrice'] && $result['salePrice'] .= '.00';
}
if ($showPoint) {
$result['price'] && $result['price'] .= '.00';
$result['salePrice'] && $result['salePrice'] .= '.00';
}
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_'
. $productData['goods_list'][0]['goods_id']
. '/' . $productData['cn_alphabet'] . '.html';
. $productData['goods_list'][0]['goods_id']
. '/' . $productData['cn_alphabet'] . '.html';
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if ($isApp) {
... ...
... ... @@ -64,7 +64,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
id = $this.closest('.shopping-cart-good').data('id'),
url;
if ($this.closest('.put-in-favorite')) {
if ($this.closest('.put-in-favorite').length > 0) {
//移入收藏夹
url = '/shoppingCart/col';
... ...
.iHelp{
width: 100%;
height: auto;
overflow: hidden;
.helpSearch{
width: 90%;
height: 84rem / $pxConvertRem;
overflow: hidden;
position: relative;
margin: 0 auto;
input{
width: 100%;
height: 100%;
overflow: hidden;
border:none;
font-size: 54em / $pxConvertRem;
}
i{
height: 100%;
line-height: 88rem / $pxConvertRem;
position: absolute;
right: 20rem / $pxConvertRem;
top: 0;
color: #e0e0e0;
}
}
ul{
width: 100%;
height: auto;
overflow: hidden;
display: block;
border-top: 1px solid #e0e0e0;
li{
width: 95%;
height: 80rem / $pxConvertRem;
line-height: 84rem / $pxConvertRem;
overflow: hidden;
font-size: 54em / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
float: right;
color: #444444;
&:last-of-type{
border-bottom:none;
}
span{
width: 88%;
height: 100%;
overflow: hidden;
float: left;
}
i{
color: #e0e0e0;
}
}
}
}
\ No newline at end of file
... ...
$vip: sprite-map("me/vip/*.png", $spacing: 10px);
$fav: sprite-map("me/fav/*.png", $spacing: 5px);
@import "home", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang";
@import "home", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang", "ihelp";
... ...
{{> layout/header}}
<div class="iHelp">
<div class="helpSearch">
<input type="text">
<i class="iconfont">&#xe60f;</i>
</div>
<ul>
{{# iHelp}}
<li><a href="{{ url }}"><span>{{ name }}</span><i class="iconfont num">&#xe604;</i></a></li>
{{/ iHelp}}
</ul>
</div>
{{> layout/footer}}
... ...
... ... @@ -94,7 +94,7 @@
</a>
</div>
<div class="group-list">
<a class="list-item" href="/help.html">
<a class="list-item" href="/home/IHelp">
<span class="iconfont icon">&#xe639;</span>
帮助
<span class="iconfont num">&#xe604;</span>
... ...
... ... @@ -14,7 +14,6 @@ use Index\UserModel as UserModel;
* @package
* @copyright yoho.inc
* @version 1.0 (2015-10-28 16:28:32)
* @author fei.hong <fei.hong@yoho.cn>
*/
class HomeController extends AbstractAction
{
... ... @@ -27,7 +26,12 @@ class HomeController extends AbstractAction
public function init()
{
// 检查用户是否登录, 未登录则跳转到登录页
$uid = 8826435; //$this->getUid(true);
// @todo 为了方便测试,支持传uid参数
$uid = $this->getUid();
if (!$uid) {
$uid = $this->_uid = $this->get('uid', 8826435); //$this->getUid(true);
}
$action = $this->getRequest()->getActionName();
if (!$uid && $action !== 'index') {
$this->go(Helpers::url('/signin.html'));
... ... @@ -654,4 +658,28 @@ class HomeController extends AbstractAction
$this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true));
}
}
/**
* 帮助列表页
*/
private function IHelpAction()
{
$this->setTitle('帮助中心');
$this->setNavHeader('帮助中心');
$data = array(
'iHelp' => array(
array('name' => '新用户注册','url' => 'http://m.dev.yohobuy.com/' ),
array('name' => '交款须知' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '服务条款' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '网站订购流程' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '会员登录' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '网站订单修改' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => 'YOHO币' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '常见问题' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '支付方式' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '发票制度说明' ,'url' => 'http://m.dev.yohobuy.com/'),
array('name' => '配送时间' ,'url' => 'http://m.dev.yohobuy.com/')
)
);
$this->_view->display('i-help', $data);
}
}
... ...
<?php
use Action\AbstractAction;
use Index\CartModel;
use Plugin\Helpers;
/**
* 购物车
*/
class ShoppingCartController extends AbstractAction
{
protected $_uid;
/**
* 初始化
*/
public function init()
{
// 检查用户是否登录, 未登录则跳转到登录页
$this->_uid = $this->getUid();
if (!$this->_uid) {
$this->go(Helpers::url('/signin.html'));
}
parent::init();
}
/*
* 首页
*/
public function indexAction()
{
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$uid = $this->getUid();
$data = array(
'shoppingCartPage' => true,
'shoppingCart' => \Index\CartModel::getCartData($uid)
'shoppingCart' => CartModel::getCartData($this->_uid)
);
// 渲染模板
$this->_view->display('index', $data);
}
/**
* 移出购物车
*/
public function delAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$result = CartModel::removeFromCart($this->_uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移入收藏夹
*/
public function colAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$result = CartModel::addToFav($this->_uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$params = array();
$params['old_product_sku']= $this->post('old_product_sku', 0);
$params['new_product_sku']= $this->post('new_product_sku', 0);
$params['buy_number']= $this->post('buy_number', 0);
$params['selected']= $this->post('selected', null);
$result = CartModel::modifyCartProduct($this->_uid, $params);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
public function giftAdvanceAction()
{
$data = array(
... ...
... ... @@ -51,6 +51,75 @@ class CartModel
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::addToFav($uid, $swapData);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
return $result;
}
/**
* 处理不同类型的购物车数据
... ... @@ -65,7 +134,7 @@ class CartModel
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_id'];
$oneGoods['id'] = $value['product_sku'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
... ...
... ... @@ -31,15 +31,44 @@ class DetailModel
if (is_numeric($productId) && is_numeric($goodsId)) {
// 调用服务
$baseInfo = DetailData::baseInfo($productId, $uid);
$baseInfo = DetailData::baseInfo($productId, $uid);
// 判断商品是否在架
if (empty($baseInfo['status'])) {
return $result;
}
// 商品名称
if (isset($baseInfo['productName'])) {
$result['goodsName'] = $baseInfo['productName'];
} else {
return $result;
}
}
// 商品标签
if (!empty($baseInfo['productTagBoList'])) {
foreach ($baseInfo['productTagBoList'] as $value) {
switch ($value['tagLabel']) {
case 'is_soon_sold_out': // 即将售磬
$result['tags']['is_soon_sold_out'] = true;
break;
case 'is_new': // 新品
$result['tags']['is_new'] = true;
break;
case 'is_discount': // 在售
$result['tags']['is_discount'] = true;
break;
case 'is_limited': // 限量
$result['tags']['is_limited'] = true;
break;
case 'is_yohood': // YOHOOD
$result['tags']['is_yohood'] = true;
break;
case 'is_advance': // 再到着
$result['tags']['is_advance'] = true;
break;
}
}
}
// 商品价格
if (isset($baseInfo['productPriceBo'])) {
$result['goodsPrice'] = array();
... ... @@ -176,6 +205,7 @@ class DetailModel
// 底部简介的URL链接
$result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html');
$result['id'] = $productId;
}
return $result;
... ...
... ... @@ -60,7 +60,55 @@ class OptController extends AbstractAction
$result = array('code' => 401, 'message' => '参数不正确', 'data' => false);
break;
}
} while (false);
$this->echoJson($result);
}
/**
* 商品收藏/取消收藏
*
* @param int id 商品ID
* @param string opt 操作标识("ok":表示收藏,"cancel":表示取消收藏)
* @return json
*/
public function favoriteProductAction()
{
$result = array('code' => 401, 'message' => '参数不正确', 'data' => false);
do {
/* 判断是否是AJAX请求 */
if (!$this->isAjax()) {
break;
}
/* 判断品牌ID是否有效 */
$id = $this->post('id');
if (!is_numeric($id)) {
break;
}
/* 判断用户是否登录 */
$uid = $this->getUid();
if (!$uid) {
$referer = $this->server('HTTP_REFERER', SITE_MAIN);
$result = array('code' => 400, 'message' => '未登录', 'data' => Helpers::url('/signin.html', array('refer' => $referer)));
break;
}
/* 取消收藏 */
$opt = $this->post('opt', 'ok');
if ($opt !== 'ok') {
$result = BrandData::favoriteCancel($id, $uid, false);
break;
}
/* 收藏 */
$result = BrandData::favorite($id, $uid, false);
if (!isset($result['code'])) {
$result = array('code' => 401, 'message' => '参数不正确', 'data' => false);
break;
}
} while (false);
$this->echoJson($result);
... ...
... ... @@ -33,12 +33,12 @@ application.debug = False
application.servers.config = APPLICATION_PATH "/configs/core"
;出错的时候是否抛出异常
application.dispatcher.throwException = False
application.dispatcher.throwException = True
;是否使用默认的异常 捕获Controller, 如果开启, 在有未捕获的异常的时候,
;控制权会交给ErrorController的errorAction 方法,
;可以通过$request->getException()获得此异常对象
application.dispatcher.catchException = False
application.dispatcher.catchException = True
;模板预编译目录,该目录需要有读写权限
application.template.compile = ROOT_PATH "/compile/m.yohobuy.com"
... ...
... ... @@ -126,10 +126,10 @@ routes.product.route.action = Index
routes.product.map.1 = productId
routes.product.map.2 = goodsId
routes.buy.type = "regex"
routes.buy.match = "#/product/intro_([0-9]+)/(.*).html#"
routes.buy.route.module = Product
routes.buy.route.controller = Detail
routes.buy.route.action = Intro
routes.buy.map.1 = productSkn
routes.productintro.type = "regex"
routes.productintro.match = "#/product/intro_([0-9]+)/(.*).html#"
routes.productintro.route.module = Product
routes.productintro.route.controller = Detail
routes.productintro.route.action = Intro
routes.productintro.map.1 = productSkn
... ...
<?php
use Yaf\Application;
define('SITE_MAIN', 'http://m.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.m.yohobuy.com'); // COOKIE作用域
define('SUB_DOMAIN', '.m.yohobuy.com'); // 子域名后缀
define('USE_CACHE', false); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'preview');
$application = new Application(APPLICATION_PATH . '/configs/application.preview.ini');
$application->bootstrap()->run();
\ No newline at end of file
... ...