Authored by Rock Zhang

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

Conflicts:
	template/m.yohobuy.com/partials/cart/good.phtml
	yohobuy/m.yohobuy.com/application/models/Index/Cart.php
	yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
... ... @@ -18,6 +18,8 @@ class CacheConfig
const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页
const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页
const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页
const KEY_ACTION_INDEX_CONFIG = 'key_action_index_config'; // 频道配置
const KEY_ACTION_BOYS_BOTTOM_BANNER = 'key_action_boys_bottom_banner'; // 男生首页底部banner
const KEY_ACTION_GRILS_BOTTOM_BANNER = 'key_action_girls_bottom_banner';// 女生首页底部banner
... ... @@ -51,6 +53,6 @@ class CacheConfig
const KEY_ACTION_GUANG_DETAIL_DATA = 'key_action_guang_detail_data'; // 逛内容详情
const KEY_ACTION_GUANG_RSS_DATA = 'key_action_guang_detail_data'; // 逛订阅内容
const KEY_ACTION_ADDRESS_LIST_DATA = 'key_action_address_list_data'; // 地址树数据
const KEY_ACTION_ADDRESS_LIST_DATA = 'key_action_address_list_data'; // 地址树数据
}
... ...
... ... @@ -77,7 +77,8 @@ class IndexData
{
$param = Yohobuy::param();
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/entrance/getEntrance',$param,3600);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/entrance/getEntrance', $param);
}
}
... ...
... ... @@ -20,7 +20,7 @@ var requesting = false;
ellipsis.init();
lazyLoad({
try_again_css: 'order-failure'
try_again_css: 'good-failure'
});
... ...
... ... @@ -10,7 +10,7 @@ var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
orderInfo = require('./order-info').orderInfo;
order = require('./order-info');
var dispatchModeHammer,
dispatchTimeHammer,
... ... @@ -18,10 +18,15 @@ var dispatchModeHammer,
$price = $('.price-cal'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString();
queryString = $.queryString(),
orderInfo = order.orderInfo;
lazyLoad();
if (window.getUid() !== orderInfo('uid')) {
order.init();
}
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
... ... @@ -79,6 +84,15 @@ function orderCompute() {
if (!res) {
tip.show('网络出错');
} else {
if (res.order_amount) {
res.order_amount = (+res.order_amount).toFixed(2);
}
if (res.discount_amount) {
res.discount_amount = (+res.discount_amount).toFixed(2);
}
if (res.last_order_amount) {
res.last_order_amount = (+res.last_order_amount).toFixed(2);
}
priceHtml = priceTmpl({
sumPrice: res.order_amount,
salePrice: res.discount_amount,
... ...
... ... @@ -6,11 +6,9 @@
var $ = require('jquery');
var info = window.cookie('order-info');
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
function init() {
info = {
uid: window.getUid(),
deliveryId: 1,
deliveryTimeId: 1,
paymentTypeId: 1,
... ... @@ -26,6 +24,15 @@ try {
window.setCookie('order-info', JSON.stringify(info));
}
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
init();
}
exports.init = init;
exports.orderInfo = function(key, value) {
if (value === undefined) {
return info[key];
... ...
... ... @@ -22,18 +22,24 @@ var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
ellipsis.init();
$newCoupon.on('submit', function() {
var $this = $(this);
if (!$this.find('[name="couponCode"]').val()) {
tip.show('请输入优惠券码');
return false;
}
$.ajax({
method: 'POST',
url: '/cart/index/couponSearch',
data: $(this).serialize()
data: $this.serialize()
}).then(function(res) {
if (res.code === 200) {
tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
orderInfo('couponValue', res.data.coupon_value);
window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code;
window.location.href = '/cart/index/orderEnsure';
} else {
tip.show(res.message);
tip.show(res.message || '网络错误');
}
}).fail(function() {
tip.show('网络错误');
... ...
... ... @@ -93,7 +93,7 @@ $addressForm.on('submit', function() {
loading.hideLoadingMask();
} else {
if (queryString.refer === 'shopping') {
window.location.href = '/shoppingCart/selectAddress';
window.location.href = '/cart/index/selectAddress';
} else {
window.location.href = '/home/address';
}
... ...
... ... @@ -43,6 +43,7 @@ optHammer.on('tap', function(e) {
$('#dialog-wrapper').hide();
if (!res) {
tip.show('网络错误');
return;
}
if (res.code === 200) {
tip.show('删除成功');
... ... @@ -74,6 +75,7 @@ optHammer.on('tap', function(e) {
$('#dialog-wrapper').hide();
if (!res) {
tip.show('网络错误');
return;
}
if (res.code === 200) {
tip.show('取消成功');
... ...
... ... @@ -18,4 +18,10 @@ require('./back/mobile');
require('./back/code');
require('./back/email');
require('./back/email-success');
require('./back/new-password');
\ No newline at end of file
require('./back/new-password');
//绑定手机
require('./bind/bind');
require('./bind/code');
require('./bind/password');
... ...
... ... @@ -78,8 +78,14 @@ $.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
$cart.find('.num-tag').html(data.data.cart_goods_count).removeClass('hide');
count = data.data.cart_goods_count || 0;
if (count > 99) {
count = '99+';
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
}
});
... ...
.order-failure {
background-image: image-url('lazy-failure/order-good.jpg');
background-size: 100%;
}
\ No newline at end of file
}
.good-failure {
background-image: image-url('lazy-failure/order-good.jpg');
background-size: 132rem / $pxConvertRem !important;
background-position-x: 40%;
}
... ...
... ... @@ -75,6 +75,20 @@
.goods {
margin-right: -20rem / $pxConvertRem;
.price-wrap {
position: static;
text-align: left;
.price {
color: #444;
}
.count {
display: inline;
margin-left: 20rem / $pxConvertRem;
}
}
}
.sale-invoice {
... ... @@ -148,21 +162,27 @@
}
}
.block input {
box-sizing: border-box;
margin: pxToRem(20px) 0;
padding: 0 pxToRem(12px);
width: 100%;
height: pxToRem(60px);
color: #444;
background: #efefef;
font-size: pxToRem(16px);
line-height: 1;
outline: 0;
border: 0;
@include border-radius(4px);
}
#invoice {
input {
width: 100%;
height: pxToRem(90px);
outline: 0;
border: 0;
border-top: 1px solid #f7f7f7;
border-bottom: 1px solid #f7f7f7;
}
border-top: 1px solid #f7f7f7;
label {
position: relative;
width: 100%;
height: pxToRem(90px);
border-bottom: 1px solid #f7f7f7;
display: block;
border-top: 1px solid #f7f7f7;
}
select {
... ... @@ -178,13 +198,7 @@
#msg {
padding-top: pxToRem(20px);
input {
padding: pxToRem(10px);
width: pxToRem(580px);
height: pxToRem(50px);
outline: 0;
border: 0;
border: 1px solid #f7f7f7;
border-radius: pxToRem(4px);
margin: 0;
}
}
... ...
... ... @@ -480,16 +480,19 @@ $basicBtnC:#eb0313;
}
}
.num-tag {
position: absolute;
left: pxToRem(66px);
height: pxToRem(20px);
display: block;
width: pxToRem(36px);
height: pxToRem(36px);
background-color: $basicBtnC;
border-radius: 50%;
position: absolute;
top: 0;
left: pxToRem(48px);
width: pxToRem(72px);
height: pxToRem(72px);
font-size: pxToRem(40px);
line-height: pxToRem(72px);
color: #fff;
font-size: pxToRem(24px);
background: $basicBtnC;
text-align: center;
border-radius: 50%;
@include transform(scale(0.5));
&.hide{
display: none;
}
... ...
... ... @@ -41,10 +41,10 @@
<section class="block">
<ul class="sale-invoice">
{{# coupon}}
<li class="coupon">
<a href="/cart/index/selectCoupon">
<span class="title">优惠券</span>
<li class="coupon">
<a href="/cart/index/selectCoupon">
<span class="title">优惠券</span>
{{# coupon}}
{{#if count}}
<span class="coupon-count">
{{count}}张可用
... ... @@ -62,13 +62,12 @@
<i class="iconfont">&#xe614;</i>
</span>
{{/if}}
</a>
</li>
{{/coupon}}
{{/coupon}}
</a>
</li>
<li class="coin" data-yoho-coin="{{yohoCoin}}">
<span class="title">YOHO币</span>
<span class="desc">可抵¥{{yohoCoin}}</span>
<span class="desc">可抵¥{{yohoCoin}}</span>
<span class="coin-check">
<em>- ¥ {{yohoCoin}}</em>
<i class="iconfont checkbox icon-cb-checked"></i>
... ...
... ... @@ -10,7 +10,7 @@
{{/if}}
<div class="info">
<img class="thumb lazy" data-original={{url}}>
<img class="thumb lazy" data-original={{thumb}}>
{{#if isAdvanceBuy}}
<p class="few-tag plus-tag">加价购</p>
{{^}}
... ... @@ -51,7 +51,6 @@
{{/if}}
<span class="iconfont icon-del" data-count="{{count}}">&#xe621;</span>
</p>
<p class="row">
... ...
... ... @@ -466,8 +466,10 @@ class HomeController extends AbstractAction
*/
public function onlineServiceDetailAction()
{
$cateId = $this->get('cateId', 0);
$cateName = $this->get('cateName', '');
$cateInfo = $this->get('cateInfo', '');
$cate = explode("_", $cateInfo);
$cateId = intval($cate[0]);
$cateName = $cate[1];
if ($cateId > 0) {
$service = Home\OnlineModel::getOnlineServiceDetail($cateId);
}
... ... @@ -831,7 +833,7 @@ class HomeController extends AbstractAction
/**
* 订单详情页
*/
public function orderDetailAction()
public function orderdetailAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
... ...
... ... @@ -23,12 +23,14 @@ class IndexController extends AbstractAction
// 设置浏览器缓存5分钟
$this->setExpires(300);
}
$result = Index\HomeModel::getChannel();
$result['background'] = Index\HomeModel::getBgImage();
$result['channelPage'] = true;
$result['showDownloadApp'] = true;
$result['searchUrl'] = Helpers::url('', null, 'search');
$result['pageFooter'] = true;
// 渲染模板
$this->_view->display('index', $result);
}
... ...
... ... @@ -39,7 +39,7 @@ class OnlineModel
if ($sub) {
foreach ($sub as $sk => $sv) {
$qTmp[$sk]['title'] = $sv['category_name'];
$qTmp[$sk]['link'] = Helpers::url('/home/onlineservicedetail', array('cateId' => $sv['id'], 'cateName' => $sv['category_name']));
$qTmp[$sk]['link'] = Helpers::url('/home/onlineservicedetail', array('cateInfo' => $sv['id'].'_'.$sv['category_name']));
}
}
$question[$key]['list'] = $qTmp;
... ...
... ... @@ -80,7 +80,7 @@ class OrderModel
$result[$key]['sumCost'] = $vo['amount'];
//类内调用格式化订单商品数据方法
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
$result[$key]['detailUrl'] = Helpers::url('/home/orderDetail', array('order_code' => $vo['order_code']));
$result[$key]['detailUrl'] = Helpers::url('/home/orderdetail', array('order_code' => $vo['order_code']));
$result[$key]['count'] = $count;
}
}
... ...
... ... @@ -52,7 +52,7 @@ class CartModel
*/
public static function getCartData($uid, $shoppingKey, $cartType = 'all', $onlyGift = false, $onlyAdvanceBuy = false)
{
$result = array();
$result = array('cartNav' => true, 'commonGoodsCount' => '0', 'presellGoodsCount' => '0');
// 用户是否登录
if (empty($uid)) {
... ... @@ -79,21 +79,21 @@ class CartModel
break;
}
$ordinaryCount = intval($cart['ordinary_cart_data']['shopping_cart_data']['goods_count']);
$advanceCount = intval($cart['advance_cart_data']['shopping_cart_data']['goods_count']);
$ordinaryCount = strval($cart['ordinary_cart_data']['shopping_cart_data']['goods_count']);
$advanceCount = strval($cart['advance_cart_data']['shopping_cart_data']['goods_count']);
// 普通购物车和预售购物车都为空
if ($ordinaryCount === 0 && $advanceCount === 0) {
if ($ordinaryCount === '0' && $advanceCount === '0') {
$result['isEmptyCart'] = true;
break;
}
/* 普通购物车 */
$result['commonGoodsCount'] = $ordinaryCount;
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
/* 预售购物车 */
$result['presellGoodsCount'] = $advanceCount;
$result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
}while(0);
} while(false);
return $result;
}
... ... @@ -188,8 +188,8 @@ class CartModel
if (empty($uid)) {
$result['code'] = 300;
$reult['message'] = '请先登录';
$result['data'] = '/signin.html';
$result['message'] = '请先登录';
$result['data'] = Helpers::url('/signin.html');
return $result;
}
... ...
... ... @@ -20,6 +20,7 @@ use Configs\CacheConfig;
class HomeModel
{
/* 频道选择页取背景图片的位置码 */
const CODE_BG = '7ba9118028f9b22090b57341487567eb';
/* 男生楼层资源的位置码 */
... ... @@ -70,7 +71,8 @@ class HomeModel
/**
* 设置选择的频道保存到浏览器COOKIE
*
* (已废弃,改成JS设置)
*
* @param string $cookie
* @return void
*/
... ... @@ -99,10 +101,10 @@ class HomeModel
// 调用接口获取数据
$banner = IndexData::getBannerStart(self::CODE_BG);
if (isset($banner['code']) && $banner['code'] == 200 && !empty($banner['data'])) {
$imgArr = $banner['data'][0]['data'];
if (isset($banner['data'][0]['data']['list'])) {
$imgArr = $banner['data'][0]['data']['list'];
}
$imgArr = $banner['data'][0]['data'];
if (isset($banner['data'][0]['data']['list'])) {
$imgArr = $banner['data'][0]['data']['list'];
}
$result = Helpers::getImageUrl($imgArr[0]['src'], 640, 800, 2);
}
... ... @@ -128,7 +130,7 @@ class HomeModel
public static function getBottomBanner($channel)
{
$result = false;
if($channel == 2) {
if ($channel == 2) {
$resource = self::CODE_NAME_GIRLS_BOTTOM_BANNER;
$cache = CacheConfig::KEY_ACTION_GRILS_BOTTOM_BANNER;
} else {
... ... @@ -324,45 +326,65 @@ class HomeModel
*
* @return array
*/
public static function getChannel(){
public static function getChannel()
{
$result = array();
$result['showYohood'] = false;
$data = IndexData::channelData();
if (USE_CACHE) {
$key = CacheConfig::KEY_ACTION_INDEX_CONFIG;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
$channelList = array();
if(isset($data['data']['list'])){
foreach($data['data']['list'] as $key => $value){
switch ($value['channel_id']) {
case 5:
$result['showYohood'] = true;
$result['yohoodHref'] = '/yohood';
break;
$data = IndexData::channelData();
if (!empty($data['data']['list'])) {
$build = array();
foreach ($data['data']['list'] as $value) {
$build = array();
switch (intval($value['channel_id'])) {
case 1:
$channelList[$key]['href'] = '/boys';
$channelList[$key]['title'] = '男生';
$channelList[$key]['entitle'] = 'BOYS';
$build['href'] = '/boys';
$build['title'] = '男生';
$build['entitle'] = 'BOYS';
break;
case 2:
$channelList[$key]['href'] = '/girls';
$channelList[$key]['title'] = '女生';
$channelList[$key]['entitle'] = 'GIRLS';
$build['href'] = '/girls';
$build['title'] = '女生';
$build['entitle'] = 'GIRLS';
break;
case 3:
$channelList[$key]['href'] = '/kids';
$channelList[$key]['title'] = '潮童';
$channelList[$key]['entitle'] = 'KIDS';
$build['href'] = '/kids';
$build['title'] = '潮童';
$build['entitle'] = 'KIDS';
break;
case 4:
$channelList[$key]['href'] = '/lifestyle';
$channelList[$key]['title'] = '创意生活';
$channelList[$key]['entitle'] = 'LIFESTYLE';
$build['href'] = '/lifestyle';
$build['title'] = '创意生活';
$build['entitle'] = 'LIFESTYLE';
break;
default:
case 5:
$result['showYohood'] = true;
$result['yohoodHref'] = 'http://yohood.cn';
break;
default:
continue;
}
$result['channelList'][] = $build;
}
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result);
}
$result['channelList'] = $channelList;
}
return $result;
... ...
... ... @@ -100,20 +100,23 @@ class UserModel
/**
* 处理个人中心页面优选新品数据
*
* @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
* @param int $channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
* @return array|mixed 处理之后的个人中心页面优选新品数据
*/
public static function getPreferenceData($yh_channel)
public static function getPreferenceData($channel)
{
$result = array();
// 调用接口获取个人中心页面优选新品数据
$preferenceData = UserData::preference($yh_channel);
$preferenceData = UserData::preference($channel);
// 处理个人中心页面优选新品数据
if (isset($preferenceData['data']) && !empty($preferenceData['data'])) {
foreach ($preferenceData['data'] as $val) {
$result['recommendList'][] = Helpers::formatProduct($val, false, true, true, 299, 388, false, false);
if (!empty($preferenceData['data'])) {
foreach ($preferenceData['data'] as $value) {
$value = Helpers::formatProduct($value, false, true, true, 299, 388, false, false);
if (false !== $value) {
$result['recommendList'][] = $value;
}
}
}
... ...
... ... @@ -33,12 +33,6 @@ class DetailModel
// 调用服务
$baseInfo = DetailData::baseInfo($productId, $uid);
// // 因PC目前是不判断的,先保持一致,以后有需要,可以去掉
// // 判断商品是否在架
// if (empty($baseInfo['status'])) {
// return $result;
// }
// 商品名称
if (isset($baseInfo['productName'])) {
$result['goodsName'] = $baseInfo['productName'];
... ... @@ -241,7 +235,7 @@ class DetailModel
'numInCart' => 0,
'goodsInstore' => $baseInfo['storage'], // 库存量
);
$soldOut = ($baseInfo['storage'] == 0) || ($totalStorageNum === 0);
$soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);
$notForSale = $baseInfo['attribute'] == 2;
// 显示加入购物车链接
if (!$soldOut && !$notForSale) {
... ... @@ -556,7 +550,10 @@ class DetailModel
$preference = DetailData::preference($productSkn, $channel, $brandId);
if (!empty($preference)) {
foreach ($preference as $value) {
$result['recommendList'][] = Helpers::formatProduct($value, false, true, true, 299, 388, false, false);
$value = Helpers::formatProduct($value, false, true, true, 299, 388, false, false);
if (false !== $value) {
$result['recommendList'][] = $value;
}
}
}
}
... ...
... ... @@ -338,7 +338,12 @@ class IndexController extends AbstractAction
$result = CartModel::getCouponList($uid);
}
$this->echoJson($result);
if (empty($result)) {
// 这儿需要返回空数组,勿改!!!
echo '[]';
} else {
$this->echoJson($result);
}
}
/**
... ...
... ... @@ -108,7 +108,7 @@ routes.girls.type = "rewrite"
routes.girls.match = "/girl$"
routes.girls.route.module = Index
routes.girls.route.controller = Girls
routes.girls.route.action = index
routes.girls.route.action = Index
; 商品筛选
routes.goodsfilter.type = "rewrite"
... ... @@ -147,3 +147,9 @@ routes.productintro.route.controller = Detail
routes.productintro.route.action = Intro
routes.productintro.map.1 = productSkn
; 订单相关
routes.cart.type = "rewrite"
routes.cart.match = "/home/order/detail$"
routes.cart.route.module = Index
routes.cart.route.controller = Home
routes.cart.route.action = Homedetail
\ No newline at end of file
... ...