|
@@ -93,13 +93,63 @@ Page({
|
|
|
"ftype": type
|
|
|
}
|
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
if (res.msg != '成功') return wx.showToast({
|
|
|
title: res.data,
|
|
|
icon: 'none'
|
|
|
});
|
|
|
+ let data = res.data,
|
|
|
+ date = new Date(),
|
|
|
+ opt = {
|
|
|
+ "Y": date.getFullYear().toString(), // 年
|
|
|
+ "m": (date.getMonth() + 1).toString(), // 月
|
|
|
+ "d": date.getDate().toString(), // 日
|
|
|
+ "H": date.getHours().toString(), // 时
|
|
|
+ "M": date.getMinutes().toString(), // 分
|
|
|
+ "S": date.getSeconds().toString() // 秒
|
|
|
+ };
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ let arr = data[i].createdate.split(' '),
|
|
|
+ YmD = arr[0].split('-'), //年月日
|
|
|
+ HM = arr[1].slice(0, arr[1].lastIndexOf(':')), //小时,分钟
|
|
|
+ optm = parseInt(opt.m),
|
|
|
+ m = parseInt(YmD[1]),
|
|
|
+ optd = parseInt(opt.d),
|
|
|
+ d = parseInt(YmD[2])
|
|
|
+
|
|
|
+ //同年
|
|
|
+ if (parseInt(opt.Y) == parseInt(YmD[0])) {
|
|
|
+ if (opt.m > 10) opt.m = "0" + opt.m;
|
|
|
+ //同月
|
|
|
+ if (optm == m) {
|
|
|
+ if (optd == d) {
|
|
|
+ data[i].time = '今天 ' + HM;
|
|
|
+ } else if (optd - d == 1) {
|
|
|
+ data[i].time = '昨天 ' + HM;
|
|
|
+ } else if (optd - d == 2) {
|
|
|
+ data[i].time = '前天 ' + HM;
|
|
|
+ } else if (optd - d >= 3) {
|
|
|
+ data[i].time = '三天前'
|
|
|
+ } else if (optd - d >= 7) {
|
|
|
+ data[i].time = '七天前'
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //不同月
|
|
|
+ if (optm - m == 1) {
|
|
|
+ data[i].time = '1月前'
|
|
|
+ } else if (optm - m == 2) {
|
|
|
+ data[i].time = '2月前'
|
|
|
+ } else if (optm - m >= 3 && opt.m - YmD[1] < 6) {
|
|
|
+ data[i].time = '3月前'
|
|
|
+ } else if (optm - m >= 6) {
|
|
|
+ data[i].time = '半年前'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data[i].time = YmD[0] + '年'
|
|
|
+ }
|
|
|
+ };
|
|
|
this.setData({
|
|
|
- msgList: res.data,
|
|
|
+ msgList: data,
|
|
|
pageTotal: res.pageTotal
|
|
|
})
|
|
|
})
|