blob: e764ad878f8b21af8f37238b3654f796134360a2 [file] [log] [blame]
<template>
<view class="message">
<u-sticky>
<view class="message-tabs">
<u-tabs :list="tabs" :current="current" @change="change" bar-width="250" item-width="250" :is-scroll="false"
bar-height="3"></u-tabs>
</view>
</u-sticky>
<view class="message-list">
<view v-if="current==1">
<scroll-view :scroll-y="true" class="scrollView" @scrolltolower="getMoreLeaveList">
<u-swipe-action :show="v.show" :index="i"
v-for="(v, i) in leaveMsg" :key="v.fbid"
@content-click="toPath('/pages/sub_mine/leaveMsgDetail?id='+v.fbid)"
@click="click"
@open="open"
@close="close"
:options="options"
v-if="v.isdelete =='0' ">
<view class="item u-border-bottom">
<view class="title-wrap">
<u-cell-group :border="false">
<u-cell-item :title="v.title" :arrow="true" :label="v.fbtime" value="查看详情" :center="true"></u-cell-item>
</u-cell-group>
</view>
</view>
</u-swipe-action>
<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="30" />
</scroll-view>
</view>
<view v-if="current==0">
<scroll-view :scroll-y="true" class="scrollView" @scrolltolower="getMoreSystemList">
<u-swipe-action :index="i"
v-for="(v, i) in system_list" :key="v.fbid"
@content-click="toPath('/pages/sub_mine/billsDetails?data='+JSON.stringify(v))">
<view class="item u-border-bottom">
<view class="title-wrap">
<u-cell-group :border="false">
<u-cell-item :title="v.content" :arrow="true" :label="v.date" value="查看详情" :center="true"></u-cell-item>
</u-cell-group>
</view>
</view>
</u-swipe-action>
<u-loadmore :status="status_system" :icon-type="iconType" :load-text="loadText" margin-top="30" />
</scroll-view>
</view>
<u-empty text="暂无消息" mode="message" margin-top="300" v-if="current ==2 "></u-empty>
</view>
</view>
</template>
<script>
export default {
data() {
return {
tabs: [{
name: "推送消息"
}, {
name: "留言消息"
}, {
name: "其他消息"
}],
current: 1,
list: [],
loadText: {
loadmore: '轻轻上拉',
loading: '努力加载中',
nomore: '暂无更多'
},
status: "loadmore",
status_system:'nomore',
iconType: 'circle',
pageno_system: 1,
pageno:1,
leaveMsg: [],
system_list:[],
options: [{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
}
},
methods: {
change(index) {
let that = this
that.current = index
that.leaveMsg.forEach(item => {
item.show = false
})
if(index==0 && that.system_list.length ==0){
this.getSystemMsgList(this.pageno_system)
}
},
open(index) {
let that = this
that.leaveMsg.forEach(item => {
item.show = false
})
that.leaveMsg[index].show = true
},
close(index) {
let that = this
that.leaveMsg[index].show = false
},
click(index) {
let that = this
let fbid = that.leaveMsg[index].fbid
//console.log(that.leaveMsg)
uni.showModal({
title: "提示",
content: "确定要删除这条留言吗?",
success(res) {
if (res.confirm) {
that.$u.post('v1/feedback/delete/' + fbid, {}).then(res => {
that.leaveMsg[index].show = false
that.leaveMsg.splice(index, 1)
uni.showToast({
title: "您已成功删除此留言",
icon: "none",
duration: 1500
})
}).catch(res => {
that.leaveMsg[index].show = false
})
} else if (res.cancel) {
that.leaveMsg[index].show = false
}
}
})
},
getLeaveMsgList(no) {
let that = this
let params = {
pageno: no,
pagesize: 10
}
that.$u.get("/v1/feedback/list", params).then(res => {
let list = res.data.list
let total = res.data.totalCount
let page = res.data.totalPage
if (no > page) {
that.status = "nomore"
return false
}
//console.log(total,list.length)
if (list.length) {
if (list.length >= total) {
that.status = "nomore"
} else {
that.status = "loadmore"
that.pageno += 1
}
list.forEach(item => {
item.fbtime = item.fbtime.substr(0, 4) + "-" + item.fbtime.substr(4, 2) + "-" + item.fbtime.substr(6, 2) +
" " + item.fbtime.substr(8, 2) + ":" + item.fbtime.substr(10, 2) + ":" + item.fbtime.substr(12, 2);
item.show = false
})
that.leaveMsg = that.leaveMsg.concat(list)
//console.log(list)
} else {
that.leaveMsg = that.leaveMsg.concat(list)
that.status = "nomore"
}
})
},
getSystemMsgList(no) {
let that = this
let params = {
pageno: no,
pagesize: 10
}
that.$u.get("/v1/pushmsg/list", params).then(res => {
let list = res.data.data
let total = res.data.totalCount
let page = res.data.totalPages
if (no > page) {
that.status_system = "nomore"
return false
}
console.log(total,list.length)
if (list.length) {
if (list.length >= total) {
that.status_system = "nomore"
} else {
that.status_system = "loadmore"
that.pageno_system += 1
}
list.forEach(item => {
item.status = 'success'
item.date = item.lastupdate.substr(0, 4) + "-" + item.lastupdate.substr(4, 2) + "-" + item.lastupdate.substr(6, 2) +
" " + item.lastupdate.substr(8, 2) + ":" + item.lastupdate.substr(10, 2) + ":" + item.lastupdate.substr(12, 2);
item.show = false
})
that.system_list = that.system_list.concat(list)
//console.log(list)
} else {
that.system_list = that.system_list.concat(list)
that.status_system = "nomore"
}
}).catch(res=>{
that.system_list = []
})
},
getMoreLeaveList() {
let that = this
let pageno = that.pageno
if (that.status != "nomore") {
that.getLeaveMsgList(pageno)
}
},
getMoreSystemList() {
let that = this
let pageno = that.pageno_system
if (that.status_system != "nomore") {
that.getSystemMsgList(pageno)
}
}
},
onLoad() {
this.getLeaveMsgList(this.pageno)
}
}
</script>
<style scoped lang="scss">
.scrollView {
height: calc(100vh - 80rpx);
}
.message {
height: 100vh;
background-color: #FFFFFF;
&-list {
&-item {
font-size: 40rpx;
font-weight: bold;
font-family: "PingFang-SC-Medium";
display: flex;
justify-content: center;
margin-top: 50rpx;
}
}
}
</style>