Authored by yyq

format js

Showing 67 changed files with 194 additions and 437 deletions
... ... @@ -10,7 +10,6 @@ const logger = global.yoho.logger;
const yohoHelpers = global.yoho.helpers;
const service = require('../models/cart-service');
const helper = require('../models/cart-helper');
const ghelper = require('../../guang/models/guang-helper');
const simpleHeaderModel = require('../../../doraemon/models/simple-header');
const stepper = [
... ...
... ... @@ -62,4 +62,4 @@ module.exports = {
index,
compute,
submit
};
\ No newline at end of file
};
... ...
/* eslint-disable */
module.exports = {
'北京市': 'b',
'天津市': 't',
... ... @@ -31,3 +32,4 @@ module.exports = {
'宁夏回族自治区': 'n',
'新疆维吾尔自治区': 'x'
};
/* eslint-enable */
... ...
... ... @@ -36,7 +36,8 @@ exports.QRcode = (req, res, next) => {
}
let vm = {
path: [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}, {name: '个人中心'}, {name: '订单中心'}, {name: '查看二维码'}],
path: [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'},
{name: '个人中心'}, {name: '订单中心'}, {name: '查看二维码'}],
qrcodeData: result,
code: id,
bgsrc: bg[bgkey],
... ...
... ... @@ -12,6 +12,7 @@ const getByNodeContent = (node, mode)=>{
mode: mode,
node: node
};
return api.get('', options);
};
... ...
/**
* @author: weiqingting<qingting.wei@yoho.cn>
*/
'use strict';
const helpers = global.yoho.helpers;
const Images = require('../../../utils/Images');
const formatFavBrand = (brandInfo, i)=>{
i = i || 10;
let hotBrands = [];
if (brandInfo.length > 0) {
for (let i = 0; i < brandInfo.length; i++) {
let value = brandInfo[i];
if (value.is_hot && value.is_hot == 'Y') {
hotBrands.push({
'href': helpers.urlFormat('', '', value['brand_domain']),
'logo': Images.getSourceUrl(value['brand_ico'], 'brandLogo'),
'name': value.brand_name
});
i--;
}
if (i <= 0) {
break;
}
}
}
return hotBrands;
};
const formatNew = (product)=>{
let result = [];
product.forEach(function(val, key) {
result[key] = {
href: helpers.getUrlBySkc(val['product_id'], val['goods_list'][0]['product_skc'], val['cn_alphabet']),
thumb: val['default_images'] ? Images.getImageUrl(val['default_images'], 400, 500) : '',
name: val['product_name'],
price: val['sales_price']
};
});
return result;
};
module.exports = {
formatFavBrand,
formatNew
};
/**
* @author: weiqingting<qingting.wei@yoho.cn>
*/
'use strict';
const querystring = require('querystring');
const searchApi = global.yoho.SearchAPI;
const getUrl = (type)=>{
var map = {
sort: '/sortgroup.json',
discount: '/discount.json',
recent: '/recent.json',
suggest: '/suggest.json',
'new-shelve': '/new-shelve.json',
shop: '/shops.json',
brand: '/brand/list.json'
};
return map[type] || '/search.json';
};
const getBrandListUrl = ()=>{
return getUrl('brand');
};
const getProductUrl = (condition, type)=>{
let orderMaps = {
s_t_desc: 'shelve_time:desc',
s_t_asc: 'shelve_time:asc',
s_p_asc: 'sales_price:asc',
s_p_desc: 'sales_price:desc',
p_d_desc: 'discount:desc',
p_d_asc: 'discount:asc',
skn_desc: 'product_skn:desc',
skn_asc: 'product_skn:asc',
activities_desc: 'activities.order_by:desc',
activities_asc: 'activities.order_by:asc',
s_n_asc: 'sales_num:asc',
s_n_desc: 'sales_num:desc',
activities_id_desc: 'activities.activity_id:desc',
activities_id_asc: 'activities.activity_id:asc',
brand_desc: 'brand_weight:desc'
};
let param = {
status: 1,
sales: 'Y',
outlets: 2,
stocknumber: 1,
attribute_not: 2
};
if (!condition.order) {
param.order = orderMaps.s_t_desc;
} else {
param.order = orderMaps[condition.order] ? orderMaps[condition.order] : '';
}
if (!condition.page) {
param.page = 1;
}
if (condition.viewNum) {
param.viewNum = condition.viewNum;
} else if (!condition.limit) {
param.viewNum = 60;
} else {
param.viewNum = condition.limit;
delete condition.limit;
}
if (!condition) {
param += condition;
}
return getUrl(type) + '?' + querystring.stringify(param);// searchApi.get(getUrl(type), param,{cache:true});
};
const searchAll = (param)=>{
param = param || {};
return searchApi.get(getUrl(type), param, {cache: true});
};
module.exports = {
getProductUrl,
getBrandListUrl,
searchAll
};
... ... @@ -4,19 +4,18 @@ const api = global.yoho.API;
const service = global.yoho.ServiceAPI;
const _ = require('lodash');
const URL_PRODUCT_FAVORITE = 'shops/service/v1/favorite/';
// const URL_PRODUCT_FAVORITE = 'shops/service/v1/favorite/';
const URL_ARTICLE_FAVORITE = '/guang/api/v1/favorite/';
const URL_ARTICLE_FAVORITE_BRAND = '/guang/service/v2/favorite/toggleBrand';
// const URL_ARTICLE_FAVORITE_BRAND = '/guang/service/v2/favorite/toggleBrand';
/**
* 根据uid和商品的id查询是否被用户收藏
* @param int $uid
* @param int $productId
* @param boolean $isOnlyUrl 是否指返回链接
* @return boolean 收藏 true 未收藏 false
*/
const getUidProductFav = (uid, productId, isOnlyUrl)=> {
isOnlyUrl = (isOnlyUrl === undefined) ? false : isOnlyUrl;
const getUidProductFav = (uid, productId)=> {
let options = {
method: 'web.favorite.isFavorite',
id: productId,
... ...
... ... @@ -84,6 +84,7 @@ exports.getTicketCode = (orderCode)=>{
method: 'app.SpaceOrders.getQrByOrderCode',
order_code: orderCode
};
return api.get('', options);
};
... ... @@ -132,6 +133,7 @@ exports.updateOrderPayment = (orderCode, payment, uid)=>{
payment: payment,
uid: uid
};
return api.get('', options);
};
... ...
'use strict';
const helpers = global.yoho.helpers;
const api = global.yoho.API;
/**
... ... @@ -11,6 +10,7 @@ const getRedenvelopes = uid=>{
method: 'app.yoho.redpacketList',
uid: uid
};
return api.get('', options);
};
... ... @@ -23,6 +23,7 @@ const getRedenvelopesTotal = uid=>{
method: 'app.yoho.redpacketInfo',
uid: uid
};
return api.get('', options);
};
... ...
... ... @@ -2,20 +2,13 @@
const api = global.yoho.API;
const privateKeyList = {
'android': 'fd4ad5fcfa0de589ef238c0e7331b585',
'iphone': 'a85bb0674e08986c6b115d5e3a4884fa',
'ipad': 'ad9fcda2e679cf9229e37feae2cdcf80',
'web': '0ed29744ed318fd28d2c07985d3ba633',
'h5': 'fd4ad5fcfa0de589ef238c0e7331b585'
};
const getVIPInfoByUid = (uid)=>{
let options = {
method: 'app.passport.vip',
uid: uid,
private_key: '0ed29744ed318fd28d2c07985d3ba633'
};
return api.get('', options);
};
... ... @@ -31,6 +24,7 @@ const getCouponsList = (uid, type, page, limit)=>{
page: page,
limit: limit
};
return api.get('', options);
};
... ...
... ... @@ -3,7 +3,7 @@
*/
'use strict';
const _ =require('lodash');
const _ = require('lodash');
const captchaService = require('../models/captcha-img-service');
const gtestCaptcha = require('./gee-captcha');
... ...
... ... @@ -11,7 +11,6 @@ const co = Promise.coroutine;
const _ = require('lodash');
const Fn = require('lodash/fp');
const cheerio = require('cheerio');
const url = require('url');
const helpers = global.yoho.helpers;
const config = global.yoho.config;
const crypto = global.yoho.crypto;
... ...
... ... @@ -94,7 +94,7 @@ const setSearchData = (result, params, channel) => {
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
}
return finalResult;
}
};
/**
* 转换价格
... ... @@ -144,10 +144,10 @@ exports.getSearchData = (params, channel) => {
return searchApi.getSortList(Object.assign({}, searchParams, {msort: '',
query: _.get(result, '[2]data.suggestion.terms_suggestion[0]', ''),
misort: '', sort: ''})).then(subRes => {
result[1] = subRes;
result[1] = subRes;
return setSearchData(result, params, channel);
});
return setSearchData(result, params, channel);
});
}
return setSearchData(result, params, channel);
... ... @@ -294,8 +294,8 @@ exports.getSearchLessProduct = (channelNum, uid, udid, page) => {
img: it.default_images ? helpers.image(it.default_images, 180, 240) : '',
alt: it.product_name,
price: '¥' + transPrice(it.sales_price),
marketPrice: transPrice(it.market_price) === transPrice(it.sales_price)
? false : ('¥' + transPrice(it.market_price))
marketPrice: transPrice(it.market_price) === transPrice(it.sales_price) ?
false : ('¥' + transPrice(it.market_price))
};
let firstGoods = it.goods_list && it.goods_list[0];
... ...
... ... @@ -52,33 +52,7 @@ const _shopTopBanner = data => {
return result;
};
/**
* 水牌
*/
const _signboard = data => {
let result = [];
let resources = data.resource_data;
resources.forEach(resource => {
if (_.isEmpty(resource)) {
return;
}
resource.data.forEach(val => {
result.push({
img: _imageView2(val.src, 160, 240),
url: val.url
});
});
});
return {
title: '',
list: result
};
};
const _shopTopBanner_base = _shopTopBanner;
const _shopTopBannerBase = _shopTopBanner;
/**
* 基础模板
... ... @@ -87,7 +61,7 @@ exports.basisTemplateAsync = shopId => {
return co(function * () {
let data = { shopTopBanner_base: {}};
const ResourceHandler = {
shopTopBanner_base: _shopTopBanner_base
shopTopBanner_base: _shopTopBannerBase
};
let shops = yield api.shopsDecoratorListAsync(shopId);
... ...
... ... @@ -68,21 +68,21 @@ exports.studentsNum = (data) => {
exports.studentResource = (data) => {
let dest = {couponObj: {}};
let rightsTextObj = [{
rightName: '认证立赠100有货币',
rightContent: '认证成功,立即赠送100有货币。'
},{
rightName: '新品立享9折',
rightContent: '学生购买指定原价新品时,可立即享受9折优惠,此折扣与VIP折扣不可同时享受。'
},{
rightName: '每1元返1个有货币',
rightContent: '学生购买指定商品时,每1元返1个有货币(以商品的实际成交金额计算);<br>' +
rightName: '认证立赠100有货币',
rightContent: '认证成功,立即赠送100有货币。'
}, {
rightName: '新品立享9折',
rightContent: '学生购买指定原价新品时,可立即享受9折优惠,此折扣与VIP折扣不可同时享受。'
}, {
rightName: '每1元返1个有货币',
rightContent: '学生购买指定商品时,每1元返1个有货币(以商品的实际成交金额计算);<br>' +
'有货币返还时间:确认收货7日后,系统自动将对应数量的有货币返还至购买账户;<br>' +
'有货币有效期:获得当日至次年12月31日,逾期自动作废;<br>' +
'查看有货币:登录后,点击“个人中心”在“我的有货币”中可以查看有货币余额及明细。'
},{
rightName: '分期付款',
rightContent: '开通有货分期后,可享受部分商品30天延后付款,最长6个月的分期付款,开启任性购物模式。'
}];
}, {
rightName: '分期付款',
rightContent: '开通有货分期后,可享受部分商品30天延后付款,最长6个月的分期付款,开启任性购物模式。'
}];
_.forEach(data, (value) => {
switch (value.template_name) {
... ...
/* eslint-disable */
// 在这个文件中配置 DNS 预读域名
module.exports = {
'file.static.yhbimg.com': 'qfile.static.yhbimg.com',
'static.yohobuy.com': 'qstatic.yohobuy.com',
... ... @@ -15,4 +15,4 @@ module.exports = {
'img13.static.yhbimg.com': 'qyhb02.static.yhbimg.com',
'cdn.yoho.cn': 'qcdn.yoho.cn'
};
/* eslint-enable */
... ...
... ... @@ -22,6 +22,7 @@ module.exports = [
origin: '/product/sale/?msort=10',
target: helpers.urlFormat('/product/lifestyle-sale/')
},
// 商品详情页老链接,形试一
{
type: TYPE.redirect,
... ...
... ... @@ -5,9 +5,11 @@ const logger = global.yoho.logger;
const ip = require('./rules/ip-list');
const userAgent = require('./rules/useragent');
const qpsLimiter = require('./rules/qps-limit');
const fakerLimiter = require('./rules/faker-limit');
// const fakerLimiter = require('./rules/faker-limit');
const captchaPolicy = require('./policies/captcha');
const reporterPolicy = require('./policies/reporter');
// const reporterPolicy = require('./policies/reporter');
const IP_WHITE_LIST = [
'106.38.38.146',
... ...
... ... @@ -19,7 +19,7 @@ module.exports = (req, res, next) => {
return next();
}
if (res.statusCode == 403) {
if (res.statusCode === 403) {
return res.end();
}
... ...
... ... @@ -25,7 +25,7 @@ function urlJoin(a, b) {
module.exports = (limiter, policy) => {
const req = limiter.req,
res = limiter.res,
next = limiter.next;
next = limiter.next; // eslint-disable-line
const key = `pc:limiter:${limiter.remoteIp}`;
... ... @@ -45,7 +45,7 @@ module.exports = (limiter, policy) => {
}
if (pageIncr > 0) {
cache.incr(key, pageIncr, (err) => {});
cache.incr(key, pageIncr, (err) => {}); // eslint-disable-line
}
});
... ...
... ... @@ -6,9 +6,6 @@ const logger = global.yoho.logger;
module.exports = (limiter, policy) => {
const req = limiter.req,
res = limiter.res,
next = limiter.next;
const blackKey = 'pc:limiter:ua:black',
whiteKey = 'pc:limiter:ua:white';
... ...
... ... @@ -16,5 +16,5 @@ $qrcodeImg.qrcode({
});
$qrcodeActivity.mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '活动页', 'id', $(this).attr('data-id')]);
window._hmt.push(['_trackEvent', '二维码', '活动页', 'id', $(this).attr('data-id')]);
});
... ...
... ... @@ -7,8 +7,6 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var Handlebars = require('yoho-handlebars');
var $tabs = $('.brands-tabs');
var $list = $('.brands-list');
var $gory = $('.brands-category');
... ...
... ... @@ -4,11 +4,12 @@
var $ = require('yoho-jquery'),
dialog = require('../common/dialog'),
Alert = dialog.Alert,
cartListTpl = require('mix/cart/cart-list.hbs');
var Alert = dialog.Alert,
CART_ITEM_DEL_URL = '/cart/cart/remove',
CART_ITEM_FAV_URL = '/cart/cart/fav',
cartItemNumChg,
cartListTpl = require('mix/cart/cart-list.hbs');
cartItemNumChg;
// 设置全选按钮的状态
function isCheckAll() {
... ...
... ... @@ -3,8 +3,10 @@
var cdnDomains = require('../../../../config/dns-prefetch');
function cdnReplace(cdn, imgUrl) {
var key;
if (cdn === 'qcloud') {
for (var key in cdnDomains) {
for (key in cdnDomains) {
if (imgUrl.indexOf(key) >= 0) {
imgUrl = imgUrl.replace(key, cdnDomains[key]);
}
... ... @@ -15,12 +17,13 @@ function cdnReplace(cdn, imgUrl) {
module.exports = function(imageUrl, opts) {
var cdn = window.cdn;
var params, urls, query, uri;
if (imageUrl) {
var params = opts.hash;
var urls = imageUrl.split('?');
var query = urls[1] || '';
var uri = urls[0];
params = opts.hash;
urls = imageUrl.split('?');
query = urls[1] || '';
uri = urls[0];
if (uri.indexOf('http:') === 0) {
uri = uri.replace('http:', '');
... ... @@ -29,7 +32,8 @@ module.exports = function(imageUrl, opts) {
uri = cdnReplace(cdn, uri);
if (query) {
query = query.replace(/{width}/g, params.w).replace(/{height}/g, params.h).replace(/{mode}/g, (params.mode || 2));
query = query.replace(/{width}/g, params.w).replace(/{height}/g, params.h).replace(/{mode}/g,
(params.mode || 2));
if (query.indexOf('imageView2') === 0) {
if (params.q && query.indexOf('/q/') > 0) {
... ...
/**
* 公共头部
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2017/02/27
*/
var $ = require('yoho-jquery'),
handlebars = require('yoho-handlebars');
var $head = $('.head-wrapper'),
$searchForm = $('#search-form'), // 头部搜索栏
$searchKey = $searchForm.find('.search-key'),
$searchSug = $head.find('.search-suggest');
var defaultSearch = $('#defaultsearch').val() || '';
// 搜索历史提示
function searchSuggest(key) {
var param = {
return_type: 'jsonp',
keyword: key
};
$.getJSON('//search.yohobuy.com/product/search/suggest?callback=?', param, function(jsonData) {
var searchSuggestHtml;
if (jsonData.code === 200) {
if (jsonData.data && jsonData.data.length) {
searchSuggestHtml = handlebars.compile($('#search-suggest-tml').html() || '');
$searchSug.html(searchSuggestHtml(jsonData)).show();
} else {
$searchSug.hide();
}
}
});
}
function submitSearch() {
var searchKey = $searchKey.val();
searchKey = $.trim(searchKey.toLowerCase());
if (reg.test(searchKey) && searchKey !== '') {
location.href = 'http://search.yohobuy.com/error?query=' + searchKey;
} else {
if (searchKey === '') {
$('#query-key').val(defaultSearch);
}
$searchForm.submit();
}
}
$searchKey.keyup(function(e) {
var val = $.trim($(this).val()),
$child = $searchSug.find('li'),
$act = $searchSug.find('.action'),
$focus;
if (e.which > 36 && e.which < 41) {
if (e.which === 38) {
$focus = $act.prev();
if (!$act.length || !$focus.length) {
$focus = $child.eq($child.length - 1);
}
} else if (e.which === 40) {
$focus = $act.next();
if (!$act.length || !$focus.length) {
$focus = $child.eq(0);
}
} else {
return;
}
$child.removeClass('action');
$focus.addClass('action');
$(this).val($focus.find('.searchvalue').text());
} else if (e.which === 13) {
submitSearch();
} else {
if ($searchSug && $searchSug.length) {
val = val.replace(new RegExp('\'', 'gm'), ''); // 去掉特殊字符
searchSuggest(val);
}
}
}).focus(function() {
var val = $.trim($(this).val());
if (val === defaultSearch) {
$(this).val('');
}
$(this).css('color', '#333');
}).blur(function() {
var val = $.trim($(this).val());
if (val === '') {
$(this).val(defaultSearch).css('color', '#999');
}
setTimeout(function() {
$searchSug.hide();
}, 200);
});
... ... @@ -35,7 +35,7 @@ function shareBase(options) {
}
if ($.inArray(defOption.channel, shareChannels) === -1) {
alert('不存在的分享平台!');
alert('不存在的分享平台!'); // eslint-disable-line
return false;
}
... ... @@ -71,6 +71,8 @@ function shareBase(options) {
openUrl = '//www.douban.com/share/service?href=' + defOption.url + '&text=' +
defOption.desc + '&image=' + defOption.image + '&title=' + defOption.title + '&comment=';
break;
default:
break;
}
if (defOption.channel === 'weixin') {
... ...
... ... @@ -146,9 +146,9 @@ $returnTop.click(function() {
});
$qrcodeHoverBox.mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
}).click(function() {
_hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
});
$(window).scroll(function() {
... ...
... ... @@ -5,8 +5,9 @@
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
$commentArea = $('#comment-area'),
lazyLoad = require('yoho-jquery-lazyload');
var $commentArea = $('#comment-area'),
articleId = $('.detail-body').data('id');
var $commentList = $commentArea.find('.comments-wrap'),
... ... @@ -135,6 +136,8 @@ $('#collect-btn').click(function() {
$this.toggleClass('collected');
}
break;
default:
break;
}
collecting = false;
});
... ... @@ -160,7 +163,7 @@ function comment(id) {
var commentInfo = $('#comment-info').val();
if (commentInfo === '') {
alert('评论不能为空');
alert('评论不能为空'); // eslint-disable-line
return false;
}
commenting = true;
... ... @@ -179,7 +182,7 @@ function comment(id) {
window.escape(location.href + '#comment-info');
break;
case 400:
alert(data.message);
alert(data.message); // eslint-disable-line
break;
case 200:
if (data.data) {
... ... @@ -191,6 +194,8 @@ function comment(id) {
$('#comment-info').val('').keyup();
}
break;
default:
break;
}
commenting = false;
}
... ...
var $ = require('yoho-jquery');
var Slide = require('../plugins/yohoui/YH.slide');
var $item = $('li', '.qrctxt');
var len = $item.length, slide;
var src = /url\("([^'"]*)"\)/g.exec($('.print-qrcode').css('background'))[1];
$('.print-qrcode').find('img').attr('src', src);
require('../common');
... ... @@ -43,15 +43,18 @@ $('.next', '.qrcmain-switch').click(function() {
});
$('.btn-qcode').click(function() {
var html = ['<ul>'];
$('.center', '.qrctxt').each(function() {
var _src, _bianhao, _zuoweihao;
html.push('<li>');
var src = $(this).find('img').attr('src');
html.push('<img src=\'' + src + '\'/>');
var bianhao = $(this).find('.bianhao').text();
html.push('<p>' + bianhao + '</p>');
var zuoweihao = $(this).find('.zuoweihao').text();
if (zuoweihao) {
html.push('<p>' + zuoweihao + '</p>');
_src = $(this).find('img').attr('src');
html.push('<img src=\'' + _src + '\'/>');
_bianhao = $(this).find('.bianhao').text();
html.push('<p>' + _bianhao + '</p>');
_zuoweihao = $(this).find('.zuoweihao').text();
if (_zuoweihao) {
html.push('<p>' + _zuoweihao + '</p>');
}
html.push('</li>');
});
... ...
... ... @@ -4,8 +4,9 @@
* @date: 2016/10/28
*/
var $ = require('yoho-jquery'),
ImgPreview = require('../common/img-preview'),
preview = new ImgPreview(); /* ,
ImgPreview = require('../common/img-preview');
var preview = new ImgPreview(); /* ,
Handlebars = require('yoho-handlebars'),
itemTpl = Handlebars.compile($('#comment-list-item-tpl').html() || '');*/
... ... @@ -62,27 +63,27 @@ $('.comment-add').on('click', '.btn-submit', function() {
// var itemH;
if (!param.satisfied) {
alert('请选择商品满意度!');
alert('请选择商品满意度!'); // eslint-disable-line
return;
}
if (!param.size) {
alert('请选择尺码符合度!');
alert('请选择尺码符合度!'); // eslint-disable-line
return;
}
if (param.content && param.content.length > 200) {
alert('内容超过限定字数!');
alert('内容超过限定字数!'); // eslint-disable-line
return;
}
if (param.height && !/^\d{0,3}$/.test(param.height)) {
alert('身高必须为最大3位数的数字');
alert('身高必须为最大3位数的数字'); // eslint-disable-line
return;
}
if (param.weight && !/^\d{0,3}$/.test(param.weight)) {
alert('体重必须为最大3位数的数字');
alert('体重必须为最大3位数的数字'); // eslint-disable-line
return;
}
... ... @@ -101,15 +102,15 @@ $('.comment-add').on('click', '.btn-submit', function() {
$list.show();
resetForm($f);*/
alert('提交成功');
alert('提交成功'); // eslint-disable-line
window.location.reload();
} else {
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
}).fail(function(jqXhr, status, err) {
var msg = (err && err.message) || '上传失败,请稍后再试!';
alert(msg);
alert(msg); // eslint-disable-line
});
});
... ... @@ -157,11 +158,11 @@ $('.comment-add').on('change', 'input[type=file]', function() {
$p.find('input[name=imgUrl]').val(relaUrl);
$p.addClass('selected');
} else if (data && data.message) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
},
error: function() { /** data, status, e **/
alert('上传失败,请稍后再试!');
alert('上传失败,请稍后再试!'); // eslint-disable-line
},
complete: function() {
$f.clone().replaceAll($f);
... ...
... ... @@ -5,8 +5,9 @@
*/
var $ = require('yoho-jquery'),
dialog = require('../common/dialog'),
Alert = dialog.Alert;
dialog = require('../common/dialog');
var Alert = dialog.Alert;
var address = {
... ... @@ -25,16 +26,16 @@ var address = {
initDomIds: function(domOptions) {
var the = this;
if (domOptions.provinceDomId !== undefined) {
if (typeof domOptions.provinceDomId !== undefined) {
the.provinceDomId = domOptions.provinceDomId;
}
if (domOptions.cityDomId !== undefined) {
if (typeof domOptions.cityDomId !== undefined) {
the.cityDomId = domOptions.cityDomId;
}
if (domOptions.areaDomId !== undefined) {
if (typeof domOptions.areaDomId !== undefined) {
the.areaDomId = domOptions.areaDomId;
}
if (domOptions.streetsDomId !== undefined) {
if (typeof domOptions.streetsDomId !== undefined) {
the.streetsDomId = domOptions.streetsDomId;
}
},
... ... @@ -96,7 +97,7 @@ var address = {
bindAreaChange: function(domOptions) {
var the = this;
if ($('#' + the.provinceDomId).data('events') !== undefined) {
if ($('#' + the.provinceDomId).data('events')) {
return;
}
... ... @@ -152,7 +153,7 @@ var address = {
strCity = $('#' + the.cityDomId).find('option:selected').text(),
strArea = $('#' + the.areaDomId).find('option:selected').text();
if (dispDomId !== undefined && dispDomId !== '') {
if (typeof dispDomId !== undefined && dispDomId !== '') {
if (strProvince.indexOf('选择') < 0) {
strAddr = strProvince;
}
... ...
... ... @@ -122,7 +122,7 @@ function addComplaint() {
if (jsonData.code === 200) {
window.location.reload();
} else {
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ... @@ -146,7 +146,7 @@ function cancelComplaint(id, dom) {
$dom.prev().remove();
$dom.text('问题已撤销');
} else {
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ...
require('../common');
var $ = require('yoho-jquery');
var yas = require('../common/data-yas');
var $couponUse = $('#coupon-use');
require('../common');
$couponUse.on('click', function() {
var couponid = $couponUse.parents('.coupon').data('couponid');
yas.yasEvent('YB_COUPON_IMMEDIATE_USE_C', {COUPON_ID: couponid});
});
... ...
... ... @@ -427,13 +427,13 @@ $('#me-del-checked').click(function() {
name = '文章';
}
if (confirm('您确定要删除您收藏的' + name + '吗?')) {
if (confirm('您确定要删除您收藏的' + name + '吗?')) { // eslint-disable-line
$('.checkbox input[type="checkbox"]:checked').each(function() {
ids.push($(this).closest('.fav-row').data('id'));
});
if (ids.length === 0) {
alert('请选中您要移除的' + name);
alert('请选中您要移除的' + name); // eslint-disable-line
return;
}
... ...
... ... @@ -12,11 +12,12 @@ var Alert = dialog.Alert;
var $giftError = $('.giftCardCode').find('.gift-error'),
reg = /^[0-9a-zA-Z]{4,4}$/,
code = '',
i = 1;
var active;
var captcha;
var Gift = {
suc: [
false,
... ... @@ -63,14 +64,14 @@ var Gift = {
if (!reg.test($('#giftCardCode1').val()) || !reg.test($('#giftCardCode2').val()) ||
!reg.test($('#giftCardCode3').val())) {
$giftError.html('您输入的兑换码有误,兑换码必须为数字或字母,每个文本框里只能输入四个兑换码!');
return $.Deferred().reject().promise();
return $.Deferred().reject().promise(); // eslint-disable-line
}
return captcha.check();
}
};
var captcha = new Captcha('.captcha-img').init();
captcha = new Captcha('.captcha-img').init();
captcha.refresh();
... ...
... ... @@ -5,8 +5,9 @@
*/
var $ = require('yoho.jquery'),
regionCode = require('./common-address'),
dialog = require('../common/dialog'),
Alert = dialog.Alert;
dialog = require('../common/dialog');
var Alert = dialog.Alert;
var active;
... ... @@ -55,7 +56,7 @@ var address = {
});
},
saveAddr: function(callbackFunc) {
saveAddr: function() {
$.post('/home/address/saveAddress', $('#address-form').serialize(), function(data) {
if (data.code === 200) {
location.reload();
... ... @@ -104,7 +105,7 @@ var address = {
};
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
Array.prototype.indexOf = function(obj, start) { // eslint-disable-line
var i,
j;
... ...
... ... @@ -83,7 +83,7 @@ $category.click(function() {
// 浮层代码
function bindTemplete($select, data, templete) {
function bindTemplete($select, data, tpl) {
var $this = $select;
var offset = {
width: $this.width(),
... ... @@ -93,7 +93,7 @@ function bindTemplete($select, data, templete) {
var myTemplate;
$list.find('.brands-layer').remove();
myTemplate = Handlebars.compile(templete);
myTemplate = Handlebars.compile(tpl);
$this.parent('li').find('.brands-dialog').html(myTemplate(data));
... ...
... ... @@ -122,7 +122,7 @@ function addComplaint() {
if (jsonData.code === 200) {
window.location.reload();
} else {
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ... @@ -146,7 +146,7 @@ function cancelComplaint(id, dom) {
$dom.prev().remove();
$dom.text('问题已撤销');
} else {
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ...
... ... @@ -656,7 +656,7 @@ $('.me-orders, .order-detail').on('click', '.cancel-order', function() {
active = editOrder(orderId);
active.show();
newAddress(0);
traceChangeAddress(orderId); // eslint-diable-line
traceChangeAddress(orderId); // eslint-disable-line
}).on('click', '.rebuy', function() {
var id = $(this).closest('.order, .order-detail').data('id');
... ...
... ... @@ -102,7 +102,7 @@ $('#captcha').keyup(function() {
}
});
} else {
$next.addClass('disable').attr('href', 'javascript:;');
$next.addClass('disable').attr('href', 'javascript:;'); // eslint-disable-line
}
}).blur(function() {
var v = $.trim($(this).val());
... ...
... ... @@ -129,7 +129,7 @@ function sendMessageValidate() {
}
}).then(function(data) {
if (data.code !== 200) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
... ... @@ -258,7 +258,7 @@ function actionSubmit() {
if (data.code === 200) {
window.location.href = '/passport/thirdlogin/bindsuccess';
} else {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
}
... ... @@ -275,23 +275,23 @@ function actionConfirm() {
validatenum = $('#validatenum').val();
pwd = $('#pwd').val();
if (validatenum === '') {
alert('短信验证码不能为空');
alert('短信验证码不能为空'); // eslint-disable-line
return;
}
if (pwd === '') {
alert('密码不能为空');
alert('密码不能为空'); // eslint-disable-line
return;
}
if (!/^(?![^a-zA-Z]+$)(?!\D+$).{6,20}$/.test(pwd)) {
alert('密码只支持6-20位字符,建议字母+数字的组合。');
alert('密码只支持6-20位字符,建议字母+数字的组合。'); // eslint-disable-line
return;
}
if (isvalidatecode === false) {
alert('请输入正确的验证码');
alert('请输入正确的验证码'); // eslint-disable-line
return;
}
if (isvalidatepwd === false) {
alert('请输入符合强度的密码');
alert('请输入符合强度的密码'); // eslint-disable-line
return;
}
actionSubmit();
... ...
... ... @@ -66,7 +66,7 @@ function sendVerifyMsg() {
}).then(function(jsonData) {
if (jsonData && jsonData.code !== 200) {
circleTime.clearTime();
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ... @@ -95,7 +95,7 @@ function relateMobile() {
$errTip.removeClass('hide');
} else {
$errTip.addClass('hide');
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ...
... ... @@ -136,7 +136,7 @@ function sendMessageValidate() {
}
}).then(function(data) {
if (data.code !== 200) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
... ... @@ -280,7 +280,7 @@ function actionSubmit() {
window.location.href = '/passport/thirdlogin/bindsuccess';
}
} else {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
}
... ...
... ... @@ -86,7 +86,7 @@ function codeValidate() {
if (data.code === 200) {
validatecode = true;
} else {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
}
... ... @@ -238,7 +238,7 @@ function sendMessageValidate() {
}
}).then(function(data) {
if (data.code !== 200) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
... ... @@ -272,7 +272,7 @@ function actionSubmit() {
window.location.href = '/passport/thirdlogin/bindsuccess';
}
} else {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
}
... ... @@ -288,7 +288,7 @@ function goToBindPhone() {
$('#inmobile').val($('#mobile').val());
actionSubmit();
} else {
alert('请输入正确验证码');
alert('请输入正确验证码'); // eslint-disable-line
}
});
}
... ... @@ -388,7 +388,7 @@ function nextStep() {
$phoneTip.removeClass('hide');
} else {
if (data && data.message) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
}
}
... ...
... ... @@ -53,7 +53,7 @@ function sendMessageValidate() {
}
}).then(function(data) {
if (data.code !== 200) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
... ... @@ -87,7 +87,7 @@ function actionSubmit() {
if (data.code === 200) {
window.location.href = data.data.nextUrl;
} else {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
}
... ... @@ -102,7 +102,7 @@ function actionConfirm() {
$('#confirmsubmit').on('click', function() {
validatenum = $('#validatenum').val();
if (validatenum === '') {
alert('短信验证码不能为空');
alert('短信验证码不能为空'); // eslint-disable-line
return;
}
... ...
... ... @@ -151,7 +151,7 @@ function nextStep() {
$phoneTip.removeClass('hide');
} else {
if (data && data.message) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
}
}
... ...
... ... @@ -66,7 +66,7 @@ function sendVerifyMsg() {
}).then(function(jsonData) {
if (jsonData && jsonData.code !== 200) {
circleTime.clearTime();
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ... @@ -94,7 +94,7 @@ function relateMobile() {
$errTip.removeClass('hide');
} else {
$errTip.addClass('hide');
alert(jsonData.message);
alert(jsonData.message); // eslint-disable-line
}
});
}
... ...
... ... @@ -136,7 +136,7 @@ function sendMessageValidate() {
}
}).then(function(data) {
if (data.code !== 200) {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
... ... @@ -280,7 +280,7 @@ function actionSubmit() {
window.location.href = '/passport/thirdlogin/bindsuccess';
}
} else {
alert(data.message);
alert(data.message); // eslint-disable-line
}
});
}
... ...
... ... @@ -653,7 +653,7 @@ exports.init = function(page) {
$('.qrcode-hover-reg').mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
}).click(function() {
_hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
});
... ...
... ... @@ -2,6 +2,7 @@
* upload plugin
*
*/
/* eslint-disable */
var $ = require('yoho-jquery');
var SWFUpload = require('./swfupload.queue').SWFUpload;
... ... @@ -308,3 +309,4 @@ function initSwfUpload(btnId, options) {
}
window.SWFUpload = SWFUpload;
/* eslint-enable */
... ...
... ... @@ -26,7 +26,7 @@ function shareBase(options) {
defOption = $.extend(defOption, options);
if ($.inArray(defOption.channel, shareChannels) === -1) {
alert('不存在的分享平台!');
alert('不存在的分享平台!'); // eslint-disable-line
return false;
}
... ... @@ -62,6 +62,8 @@ function shareBase(options) {
openUrl = 'http://www.douban.com/share/service?href=' + defOption.url + '&text=' +
defOption.desc + '&image=' + defOption.image + '&title=' + defOption.title + '&comment=';
break;
default:
break;
}
if (defOption.channel === 'weixin') {
... ...
... ... @@ -10,7 +10,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
*/
/* eslint-disable */
/* ******************* */
/* Constructor & Init */
... ... @@ -986,3 +986,4 @@ SWFUpload.Console.writeLine = function(message) {
};
exports.SWFUpload = SWFUpload;
/* eslint-enable */
... ...
... ... @@ -10,6 +10,8 @@
Set the event handler with the queue_complete_handler setting.
*/
/* eslint-disable */
var SWFUpload = require('./swfupload').SWFUpload;
if (typeof(SWFUpload) === 'function') {
... ... @@ -98,3 +100,4 @@ if (typeof(SWFUpload) === 'function') {
}
exports.SWFUpload = SWFUpload;
/* eslint-enable */
... ...
/* eslint-disable */
var assembly;
var classtype = {
'[object Array]': 'array',
... ... @@ -432,3 +433,4 @@ assembly.prototype.off = function(name, callback) {
me.assembly = assembly;
module.exports = me;
/* eslint-enable */
... ...
/* eslint-disable */
var me = require('./YH.base');
var slide = function(options) {
... ... @@ -137,3 +138,4 @@ slide.prototype.defaults = {
};
module.exports = slide;
/* eslint-enable */
... ...
... ... @@ -399,7 +399,7 @@ bindEvent.add(function() {
});
$('.qrcode-buy').mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '商品详情页', 'skn', $(this).attr('skn')]);
window._hmt.push(['_trackEvent', '二维码', '商品详情页', 'skn', $(this).attr('skn')]);
});
// 是否能:量贩购买,量贩小于库存才能购买
... ...
... ... @@ -67,7 +67,7 @@ function getSearchRecommend() {
$goodsIdArr.push($(this).data('id'));
});
initPageYas();
initPageYas(); // eslint-disable-line
}
}
... ... @@ -88,6 +88,7 @@ function initPageYas() {
ACTION_ID: 0,
PAGE_NUM: 1
};
// 关键词搜索结果页展示时
yas.givePoint('YB_CHOOSE_FOR_YOU_Y', loadYas);
}
... ...
var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload');
var Handlebars = require('yoho-handlebars');
function InfiniteLoad(options) {
var defaults = {
... ...
... ... @@ -116,6 +116,8 @@ module.exports = function($o, rowWidth) {
}
loadInfo = false;
break;
default:
break;
}
}
... ...
... ... @@ -144,6 +144,6 @@ $qrcodeImg.qrcode({
});
$('.qrcode-hover-box').mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '普通店铺', 'shopId', $(this).attr('data-id')]);
window._hmt.push(['_trackEvent', '二维码', '普通店铺', 'shopId', $(this).attr('data-id')]);
});
require('./good-slide');
... ...
... ... @@ -43,7 +43,7 @@ $qrcodeImg.qrcode({
});
$('.qrcode-decoration').mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '经典店铺', 'shopId', $(this).attr('data-id')]);
window._hmt.push(['_trackEvent', '二维码', '经典店铺', 'shopId', $(this).attr('data-id')]);
});
// require('../product/list');
... ...
... ... @@ -446,13 +446,13 @@ $couponDia.on('click', function() {
createStuDialog('stu-agree-dialog', cont);
});
$rightsItem.each(function(index,ele) {
$rightsItem.each(function(index, ele) {
var title = $(ele).find('.item-title').html(),
detail = $(ele).find('.item-detail').html(),
i = Number(index) + 1;
rightsText += '<p>权益' + i + ':' + title + '</p><p>' + detail + '</p>';
i !== $rightsItem.length ? rightsText+='<br>' : '';
i !== $rightsItem.length ? rightsText += '<br>' : '';
});
$rightDia.on('click', function() {
... ... @@ -794,22 +794,22 @@ $(function() {
// 悬浮效果
$rightsItem.hover(function() {
var content = $(this).find('.item-content');
var content = $(this).find('.item-content');
var gapHeight;
var gapHeight;
content.removeClass('hide');
content.removeClass('hide');
gapHeight = parseInt(content.height(), 10) + 40 - parseInt($(this).height(), 10);
gapHeight = parseInt(content.height(), 10) + 40 - parseInt($(this).height(), 10);
if (gapHeight > 0) {
content.css('margin-top', -(gapHeight) + 'px');
}
}, function() {
var content = $(this).find('.item-content');
if (gapHeight > 0) {
content.css('margin-top', -(gapHeight) + 'px');
}
}, function() {
var content = $(this).find('.item-content');
content.addClass('hide').css('margin-top', '0');
});
content.addClass('hide').css('margin-top', '0');
});
});
window.onbeforeunload = function() {
... ...
... ... @@ -82,22 +82,6 @@ function setLoginStatus(data) {
$('.header-tool li').eq(0).html(loginHtml);
}
/**
* 获取登录信息
* @return {[type]} [description]
*/
function actionLoginInfo() {
var param = {
return_type: 'jsonp'
};
$.getJSON('//www.yohobuy.com/common/passport/?callback=?', param, function(_data) {
if (_data && _data.data) {
setLoginStatus(_data.data);
}
});
}
// 获取头部登陆信息
(function() {
var uid = getUid(), //eslint-disable-line
... ...
'use strict';
const url = require('url');
const _ = require('lodash');
const config = require('../config/common');
const assetUrl = config.assetUrl;
let cdnDomains = require('../config/dns-prefetch');
... ... @@ -35,7 +32,8 @@ module.exports = {
uri = cdnReplace(cdn, uri);
if (query) {
query = query.replace(/{width}/g, params.w).replace(/{height}/g, params.h).replace(/{mode}/g, (params.mode || 2));
query = query.replace(/{width}/g, params.w).replace(/{height}/g,
params.h).replace(/{mode}/g, (params.mode || 2));
if (query.indexOf('imageView2') === 0) {
if (params.q && query.indexOf('/q/') > 0) {
... ...
... ... @@ -131,6 +131,7 @@ exports.getSourceUrl = (fileName, bucket)=>{
return fileName;
}
let domain = getDomain(bucket, fileName);
return '//' + domain + '/' + bucket + fileName;
};
... ...