Authored by yangyang

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

... ... @@ -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);
}
/**
... ...
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');
... ...
... ... @@ -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,66 @@ $('.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'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: orderInfo('invoiceText'),
invoiceType: orderInfo('invoiceType'),
msg: orderInfo('msg'),
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
couponCode: orderInfo('couponCode'),
yohoCoin: orderInfo('yohoCoin')
}
}).then(function(res) {
console.log(res);
}).fail(function() {
tip.show('网络出错');
});
}
// 界面点击,状态存 cookie
$('.dispatch-mode').on('touchend', 'li', function() {
orderInfo('deliveryId', $(this).data('id'));
orderCompute();
});
$('.dispatch-time').on('touchend', 'li', function() {
... ... @@ -69,9 +130,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 +156,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,19 @@ 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
};
}
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);
}
}
... ...
{{# 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>
... ...
... ... @@ -102,23 +102,23 @@
</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}}
... ...
... ... @@ -308,3 +308,8 @@
seajs.use('js/me/pay');
</script>
{{/if}}
{{#if currencyDetail}}
<script>
seajs.use('js/me/currency');
</script>
{{/if}}
... ...
... ... @@ -876,5 +876,44 @@ 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
));
}
}
... ...
... ... @@ -156,7 +156,6 @@ class ShoppingCartController extends AbstractAction
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
$this->_view->display('order-ensure', $data);
}
... ... @@ -169,10 +168,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 +267,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 +282,7 @@ class ShoppingCartController extends AbstractAction
echo ' ';
} else {
// 提交成功清除Cookie
$this->setCookie('orderInfo', null);
$this->setCookie('order-info', null);
$this->echoJson($result);
}
... ...
... ... @@ -369,6 +369,35 @@ 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币数据
$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
... ...
... ... @@ -134,7 +134,7 @@ class BindController extends AbstractAction
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));
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('is_register' => $res['data']['is_register'], 'next' => $next));
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next));
}
else
{
... ...