Commit 6f678f58 authored by chuan.liu's avatar chuan.liu

消息列表新增

parent 6bf871b8
......@@ -12,7 +12,7 @@
</div>
</uni-refresh>
<uni-cell v-for="(item, index) in dataList" :key="item.id">
<message-list :newsItem="item" @click="goDetail(item)"></message-list>
<message-list :newsItem="item" :index='index' @click.native="goDetail(item)"></message-list>
</uni-cell>
<uni-cell v-if="isLoading || dataList.length > 4">
<view class="loading-more">
......@@ -20,7 +20,7 @@
</view>
</uni-cell>
</uni-list>
<!-- <no-data class="no-data" v-if="isNoData" @retry="loadMore"></no-data> -->
<no-data class="no-data" v-if="isNoData" @retry="loadMore"></no-data>
</view>
</template>
......@@ -32,6 +32,15 @@
import noData from '@/components/nodata.nvue';
import messageList from './message-list.nvue';
import {
mapState
} from 'vuex'
import {
apiFindUnreadMsg,
apiEditStatus
} from '@/servers/message.js'
export default {
components: {
uniList,
......@@ -41,23 +50,9 @@
noData,
messageList
},
props: {
nid: {
type: [Number, String],
default: '0'
}
},
data() {
return {
dataList: [{
id: "tab01",
name: '最新',
newsid: 0
}, {
id: "tab02",
name: '大公司',
newsid: 23
}],
dataList: [],
navigateFlag: false,
pulling: false,
refreshing: false,
......@@ -73,17 +68,29 @@
contentrefresh: '',
contentnomore: ''
},
refreshIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB5QTFRFcHBw3Nzct7e39vb2ycnJioqK7e3tpqam29vb////D8oK7wAAAAp0Uk5T////////////ALLMLM8AAABxSURBVHja7JVBDoAgDASrjqj//7CJBi90iyYeOHTPMwmFZrHjYyyFYYUy1bwUZqtJIYVxhf1a6u0R7iUvWsCcrEtwJHp8MwMdvh2amHduiZD3rpWId9+BgPd7Cc2LIkPyqvlQvKxKBJ//Qwq/CacAAwDUv0a0YuKhzgAAAABJRU5ErkJggg=="
refreshIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB5QTFRFcHBw3Nzct7e39vb2ycnJioqK7e3tpqam29vb////D8oK7wAAAAp0Uk5T////////////ALLMLM8AAABxSURBVHja7JVBDoAgDASrjqj//7CJBi90iyYeOHTPMwmFZrHjYyyFYYUy1bwUZqtJIYVxhf1a6u0R7iUvWsCcrEtwJHp8MwMdvh2amHduiZD3rpWId9+BgPd7Cc2LIkPyqvlQvKxKBJ//Qwq/CacAAwDUv0a0YuKhzgAAAABJRU5ErkJggg==",
page: {
"PAGE": "1",
"PAGESIZE": "10",
},
loadParams: {
total: 0,
totalPage: 1,
isDone: false,
isRefresh: false
},
messageType: 0
}
},
computed: {
...mapState(['userInfo'])
},
onLoad(option) {
this.messageType = option.messageType
this.loadData(true)
},
created() {
this.pullTimer = null;
this.requestParams = {
columnId: this.nid,
minId: 0,
pageSize: 10,
column: 'id,post_id,title,author_name,cover,published_at,comments_count'
};
this._isWidescreen = false;
// #ifdef H5
......@@ -103,74 +110,85 @@
this.isLoading = true;
this.isNoData = false;
this.requestParams.time = new Date().getTime() + '';
var startTime = new Date();
uni.request({
// url: this.$host + 'api/news',
url: 'https://unidemo.dcloud.net.cn/api/news',
data: this.requestParams,
success: (result) => {
var endTime = new Date();
const data = result.data;
this.isNoData = (data.length <= 0);
const params = {
customer: this.userInfo.code,
msgType: 'app',
msgStatus: this.messageType,
...this.page
}
const data_list = data.map((news) => {
return {
id: this.newGuid() + news.id,
newsid: news.id,
article_type: 1,
datetime: (new Date(news.published_at.replace(/\-/g, '/')).getTime()),
title: news.title,
image_url: news.cover,
source: news.author_name,
comment_count: news.comments_count,
post_id: news.post_id
};
});
apiFindUnreadMsg(params).then((res) => {
const {
Rows,
page,
Total
} = res.data
const data_list = Rows;
this.page.PAGE = page
this.loadParams.total = Total
this.loadParams.totalPage = Math.ceil(Total * 1 / this.page.PAGESIZE * 1)
if (refresh) {
this.dataList = data_list;
this.requestParams.minId = 0;
} else {
this.dataList = this.dataList.concat(data_list);
this.requestParams.minId = data[data.length - 1].id;
}
this.isNoData = (data_list.length <= 0);
if (this.dataList.length > 0 && this._isWidescreen && this.dataList.length <= 10) {
this.goDetail(this.dataList[0]);
}
},
fail: (err) => {
if (this.dataList.length == 0) {
this.isNoData = true;
}
},
complete: (e) => {
this.isLoading = false;
if (refresh) {
this.refreshing = false;
this.refreshFlag = false;
this.refreshText = "已刷新";
if (this.pullTimer) {
clearTimeout(this.pullTimer);
}
this.pullTimer = setTimeout(() => {
this.pulling = false;
}, 1000);
if (refresh) {
this.dataList = data_list;
} else {
this.dataList = this.dataList.concat(data_list);
}
if (this.dataList.length > 0 && this._isWidescreen && this.dataList.length <= 10) {
// this.goDetail(this.dataList[0]);
}
}).catch(() => {
if (this.dataList.length == 0) {
this.isNoData = true;
}
}).finally(() => {
this.isLoading = false;
if (refresh) {
this.refreshing = false;
this.refreshFlag = false;
this.refreshText = "已刷新";
if (this.pullTimer) {
clearTimeout(this.pullTimer);
}
this.pullTimer = setTimeout(() => {
this.pulling = false;
}, 1000);
}
});
})
},
loadMore(e) {
this.loadData();
console.log('loadMore')
if (this.page.PAGE < this.loadParams.totalPage) {
this.page.PAGE++
this.loadData();
} else {
this.loadingText = '-- 到底了 --'
}
},
clear() {
this.dataList.length = 0;
this.requestParams.minId = 0;
},
goDetail(detail) {
async goDetail(item) {
const params = {
id: item.id
}
uni.showLoading({
title: '加载中'
});
setTimeout(function() {
uni.hideLoading();
}, 2000);
let res = await apiEditStatus(params)
uni.hideLoading();
if (res.status === 1) {
this.loadData(true);
}
},
refreshData() {
if (this.isLoading) {
......@@ -179,6 +197,14 @@
this.pulling = true;
this.refreshing = true;
this.refreshText = "正在刷新...";
this.loadingText = '加载中...'
this.loadParams = {
total: 0,
totalPage: 1,
isDone: false,
isRefresh: false
}
this.page.PAGE = 1
this.loadData(true);
},
onrefresh(e) {
......@@ -207,13 +233,6 @@
this.refreshText = "下拉可以刷新";
}
},
newGuid() {
let s4 = function() {
return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
}
return (s4() + s4() + "-" + s4() + "-4" + s4().substr(0, 3) + "-" + s4() + "-" + s4() + s4() + s4())
.toUpperCase();
}
}
}
</script>
......@@ -298,6 +317,7 @@
}
.loading-more {
flex: 1;
align-items: center;
justify-content: center;
padding-top: 14px;
......
<template>
<view class="order view">
<view class="status_bar" :style="navHeight"></view>
<view class="status_bar" v-if="index===0" :style="navHeight"></view>
<view class="listview">
<view class="cell-list">
<text class="date">10:18</text>
<text class="date">{{newsItem.CREATEDATE}}</text>
<view class="cell-list-block">
<view class="list-block-title">
<image class="icon-address" src="@/static/image/message_notice@3x.png" mode="aspectFit"></image>
<text class="list-block-title__text">最新消息</text>
<text class="list-block-title__text">{{newsItem.MSGTITLE}}</text>
</view>
<view class="cell-list-block__content">
<text class="cell-list-block__title">新川商贸要货审批,请尽快审批。新川商贸要货审批,请尽快审批。</text>
</view>
</view>
<view class="cell-list-block">
<view class="list-block-title">
<image class="icon-address" src="@/static/image/message_notice@3x.png" mode="aspectFit"></image>
<text class="list-block-title__text">最新消息</text>
</view>
<view class="cell-list-block__content">
<text
class="cell-list-block__title">新川商贸要货审批,请尽快审批。新川商贸要货审批,请尽快审批。新川商贸要货审批,请尽快审批。新川商贸要货审批,请尽快审批。</text>
<text class="cell-list-block__title">{{newsItem.MSGCONTENT}}</text>
</view>
</view>
</view>
......@@ -38,9 +28,17 @@
props: {
newsItem: {
type: Object,
default: function(e) {
return {}
default: () => {
return {
CREATEDATE: '',
MSGCONTENT: '',
MSGTITLE: '',
}
}
},
index: {
type: Number,
default: 0
}
},
data() {
......@@ -48,27 +46,8 @@
}
},
created() {
this.getMessageList(0)
this.getMessageList(1)
},
created() {},
computed: {
async getMessageList(type) {
let params = {
customer: this.userInfo.code,
msgType: 'app',
page: 1,
pagesize: 1,
msgStatus: type
}
let res = await apiFindUnreadMsg(params)
if (type === 0) {
this.unreadList = res.data.list
this.unreadCount = res.data.total
} else {
this.readList = res.data
}
},
navHeight() {
return {
'height': `${this.sysinfo.safeArea.top + 44}px`
......@@ -104,7 +83,6 @@
.order {
flex: 1;
background: #f0f4f5;
overflow-y: scroll;
padding: 24rpx;
}
......@@ -153,7 +131,7 @@
background: #fff;
padding: 20rpx 24rpx;
border-radius: 20rpx;
margin-bottom: 56rpx;
// margin-bottom: 56rpx;
}
.list-block-title {
......
......@@ -3,21 +3,21 @@
<view class="status_bar" :style="navHeight"></view>
<view class="listview">
<view class="cell-list">
<view class="cell-list-block" @click="goMessageList('unread')">
<view class="cell-list-block" @click="goMessageList('0')">
<image class="icon-address" src="@/static/image/message_unread@3x.png" mode="aspectFit"></image>
<view class="cell-list-block__content">
<text class="cell-list-block__title">未读消息</text>
<text class="cell-list-block__desc">最新消息:新川商贸要货审批</text>
<text class="cell-list-block__desc">最新消息:{{unreadList[0].MSGTITLE}}</text>
</view>
<text class="dot">2</text>
<text class="dot" v-if="unreadCount>0">{{unreadCount}}</text>
<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
<view class="line"></view>
</view>
<view class="cell-list-block" @click="goMessageList('read')">
<view class="cell-list-block" @click="goMessageList('1')">
<image class="icon-address" src="@/static/image/message_read@3x.png" mode="aspectFit"></image>
<view class="cell-list-block__content">
<text class="cell-list-block__title">已读消息</text>
<text class="cell-list-block__desc">暂无内容</text>
<text class="cell-list-block__desc">{{readList[0].MSGTITLE}}</text>
</view>
<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
</view>
......@@ -35,16 +35,15 @@
apiFindUnreadMsg
} from '@/servers/message.js'
import {
apiGetBpPrice
} from '@/servers/common.js'
export default {
data() {
return {
readList: [],
unreadList: [],
readList: [{
MSGTITLE: '暂无内容'
}],
unreadList: [{
MSGTITLE: '暂无内容'
}],
unreadCount: 0
}
},
......@@ -58,15 +57,9 @@
},
onShow() {
this.getMessageList(0)
// this.getMessageList(1)
// this.getBpPrice()
this.getMessageList(1)
},
methods: {
async getBpPrice() {
const res = await apiGetBpPrice({
PARTNER: this.userInfo.code
})
},
async getMessageList(type) {
console.log(1)
let params = {
......@@ -77,16 +70,19 @@
msgStatus: type
}
let res = await apiFindUnreadMsg(params)
if (type === 0) {
this.unreadList = res.data.list
this.unreadCount = res.data.total
} else {
this.readList = res.data
if (res.status === 1 && res.data.Rows.length > 0) {
if (type === 0) {
this.unreadList = res.data.Rows
this.unreadCount = res.data.Total
} else {
this.readList = res.data.Rows
}
}
},
goMessageList(type) {
uni.navigateTo({
url: `/pages/message-list/message-list-page`
url: `/pages/message-list/message-list-page?messageType=${type}`
});
}
}
......
......@@ -112,7 +112,7 @@
}
},
computed: {
...mapState(['sysinfo', 'userInfo'])
...mapState(['userInfo'])
},
created() {
this.pullTimer = null;
......
......@@ -39,7 +39,7 @@ class Request {
return new Promise((resolve, reject) => {
options.complete = (response) => {
console.log('api.helper---options.complete', response)
// console.log('api.helper---options.complete', response)
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
uni.hideLoading();
// 清除定时器,如果请求回来了,就无需loading
......@@ -123,7 +123,7 @@ class Request {
this.config.timer = null;
}, this.config.loadingTime);
}
console.log('api.helper-----finally***request', options)
// console.log('api.helper-----finally***request', options)
uni.request(options);
})
// .catch(res => {
......
......@@ -16,7 +16,9 @@ export async function apiFindUnreadMsg(params) {
* @returns {Promise<AxiosResponse<T>>}
*/
export async function apiEditStatus(params) {
const res = await apiHelper.post('/crm-app//message/editStatus', params)
const res = await apiHelper.post('/crm-app//message/editStatus', params, {
'content-type': "application/x-www-form-urlencoded"
})
return res
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment