Authored by 沈志敏

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

... ... @@ -144,3 +144,4 @@ public/bundle/*
*.log.*
nbproject/*
.DS_Store
.devhost
... ...
... ... @@ -22,6 +22,7 @@ const session = require('express-session');
const memcached = require('connect-memcached');
const hbs = require('express-handlebars');
const pkg = require('./package.json');
const devtools = require('./doraemon/middleware/devtools');
const app = express();
const MemcachedStore = memcached(session);
... ... @@ -40,6 +41,10 @@ global.doraemon = path.resolve('./doraemon');
const logger = global.yoho.logger;
if (app.locals.devEnv) {
app.use(devtools());
}
app.set('view engine', '.hbs');
app.set('views', './doraemon/views');
app.engine('.hbs', hbs({
... ...
'use strict';
const fs = require('fs');
let devHost = 'localhost';
fs.readFile('.devhost', (err, buf)=> {
if (!err) {
devHost = JSON.parse(buf.toString()).host;
}
});
module.exports = () => {
return (req, res, next) => {
Object.assign(res.locals, {
devHost: devHost
});
next();
};
};
... ...
... ... @@ -15,9 +15,9 @@
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=750){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/750)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
{{#if devEnv}}
<link rel="stylesheet" media="all" href="//localhost:5004/css/index.css">
<link rel="stylesheet" media="all" href="//{{devHost}}:5004/css/index.css">
{{#unless noLocalCSS}}
<link rel="stylesheet" media="all" href="//localhost:5004/{{module}}.{{page}}.css">
<link rel="stylesheet" media="all" href="//{{devHost}}:5004/{{module}}.{{page}}.css">
{{/unless}}
{{^}}
<link rel="stylesheet" href="//cdn.yoho.cn/yohoblk-wap/{{version}}/index.css">
... ... @@ -32,9 +32,9 @@
</div>
{{#if devEnv}}
<script src="//localhost:5004/libs.js"></script>
<script src="//{{devHost}}:5004/libs.js"></script>
{{#unless noLocalJS}}
<script src="//localhost:5004/{{module}}.{{page}}.js"></script>
<script src="//{{devHost}}:5004/{{module}}.{{page}}.js"></script>
{{/unless}}
{{^}}
<script src="//cdn.yoho.cn/yohoblk-wap/{{version}}/libs.js"></script>
... ...
... ... @@ -11,7 +11,7 @@ const brandListBox = require('channel/brand-list-box.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
new Vue({
el: '#brand-list',
... ...
... ... @@ -4,7 +4,7 @@ const cateRes = require('channel/cate-resource-box.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
new Vue({
el: '#cate-resource',
... ...
... ... @@ -6,7 +6,7 @@ const channel = require('channel/index.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
new Vue({
... ...
... ... @@ -5,7 +5,7 @@ const sidebar = require('channel/sidebar.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
new Vue({
el: '#sidebar',
... ...
... ... @@ -7,6 +7,7 @@
module.exports = (Vue) => {
Vue.directive('lazy-html', function(html) {
// TODO 首屏幕不使用
html = html.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, '<img v-lazy="\'$1\'">');
this.el.innerHTML = html;
this.vm.$compile(this.el);
... ...
... ... @@ -4,7 +4,7 @@ const directive = require('common/vue-directive');
const app = require('editorial/detail.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(directive);
new Vue({
... ...
... ... @@ -8,7 +8,7 @@ const Vue = require('vue');
const lazyload = require('vue-lazyload');
const infinitScroll = require('vue-infinite-scroll');
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
require('common/vue-filter')(Vue);
... ...
... ... @@ -17,4 +17,4 @@ new Vue({
}
});
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
... ...
... ... @@ -5,6 +5,6 @@ const exchange = require('me/exchange.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
new Vue(exchange);
... ...
... ... @@ -5,7 +5,7 @@ const refund = require('me/refund.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
new Vue({
el: '#refund',
... ...
... ... @@ -4,7 +4,7 @@ const directive = require('common/vue-directive');
const app = require('product/detail/index.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(directive);
new Vue({
... ...
... ... @@ -10,8 +10,9 @@ const lazyload = require('vue-lazyload');
const shareBox = require('product/shop/share-box.vue');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, {
preLoad: 3
});
new Vue({
el: '#share',
... ...
... ... @@ -9,7 +9,9 @@ const lazyload = require('vue-lazyload');
const infinitScroll = require('vue-infinite-scroll');
require('common/vue-filter')(Vue);
Vue.use(lazyload);
Vue.use(lazyload, {
preLoad: 3
});
Vue.use(infinitScroll);
const shopBox = require('product/shop/shop-box.vue');
... ...
... ... @@ -3,7 +3,7 @@
<div class="blk-header">
<div class="blk-header-left">
<slot name="left">
<i class="icon icon-left" @click="goBack"></i>
<i class="icon icon-left go-back-btn" @click="goBack"></i>
</slot>
</div>
<div class="blk-header-right">
... ... @@ -92,6 +92,13 @@
.blk-header-title {
vertical-align: middle;
}
.go-back-btn {
width: 128px;
text-indent: 32px;
margin-left: -32px;
display: inline-block;
}
}
.blk-header-main {
... ...
... ... @@ -31,7 +31,7 @@
const lazyload = require('vue-lazyload');
const infinitScroll = require('vue-infinite-scroll');
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
let bus = require('common/vue-bus');
... ...
... ... @@ -23,7 +23,7 @@
let locationQuery = qs(decodeURIComponent(location.search.replace(/^\?/, '')));
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
require('common/vue-filter')(Vue);
... ...
... ... @@ -21,7 +21,7 @@
let locationQuery = qs(decodeURIComponent(location.search.replace(/^\?/, '')));
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
require('common/vue-filter')(Vue);
... ...
... ... @@ -18,7 +18,7 @@
const order = require('component/product/order.vue');
const list = require('component/product/list.vue');
Vue.use(lazyload);
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
require('common/vue-filter')(Vue);
... ...
<template>
<top-bar :share-data="shareData"></top-bar>
<top-bar :share-data="shareData" :show-top-bar="showTopBar"></top-bar>
<shop-top :shop-info="shopInfo"></shop-top>
<div :class='{"shop-goods-top": !shopInfo.isBlkShop}'>
<goods-list :data="productList" :empty="empty"></goods-list>
... ... @@ -34,9 +35,9 @@
return {
shareData: {}, // 分享相关数据
shopInfo: {}, // 店铺介绍相关数据
sortConfig: {},
filterConfig: {},
showTopBar: false,
// query
url: '/product/shop/goods.json',
... ... @@ -73,7 +74,7 @@
/* 获取店铺简介相关数据 */
getShopInfo() {
$.get({
async: false,
// async: false,
url: '/product/shop/info.json',
data: {
domain: $shop.data('domain'),
... ... @@ -83,6 +84,7 @@
if (result) {
this.shopInfo = result;
this.shopInfo.showBrandInfo = true;
let shareUrl = locationQuery.id ?
location.origin + '/product/shop/favorite/share?id=' + locationQuery.id :
location.origin + '/product/shop/' + $shop.data('domain') + '/share';
... ... @@ -103,6 +105,8 @@
} else {
this.shopInfo.showBrandInfo = false;
}
this.showTopBar = true;
}).fail(() => {
tip('网络出错~');
});
... ...
<template>
<div :style="{display: topBarDisplay}">
<cheader :title="title" :class="{ghost: shareData.isBlkShop}" :fixed="shareData.isBlkShop" v-ref:header>
<template slot="right" v-on:scroll="">
<span v-if="shareData.isBlkShop" v-show="shareData.isFav" class="icon" @click="collectShop()">&#xe60d;</span>
... ... @@ -7,6 +8,7 @@
<span class="icon" @click="showFilter()">&#xe60b;</span>
</template>
</cheader>
</div>
</template>
<style>
... ... @@ -31,8 +33,9 @@
},
props: {
shareData: {
type: Object
}
type: Object,
},
showTopBar: false
},
computed: {
title() {
... ... @@ -43,6 +46,9 @@
}
return result;
},
topBarDisplay() {
return this.showTopBar ? 'block' : 'none';
}
},
components: {
... ...