Authored by 陈峰

commit

import Login from 'yoho-activity-sdk/src/public/login';
import Base from 'yoho-activity-sdk/src/public/base';
import yoho from 'common/yoho';
import cookie from 'yoho-cookie';
var env = Base.env();
var loginUrl = Base.loginUrl();
var login = new Login({loginUrl: loginUrl, env: env});
async function getUser() {
if (yoho.isApp) {
const user = await Base.getUser();
if (user && user.uid) {
cookie.set('app_uid', user.uid);
cookie.set('app_session_key', user.sessionKey);
cookie.set('app_version', user.appVersion);
cookie.set('app_client_type', user.sessionType);
}
return user;
} else {
return Base.getUser();
}
}
export default {
goLogin: login.goLogin.bind(login),
getUser: Base.getUser.bind(Base)
getUser
};
... ...
... ... @@ -8,7 +8,6 @@
*
* 希望能与 微信 JS-SDK 一样方便
*/
import cookie from 'yoho-cookie';
/* 空方法 */
const nullFun = () => {};
... ...
... ... @@ -70,7 +70,7 @@ export default {
},
methods: {
...mapActions(['fetchCommentList', 'fetchReplayList', 'postComment']),
async fetchComments(refresh) {
async fetchComments(lazy) {
const result = await this.fetchCommentList({
destId: this.destId,
columnType: this.columnType,
... ... @@ -81,23 +81,24 @@ export default {
if (result.code === 200) {
const comments = get(result, 'data.commentInfos', []);
if (refresh) {
setTimeout(() => {
setTimeout(() => {
if (this.page === 1) {
this.commentList = comments;
}, 200);
} else {
this.commentList = this.commentList.concat(comments);
}
if (comments.length) {
this.page++;
} else {
dirty = false;
}
this.$emit('on-page-change', {
page: this.page,
size: result.data.total
});
console.log('this.commentList')
} else {
this.commentList = this.commentList.concat(comments);
}
if (comments.length) {
this.page++;
} else {
dirty = false;
}
this.$emit('on-page-change', {
page: this.page,
size: result.data.total
});
this.$refs.scroll.forceUpdate(dirty);
}, lazy ? 200 : 0);
} else {
this.$createToast && this.$createToast({
txt: result.message || '服务器开小差了',
... ... @@ -105,20 +106,20 @@ export default {
time: 1000
}).show();
}
this.$refs.scroll.forceUpdate(dirty);
return result;
},
onPullingUp() {
this.fetchComments();
},
async onComment() {
this.init();
this.page = 1;
this.$refs.scroll.scrollTo(0, 0, 200);
this.fetchComments(false);
},
async init() {
this.page = 1;
this.commentList = [];
this.$refs.scroll.forceUpdate(true);
await this.fetchComments(true);
this.fetchComments(true);
},
async onReply({commentId}) {
const result = await this.fetchReplayList({
... ...
... ... @@ -135,12 +135,10 @@ export default {
window.addEventListener('test', null, opts);
} catch (e) {} //eslint-disable-line
this.$el.addEventListener(EVENT_SCROLL, this._onScroll, supportsPassive ? { passive: true } : false);
window.addEventListener(EVENT_RESIZE, this._onResize);
this.init();
},
beforeDestroy() {
this.$el.removeEventListener(EVENT_SCROLL, this._onScroll);
window.removeEventListener(EVENT_RESIZE, this._onResize);
},
methods: {
init() {
... ...