Authored by biao

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

Showing 32 changed files with 880 additions and 167 deletions
... ... @@ -1282,7 +1282,7 @@
chosed: true,
name: '黄色',
colorNum:10,
shortUrl:'',
sizeNumStr:'10/20/30' //对应的商品尺码数目,用斜杠分割
},
...
... ... @@ -1292,7 +1292,8 @@
id: 2,
chosed: true,
name: 'X',
sizeNum: 2
sizeNum: 2,
colorNumStr:'10/20/30' //对应的商品颜色数目用斜杠分割
},
...
],
... ...
... ... @@ -48,6 +48,32 @@ class CartData
}
/**
* 购物车商品选择与取消接口
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public static function selectGoods($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.selected';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
$param['uid'] = $uid;
}
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车数据
*
* @param int $uid 用户ID
... ...
... ... @@ -212,9 +212,10 @@ class UserData
* @param int $uid 用户ID
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @param string $type 请求类型 get,post
* @return array YOHO币接口返回的数据
*/
public static function yohoCoinData($uid, $page = 1, $limit = 10)
public static function yohoCoinData($uid, $page = 1, $limit = 10,$type = 'get')
{
$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.lists';
... ... @@ -223,7 +224,7 @@ class UserData
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::$type(Yohobuy::API_URL, $param);
}
/**
... ...
... ... @@ -556,6 +556,86 @@ class Helpers
}
/**
* 格式化购物车商品
*
* @param array $cartGoods 购物车商品列表
* @param bool $haveLink 控制是否需要商品链接
*/
public static function formatCartGoods($cartGoods, $haveLink = false)
{
$arr = array();
$oneGoods = array();
foreach ($cartGoods as $key => $value) {
$oneGoods['id'] = $value['product_sku'];
$oneGoods['skn'] = $value['product_skn'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 120, 120) : '';
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = ($value['buy_number'] < $value['storage_number']);
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
if (!isset($value['goods_type'])) {
$oneGoods['soldOut'] = true;
} elseif ($value['goods_type'] == 'gift') {
$oneGoods['gift'] = true;
} elseif ($value['goods_type'] == 'price_gift') {
$oneGoods['advanceBuy'] = true;
}
// 上市期
if (!empty($value['expect_arrival_time'])) {
$oneGoods['appearDate'] = $value['expect_arrival_time'];
}
// 商品链接
if ($haveLink && isset($value['product_id'])) {
$oneGoods['link'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $value['cn_alphabet'] . '.html');
}
$arr[$key] = $oneGoods;
}
return $arr;
}
/**
* 格式化加价购商品
*
* @param array $advanceGoods 加价购商品列表
* @param bool $haveLink 控制是否需要商品链接
*/
public static function formatAdvanceGoods($advanceGoods)
{
$arr = array();
$gift = array();
$oneGoods = array();
foreach ($advanceGoods as $value) {
$gift = array();
$gift['promotionTitle'] = $value['promotion_title'];
foreach ($value['goods_list'] as $single) {
$oneGoods['id'] = $single['product_skn'];
$oneGoods['name'] = $single['product_name'];
$oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 120) : '';
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $single['last_price'];
$oneGoods['marketPrice'] = $single['market_price'];
$oneGoods['count'] = $single['storage_number'];
$gift['goods'][] = $oneGoods;
}
$arr[] = $gift;
}
return $arr;
}
/**
* 订单状态,按订单支付类型和订单状态
* @var array
*/
... ...
var $ = require('jquery');
var page = 1;
function ajaxCurrencyDetail(page) {
$.ajax({
type: 'POST',
url: '/home/ajaxCurrencyDetail',
dataType: 'html',
data: {
page: page
},
success: function(data) {
$('.coin-detail').append(data);
window.rePosFooter();
}
});
}
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() > $('body').height() - 1) {
page++;
ajaxCurrencyDetail(page);
return;
}
});
ajaxCurrencyDetail(page);
\ No newline at end of file
... ...
... ... @@ -18,3 +18,4 @@ require('./address-act');
require('./logistic');
require('./pay');
require('./personal-details');
require('./currency');
... ...
... ... @@ -5,6 +5,7 @@
*/
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var $cartContent = $('.cart-content');
... ... @@ -13,6 +14,8 @@ var navHammer;
require('./good');
lazyLoad($('img.lazy'));
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li');
... ...
... ... @@ -58,21 +58,51 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}).on('touchstart', '#chose-btn-sure', function() {
//确定
}).on('touchstart', '.block', function() {
}).on('touchstart', '.block', function(e) {
//尺寸颜色点选
var $this = $(this);
if ($this.hasClass('.chosed') || $this.hasClass('disable')) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
numArray,
index;
if ($this.hasClass('chosed')) {
$this.parent().find('.block').removeClass('chosed');
$that.find('.num .left-num').html('');
} else if ($this.hasClass('disable')) {
$this.css('background-color', '#000');
return;
} else if (!$this.hasClass('chosed')) {
$this.siblings('.chosed').removeClass('chosed');
$this.addClass('chosed');
index = $this.index();
//根据颜色切换图片
if ($this.closest('.block-list').hasClass('color-list')) {
$('.chose-panel .basic-info').find('.thumb').addClass('hide').eq(index).removeClass('hide');
}
//剩余的商品数
if ($that.find('.color-list ul>li').hasClass('chosed') && $that.find('.size-list ul>li').hasClass('chosed')) {
numArray = $this.closest('.block-list').siblings(':first').find('.chosed').data('numstr').split('/');
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
} else {
$that.find('.num .left-num').html('');
}
//点击切换
}
$this.siblings('.chosed').removeClass('chosed');
$this.addClass('chosed');
}).on('touchstart', '.btn-minus', function() {
var num = +$num.val();
if (num === 1) {
//若颜色和尺码没有被同时选中,则不能点击
if ($('.block-list>ul>li.chosed').length < 2) {
return;
}
if (num === 0) {
return;
}
... ... @@ -80,6 +110,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}).on('touchstart', '.btn-plus', function() {
var num = +$num.val();
//若颜色和尺码没有被同时选中,则不能点击
if ($('.block-list>ul>li.chosed').length < 2) {
return;
}
//TODO:库存数验证
$num.val(num + 1);
});
... ...
... ... @@ -8,78 +8,151 @@ var $ = require('jquery'),
ellipsis = require('mlellipsis'),
lazyLoad = require('yoho.lazyload');
var chosePanel = require('./chose-panel');
var dialog = require('../me/dialog'),
tip = require('../plugin/tip');
var $curDelPanel;
var $names;
//删除面板显示后任何点击行为都将触发隐藏面板
function docTouchEvt() {
$curDelPanel && $curDelPanel.addClass('hide');
//chosePanel = require('./chose-panel');
//
$(document).off('touchstart', docTouchEvt);
}
var cartType = 'ordinary';
//var $curDelPanel;
////删除面板显示后任何点击行为都将触发隐藏面板
//function docTouchEvt() {
// $curDelPanel && $curDelPanel.addClass('hide');
//
// //
// $(document).off('touchstart', docTouchEvt);
//}
ellipsis.init();
lazyLoad($('.lazy'));
lazyLoad({
try_again_css: 'order-failure'
});
$('.name')[0].mlellipsis(2);
$names = $('.name');
if ($names.length > 0) {
$names[0].mlellipsis(2);
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this);
if ($this.hasClass('icon-cb-checked')) {
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
}).on('touchstart', '.icon-edit', function() {
var id = $(this).closest('.shopping-cart-good').data('id');
var $this = $(this),
id = $(this).closest('.shopping-cart-good').data('id');
$.ajax({
type: 'GET',
url: '/shoppingCart/goodinfo',
url: '/shoppingCart/select',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
chosePanel.show(data.data);
}
}).then(function(data) {
if (data.code === 200) {
if ($this.hasClass('icon-cb-checked')) {
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
}
$.ajax({
type: 'GET',
url: '/shoppingCart/getCartData',
data: {
id: id
},
success: function(data) {
if (data) {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html(data.commonCart.count + '件总计:¥' + data.commonCart.sumPrice);
}
},
error: function() {
tip.show('网络错误');
}
});
}).fail(function() {
tip.show('网络错误');
});
}).on('touchstart', '.icon-edit', function() {
}).on('touchstart', '.icon-del', function(e) {
var $this = $(this);
e.stopPropagation();
//手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板
docTouchEvt();
$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
$(document).on('touchstart', docTouchEvt);
}).on('touchstart', '.opt-panel', function() {
var $this = $(this),
id = $this.closest('.shopping-cart-good').data('id'),
url;
if ($this.closest('.put-in-favorite').length > 0) {
//移入收藏夹
url = '/shoppingCart/col';
} else {
//删除
url = '/shoppingCart/del';
}
//docTouchEvt();
//
//$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
//
//$(document).on('touchstart', docTouchEvt);
$.ajax({
type: 'POST',
url: url,
data: {
id: id
dialog.showDialog({
dialogText: '您确定要从购物车中删除吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id');
$.ajax({
method: 'post',
url: '/shoppingCart/del',
data: {
id: id
}
}).then(function(data) {
if (data.code === 200) {
dialog.showDialog({
dialogText: '删除成功',
autoHide: true,
fast: true
});
history.go(0);
}
}).fail(function() {
dialog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
});
// .on('touchstart', '.opt-panel', function() {
// var $this = $(this),
// id = $this.closest('.shopping-cart-good').data('id'),
// url;
//
// if ($this.closest('.put-in-favorite').length > 0) {
//
// //移入收藏夹
// url = '/shoppingCart/col';
// } else {
//
// //删除
// url = '/shoppingCart/del';
// }
//
// $.ajax({
// type: 'POST',
// url: url,
// data: {
// id: id
// }
// });
//})
$('.btn-balance').on('touchend', function() {
window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType;
});
... ...
... ... @@ -7,11 +7,15 @@
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
orderInfo = require('./order-info').orderInfo;
var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice');
$invoice = $('.invoice'),
$price = $('.price-cal'),
priceTmpl = Handlebars.compile($('#tmpl-price').html());
lazyLoad();
... ... @@ -55,9 +59,77 @@ $('.invoice').on('touchend', '.checkbox', function() {
}
});
function orderCompute() {
$.ajax({
method: 'POST',
url: '/shoppingCart/orderCompute',
data: {
cartType: orderInfo('cartType'),
deliveryId: orderInfo('deliveryId'),
paymentTypeId: orderInfo('paymentTypeId'),
couponCode: orderInfo('couponCode'),
yohoCoin: orderInfo('yohoCoin')
}
}).then(function(res) {
var priceHtml;
if (!res) {
tip.show('网络出错');
} else {
priceHtml = priceTmpl({
sumPrice: res.order_amount,
salePrice: res.discount_amount,
freight: res.promotion_formula_list[1].promotion_amount,
yohoCoin: res.use_yoho_coin,
price: res.last_order_amount
});
$price.html(priceHtml);
}
}).fail(function() {
tip.show('网络出错');
});
}
function submitOrder() {
$.ajax({
method: 'POST',
url: '/shoppingCart/orderSub',
data: {
addressId: orderInfo('addressId'),
cartType: orderInfo('cartType'),
deliveryId: orderInfo('deliveryId') || 1,
deliveryTimeId: orderInfo('deliveryTimeId') || 1,
invoiceText: orderInfo('invoiceText'),
invoiceType: orderInfo('invoiceType'),
msg: orderInfo('msg'),
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
couponCode: orderInfo('couponCode'),
yohoCoin: orderInfo('yohoCoin')
}
}).then(function(res) {
if (!res) {
tip.show('网络出错');
}
if (res.code !== 200) {
tip.show(res.message || '网络出错');
} else {
console.log(1);
}
}).fail(function() {
tip.show('网络出错');
});
}
// 界面点击,状态存 cookie
if (!orderInfo('addressId')) {
orderInfo('addressId', $('.address-wrap').data('address-id'));
}
$('.dispatch-mode').on('touchend', 'li', function() {
orderInfo('deliveryId', $(this).data('id'));
orderCompute();
});
$('.dispatch-time').on('touchend', 'li', function() {
... ... @@ -69,9 +141,12 @@ $('.coin').on('touchend', function() {
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
orderInfo('yohoCoin', $this.data('yoho-coin'));
$this.find('.coin-check em').show();
} else {
orderInfo('yohoCoin', 0);
$this.find('.coin-check em').hide();
}
orderCompute();
});
$invoice.on('touchend', function() {
... ... @@ -92,4 +167,6 @@ $('#msg').find('input').on('blur', function() {
$('.pay-mode').on('click', 'li', function() {
orderInfo('paymentTypeId', $(this).data('pay-id'));
orderInfo('paymentType', $(this).data('pay-type'));
submitOrder();
});
... ...
... ... @@ -9,7 +9,20 @@ var info = window.cookie('order-info');
try {
info = JSON.parse(info);
} catch (e) {
info = {};
info = {
deliveryId: null,
deliveryTimeId: null,
paymentTypeId: null,
yohoCoin: null,
addressId: null,
couponCode: null,
couponValue: null,
invoice: null,
invoiceText: null,
invoiceType: null,
msg: null
};
window.setCookie('order-info', JSON.stringify(info));
}
exports.orderInfo = function(key, value) {
... ...
$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", "ihelp", "browse-record", "logistic", "pay";
@import "home", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang", "ihelp", "browse-record", "logistic", "pay","yoho-coin-new", "yoho-coin-detail";
... ...
.yoho-coin-detail-page {
background: #f0f0f0;
.money{
width: 100%;
height: pxToRem(70px);
background:#fff;
margin-bottom: pxToRem(20px);
line-height: pxToRem(70px);
font-size: pxToRem(30px);
text-indent: 1em;
span{
color: #f00;
font-weight: bold;
}
}
.coin-detail {
background: #fff;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
}
.detail-item {
position: relative;
margin-left: pxToRem(30px);
border-bottom: 1px solid #e0e0e0;
color: #444;
padding: pxToRem(15px) 0;
.title {
width: pxToRem(480px);
font-size: pxToRem(28px);
line-height: pxToRem(40px);
font-weight: bold;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.time {
font-size: pxToRem(20px);
line-height: pxToRem(30px);
color: #b0b0b0;
}
.count {
position: absolute;
right: 0;
top: 0;
margin-right: pxToRem(30px);
font-size: pxToRem(28px);
font-weight: bold;
line-height: pxToRem(100px);
}
}
li:last-child {
.detail-item {
border-bottom: none;
}
}
}
... ...
.yoho-coin-new-page {
padding-top: pxToRem(30px);
text-align: center;
.coin-num {
color: #d0021b;
font-size: pxToRem(66px);
font-weight: bold;
line-height: pxToRem(106px);
letter-spacing: pxToRem(8px);
}
.info {
color: #b0b0b0;
font-size: pxToRem(24px);
line-height: 1;
.dollar {
display: inline-block;
margin-right: pxToRem(6px);
vertical-align: middle;
width: pxToRem(24px);
height: pxToRem(24px);
background: image-url("me/yoho-coin/dollar.png") center center;
background-size: 100%;
}
}
.more {
display: inline-block;
margin: pxToRem(30px) 0;
color: #444;
font-size: pxToRem(24px);
line-height: pxToRem(36px);
width: pxToRem(152px);
height: pxToRem(36px);
text-align: center;
border: 1px solid #444;
border-radius: pxToRem(36px);
}
.coin-tip {
margin-bottom: pxToRem(30px);
padding: pxToRem(20px) pxToRem(30px);
font-size: pxToRem(24px);
line-height: pxToRem(32px);
color: #dc6870;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
.icon {
display: inline-block;
width: pxToRem(32px);
height: pxToRem(32px);
font-weight: bold;
border: 2px solid #dc6870;
border-radius: 50%;
}
}
.banner {
margin-bottom: pxToRem(30px);
}
}
... ...
... ... @@ -79,6 +79,11 @@
left: 0;
top: 20rem / $pxConvertRem;
}
>span.left-num{
position: absolute;
left: pxToRem(380px);
top: 20rem / $pxConvertRem;
}
}
.block {
... ... @@ -99,6 +104,11 @@
background-position: bottom right;
color: #e10;
}
&.disable {
color: #e0e0e0;
border-color: #e0e0e0;
}
}
.num {
... ...
.shopping-cart-good {
$cartRed: #d0253b;
position: relative;
padding-left: 16rem / $pxConvertRem;
... ... @@ -16,26 +17,30 @@
.info {
float: left;
margin-left: 50rem / $pxConvertRem;
margin-left: 30rem / $pxConvertRem;
padding: 16rem / $pxConvertRem 0;
border-bottom: 1px solid #e0e0e0;
padding-right: 20rem / $pxConvertRem;
}
.thumb {
float: left;
width: 120rem / $pxConvertRem;
height: 160rem / $pxConvertRem;
width: 180rem / $pxConvertRem;
height: 200rem / $pxConvertRem;
background-size: 100%;
background-repeat: no-repeat;
}
.deps {
margin-left: 135rem / $pxConvertRem;
padding-right: 20rem / $pxConvertRem;
margin-left: 173rem / $pxConvertRem;
padding-bottom: 60rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
}
.name {
font-size: 28rem / $pxConvertRem;
color: #5a5a5a;
}
.row:nth-child(2) {
font-size: 22rem / $pxConvertRem;
height: 45rem / $pxConvertRem;
... ... @@ -55,12 +60,14 @@
}
.appear-date {
color: #e01;
color: $cartRed;
display: block;
margin-top: 4rem / $pxConvertRem;
}
.price {
font-size: 24rem / $pxConvertRem;
color: #000;
color: $cartRed;
}
.count {
... ... @@ -78,7 +85,11 @@
border: none;
color: #fff;
text-align: center;
margin-left: 16rem / $pxConvertRem;
float: right;
margin-top: 20rem / $pxConvertRem;
margin-right: 16rem / $pxConvertRem;
border-radius: 20rem / $pxConvertRem;
padding: 4rem / $pxConvertRem;
}
.sold-out {
... ... @@ -86,7 +97,7 @@
}
.low-stocks {
background: #e01;
background: #7f7f7f;
}
.icon-del,
... ... @@ -140,4 +151,10 @@
}
}
}
}
\ No newline at end of file
}
.shopping-cart-good:last-child {
.deps {
border: none;
}
}
... ...
{{# currency}}
<li>
<div class="detail-item">
<p class="title">{{title}}</p>
<p class="time">{{time}}</p>
<div class="count">
{{count}}
</div>
</div>
</li>
{{/ currency}}
\ No newline at end of file
... ...
{{> layout/header}}
<div class="yoho-coin-detail-page yoho-page">
<div class="money">你拥有的有货币:<span>{{ money}}</span></div>
<ul class="coin-detail"></ul>
</div>
{{> layout/footer}}
... ...
{{> layout/header}}
<div class="yoho-coin-new-page yoho-page">
<div class="coin">
<p class="coin-num">
7876
</p>
<p class="info">
<span class="dollar"></span>
YOHO
</p>
<a href="" class="more">查看明细</a>
<div class="coin-tip">
<span class="icon">!</span>
您有300个YOHO币即将于20171231日过期,请尽快使用
</div>
</div>
<div class="banner">
<a href="">
{{!-- 演示图片 --}}
<img src="http://temp.im/640x200" alt="">
</a>
</div>
{{> home/maybe_like}}
</div>
{{> layout/footer}}
... ...
... ... @@ -81,7 +81,7 @@
优惠券
<span class="iconfont num">{{coupon_num}} &#xe604;</span>
</a>
<a class="list-item" href="/home/currency">
<a class="list-item" href="/home/currencyDetail">
<span class="iconfont icon">&#xe635;</span>
YOHO
<span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
... ...
{{> layout/header}}
<div class="order-ensure-page yoho-page">
{{# orderEnsure}}
<a class="address-wrap block" href="/shoppingCart/selectAddress">
<a class="address-wrap block" href="/shoppingCart/selectAddress" data-address-id="{{addressId}}">
<p class="infos">
收货地址
<span class="per-info">{{name}} {{phoneNum}}</span>
... ... @@ -41,7 +41,7 @@
<section class="block">
<ul class="sale-invoice">
{{# coupon}}
{{#if coupon}}
<li class="coupon">
<a href="/shoppingCart/selectCoupon">
<!-- <a href="{{url}}"> -->
... ... @@ -65,7 +65,7 @@
{{/if}}
</a>
</li>
{{/ coupon}}
{{/if}}
{{# yohoCoin}}
<li class="coin" data-yoho-coin="{{.}}">
... ... @@ -79,16 +79,16 @@
{{/ yohoCoin}}
{{#if invoice}}
<li class="invoice">
<li class="invoice {{#if needInvoice}}focus{{/if}}">
<span class="title">发票</span>
<span class="iconfont checkbox icon-checkbox"></span>
<span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
<form id="invoice">
<input type="text" name="invoice-title" value="" placeholder="发票抬头">
<input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头">
<label>
发票类型
<select class="invoice-type" name="invoice-type">
{{# invoice}}
<option value="{{id}}">{{name}}</option>
<option value="{{id}}" {{#if isSelected}}selected{{/if}}>{{name}}</option>
{{/ invoice}}
</select>
</label>
... ... @@ -98,27 +98,27 @@
</ul>
<form id="msg" action="" method="post">
<input type="text" name="msg" value="" placeholder="留言">
<input type="text" name="msg" value="{{msg}}" placeholder="留言">
</form>
</section>
<section class="block">
<section class="price-cal block">
<ul class="total">
<li>
<span>总价</span>
&nbsp;&nbsp;¥ {{sumPrice}}
&nbsp;&nbsp;¥{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥ {{salePrice}}
- ¥{{salePrice}}
</li>
<li>
<span>运费</span>
+ ¥ {{freight}}
+ ¥{{freight}}
</li>
<li>
<span>YOHO币</span>
- ¥ {{yohoCoin}}
- ¥{{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥{{price}}</em>
... ... @@ -128,7 +128,7 @@
<ul class="pay-mode">
{{# paymentWay}}
<li class="{{#if default}}default{{/if}}" data-pay-id={{id}}>
<li class="{{#if default}}default{{/if}}" data-pay-type="{{paymentType}}" data-pay-id="{{id}}">
<span class="iconfont">
{{#if default}}
&#xe62f;
... ... @@ -142,4 +142,27 @@
</ul>
{{/ orderEnsure}}
</div>
<script id="tmpl-price" type="text/tmpl">
<ul class="total">
<li>
<span>总价</span>
&nbsp;&nbsp;¥\{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥\{{salePrice}}
</li>
<li>
<span>运费</span>
+ \{{freight}}
</li>
<li>
<span>YOHO币</span>
- ¥\{{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥\{{price}}</em>
</li>
</ul>
</script>
{{> layout/footer}}
... ...
... ... @@ -324,3 +324,8 @@
seajs.use('js/me/pay');
</script>
{{/if}}
{{#if currencyDetail}}
<script>
seajs.use('js/me/currency');
</script>
{{/if}}
... ...
... ... @@ -32,26 +32,26 @@
<div class="price-compute">
<p class="sum-price">
<span class="title">总价</span>
¥{{price}}
<span id="good-totalprice">¥{{price}}</span>
</p>
<p class="activity-price">
<span class="title">
活动价
<i class="minus">-</i>
</span>
¥{{activityPrice}}
<span id="good-activityPrice">¥{{activityPrice}}</span>
</p>
</div>
<div class="balance">
<span class="iconfont icon-cb-checked"></span>
<p>
<span>
<span id="good-total">
{{count}}件总计:¥{{sumPrice}}
</span>
<span class="tip">(不含运费)</span>
</p>
<button class="btn-balance">
<a class="btn-balance">
结算
</button>
</a>
</div>
\ No newline at end of file
... ...
... ... @@ -3,7 +3,13 @@
<div class="main">
<div class="infos">
<div class="basic-info">
<img class="thumb" src={{thumb}}>
{{#thumbs}}
{{#if @first}}
<img class="thumb" src={{img}}>
{{else}}
<img class="thumb hide" src={{img}}>
{{/if}}
{{/thumbs}}
<div class="text-info">
<p class="name">{{name}}</p>
<p class="price">
... ... @@ -15,21 +21,21 @@
</div>
</div>
<div class="chose-items">
<div class="color-list">
<div class="color-list block-list">
<span>颜色</span>
<ul class="clearfix" data-type="color">
{{# colors}}
<li class="block {{#if chosed}}chosed{{/if}}" data-id={{id}}>
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}disable{{/unless}}" data-id={{id}} data-numstr="{{sizeNumStr}}">
{{name}}
</li>
{{/ colors}}
</ul>
</div>
<div class="size-list">
<div class="size-list block-list">
<span>尺码</span>
<ul class="clearfix {{#if @first}}{{^}}hide{{/if}}" data-type="size" >
<ul class="clearfix" data-type="size" >
{{# sizes}}
<li class="block {{#if chosed}}chosed{{/if}}" data-id={{id}}>
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}disable{{/unless}}" data-id={{id}} data-numstr="{{colorNumStr}}">
{{name}}
</li>
{{/ sizes}}
... ... @@ -44,8 +50,9 @@
<input id="good-num" class="good-num" type="text" value={{num}}>
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
</a>
</div>
<span class="left-num"></span>
</div>
</div>
</div>
... ...
... ... @@ -22,6 +22,9 @@
<span class="price">
¥{{price}}
</span>
<span class="price">
¥{{salePrice}}
</span>
<span class="count">
×{{count}}
</span>
... ...
... ... @@ -17,11 +17,6 @@
</span>
{{/if}}
{{#if appearDate}}
<span class="appear-date">
上市期:{{appearDate}}
</span>
{{/if}}
</p>
<p class="row">
<span class="price">
... ... @@ -36,18 +31,27 @@
</span>
{{/if}}
<span class="iconfont icon-edit">&#xe61e;</span>
<span class="iconfont icon-del">&#xe621;</span>
</p>
<p class="row">
{{#if lowStocks}}
<span class="low-stocks">
库存不足
</span>
{{/if}}
<span class="iconfont icon-edit">&#xe61e;</span>
<span class="iconfont icon-del">&#xe621;</span>
</p>
<p class="row">
{{#if appearDate}}
<span class="appear-date">
上市期:{{appearDate}}
</span>
{{/if}}
</p>
</div>
</div>
<div class="opt-panel hide">
<!--<div class="opt-panel hide">
<div class="put-in-favorite">
<span class="iconfont">&#xe622;</span>
<span>移入</span>
... ... @@ -57,5 +61,5 @@
<span class="iconfont">&#xe626;</span>
删除
</div>
</div>
</div>
\ No newline at end of file
</div>-->
</div>
... ...
... ... @@ -876,5 +876,45 @@ class HomeController extends AbstractAction
);
$this->_view->display('helpDetail', $data);
}
/**
* YOHO币详情 新版
*/
public function currencyDetailAction()
{
$this->setTitle('YOHO币');
$this->setNavHeader('YOHO币', true, false);
$data['money'] = '0';
$page = $this->post('page',1);
$size = $this->post('size', 20);
// $data = UserModel::getYohoCoinLists($this->_uid,$page,$size);
$data = UserModel::getYohoCoinLists(3965746,$page,$size);
$this->_view->display('currency-detail', array(
'money' => $data['money'],
'pageFooter' => true,
'currencyDetail' => true,
'currencyDetailPage' => true
));
}
/**
* YOHO币详情 AJAX
*/
public function ajaxCurrencyDetailAction()
{
$data['list'] = array();
$data['money'] = 0;
$page = $this->post('page',1);
$size = $this->post('size', 20);
$data = UserModel::getYohoCoinLists($this->_uid,$page,$size);
//$data = UserModel::getYohoCoinLists(3965746,$page,$size);
$this->_view->display('ajax-currency-detail', array(
'currency' => $data['list'],
'pageFooter' => true,
'currencyDetailPage' => true
));
}
}
... ...
... ... @@ -13,7 +13,6 @@ class ShoppingCartController extends AbstractAction
/*
* 购物车首页
*/
public function indexAction()
{
$this->setTitle('购物车');
... ... @@ -30,6 +29,47 @@ class ShoppingCartController extends AbstractAction
// 渲染模板
$this->_view->display('index', $data);
}
/*
* 异步获取购物车数据
*/
public function getCartDataAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$result = CartModel::getCartData($uid, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车商品选择与取消
*/
public function selectAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移出购物车
... ... @@ -155,8 +195,7 @@ class ShoppingCartController extends AbstractAction
'orderEnsurePage' => true,
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
// var_dump($data);
$this->_view->display('order-ensure', $data);
}
... ... @@ -169,10 +208,10 @@ class ShoppingCartController extends AbstractAction
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('paymentType', null);
$yohoCoin = $this->post('paymentType', null);
$deliveryWay = $this->post('deliveryId', 1);
$paymentType = $this->post('paymentTypeId', 1);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$uid = $this->getUid(true);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
}
... ... @@ -268,13 +307,13 @@ class ShoppingCartController extends AbstractAction
$uid = $this->getUid(true);
$addressId = $this->post('addressId', null);
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTime = $this->post('deliveryTime', 1); // 默认只工作日配送
$deliveryWay = $this->post('deliveryWay', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceTitle', null);
$invoiceId = $this->post('invoiceId', null);
$paymentId = $this->post('paymentId', 15);
$deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWay = $this->post('deliveryId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceText', null);
$invoiceId = $this->post('invoiceType', null);
$paymentId = $this->post('paymentTypeId', 15);
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('remark', null); // 默认在线支付
$remark = $this->post('msg', null);
$yohoCoin = $this->post('yohoCoin', 1);
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin);
}
... ... @@ -283,7 +322,7 @@ class ShoppingCartController extends AbstractAction
echo ' ';
} else {
// 提交成功清除Cookie
$this->setCookie('orderInfo', null);
$this->setCookie('order-info', null);
$this->echoJson($result);
}
... ...
... ... @@ -63,13 +63,13 @@ class CartModel
/* 普通购物车 */
if(isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
$result['commonGoodsCount'] = $cart['ordinary_cart_data']['shopping_cart_data']['goods_count'];
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
}
/* 预售购物车 */
if(isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
$result['presellGoodsCount'] = $cart['advance_cart_data']['shopping_cart_data']['goods_count'];
$result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
}
... ... @@ -79,6 +79,30 @@ class CartModel
}
/**
* 购物车商品选择与取消接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public static function selectGoods($uid, $sku, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$select = CartData::selectGoods($uid, $sku_list, $shoppingKey);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
}
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
... ... @@ -306,7 +330,7 @@ class CartModel
// cookie保存的数据
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
// $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
}
// 根据地址id查询地址信息
... ... @@ -425,13 +449,24 @@ class CartModel
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
isset($orderInfo['invoiceType']) && $one['id'] == $orderInfo['invoiceType'] && $one['isSelected'] = true;
$result['invoice'][] = $one;
}
// 发票信息需要记录
if (isset($orderInfo['invoice'])) {
$result['needInvoice'] = $orderInfo['invoice'];
$result['invoiceText'] = $orderInfo['invoiceText'];
}
}
// 留言
isset($orderInfo['msg']) && $result['msg'] = $orderInfo['msg'];
// 优惠券数据
$coupons = array('notUsed' => true);
$coupons = array();
!empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue'];
$coupons += self::getCouponList($uid, 0, 1, true);
$result['coupon'] = $coupons;
... ... @@ -540,7 +575,7 @@ class CartModel
$result = array();
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin);
if ($orderSubRes && isset($orderSubRes['code']) && $orderSubRes['code'] === 200) {
if ($orderSubRes && isset($orderSubRes['code'])) {
$result = $orderSubRes;
}
... ... @@ -559,26 +594,19 @@ class CartModel
$result = array();
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_sku'];
$oneGoods['skn'] = $value['product_skn'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = true;
$result['goods'][] = $oneGoods;
}
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
!empty($validGoods) && $result['goods'] = $validGoods;
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']);
!empty($notValidGoods) && $result['$notValidGoods'] = $notValidGoods;
// 赠品
count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
(count($data['gift_list']) || count($data['price_gift'])) && $result['freebieOrAdvanceBuy'] = true;
$result['freebie'] = $data['gift_list'];
// 加价购
$result['advanceBuy'] = $data['price_gift'];
$result['advanceBuy'] = Helpers::formatAdvanceGoods($data['price_gift']);
// 结算数据
$result['price'] = $data['shopping_cart_data']['order_amount'];
$result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
... ...
... ... @@ -369,6 +369,37 @@ class UserModel
}
/**
* 处理YOHO币变化履历数据
*
* @param int $uid 用户ID
* @param int $page 当前页
* @param int $limit 一页记录数
* @return array|mixed 处理之后的YOHO币数据
*/
public static function getYohoCoinLists($uid, $page, $limit)
{
$result = array();
// 调用接口获取YOHO币
$yohoCoin = UserData::yohoCoinData($uid, $page, $limit, 'post');
// 处理YOHO币数据
if(isset($yohoCoin['data']) && !empty($yohoCoin['data'])){
$coinList = $yohoCoin['data']['coinlist'];
$data['money'] = $yohoCoin['data']['total'];
foreach($coinList as $key => $val){
$result[$key]['title'] = $val['message'];
$result[$key]['time'] = $val['date'];
if($val['num'] > 0){
$val['num'] = '+'.$val['num'];
}
$result[$key]['count'] = $val['num'];
}
}
$data['list'] = $result;
return $data;
}
/**
* 处理优惠券数据
*
* @param int $uid 用户ID
... ...
... ... @@ -56,8 +56,8 @@ class BindController extends AbstractAction
$nickname = $this->get('nickname');
$areaCode = $this->get('areaCode', '86');
$isReg = $this->get('isReg');
$mobile=$this->get('mobile');
$phoneNum=$this->get('phoneNum');
$data = array(
'bindIndex'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
... ... @@ -68,7 +68,7 @@ class BindController extends AbstractAction
'nickname' => $nickname, //昵称
'isReg' => $isReg, //是否是已注册过的手机号
'areaCode' => $areaCode, //国别码
'phoneNum'=>$mobile,//手机号码
'phoneNum'=>$phoneNum,//手机号码
);
// 渲染模板
... ... @@ -114,31 +114,31 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$openId = $this->post('openId');
$areaCode = $this->post('areaCode', '86');
$sourceType = $this->post('sourceType');
$nickname = $this->post('nickname');
if (!is_numeric($mobile) || !$openId || !$areaCode || !$sourceType)
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType)
{
break;
}
$res = BindData::bindCheck($mobile, $openId, $sourceType);
$res = BindData::bindCheck($phoneNum, $openId, $sourceType);
if (!isset($res['code']))
{
break;
}
if ($res['code'] == 200)
{
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'mobile' => $mobile));
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum));
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next));
}
else
{
$data = array('code' => 500, 'message' => $res['message'], 'data' => $res['data']);
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => $res['data']);
}
}
while (false);
... ... @@ -159,15 +159,15 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
if (!is_numeric($mobile))
if (!is_numeric($phoneNum))
{
break;
}
$data = BindData::sendBindMsg($areaCode,$mobile);
$data = BindData::sendBindMsg($areaCode,$phoneNum);
if (!isset($data['code']))
{
break;
... ... @@ -191,16 +191,16 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$msgCode = $this->post('msgCode');
$areaCode = $this->post('areaCode');
if (!is_numeric($mobile) || !$msgCode)
if (!is_numeric($phoneNum) || !$msgCode)
{
break;
}
$data = BindData::checkBindCode($areaCode,$mobile, $msgCode);
$data = BindData::checkBindCode($areaCode,$phoneNum, $msgCode);
if (!isset($data['code']))
{
break;
... ... @@ -224,19 +224,19 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$openId = $this->post('openId');
$areaCode = $this->post('areaCode', '86');
$sourceType = $this->post('sourceType');
$nickname = $this->post('nickname');
$password = $this->post('password');
if (!is_numeric($mobile) || !$openId || !$sourceType || !$areaCode)
if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode)
{
break;
}
$res = BindData::bindMobile($openId, $nickname, $sourceType, $mobile, $areaCode, $password);
$res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password);
if (!isset($res['code']))
{
break;
... ...