Authored by 陈峰

merge

... ... @@ -14,6 +14,7 @@
</template>
<script>
import {mapState} from 'vuex';
export default {
name: 'YohoActionSheet',
props: {
... ... @@ -58,11 +59,18 @@ export default {
});
},
computed: {
...mapState(['yoho']),
actionCls() {
return [{ 'yoho-action-sheet': this.full }];
},
contentHeight() {
return this.full ? `${this.maxHeight - 20}px` : 'auto';
let {statusBarHeight, statusBarStatus} = this.yoho.window || {};
if (!statusBarStatus) {
statusBarHeight = 0;
}
return this.full ? `${this.maxHeight - 20 - statusBarHeight}px` : 'auto';
}
},
methods: {
... ...
... ... @@ -124,6 +124,8 @@ export default {
if (params.rootCommentId) {
this.page = get(result, 'data.page', 1);
this.prePage = this.page - 1;
} else {
this.prePage = 0;
}
this.totalPage = get(result, 'data.totalPage', 1);
... ... @@ -173,8 +175,8 @@ export default {
let scrollHeight = this.$refs.scroll.$el.offsetHeight;
let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetoffsetTop > scrollHeight)) {
this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetoffsetTop);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);
}
}, 500);
}
... ... @@ -209,7 +211,7 @@ export default {
onScrollEndHandle(e) {
this.scrollY = e.y;
if (this.prePage < 1) {
if (!this.commentId || this.prePage < 1) {
return;
}
... ...
<template>
<img v-lazy="currentSrc" :alt="alt" v-if="currentLazy" @error="onError">
<img v-lazy="currentSrc" :alt="alt" v-if="currentLazy" class="lazy-img" @error="onError">
<img :src="currentSrc" :alt="alt" v-else lazy="" data-src="" @error="onError">
</template>
... ...
... ... @@ -26,6 +26,9 @@ export default {
},
init() {
this.$refs.scroll.init();
},
clear() {
this.$refs.scroll.clear();
}
},
};
... ...
... ... @@ -156,10 +156,13 @@ export default {
this.getItems(reload);
}
},
clear() {
this.noMore = false;
this.items = [];
},
getItems(reload) {
if (reload) {
this.noMore = false;
this.items = [];
this.clear();
}
this.loadings.push('pending');
this.onFetch().then((res) => {
... ...
<template>
<div class="recycle-scroll-reveal" v-bind="$attrs" v-on="$listeners">
<div class="recycle-scroll-reveal">
<div class="recycle-scroll-reveal-main" ref="scroll">
<div ref="eternal" class="eternal-top">
<slot name="eternalTop"></slot>
... ... @@ -101,11 +101,13 @@ export default {
items(newList, oldList) {
let list = newList.slice(oldList.length, newList.length);
this.loadItems(list, oldList.length).then(() => {
if (oldList.length < 2) {
this._updateList();
}
});
if (list.length) {
this.loadItems(list, oldList.length).then(() => {
if (oldList.length < 2) {
this._updateList();
}
});
}
}
},
mounted() {
... ... @@ -132,25 +134,25 @@ export default {
this.$el.removeEventListener(EVENT_SCROLL, this.onScroll);
},
methods: {
resize(index) {
this.$refs.scroll.resize(index);
},
init() {
this.colsHeight = [];
this.itemWidth = Math.floor(this.$el.offsetWidth / this.cols);
this.load(true);
},
clear() {
this.noMore = false;
this.items = [];
for (let i = 0; i < this.cols; i++) {
this[this.colPrefix + i].length = 0;
this.visibleItems[i] = this[this.colPrefix + i];
this.visibleItems[i].length = 0;
this.colsHeight[i] = 0;
this.startIndexs[i] = 0;
}
this.load(true);
},
load(reload) {
if (reload) {
this.noMore = false;
this.items = [];
this.clear();
}
if (!reload && (this.loading || this.noMore)) {
... ... @@ -222,9 +224,9 @@ export default {
k--;
}
}
});
return true;
return true;
});
},
loadItem(item, colIndex) {
return new Promise(r => {
... ... @@ -289,6 +291,7 @@ export default {
} else {
this.$set(col[i], 'placeholder', false);
}
if (!hasTopItem && col[i].top > top) {
startIndex = Math.max(0, i - 1);
hasTopItem = true;
... ...
... ... @@ -90,7 +90,7 @@ export default {
if (!this.title) {
let first = get(result, 'data.detailList[0]');
this.title = `@${first.authorName} 在有货上发了一篇笔记,快点开看看!`;
this.title = `@${first.authorName} 在有货社区上发了一篇笔记,快点开看看!`;
if (!this.$yoho.isApp) {
let shareImage = '';
... ...
... ... @@ -146,7 +146,7 @@ export default {
this.CHANGE_ARTICLE_LIST_INTRO_HEIGHT({
articleId: this.data.articleId,
introHeight: get(this.$refs, 'introPool.scrollHeight', 0) + 20,
introCollapseHeight: get(this.$refs, 'intro.scrollHeight', 0),
introCollapseHeight: get(this.$refs, 'intro.offsetHeight', 0),
type: this.type
});
}
... ... @@ -172,7 +172,7 @@ export default {
},
onShare() {
this.$yoho.share({
title: `@${this.data.authorName} 在有货上发了一篇笔记,快点开看看!`,
title: `@${this.data.authorName} 在有货社区上发了一篇笔记,快点开看看!`,
imgUrl: this.data.shareImage,
link: `${location.origin}/grass/article/share/${this.data.articleId}`,
desc: this.data.intro,
... ...
... ... @@ -75,7 +75,7 @@ export default {
},
favOption() {
return {
selected: this.articleState.hasPraised === 'Y',
selected: this.articleState.hasPraise === 'Y',
iconBold: true,
iconFontSize: 30,
textAlign: 'normal'
... ...
<template>
<Layout class="article">
<LayoutHeader v-if="!noHeader" theme="white" slot='header' :title="title">
<LayoutHeader v-if="!noHeader" theme="white" slot='header'>
<template v-if="showHeader">
<div class="avatar-wrapper" @click="toUserPage">
<WidgetAvatar class="widget-avatar" :src="currentAuthor.authorHeadIco" :width="70" :height="70"></WidgetAvatar>
<span class="user-name">{{currentAuthor.authorName}}</span>
</div>
</template>
<template v-else>
<div class="article-title">{{title}}</div>
</template>
<template v-if="showHeader" v-slot:opts>
<WidgetFollow :share="share" class="widget-follow" :class="headerFollowClass" :author-uid="currentAuthor.authorUid" :follow="currentAuthor.hasAttention === 'Y'" @on-follow="follow => onFollow(currentAuthor, follow)" :pos-id="posId"></WidgetFollow>
<i class="iconfont icon-more1" @click="onShowMore(currentAuthor)"></i>
... ... @@ -67,7 +70,7 @@ export default {
props: {
title: {
type: String,
default: ''
default: '有货社区'
},
share: Boolean,
type: String,
... ... @@ -200,6 +203,10 @@ export default {
onDounceScroll({item, scrollTop, startIndex}) {
this.scrollTop = scrollTop;
if (item) {
this.reportShow(startIndex, item);
}
// 产品要求去掉头部交互
return;
... ... @@ -230,8 +237,6 @@ export default {
this.currentAuthor.index = item.index;
this.showHeader = true;
this.reportShow(startIndex, item);
}
},
init() {
... ... @@ -358,6 +363,11 @@ export default {
white-space: nowrap;
}
.article-title {
font-size: 34px;
font-weight: 500;
}
.icon-more1 {
font-size: 40px!important;
margin-right: 6px;
... ...
... ... @@ -220,8 +220,8 @@ export default {
}, 400);
this.scrollEvent(params);
setTimeout(() => {
this._ttTimer && clearTimeout(this._ttTimer);
this._ttTimer = setTimeout(() => {
this.scrollEvent(params);
}, throttleTime)
},
... ... @@ -251,62 +251,62 @@ export default {
this.page = 1;
this.headerAnimateStep = 0;
this.fetchTopicSimpleInfo({topicId: this.topicId}).then(res => {
let {topicName, topicImageUrl, topicDesc} = get(res, 'data') || {};
if (this.share) {
document && (document.title = topicName);
}
if (this.share && !this.$yoho.isApp && res.code === 200) {
Share.setShareInfo({
title: topicName,
imgUrl: topicImageUrl,
desc: '我在有货的社区发现一个热门话题。' + topicDesc,
});
}
if (!topicImageUrl) {
this.headerAnimateStep = 100;
}
if (this.$refs.scroll) {
this.$refs.scroll.$el.scrollTop = 0;
this.$refs.scroll.clear();
}
return this.load().then(() => {
this.$nextTick(() => {
if (this.$refs.scroll) {
this.$refs.scroll.$el.scrollTop = 0;
this.$refs.scroll.init();
}
this.$refs.scroll && this.$refs.scroll.init();
});
});
},
load() {
this.listPreCache = {};
return Promise.all([
this.fetchTopicSimpleInfo({topicId: this.topicId}).then(res => {
if (res.code === 200) {
this.setPageShareInfo(get(res, 'data', {}));
}
if (!get(res, 'data.topicImageUrl')) {
this.headerAnimateStep = 100;
}
}),
this.fetchTopicRelatedArticles({topicId: this.topicId, page: 1}).then(res => {
if (res.code === 200) {
this.listPreCache[`${this.topicId}-1`] = res;
}
})
]);
},
async onFetch() {
const topicId = parseInt(this.topicId, 10);
if (!topicId) {
return;
if (!topicId || this.fetching) {
return [];
}
this.fetching = true;
this.page = this.page || 1;
const result = await this.fetchTopicRelatedArticles({
topicId,
page: this.page
});
let result = get(this.listPreCache, `${this.topicId}-${this.page}`);
if (!result) {
result = await this.fetchTopicRelatedArticles({
topicId,
page: this.page
});
}
this.fetching = false;
let list = [];
if (result.code === 200) {
this.page++;
list = get(result, 'data.detailList', []);
if (list.length) {
this.$sdk.getUser().then(user => {
if (user && user.uid) {
this.fetchArticleProductFavs({
articles: list
});
}
});
}
} else {
this.$createToast && this.$createToast({
txt: result.message || '服务器开小差了',
... ... @@ -316,7 +316,7 @@ export default {
}
return new Promise(resolve => {
if (this.topicInfo.viewModel === 1 && this.page <= 2) {
if (get(this.topicInfo, 'viewModel') === 1 && this.page <= 2) {
list = [{topicHead: true}, ...list];
}
... ... @@ -348,6 +348,19 @@ export default {
this.$refs.actionSheet.show(params);
});
},
setPageShareInfo({topicName, topicImageUrl, topicDesc}) {
if (this.share) {
document && (document.title = topicName || '话题');
if (!this.$yoho.isApp) {
Share.setShareInfo({
title: topicName,
imgUrl: topicImageUrl,
desc: '我在有货的社区发现一个热门话题。' + topicDesc,
});
}
}
},
startReportShow() {
let preview = null;
let name = this.$yoho.isiOS ? 'iFP_ArticleList' : 'aFP_ArticleList';
... ...
... ... @@ -611,6 +611,11 @@ ul {
white-space: nowrap;
}
img.lazy-img {
opacity: 0;
transition: opacity 800ms ease-in-out;
}
img[lazy=loading] {
opacity: 0.2;
}
... ...
... ... @@ -163,7 +163,6 @@ export default {
});
},
[Types.CHANGE_ARTICLE_LIST_SLIDE](state, {articleId, index, type}) {
console.log(articleId, index, type);
state[articlefield(type)].forEach(article => {
if (article.articleId === articleId) {
article.blockIndex = index;
... ...
... ... @@ -60,7 +60,7 @@ class Day {
const days = Math.floor((today - date) / (24 * 60 * 60 * 1000)) + 1;
if (days > 5) {
return `${this.year()}-${this._fix(this.month(), 2)}-${this._fix(this.day(), 2)}`;
return `${this.year()}-${this._fix(this.month(), 2)}-${this._fix(this.date(), 2)}`;
} else if (days > 2) {
return '2天前';
} else if (days > 1) {
... ...
... ... @@ -17,7 +17,15 @@ const setStatusBar = (width, height, store) => {
height: statusBar.statusBarHeight
});
if (version(cookie.get('app_version'),' 6.9.2') >= 0) {
function getAppVersion(str, split) {
const match = str.match(new RegExp('(^|)app_version=([^' + split + ']*)(' + split + '|$)'));
return match && match.length ? match[2] : '';
}
const appVersion = getAppVersion(document.cookie, ';') || getAppVersion(location.href, '&');
if (version(appVersion, '6.9.2') >= 0) {
statusBar.statusBarStatus = true;
store && store.commit('SET_STATUS_BAR_STATUS', {status: true});
}
... ...
... ... @@ -15,6 +15,7 @@ const checkRefer = helpers.urlFormat('/3party/check', {refer: replaceKey});
*/
exports.serverError = (err, req, res, next) => { // eslint-disable-line
err = err || {};
logger.error(`error at path: ${req.url}`);
logger.error(`${req.url},${typeof err === 'object' ? JSON.stringify(err) : err}`);
... ...
... ... @@ -2,7 +2,6 @@ const _ = require('lodash');
module.exports = (result, apiInfo) => {
if (result.code === 200 && _.isObject(apiInfo.fields)) {
console.log(apiInfo.fields);
let resData = result.data || {};
let data = {};
... ...