评论后刷新视频数据
This commit is contained in:
parent
6ad4f76fa1
commit
af7f967d39
5
App.vue
5
App.vue
@ -63,8 +63,8 @@ export default {
|
|||||||
this.checkArguments(); // 检测启动参数
|
this.checkArguments(); // 检测启动参数
|
||||||
});
|
});
|
||||||
// init im
|
// init im
|
||||||
var ddd = TUIChatKit.init();
|
TUIChatKit.init();
|
||||||
console.log('dasjdlasjdlajsldjaslkdjasljdklasdljasldadjaldjlkasdlkasjdalsdjl', ddd);
|
console.log('IM初始化完成');
|
||||||
// 如果有缓存登录信息
|
// 如果有缓存登录信息
|
||||||
console.log('是否登录', storage.getHasLogin());
|
console.log('是否登录', storage.getHasLogin());
|
||||||
if (storage.getHasLogin()) {
|
if (storage.getHasLogin()) {
|
||||||
@ -83,7 +83,6 @@ export default {
|
|||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
//
|
|
||||||
hanleTabCenter() {
|
hanleTabCenter() {
|
||||||
// 点击中间的➕
|
// 点击中间的➕
|
||||||
uni.onTabBarMidButtonTap(() => {
|
uni.onTabBarMidButtonTap(() => {
|
||||||
|
@ -402,6 +402,7 @@
|
|||||||
<uni-popup-comments
|
<uni-popup-comments
|
||||||
:thisVlogerId="pinglunInfo.vlogerId"
|
:thisVlogerId="pinglunInfo.vlogerId"
|
||||||
:thisVlogId="pinglunInfo.vlogId"
|
:thisVlogId="pinglunInfo.vlogId"
|
||||||
|
:from="'guanzhu'"
|
||||||
></uni-popup-comments>
|
></uni-popup-comments>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
<!-- 分享 -->
|
<!-- 分享 -->
|
||||||
@ -509,7 +510,8 @@ export default {
|
|||||||
vlogId: '', // 视频id
|
vlogId: '', // 视频id
|
||||||
url: '',
|
url: '',
|
||||||
isPrivate: 0
|
isPrivate: 0
|
||||||
}
|
},
|
||||||
|
channelComment: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// components: {
|
// components: {
|
||||||
@ -573,6 +575,16 @@ export default {
|
|||||||
// },
|
// },
|
||||||
created() {
|
created() {
|
||||||
this.channel = new BroadcastChannel('video-progress');
|
this.channel = new BroadcastChannel('video-progress');
|
||||||
|
this.channelComment = new BroadcastChannel('comment-counts');
|
||||||
|
this.channelComment.onmessage = (event) => {
|
||||||
|
const { type, data } = event.data;
|
||||||
|
if (type == 'comment-counts') {
|
||||||
|
if (data.from == 'guanzhu') {
|
||||||
|
this.refreshVlogCounts();
|
||||||
|
this.freshCommentCounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
this.platform = uni.getSystemInfoSync().platform;
|
this.platform = uni.getSystemInfoSync().platform;
|
||||||
var model = uni.getSystemInfoSync().model;
|
var model = uni.getSystemInfoSync().model;
|
||||||
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
||||||
@ -609,6 +621,25 @@ export default {
|
|||||||
},
|
},
|
||||||
onReady() {},
|
onReady() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
async refreshVlogCounts() {
|
||||||
|
// 查询当前点赞数,重新赋值给当前视频
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogTotalLikedCounts(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].likeCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async freshCommentCounts() {
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogComment(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].commentsCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
// 关注博主
|
// 关注博主
|
||||||
async followMe(vlogerId) {
|
async followMe(vlogerId) {
|
||||||
var myUserInfo = storage.getVlogUserInfo();
|
var myUserInfo = storage.getVlogUserInfo();
|
||||||
|
@ -402,6 +402,7 @@
|
|||||||
<uni-popup-comments
|
<uni-popup-comments
|
||||||
:thisVlogerId="pinglunInfo.vlogerId"
|
:thisVlogerId="pinglunInfo.vlogerId"
|
||||||
:thisVlogId="pinglunInfo.vlogId"
|
:thisVlogId="pinglunInfo.vlogId"
|
||||||
|
:from="'local'"
|
||||||
></uni-popup-comments>
|
></uni-popup-comments>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
<!-- 分享 -->
|
<!-- 分享 -->
|
||||||
@ -509,7 +510,8 @@ export default {
|
|||||||
vlogId: '', // 视频id
|
vlogId: '', // 视频id
|
||||||
url: '',
|
url: '',
|
||||||
isPrivate: 0
|
isPrivate: 0
|
||||||
}
|
},
|
||||||
|
channelComment: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// components: {
|
// components: {
|
||||||
@ -573,6 +575,16 @@ export default {
|
|||||||
// },
|
// },
|
||||||
created() {
|
created() {
|
||||||
this.channel = new BroadcastChannel('video-progress');
|
this.channel = new BroadcastChannel('video-progress');
|
||||||
|
this.channelComment = new BroadcastChannel('comment-counts');
|
||||||
|
this.channelComment.onmessage = (event) => {
|
||||||
|
const { type, data } = event.data;
|
||||||
|
if (type == 'comment-counts') {
|
||||||
|
if (data.from == 'local') {
|
||||||
|
this.refreshVlogCounts();
|
||||||
|
this.freshCommentCounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
this.platform = uni.getSystemInfoSync().platform;
|
this.platform = uni.getSystemInfoSync().platform;
|
||||||
var model = uni.getSystemInfoSync().model;
|
var model = uni.getSystemInfoSync().model;
|
||||||
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
||||||
@ -609,6 +621,25 @@ export default {
|
|||||||
},
|
},
|
||||||
onReady() {},
|
onReady() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
async refreshVlogCounts() {
|
||||||
|
// 查询当前点赞数,重新赋值给当前视频
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogTotalLikedCounts(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].likeCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async freshCommentCounts() {
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogComment(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].commentsCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
// 关注博主
|
// 关注博主
|
||||||
async followMe(vlogerId) {
|
async followMe(vlogerId) {
|
||||||
var myUserInfo = storage.getVlogUserInfo();
|
var myUserInfo = storage.getVlogUserInfo();
|
||||||
|
@ -395,6 +395,7 @@
|
|||||||
<uni-popup-comments
|
<uni-popup-comments
|
||||||
:thisVlogerId="pinglunInfo.vlogerId"
|
:thisVlogerId="pinglunInfo.vlogerId"
|
||||||
:thisVlogId="pinglunInfo.vlogId"
|
:thisVlogId="pinglunInfo.vlogId"
|
||||||
|
:from="'tuijian'"
|
||||||
></uni-popup-comments>
|
></uni-popup-comments>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
<!-- 分享 -->
|
<!-- 分享 -->
|
||||||
@ -494,7 +495,8 @@ export default {
|
|||||||
player: '',
|
player: '',
|
||||||
// 新增内容
|
// 新增内容
|
||||||
page: 1,
|
page: 1,
|
||||||
channel: null,
|
channel: null, // 处理进度条
|
||||||
|
channelComment: null, // 处理评论数量显示
|
||||||
userId: '',
|
userId: '',
|
||||||
pinglunInfo: {
|
pinglunInfo: {
|
||||||
vlogerId: '', // 博主id
|
vlogerId: '', // 博主id
|
||||||
@ -565,6 +567,16 @@ export default {
|
|||||||
// },
|
// },
|
||||||
created() {
|
created() {
|
||||||
this.channel = new BroadcastChannel('video-progress');
|
this.channel = new BroadcastChannel('video-progress');
|
||||||
|
this.channelComment = new BroadcastChannel('comment-counts');
|
||||||
|
this.channelComment.onmessage = (event) => {
|
||||||
|
const { type, data } = event.data;
|
||||||
|
if (type == 'comment-counts') {
|
||||||
|
if (data.from == 'tuijian') {
|
||||||
|
this.refreshVlogCounts();
|
||||||
|
this.freshCommentCounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
this.platform = uni.getSystemInfoSync().platform;
|
this.platform = uni.getSystemInfoSync().platform;
|
||||||
var model = uni.getSystemInfoSync().model;
|
var model = uni.getSystemInfoSync().model;
|
||||||
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
||||||
@ -600,6 +612,25 @@ export default {
|
|||||||
},
|
},
|
||||||
onReady() {},
|
onReady() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
async refreshVlogCounts() {
|
||||||
|
// 查询当前点赞数,重新赋值给当前视频
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogTotalLikedCounts(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].likeCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async freshCommentCounts() {
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogComment(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].commentsCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
// 关注博主
|
// 关注博主
|
||||||
async followMe(vlogerId) {
|
async followMe(vlogerId) {
|
||||||
var myUserInfo = storage.getVlogUserInfo();
|
var myUserInfo = storage.getVlogUserInfo();
|
||||||
@ -888,7 +919,7 @@ export default {
|
|||||||
tozuozhe(userId) {
|
tozuozhe(userId) {
|
||||||
var myInfo = storage.getVlogUserInfo();
|
var myInfo = storage.getVlogUserInfo();
|
||||||
var myId = '';
|
var myId = '';
|
||||||
if (myId != null) {
|
if (myInfo != null) {
|
||||||
myId = myInfo.id;
|
myId = myInfo.id;
|
||||||
}
|
}
|
||||||
if (userId == myId) {
|
if (userId == myId) {
|
||||||
|
@ -405,6 +405,7 @@
|
|||||||
<uni-popup-comments
|
<uni-popup-comments
|
||||||
:thisVlogerId="pinglunInfo.vlogerId"
|
:thisVlogerId="pinglunInfo.vlogerId"
|
||||||
:thisVlogId="pinglunInfo.vlogId"
|
:thisVlogId="pinglunInfo.vlogId"
|
||||||
|
:from="'item'"
|
||||||
></uni-popup-comments>
|
></uni-popup-comments>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
<!-- 分享 -->
|
<!-- 分享 -->
|
||||||
@ -512,7 +513,8 @@ export default {
|
|||||||
url: '',
|
url: '',
|
||||||
isPrivate: 0
|
isPrivate: 0
|
||||||
},
|
},
|
||||||
vlogId: ''
|
vlogId: '',
|
||||||
|
channelComment: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// components: {
|
// components: {
|
||||||
@ -579,6 +581,16 @@ export default {
|
|||||||
// this.channel = new BroadcastChannel('video-progress');
|
// this.channel = new BroadcastChannel('video-progress');
|
||||||
// },
|
// },
|
||||||
created() {
|
created() {
|
||||||
|
this.channelComment = new BroadcastChannel('comment-counts');
|
||||||
|
this.channelComment.onmessage = (event) => {
|
||||||
|
const { type, data } = event.data;
|
||||||
|
if (type == 'comment-counts') {
|
||||||
|
if (data.from == 'item') {
|
||||||
|
this.refreshVlogCounts();
|
||||||
|
this.freshCommentCounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
this.platform = uni.getSystemInfoSync().platform;
|
this.platform = uni.getSystemInfoSync().platform;
|
||||||
var model = uni.getSystemInfoSync().model;
|
var model = uni.getSystemInfoSync().model;
|
||||||
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
|
||||||
@ -614,6 +626,25 @@ export default {
|
|||||||
},
|
},
|
||||||
onReady() {},
|
onReady() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
async refreshVlogCounts() {
|
||||||
|
// 查询当前点赞数,重新赋值给当前视频
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogTotalLikedCounts(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].likeCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async freshCommentCounts() {
|
||||||
|
var me = this;
|
||||||
|
var vlog = me.dataList[this.k];
|
||||||
|
var result = await vlogComment(vlog.vlogId);
|
||||||
|
if (result.data.status == 200) {
|
||||||
|
var counts = result.data.data;
|
||||||
|
this.dataList[this.k].commentsCounts = counts;
|
||||||
|
}
|
||||||
|
},
|
||||||
back() {
|
back() {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1
|
delta: 1
|
||||||
|
@ -111,6 +111,7 @@
|
|||||||
let animation = weex.requireModule('animation');
|
let animation = weex.requireModule('animation');
|
||||||
let dom = weex.requireModule('dom');
|
let dom = weex.requireModule('dom');
|
||||||
let system = uni.getSystemInfoSync();
|
let system = uni.getSystemInfoSync();
|
||||||
|
|
||||||
console.log(system);
|
console.log(system);
|
||||||
// 缓存每页最多
|
// 缓存每页最多
|
||||||
const MAX_CACHE_DATA = 100;
|
const MAX_CACHE_DATA = 100;
|
||||||
@ -180,8 +181,8 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
// 处理进度条事件
|
||||||
this.channel = new BroadcastChannel('video-progress');
|
this.channel = new BroadcastChannel('video-progress');
|
||||||
|
|
||||||
this.channel.onmessage = (event) => {
|
this.channel.onmessage = (event) => {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
const { type, data } = event.data;
|
const { type, data } = event.data;
|
||||||
@ -193,6 +194,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
onReady() {
|
onReady() {
|
||||||
|
this.handleHuaWei();
|
||||||
this._lastTabIndex = 0;
|
this._lastTabIndex = 0;
|
||||||
this.swiperWidth = 0;
|
this.swiperWidth = 0;
|
||||||
this.tabbarWidth = 0;
|
this.tabbarWidth = 0;
|
||||||
@ -268,6 +270,17 @@ export default {
|
|||||||
|
|
||||||
// },
|
// },
|
||||||
methods: {
|
methods: {
|
||||||
|
handleHuaWei() {
|
||||||
|
// 处理华为机型问题
|
||||||
|
const deviceInfo = uni.getSystemInfoSync();
|
||||||
|
console.log(deviceInfo.brand);
|
||||||
|
if (deviceInfo.brand === 'HUAWEI') {
|
||||||
|
// 针对华为设备,修改 Tabbar 样式
|
||||||
|
uni.setTabBarStyle({
|
||||||
|
color: '#e8e8e8'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
getLocation() {
|
getLocation() {
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wg84',
|
type: 'wg84',
|
||||||
@ -629,7 +642,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.uni-tab-item-title {
|
.uni-tab-item-title {
|
||||||
color: #999;
|
/* color: #999; */
|
||||||
|
color: #e8e8e8;
|
||||||
font-size: 30upx;
|
font-size: 30upx;
|
||||||
height: 80upx;
|
height: 80upx;
|
||||||
line-height: 80upx;
|
line-height: 80upx;
|
||||||
|
@ -388,6 +388,10 @@ export default {
|
|||||||
thisVlogId: {
|
thisVlogId: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
from: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -421,11 +425,20 @@ export default {
|
|||||||
page: 0,
|
page: 0,
|
||||||
totalPage: 0,
|
totalPage: 0,
|
||||||
commentCounts: 88,
|
commentCounts: 88,
|
||||||
commentList: []
|
commentList: [],
|
||||||
|
channelComment: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onShow() {},
|
onShow() {},
|
||||||
|
destroyed() {
|
||||||
|
console.log('评论组件销毁');
|
||||||
|
// 销毁时关闭 BroadcastChannel
|
||||||
|
if (this.channelComment) {
|
||||||
|
this.channelComment.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
|
console.log('评论组件创建');
|
||||||
var me = this;
|
var me = this;
|
||||||
var myUserInfo = storage.getVlogUserInfo();
|
var myUserInfo = storage.getVlogUserInfo();
|
||||||
var userId = '';
|
var userId = '';
|
||||||
@ -436,7 +449,7 @@ export default {
|
|||||||
this.isLogin = false;
|
this.isLogin = false;
|
||||||
}
|
}
|
||||||
me.loginUserId = userId;
|
me.loginUserId = userId;
|
||||||
|
this.channelComment = new BroadcastChannel('comment-counts');
|
||||||
this.freshCommentCounts();
|
this.freshCommentCounts();
|
||||||
this.doCommentPagingList(this.page + 1, true);
|
this.doCommentPagingList(this.page + 1, true);
|
||||||
},
|
},
|
||||||
@ -548,6 +561,11 @@ export default {
|
|||||||
var result = await vlogCommentDelete(vlogId, commentUserId, commentId);
|
var result = await vlogCommentDelete(vlogId, commentUserId, commentId);
|
||||||
if (result.data.status == 200) {
|
if (result.data.status == 200) {
|
||||||
me.doCommentPagingList(1, true);
|
me.doCommentPagingList(1, true);
|
||||||
|
// 刷新评论数量-1
|
||||||
|
this.channelComment.postMessage({
|
||||||
|
type: 'comment-counts',
|
||||||
|
data: { handle: 'reduce', from: this.from }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: result.data.msg,
|
title: result.data.msg,
|
||||||
@ -680,21 +698,21 @@ export default {
|
|||||||
var result = await vlogCommentCreate(pendingCommentObject);
|
var result = await vlogCommentCreate(pendingCommentObject);
|
||||||
console.log(result);
|
console.log(result);
|
||||||
if (result.data.status == 200) {
|
if (result.data.status == 200) {
|
||||||
var newCommentObject = result.data.data;
|
// var newCommentObject = result.data.data;
|
||||||
newCommentObject.commentId = newCommentObject.id;
|
// newCommentObject.commentId = newCommentObject.id;
|
||||||
newCommentObject.commentUserNickname = myUserInfo.nickname;
|
// newCommentObject.commentUserNickname = myUserInfo.nickname;
|
||||||
newCommentObject.commentUserFace = myUserInfo.face;
|
// newCommentObject.commentUserFace = myUserInfo.face;
|
||||||
newCommentObject.isLike = 0;
|
// newCommentObject.isLike = 0;
|
||||||
newCommentObject.vlogerId = userId;
|
// newCommentObject.vlogerId = userId;
|
||||||
newCommentObject.createTime = new Date().getTime();
|
// // var timeStr = dateFormat('YYYY-MM-DD HH:mm:ss', new Date());
|
||||||
|
// // newCommentObject.createTime = timeStr;
|
||||||
|
|
||||||
me.doCommentPagingList(1, true);
|
// // 评论/回复完毕后,回复thisFatherCommentId为“0”
|
||||||
|
// me.thisFatherCommentId = '0';
|
||||||
|
|
||||||
// 评论/回复完毕后,回复thisFatherCommentId为“0”
|
// // 把新评论添加到第一个位置,弱一致性,不需要从数据库里再去取
|
||||||
me.thisFatherCommentId = '0';
|
// me.commentList.unshift(newCommentObject);
|
||||||
|
|
||||||
// 把新评论添加到第一个位置,弱一致性,不需要从数据库里再去取
|
|
||||||
me.commentList.unshift(newCommentObject);
|
|
||||||
// 清空文本框
|
// 清空文本框
|
||||||
me.currentComment = '';
|
me.currentComment = '';
|
||||||
// 隐藏键盘
|
// 隐藏键盘
|
||||||
@ -707,6 +725,11 @@ export default {
|
|||||||
me.$nextTick(() => {
|
me.$nextTick(() => {
|
||||||
me.scrollTop = 0; //赋值为0即代表返回顶部
|
me.scrollTop = 0; //赋值为0即代表返回顶部
|
||||||
});
|
});
|
||||||
|
// 刷新评论数量+1
|
||||||
|
this.channelComment.postMessage({
|
||||||
|
type: 'comment-counts',
|
||||||
|
data: { handle: 'add', from: this.from }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: result.data.msg,
|
title: result.data.msg,
|
||||||
@ -716,26 +739,14 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
me.freshCommentCounts();
|
me.freshCommentCounts();
|
||||||
|
me.doCommentPagingList(1, true);
|
||||||
// uni.request({
|
|
||||||
// method: "POST",
|
|
||||||
// header: {
|
|
||||||
// headerUserId: userId,
|
|
||||||
// headerUserToken: app.getUserSessionToken()
|
|
||||||
// },
|
|
||||||
// url: serverUrl + "/comment/create",
|
|
||||||
// data: pendingCommentObject,
|
|
||||||
// success(result) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
// 把超过1000或10000的数字调整,比如1.3k/6.8w
|
// 把超过1000或10000的数字调整,比如1.3k/6.8w
|
||||||
getGraceNumber(num) {
|
getGraceNumber(num) {
|
||||||
return graceNumber(num);
|
return graceNumber(num);
|
||||||
},
|
},
|
||||||
// 时间显示 刚刚/xx小时前/...
|
// 时间显示 刚刚/xx小时前/...
|
||||||
getGraceDateBeforeNow(dateTimeStr) {
|
getGraceDateBeforeNow(dateTimeStr = '') {
|
||||||
// var date = dateFormat('YYYY-MM-DD HH:mm:ss', new Date(dateTimeStr));
|
// var date = dateFormat('YYYY-MM-DD HH:mm:ss', new Date(dateTimeStr));
|
||||||
return getDateBeforeNow(dateTimeStr);
|
return getDateBeforeNow(dateTimeStr);
|
||||||
},
|
},
|
||||||
|
@ -121,33 +121,71 @@ const graceNumber = (number) => {
|
|||||||
|
|
||||||
// 时间格式化时间为: 多少分钟前、多少天前
|
// 时间格式化时间为: 多少分钟前、多少天前
|
||||||
// time 2020-09-10 20:20:20
|
// time 2020-09-10 20:20:20
|
||||||
const getDateBeforeNow = (stringTime) => {
|
const getDateBeforeNow = (stringTime = '') => {
|
||||||
stringTime = new Date(stringTime.replace(/-/g, "/"));
|
const minute = 1000 * 60;
|
||||||
let minute = 1000 * 60;
|
const hour = minute * 60;
|
||||||
let hour = minute * 60;
|
const day = hour * 24;
|
||||||
let day = hour * 24;
|
const week = day * 7;
|
||||||
let week = day * 7;
|
const month = day * 30;
|
||||||
let month = day * 30;
|
|
||||||
let time1 = new Date().getTime(); //当前的时间戳
|
// 获取当前时间戳
|
||||||
let time2 = Date.parse(new Date(stringTime)); //指定时间的时间戳
|
const currentTime = new Date().getTime();
|
||||||
let time = time1 - time2;
|
|
||||||
|
// 如果没有传入时间参数,使用当前时间
|
||||||
|
const time = stringTime ? new Date(stringTime.replace(/-/g, "/")).getTime() : currentTime;
|
||||||
|
|
||||||
|
const difference = currentTime - time; // 计算时间差
|
||||||
|
|
||||||
let result = null;
|
let result = null;
|
||||||
if (time < 0) {
|
|
||||||
|
// 如果时间差小于0(未来的时间),返回原始时间
|
||||||
|
if (difference < 0) {
|
||||||
result = stringTime;
|
result = stringTime;
|
||||||
} else if (time / month >= 1) {
|
} else if (difference >= month) {
|
||||||
result = parseInt(time / month) + "月前";
|
result = Math.floor(difference / month) + "月前";
|
||||||
} else if (time / week >= 1) {
|
} else if (difference >= week) {
|
||||||
result = parseInt(time / week) + "周前";
|
result = Math.floor(difference / week) + "周前";
|
||||||
} else if (time / day >= 1) {
|
} else if (difference >= day) {
|
||||||
result = parseInt(time / day) + "天前";
|
result = Math.floor(difference / day) + "天前";
|
||||||
} else if (time / hour >= 1) {
|
} else if (difference >= hour) {
|
||||||
result = parseInt(time / hour) + "小时前";
|
result = Math.floor(difference / hour) + "小时前";
|
||||||
} else if (time / minute >= 1) {
|
} else if (difference >= minute) {
|
||||||
result = parseInt(time / minute) + "分钟前";
|
result = Math.floor(difference / minute) + "分钟前";
|
||||||
} else {
|
} else {
|
||||||
result = "刚刚";
|
result = "刚刚";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
// let minute = 1000 * 60;
|
||||||
|
// let hour = minute * 60;
|
||||||
|
// let day = hour * 24;
|
||||||
|
// let week = day * 7;
|
||||||
|
// let month = day * 30;
|
||||||
|
// let time1 = new Date().getTime(); //当前的时间戳
|
||||||
|
// if (stringTime == '') {
|
||||||
|
// stringTime = time1
|
||||||
|
// } else {
|
||||||
|
// stringTime = new Date(stringTime.replace(/-/g, "/"));
|
||||||
|
// }
|
||||||
|
// let time2 = Date.parse(new Date(stringTime)); //指定时间的时间戳
|
||||||
|
// let time = time1 - time2;
|
||||||
|
// let result = null;
|
||||||
|
// if (time < 0) {
|
||||||
|
// result = stringTime;
|
||||||
|
// } else if (time / month >= 1) {
|
||||||
|
// result = parseInt(time / month) + "月前";
|
||||||
|
// } else if (time / week >= 1) {
|
||||||
|
// result = parseInt(time / week) + "周前";
|
||||||
|
// } else if (time / day >= 1) {
|
||||||
|
// result = parseInt(time / day) + "天前";
|
||||||
|
// } else if (time / hour >= 1) {
|
||||||
|
// result = parseInt(time / hour) + "小时前";
|
||||||
|
// } else if (time / minute >= 1) {
|
||||||
|
// result = parseInt(time / minute) + "分钟前";
|
||||||
|
// } else {
|
||||||
|
// result = "刚刚";
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
}
|
}
|
||||||
// 判断是否为空
|
// 判断是否为空
|
||||||
const isStrEmpty = (str) => {
|
const isStrEmpty = (str) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user