Authored by hf

code review by hf: fixes some bugs

... ... @@ -23,16 +23,16 @@ class Yohobuy
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_URL = 'http://apih5.yoho.cn/';
const API_URL2 = 'http://apih5.yoho.cn/';
const SERVICE_URL = 'http://serviceh5.yoho.cn/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
// /* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://testapi.yoho.cn:28078/';
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
*
... ...
... ... @@ -726,8 +726,8 @@ class Helpers
*/
public static function syncUserSession($uid, $refer = '', $callback = 'call')
{
return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback
. '&sign=' . md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer;
return 'http://m1.yohobuy.com/Passport/session/index?callback=' . $callback
. '&sign=' .md5($uid . 'Js8Yn0!EwPM45-ws') . '&uid=' . $uid . '&go=' . $refer;
}
/**
... ... @@ -742,8 +742,8 @@ class Helpers
*/
public static function logoutSession($token, $refer = '', $callback = 'call')
{
return 'http://mapi.yohobuy.com/Passport/session/logout?callback=' . $callback
. '&sign=' . md5(md5('Js8Yn0!EwPM45-ws')) . '&token=' . $token . '&go=' . $refer;
return 'http://m1.yohobuy.com/Passport/session/logout?callback=' . $callback
. '&sign=' . md5('Js8Yn0!EwPM45-ws') . '&token=' . $token . '&go=' . $refer;
}
}
... ...
This diff could not be displayed because it is too large.
... ... @@ -10,6 +10,7 @@ require("js/index/entry");
require("js/passport/entry");
require("js/product/entry");
require("js/me/entry");
require("js/cart/entry");
module.exports = yohobuy;
... ... @@ -2327,7 +2328,7 @@ $channelLink.on('touchstart', function() {
});
});
define("js/passport/entry", ["jquery"], function(require, exports, module){
define("js/passport/entry", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
/**
* 注册、登录、密码找回打包入口
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -2349,6 +2350,9 @@ require("js/passport/back/code");
require("js/passport/back/email");
require("js/passport/back/email-success");
require("js/passport/back/new-password");
// 绑定手机号
require("js/passport/bind/bind");
});
define("js/passport/register/register", ["jquery"], function(require, exports, module){
/**
... ... @@ -3308,6 +3312,210 @@ $btnOk.on('touchstart', function() {
}
});
});
define("js/passport/bind/bind", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
/**
* 注册
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
var $ = require("jquery");
var $phoneNum = $('#phone-num'),
$countrySelect = $('#country-select'),
$areaCode = $('#area-code'),
$openId = $('#openId'),
$nickname = $('#nickname'),
$sourceType = $('#sourceType'),
$btnNext = $('#btn-next');
var api = require("js/passport/api"),
tip = require("js/plugin/tip"),
dialog = require("js/me/dialog");
var trim = $.trim;
var showErrTip = tip.show;
function nextStep(url, mobileNo, areaCode) {
$.ajax({
type: 'POST',
url: '/passport/bind/sendBindMsg',
data: {
phoneNum: mobileNo,
areaCode: areaCode.replace('+', '')
},
success: function(res) {
console.log(res.data);
location.href = url;
},
error: function() {
tip.show('出错了,请重试!');
}
});
}
api.selectCssHack($('#country-select'));
api.bindClearEvt();
$phoneNum.bind('input', function() {
if (trim($phoneNum.val()) === '') {
$btnNext.addClass('disable');
} else {
$btnNext.removeClass('disable');
}
});
$countrySelect.change(function() {
$areaCode.text($countrySelect.val());
});
$btnNext.on('touchstart', function() {
var pn = trim($phoneNum.val()),
openId = trim($openId.val()),
nickname = trim($nickname.val()),
sourceType = trim($sourceType.val()),
areaCode = $countrySelect.val();
if ($btnNext.hasClass('disable')) {
return;
}
if (api.phoneRegx[areaCode].test(pn)) {
$.ajax({
url: '/passport/bind/bindCheck',
type: 'POST',
data: {
areaCode: areaCode.replace('+', ''),
phoneNum: pn,
openId: openId,
sourceType: sourceType,
nickname: nickname
},
success: function(res) {
console.log(res);
//res : {
// code: 'xxx',
// data: {
// isReg: 0,
// next: 'xxxx'
// },
// message: 'xxxx',
//}
if (res.code === 200) {
if (res.data.isReg === 1) {
dialog.showDialog({
dialogText: '该手机号已注册过有货\n' + pn + ',确定绑定吗?',
hasFooter: {
leftBtnText: '更换号码',
rightBtnText: '继续绑定'
}
}, function() {
nextStep(res.data.next, pn, areaCode);
});
} else {
nextStep(res.data.next, pn, areaCode);
}
} else {
showErrTip(res.message);
}
}
});
} else {
showErrTip('手机号格式不正确,请重新输入');
}
});
});
define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
/*
* @Description: dialog
* @Time: 2015/11/18
* @author: chenglong.wang
*/
var $ = require("jquery"),
Handlebars = require("handlebars"),
Hammer = require("hammer");
var $dialogWrapper,
dialogTpl,
dialogTemplate;
dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
'<div class="dialog-box">' +
'{{# hasHeader}}' +
'{{/ hasHeader}}' +
'<div class="dialog-content">{{dialogText}}</div>' +
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
'</div>' +
'</div>';
dialogTemplate = Handlebars.compile(dialogTpl);
exports.showDialog = function(data, callback) {
var dialogStr = dialogTemplate(data),
$dialogBox,
defaultHideDuraton,
dialogWrapperHammer;
$('.dialog-wrapper').remove();
$('body').append($(dialogStr));
$dialogBox = $('.dialog-box');
$dialogWrapper = $('.dialog-wrapper');
dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper'));
// 显示
if (data.fast) {
$dialogWrapper.css({
display: 'block'
});
} else {
$dialogWrapper.fadeIn();
}
$dialogBox.css({
top: '50%',
marginTop: -($dialogBox.height() / 2)
});
//隐藏
if (data.autoHide) {
defaultHideDuraton = 1000;
if (data.autoHide > 1) {
defaultHideDuraton = data.autoHide;
}
setTimeout(function() {
$dialogWrapper.fadeOut();
}, defaultHideDuraton);
}
dialogWrapperHammer.on('tap', function(event) {
if ($(event.target).hasClass('dialog-left-btn')) {
$dialogWrapper.fadeOut();
} else if ($(event.target).hasClass('dialog-right-btn')) {
callback();
}
});
};
});
define("js/product/entry", ["jquery","swiper","lazyload","hammer","index"], function(require, exports, module){
/**
* 产品打包入口
... ... @@ -5939,93 +6147,6 @@ $(window).scroll(function() {
getOrders();
});
define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
/*
* @Description: dialog
* @Time: 2015/11/18
* @author: chenglong.wang
*/
var $ = require("jquery"),
Handlebars = require("handlebars"),
Hammer = require("hammer");
var $dialogWrapper,
dialogTpl,
dialogTemplate;
dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
'<div class="dialog-box">' +
'{{# hasHeader}}' +
'{{/ hasHeader}}' +
'<div class="dialog-content">{{dialogText}}</div>' +
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
'</div>' +
'</div>';
dialogTemplate = Handlebars.compile(dialogTpl);
exports.showDialog = function(data, callback) {
var dialogStr = dialogTemplate(data),
$dialogBox,
defaultHideDuraton,
dialogWrapperHammer;
$('.dialog-wrapper').remove();
$('body').append($(dialogStr));
$dialogBox = $('.dialog-box');
$dialogWrapper = $('.dialog-wrapper');
dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper'));
// 显示
if (data.fast) {
$dialogWrapper.css({
display: 'block'
});
} else {
$dialogWrapper.fadeIn();
}
$dialogBox.css({
top: '50%',
marginTop: -($dialogBox.height() / 2)
});
//隐藏
if (data.autoHide) {
defaultHideDuraton = 1000;
if (data.autoHide > 1) {
defaultHideDuraton = data.autoHide;
}
setTimeout(function() {
$dialogWrapper.fadeOut();
}, defaultHideDuraton);
}
dialogWrapperHammer.on('tap', function(event) {
if ($(event.target).hasClass('dialog-left-btn')) {
$dialogWrapper.fadeOut();
} else if ($(event.target).hasClass('dialog-right-btn')) {
callback();
}
});
};
});
define("js/me/order-detail", ["jquery","lazyload","hammer","handlebars","source-map"], function(require, exports, module){
/**
* 订单详情页
... ... @@ -8203,3 +8324,839 @@ $(window).scroll(function() {
ajaxCurrencyDetail(page);
});
define("js/cart/entry", ["jquery","lazyload","hammer","mlellipsis","handlebars","source-map"], function(require, exports, module){
/**
* 购物车打包入口
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/23
*/
require("js/cart/cart");
require("js/cart/gift-advance");
require("js/cart/order-ensure");
require("js/cart/select-coupon");
require("js/cart/select-address");
});
define("js/cart/cart", ["jquery","lazyload","hammer","mlellipsis","handlebars","source-map"], function(require, exports, module){
/**
* 购物车Logic
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/20
*/
var $ = require("jquery"),
lazyLoad = require("lazyload"),
Hammer = require("hammer");
var chosePanel = require("js/cart/chose-panel");
var $cartContent = $('.cart-content');
var navHammer,
cartType = 'ordinary';
require("js/cart/good");
lazyLoad($('img.lazy'));
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li');
if ($this.hasClass('active')) {
return;
}
if (cartType === 'ordinary') {
cartType = 'advance';
} else {
cartType = 'ordinary';
}
$this.siblings('.active').removeClass('active');
$this.addClass('active');
//切换普通商品和预售商品购物车显示
$cartContent.toggleClass('hide');
//trigger lazyload
$(window).trigger('scroll');
});
$('.btn-balance').on('touchend', function() {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
$('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
});
define("js/cart/good", ["jquery","mlellipsis","lazyload","handlebars","source-map","hammer"], function(require, exports, module){
/**
* 购物车商品
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/20
*/
var $ = require("jquery"),
ellipsis = require("mlellipsis"),
chosePanel = require("js/cart/chose-panel"),
lazyLoad = require("lazyload");
var dialog = require("js/me/dialog"),
tip = require("js/plugin/tip");
var $names,
$selectAllBtn = $('.balance .iconfont');
var requesting = false;
ellipsis.init();
lazyLoad({
try_again_css: 'order-failure'
});
$names = $('.name');
if ($names.length > 0) {
$names[0].mlellipsis(2);
}
//获取当前购物车类型
function getCartType() {
var $navItem = $('.cart-nav ').find('li'),
type = 'ordinary';
if ($navItem.eq(0).hasClass('active')) {
type = 'ordinary';
} else {
type = 'advance';
}
return type;
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this),
$good = $this.closest('.shopping-cart-good'),
id = $good.data('id');
var goodsList = [],
goodInfo = {},
isSelected = true;
if ($this.hasClass('icon-cb-checked')) {
isSelected = true;
} else {
isSelected = false;
}
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
goodInfo.goods_type = getCartType();
goodInfo.selected = isSelected ? 'N' : 'Y';
goodInfo.product_sku = id;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
goodsList.push(new GoodInfo(goodInfo));
$.ajax({
type: 'post',
url: 'select',
data: {
skuList: JSON.stringify(goodsList)
}
}).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: '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.sumPrice + ' (' + data.commonCart.count + '件)');
if (data.commonCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
}
},
error: function() {
tip.show('网络错误');
}
});
} else if (data.code === 400) {
tip.show('网络错误');
}
}).fail(function() {
tip.show('网络错误');
});
}).on('touchstart', '.icon-edit', function() {
//var $this = $(this);
//
//var $cartgood = $this.closest('.shopping-cart-good');
//
////var id = $this.closest('.shopping-cart-good').data('id');
//
//var $viewGood = $cartgood.find('.deps');
// $editGoot = $cartgood.find('.calculate-num');
//
//if ($viewGood.hasClass('show')) {
// $viewGood.removeClass('show').addClass('hide');
// $editGoot.removeClass('hide').addClass('show');
//} else {
// $viewGood.removeClass('hide').addClass('show');
// $editGoot.removeClass('show').addClass('hide');
//}
}).on('touchstart', '.icon-del', function(e) {
var $this = $(this);
e.stopPropagation();
dialog.showDialog({
dialogText: '您确定要从购物车中删除吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id');
$.ajax({
method: 'post',
url: '/cart/index/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: '网络错误~'
});
});
});
});
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
if (requesting) {
return;
}
requesting = true;
$.ajax({
url: 'select',
type: 'post',
data: {
skuList: JSON.stringify(theGoods)
},
success: function(res) {
if (res.code === 200) {
successHandeler();
} else {
tip.show(res.message);
}
},
error: function(err) {
tip.show('网络异常');
},
complete: function() {
requesting = false;
}
});
}
function didUpdateAllGoodsCheckStatus() {
var $checkedBoxs = $('.shopping-cart-good .icon-cb-checked'),
$uncheckedBoxs = $('.shopping-cart-good .icon-checkbox');
var shouldSelectAll;
if ($selectAllBtn.hasClass('icon-cb-checked')) {
$selectAllBtn.removeClass('icon-cb-checked').addClass('icon-checkbox');
shouldSelectAll = true;
} else {
$selectAllBtn.removeClass('icon-checkbox').addClass('icon-cb-checked');
shouldSelectAll = false;
}
if (!shouldSelectAll) {
$uncheckedBoxs.each(function(idx, uncheckedBox) {
$(uncheckedBox).removeClass('icon-checkbox').addClass('icon-cb-checked');
});
} else {
$checkedBoxs.each(function(idx, checkedBox) {
$(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox');
});
}
}
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
var goodInfo = {};
var $goods = $('.cart-content:not(.hide) .shopping-cart-good');
var $good = null;
var goodsList = [];
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
goodInfo.goods_type = type;
goodInfo.selected = isSelected ? 'Y' : 'N';
$goods.each(function(idx, good) {
$good = $(good);
goodInfo.product_sku = $(good).data('id');
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
goodsList.push(new GoodInfo(goodInfo));
});
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
}
//是否要全选
function willBeSelected() {
var isSelected = true;
var $this = $(this);
if ($this.hasClass('icon-cb-checked')) {
isSelected = true;
} else {
isSelected = false;
}
return isSelected;
}
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
bottomCheckBoxHandeler(willBeSelected(), getCartType(), didUpdateAllGoodsCheckStatus);
});
$('.down').on('touchend', function() {
chosePanel.show();
});
});
define("js/cart/gift-advance", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){
/**
* 赠品/加价购
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/23
*/
var $ = require("jquery"),
lazyLoad = require("lazyload"),
Handlebars = require("handlebars"),
tip = require("js/plugin/tip"),
loading = require("js/plugin/loading"),
chosePanel = require("js/cart/chose-panel");
var panelTmpl,
$page = $('.gift-advance-page'),
$chosePanel = $('#chose-panel');
lazyLoad($('.lazy'));
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
function getProductInfo(skn, promotionId) {
loading.showLoadingMask();
$.get('/cart/index/giftinfo', {
skn: skn,
promotionId: promotionId
}).then(function(res) {
if (!res) {
tip.show('网络错误');
return;
}
if (!panelTmpl) {
return;
}
if (res.code === 200) {
$chosePanel.html(panelTmpl({
cartInfo: res.data
}));
chosePanel.show();
} else {
tip.show(res.message || '网络错误');
}
}).fail(function() {
tip.show('网络错误');
}).always(function() {
loading.hideLoadingMask();
});
}
$page.on('touchend', '.chose', function() {
var $this = $(this),
id = $this.closest('.gift-advance-good').data('id'),
promotionId = $this.closest('.advance-block').data('promotion-id');
getProductInfo(id, promotionId);
});
});
define("js/cart/order-ensure", ["jquery","lazyload","hammer","handlebars","source-map"], function(require, exports, module){
/**
* 订单确认
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/12
*/
var $ = require("jquery"),
lazyLoad = require("lazyload"),
Hammer = require("hammer"),
Handlebars = require("handlebars"),
tip = require("js/plugin/tip"),
loading = require("js/plugin/loading"),
orderInfo = require("js/cart/order-info").orderInfo;
var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice'),
$price = $('.price-cal'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString();
lazyLoad();
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
if ($cur.length === 0 || $cur.hasClass('chosed')) {
return;
}
$cur.siblings('li.chosed').removeClass('chosed');
$cur.addClass('chosed');
}
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
dispatchModeHammer.on('tap', dispacthTapEvt);
dispatchTimeHammer = new Hammer(document.getElementsByClassName('dispatch-time')[0]);
dispatchTimeHammer.on('tap', dispacthTapEvt);
$('.checkbox').on('touchstart', function() {
var $this = $(this);
if ($this.hasClass('icon-cb-checked')) {
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
return;
}
if ($this.hasClass('icon-checkbox')) {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
});
$('.invoice').on('touchend', '.checkbox', function() {
var $this = $(this);
if ($this.hasClass('icon-cb-checked')) {
$('.invoice').addClass('focus');
}
if ($this.hasClass('icon-checkbox')) {
$('.invoice').removeClass('focus');
}
});
function orderCompute() {
$.ajax({
method: 'POST',
url: '/cart/index/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,
couponPrice: res.coupon_amount,
yohoCoin: res.use_yoho_coin,
price: res.last_order_amount
});
$price.html(priceHtml);
}
}).fail(function() {
tip.show('网络出错');
});
}
function submitOrder() {
if (orderInfo('invoice') && !orderInfo('invoiceText')) {
tip.show('请输入发票抬头');
return;
}
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/cart/index/orderSub',
data: {
addressId: orderInfo('addressId'),
cartType: queryString.cartType || queryString.carttype || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
msg: $('#msg').find('input').val() || orderInfo('msg'),
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
couponCode: orderInfo('couponCode'),
yohoCoin: orderInfo('yohoCoin')
}
}).then(function(res) {
var url;
if (!res) {
loading.hideLoadingMask();
tip.show('网络出错');
return;
}
if (res.code === 200) {
if (payType === 2) {
// 货到付款的进入订单页面
url = '/home/orderDetail?order_code=' + res.data.order_code;
} else {
url = '/home/pay?order_code=' + res.data.order_code;
}
window.setCookie('order-info', '');
window.location.href = url;
} else {
loading.hideLoadingMask();
tip.show(res.message || '网络出错');
}
}).fail(function() {
loading.hideLoadingMask();
tip.show('网络出错');
});
}
// 界面点击,状态存 cookie
if (!orderInfo('addressId')) {
orderInfo('addressId', $('.address-wrap').data('id'));
}
$('.dispatch-mode').on('touchend', 'li', function() {
orderInfo('deliveryId', $(this).data('id'));
orderCompute();
});
$('.dispatch-time').on('touchend', 'li', function() {
orderInfo('deliveryTimeId', $(this).data('id'));
});
$('.coin').on('touchend', function() {
var $this = $(this);
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() {
var $this = $(this);
orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked'));
});
$invoice.find('[name="invoice-title"]').on('blur', function() {
orderInfo('invoiceText', $(this).val());
}).end().find('.invoice-type').on('change', function() {
orderInfo('invoiceType', $(this).val());
});
$('#msg').find('input').on('blur', function() {
orderInfo('msg', $(this).val());
});
$('.pay-mode').on('click', 'li', function() {
var $this = $(this);
orderInfo('paymentTypeId', $this.data('pay-id'));
orderInfo('paymentType', $this.data('pay-type'));
payType = $this.data('pay-type');
submitOrder();
});
});
define("js/cart/order-info", ["jquery"], function(require, exports, module){
/**
* 订单信息读取
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require("jquery");
var info = window.cookie('order-info');
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
info = {
deliveryId: 1,
deliveryTimeId: 1,
paymentTypeId: 1,
yohoCoin: $('.coin').data('yoho-coin') || 0,
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) {
if (value === undefined) {
return info[key];
}
info[key] = value;
window.setCookie('order-info', JSON.stringify(info));
};
});
define("js/cart/select-coupon", ["jquery","handlebars","source-map","mlellipsis"], function(require, exports, module){
/**
* 优惠券选择
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/10
*/
var $ = require("jquery"),
Handlebars = require("handlebars"),
ellipsis = require("mlellipsis"),
loading = require("js/plugin/loading"),
tip = require("js/plugin/tip"),
orderInfo = require("js/cart/order-info").orderInfo;
var page = 1,
canGetCoupon = true,
isGetData;
var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
$newCoupon = $('#new-coupon');
ellipsis.init();
$newCoupon.on('submit', function() {
$.ajax({
method: 'POST',
url: '/cart/index/couponSearch',
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;
} else {
tip.show(res.message);
}
}).fail(function() {
tip.show('网络错误');
});
return false;
});
$('#coupon-list').on('touchend', '.employ-main', function() {
var $this = $(this);
orderInfo('couponCode', $this.data('coupon-code'));
orderInfo('couponValue', $this.data('coupon-value'));
});
$newCoupon.find('input').on('input', function() {
if ($(this).val() !== '') {
$newCoupon.find('.submit').css('background', '#444');
} else {
$newCoupon.find('.submit').css('background', '#b0b0b0');
}
});
function getCouponHandle(coupons) {
var notAvailableCoupons = [];
// 后端需要返回一个 coupons 列表,如下
// notAvailable 表示不可用的优惠券
// coupons = [{
// money: '99',
// coupon_name: '满XX-减去吴悠右腿有益于有2222',
// couponValidity: '20150129-20150430',
// coupon_id: '22222'
// }, {
// money: '99',
// coupon_name: '满XX-减去吴悠右腿有益于有2222',
// couponValidity: '20150129-20150430',
// coupon_id: '2222233'
// }, {
// money: '99',
// coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222',
// couponValidity: '20150129-20150430',
// coupon_id: '2222233',
// notAvailable: 1
// }];
// coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算
if (!$.isArray(coupons)) {
page--;
return;
}
// 每页10张,当不足10张时,说明已经加载完
if (coupons.length < 10) {
canGetCoupon = false;
}
// 第一页张数为 0 ,显示优惠券为空
if (!coupons.length && page === 2) {
$('.coupin-wrap').html($('#tmpl-no-coupon').html());
return;
}
// 把不可用的优惠券分离出来
$.each(coupons, function(i, coupon) {
if (coupon.notAvailable) {
notAvailableCoupons.push(coupon);
}
});
if (notAvailableCoupons.length) {
$('.not-avaliable-coupon-line').show();
}
$('#coupon-list').append(conponTmpl({
coupons: coupons
}));
$('#coupon-list-not').append(conponNotAvaliableTmpl({
notAvailableCoupons: notAvailableCoupons
}));
window.rePosFooter();
}
function getCouponDate() {
if (!canGetCoupon) {
return;
}
if (isGetData) {
return;
}
loading.showLoadingMask();
page += 1;
isGetData = true;
$.ajax({
type: 'POST',
url: '/cart/index/couponList',
dataType: 'json',
data: {
page: page
}
}).then(getCouponHandle).fail(function() {
page -= 1;
tip.show('加载优惠券失败');
}).always(function() {
isGetData = false;
loading.hideLoadingMask();
});
}
getCouponDate();
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
getCouponDate();
}
});
});
define("js/cart/select-address", ["jquery"], function(require, exports, module){
/**
* 购物车 地址选择
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require("jquery"),
orderInfo = require("js/cart/order-info").orderInfo;
$('.address-item').on('touchend', function() {
orderInfo('addressId', $(this).data('address-id'));
}).on('touchend', '.edit', function() {
window.location.href = $(this).data('href');
return false;
});
});
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -20,8 +20,13 @@ require('./back/email');
require('./back/email-success');
require('./back/new-password');
<<<<<<< HEAD
//绑定手机
require('./bind/bind');
require('./bind/code');
require('./bind/password');
=======
// 绑定手机号
require('./bind/bind');
>>>>>>> aaefe4b5074e522f16bdd6940a6387d6254a18f2
... ...