|
@@ -30,14 +30,19 @@
|
|
|
<view class="left flex">
|
|
|
<image :src="item.img" mode="" class="avatar"/>
|
|
|
<view class="content">
|
|
|
- <view class="text_oneLine">{{item.content_first}}</view>
|
|
|
+ <view class="text_oneLine" style="width: 500rpx">{{item.content_first}}</view>
|
|
|
<view class="msg text_oneLine">{{item.content_second}}</view>
|
|
|
- <view class="time">{{item.content_second}}</view>
|
|
|
+ <view class="time">
|
|
|
+ {{item.create_time | formatTime}}
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<text class="read-ico" v-if="!item.is_read"/>
|
|
|
+ <view class="detail-ico" @click="toReportDetail(item)">
|
|
|
+ 查看详情<van-icon name="arrow"/>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="action" @click.stop="delMessageHandle(item)">删除</view>
|
|
|
+ <view class="action" @click.stop="delMessageHandle(item,index)">删除</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="nodata" v-else>
|
|
@@ -49,8 +54,33 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import * as $message from '@/api/message'
|
|
|
+ import * as $message from '@/api/message.js'
|
|
|
+ const moment = require('../utils/moment-with-locales.min.js');
|
|
|
+ moment.locale('zh-cn');
|
|
|
export default {
|
|
|
+ filters: {
|
|
|
+ formatTime(val) {
|
|
|
+ const time = new Date(val);
|
|
|
+ const now = new Date();
|
|
|
+ const infer_time = parseInt((now.getTime() - time.getTime())/1000/60/60/24);//时间差
|
|
|
+ const infer_year = parseInt(now.getFullYear() - time.getFullYear());// 年限差
|
|
|
+
|
|
|
+ //当天
|
|
|
+ if(infer_time === 0) {
|
|
|
+ return moment(time).format('HH:mm:ss')
|
|
|
+ } else if(infer_time === 1) {
|
|
|
+ return `昨天 ${moment(time).format('HH:mm:ss')}`
|
|
|
+ } else if(infer_time === 2) {
|
|
|
+ return `前天 ${moment(time).format('HH:mm:ss')}`
|
|
|
+ } else if( infer_time >=3 && infer_time <=7 ) { //周内
|
|
|
+ return moment(time).format('ddd HH:mm:ss')
|
|
|
+ } else if(infer_year === 0) {
|
|
|
+ return moment(time).format('MM-DD HH:mm:ss')
|
|
|
+ } else {
|
|
|
+ return moment(time).format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
default_tab: 0,
|
|
@@ -83,7 +113,7 @@ import * as $message from '@/api/message'
|
|
|
|
|
|
/* 获取列表 */
|
|
|
async getMessageList() {
|
|
|
- const { code,data } = $message.apiMessageList({
|
|
|
+ const { code,data } = await $message.apiMessageList({
|
|
|
type: this.default_tab,
|
|
|
current_index: this.page_no,
|
|
|
page_size: 20
|
|
@@ -93,12 +123,12 @@ import * as $message from '@/api/message'
|
|
|
const { list,paging } = data;
|
|
|
|
|
|
this.isHaveMore = this.page_no >= paging.pages ? false : true;
|
|
|
- this.messageList = this.page_no === 1 ? (list || []) : [...this.messageList,...list]
|
|
|
+ this.messageList = this.page_no === 1 ? (list || []) : [...this.messageList,...list];
|
|
|
},
|
|
|
|
|
|
/* 一键已读 */
|
|
|
async allReadHandle() {
|
|
|
- const { code } = $message.apiReadAll({ type: this.default_tab })
|
|
|
+ const { code } = await $message.apiReadAll({ type: this.default_tab })
|
|
|
if( code!==200 ) return
|
|
|
|
|
|
this.page_no = 1;
|
|
@@ -107,19 +137,28 @@ import * as $message from '@/api/message'
|
|
|
},
|
|
|
|
|
|
/* 删除消息 */
|
|
|
- delMessageHandle() {
|
|
|
+ delMessageHandle({msg_id},index) {
|
|
|
+ const _this = this;
|
|
|
uni.showModal({
|
|
|
title: "",
|
|
|
content: "确定要删除该留言吗?",
|
|
|
confirmColor: "#6784A7",
|
|
|
- success: function() {
|
|
|
+ success: async function() {
|
|
|
+ const { code } = await $message.apiReadOneMessage({ msg_id })
|
|
|
+ if( code!==200 ) return
|
|
|
|
|
|
+ uni.showToast({
|
|
|
+ title: '删除成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ _this.messageList.splice(index,1)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
onPullDownRefresh() {
|
|
|
this.page_no = 1;
|
|
|
+ this.getMessageList()
|
|
|
setTimeout(() => {
|
|
|
uni.stopPullDownRefresh()
|
|
|
}, 1500)
|
|
@@ -131,14 +170,23 @@ import * as $message from '@/api/message'
|
|
|
this.getMessageList()
|
|
|
},
|
|
|
|
|
|
+ /* 到报告详情 */
|
|
|
+ toReportDetail({ report_chapter_id,report_id }) {
|
|
|
+ report_chapter_id
|
|
|
+ ? uni.navigateTo({url: `/pages-report/chapterDetail?chapterId=${report_chapter_id}&fromPage=message`})
|
|
|
+ : uni.navigateTo({url:`/pages-report/reportDetail?reportId=${report_id}&fromPage=message`})
|
|
|
+ },
|
|
|
+
|
|
|
async drawStart(item,e) {
|
|
|
let touch = e.touches[0];
|
|
|
this.startX = touch.clientX;
|
|
|
|
|
|
- const { msg_id } = item;
|
|
|
- const { code } = await apiReadOneMessage({ msg_id })
|
|
|
- if( code!==200 ) return
|
|
|
- item.is_read = 1;
|
|
|
+ if(!item.is_read) {
|
|
|
+ const { msg_id } = item;
|
|
|
+ const { code } = await $message.apiReadOneMessage({ msg_id })
|
|
|
+ if( code!==200 ) return
|
|
|
+ item.is_read = 1;
|
|
|
+ }
|
|
|
},
|
|
|
//触摸滑动
|
|
|
drawMove(e) {
|
|
@@ -223,8 +271,9 @@ import * as $message from '@/api/message'
|
|
|
.content {
|
|
|
color: #666;
|
|
|
font-size: 28rpx;
|
|
|
- width: 80%;
|
|
|
+ flex: 1;
|
|
|
.msg {
|
|
|
+ width: 500rpx;
|
|
|
color: #333;
|
|
|
font-size: 30rpx;
|
|
|
margin: 10rpx 0;
|
|
@@ -236,8 +285,8 @@ import * as $message from '@/api/message'
|
|
|
}
|
|
|
}
|
|
|
.read-ico {
|
|
|
- width: 30rpx;
|
|
|
- height: 30rpx;
|
|
|
+ width: 26rpx;
|
|
|
+ height: 26rpx;
|
|
|
border-radius: 50%;
|
|
|
position: absolute;
|
|
|
right: 0;
|
|
@@ -245,6 +294,13 @@ import * as $message from '@/api/message'
|
|
|
transform: translateY(-50%);
|
|
|
background-color: #D62020;
|
|
|
}
|
|
|
+
|
|
|
+ .detail-ico {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
|
|
|
.action {
|
|
|
width: 176rpx;
|