Authored by 沈志敏

Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop

... ... @@ -22,8 +22,8 @@ module.exports = {
/* 获取资讯列表数据 */
getEditorialList: (req, res, next) => {
let params = {
page: req.body.page,
channel: req.body.channel,
page: req.query.page,
channel: req.query.channel,
uid: req.user.uid
};
... ...
... ... @@ -30,6 +30,6 @@ module.exports = {
uid: params.uid || '0',
page: params.page,
limit: '10'
});
}, {code: 200, cache: true});
}
};
... ...
... ... @@ -7,7 +7,6 @@
'use strict';
const logger = global.yoho.logger;
const api = global.yoho.API;
const editorialListApi = require('./list-api');
const camelCase = global.yoho.camelCase;
... ... @@ -19,19 +18,17 @@ const camelCase = global.yoho.camelCase;
const editorialList = params => {
let finalResult = {};
return api.all([
editorialListApi.getEditorialListData(params)
]).then(result => {
if (result[0].code === 200 && result[0].data.list) {
return editorialListApi.getEditorialListData(params).then(result => {
if (result.data && result.data.list) {
Object.assign(finalResult, {
data: {
list: result[0].data.list.artList,
totalPage: result[0].data.totalPage
list: result.data.list.artList,
totalPage: result.data.totalPage
},
code: 200
});
} else {
logger.error('getEitorialListData api code no 200');
logger.error('getEitorialListData api no data');
}
return camelCase(finalResult);
... ...
... ... @@ -13,7 +13,7 @@ const router = expressRouter();
const editorial = require(`${cRoot}/index`);
router.get('/list', editorial.index); // 首页
router.post('/list.json', editorial.getEditorialList); // 获取资讯数据
router.get('/list.json', editorial.getEditorialList); // 获取资讯数据
// 详情controller
const detail = require(`${cRoot}/detail`);
... ...
... ... @@ -43,7 +43,7 @@ module.exports = {
order: req.query.order || 's_t_desc',
limit: req.query.limit || '60',
color: req.query.color,
price: req.query.price,
price: req.query.priceRange,
size: req.query.size,
pd: req.query.pd,
tagsFilter: req.query.tagsFilter
... ...
... ... @@ -45,10 +45,10 @@
},
"devDependencies": {
"autoprefixer": "^6.4.0",
"babel-core": "^6.11.4",
"babel-core": "^6.13.0",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015": "^6.13.0",
"babel-runtime": "^6.11.6",
"eslint": "^3.2.2",
"eslint-config-yoho": "^1.0.1",
... ...
... ... @@ -164,7 +164,7 @@ const enDict = {
color: 'Color',
gender: 'Gender',
size: 'Size',
brand: 'Brand品牌',
brand: 'Brand',
priceRange: 'Price',
groupSort: 'Category',
discount: 'Sale',
... ...
... ... @@ -34,19 +34,21 @@ Vue.mixin({
$(() => {
const $body = $('body');
// 页面内无 JS 时, 自动隐藏 App 显示的 Loading
if ($body.hasClass('no-local-js')) {
yoho.showLoading(false); // 隐藏 App 默认显示的 loading
util.visibilitychange();
}
// 拦截页面内所有 a 标签的跳转
$body.on('click', 'a[href]', function() {
// 拦截跳转
if (!$(this).hasClass('no-intercept')) {
interceptClick.intercept($(this).attr('href'));
return false;
}
});
// App 发送给 H5 的事件,统一转为 Vue-bus 的事件
yoho.addNativeMethod('triggerH5Event', (eventName) => {
alert(eventName);
bus.$emit(eventName);
... ...
... ... @@ -40,7 +40,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goTab(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.tab',
arguments: args
... ... @@ -57,7 +57,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goLogin(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.login',
arguments: args
... ... @@ -74,7 +74,7 @@ const yoho = {
* @param fail
*/
goLogout(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.loginout',
arguments: args
... ... @@ -92,7 +92,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goShopingKey(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.shoppingkey',
arguments: args
... ... @@ -110,7 +110,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goShopingCart(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.shopingCart',
arguments: args
... ... @@ -127,7 +127,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goAddress(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.address',
arguments: args
... ... @@ -144,7 +144,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goImageBrowser(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.imageBrowser',
arguments: args
... ... @@ -162,7 +162,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goNewPage(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.newPage',
arguments: args
... ... @@ -181,7 +181,7 @@ const yoho = {
* @param fail 调用失败的回调方法
*/
goPay(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.pay',
arguments: args
... ... @@ -198,7 +198,7 @@ const yoho = {
* @param fail
*/
goBack(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.back',
arguments: args
... ... @@ -215,7 +215,7 @@ const yoho = {
* @param fail
*/
goShare(args, success, fail) {
if (this.isApp) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.share',
arguments: args
... ... @@ -232,8 +232,8 @@ const yoho = {
* @param fail
*/
goSearch(args, success, fail) {
if (this.isApp) {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.search',
arguments: args
});
... ... @@ -249,8 +249,8 @@ const yoho = {
* @param fail
*/
goSetting(args, success, fail) {
if (this.isApp) {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.setting',
arguments: args
});
... ... @@ -266,8 +266,8 @@ const yoho = {
* @param fail
*/
goSetAvatar(args, success, fail) {
if (this.isApp) {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.setAvatar',
arguments: args
});
... ... @@ -283,8 +283,8 @@ const yoho = {
* @param fail
*/
goPageView(args, success, fail) {
if (this.isApp) {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.pageView',
arguments: args
});
... ... @@ -317,8 +317,8 @@ const yoho = {
* @param fail
*/
showLoading(args, success, fail) {
if (this.isApp) {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.loading',
arguments: {
show: args ? 'yes' : 'no'
... ...
... ... @@ -38,3 +38,9 @@
color: $grey;
}
}
.button-ghost {
background-color: transparent;
border: none;
outline: none;
}
... ...
... ... @@ -2,7 +2,7 @@
<div class="filter-box">
<div class="filter" :class="{ 'filter-open': isVisible}">
<div class="filter-actions">
<a href="javascript:;" class="filter-action" @click="clearVals">清空</a>
<button class="button-ghost filter-action" @click="clearVals">清空</button>
<button class="button button-small filter-action" @click="okAction">确定</button>
</div>
<div class="filter-params">
... ... @@ -62,7 +62,7 @@
},
okAction: function() {
this.$set('selected', Object.assign({}, this.selected,this.params));
this.$set('selected', Object.assign({}, this.selected, this.params));
bus.$emit('filter.change', {
val: this.selected,
ref: this._uid
... ... @@ -82,11 +82,11 @@
this.$set(`params.${this.subType}`, item);
},
showLabel: function(key){
showLabel: function(key) {
const newSelected = this.params[key];
const oldSelected = this.selected[key];
if(newSelected) {
if (newSelected) {
return newSelected.name || '';
} else {
return oldSelected && oldSelected.name || '';
... ...
... ... @@ -23,7 +23,7 @@
};
},
methods: {
selectItem(item) {
selectItem() {
this.hide();
return true;
},
... ... @@ -49,7 +49,6 @@
z-index: 2010;
overflow: auto;
&.filter-sub-open {
transform: translate3d(0, 0, 0);
}
... ... @@ -85,6 +84,10 @@
padding: 0 $w;
height: 100px;
line-height: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
</style>
\ No newline at end of file
... ...
... ... @@ -85,7 +85,8 @@
contentCode: contentCode.editorial.all,
editorialList: [],
page: 0,
scrollDisabled: false
scrollDisabled: false,
channel: qs.channel
};
},
watch: {
... ... @@ -97,11 +98,11 @@
/* 获取资讯列表数据 */
getNewsList() {
$.post({
$.get({
url: '/editorial/list.json',
data: {
page: this.page++,
channel: qs.channel || 'all'
channel: this.channel
}
}).done(result => {
if (result.code === 200) {
... ...
... ... @@ -409,6 +409,7 @@
const tip = require('common/tip');
const yoho = require('yoho');
const share = require('common/share');
const bus = require('common/vue-bus');
require('vue-swipe/dist/vue-swipe.css');
... ... @@ -498,6 +499,17 @@
});
}
});
},
/*
刷新购物车
*/
refreshCart: function() {
$.get('/product/cart-count.json').then(result=> {
if (result.code === 200) {
this.cartCount = result.data.cart_goods_count;
}
});
}
},
created() {
... ... @@ -555,11 +567,8 @@
// 读取购物车数量
if (this.isApp) {
$.get('/product/cart-count.json').then(result=> {
if (result.code === 200) {
this.cartCount = result.data.cart_goods_count;
}
});
this.refreshCart();
bus.on('app.shoppingcart,refresh', () => this.refreshCart);
}
}
};
... ...
... ... @@ -8,9 +8,12 @@ const _ = require('lodash');
/**
* 处理 以风格的数据
* 风格1:
* [
* {filter_attribute: value}
* ]
* 风格2:
* {filter_attribute: value}
*
* 处理结果
* [
... ... @@ -22,18 +25,32 @@ let verboseAttrHandler = (filterField, dataArr) => {
let result = [];
let re = new RegExp(`^${filterField}_`);
dataArr.forEach(obj => {
// 处理 {filter_attribute: value}
function handlerAttrObj(obj) {
let item = {};
let keys = Object.keys(obj);
keys.forEach(key=>{
keys.forEach(key => {
let newKey = key.replace(re, '');
item[newKey] = obj[key];
});
return item;
}
result.push(item);
});
if (_.isPlainObject(dataArr)) {
// 风格2
let attr = handlerAttrObj(dataArr);
result.push(attr);
} else {
// 风格1
dataArr.forEach(obj => {
let attr = handlerAttrObj(obj);
result.push(attr);
});
}
return result;
};
... ... @@ -60,7 +77,7 @@ let keyIdHandler = (filterField, obj) => {
const keys = Object.keys(obj);
keys.sort();
keys.forEach(key=> {
keys.forEach(key => {
let item = {};
item.id = key;
... ...