blob: e764ad878f8b21af8f37238b3654f796134360a2 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="message">
3 <u-sticky>
4 <view class="message-tabs">
5 <u-tabs :list="tabs" :current="current" @change="change" bar-width="250" item-width="250" :is-scroll="false"
6 bar-height="3"></u-tabs>
7 </view>
8 </u-sticky>
9 <view class="message-list">
10 <view v-if="current==1">
11 <scroll-view :scroll-y="true" class="scrollView" @scrolltolower="getMoreLeaveList">
12 <u-swipe-action :show="v.show" :index="i"
13 v-for="(v, i) in leaveMsg" :key="v.fbid"
guangchao.xu6cdd45e2021-04-16 17:44:30 +080014 @content-click="toPath('/pages/sub_mine/leaveMsgDetail?id='+v.fbid)"
guangchao.xu070005a2020-12-07 09:56:40 +080015 @click="click"
16 @open="open"
17 @close="close"
18 :options="options"
19 v-if="v.isdelete =='0' ">
20 <view class="item u-border-bottom">
21 <view class="title-wrap">
22 <u-cell-group :border="false">
23 <u-cell-item :title="v.title" :arrow="true" :label="v.fbtime" value="查看详情" :center="true"></u-cell-item>
24 </u-cell-group>
25 </view>
26 </view>
27 </u-swipe-action>
28 <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="30" />
29 </scroll-view>
30 </view>
guangchao.xu6cdd45e2021-04-16 17:44:30 +080031 <view v-if="current==0">
32 <scroll-view :scroll-y="true" class="scrollView" @scrolltolower="getMoreSystemList">
33 <u-swipe-action :index="i"
34 v-for="(v, i) in system_list" :key="v.fbid"
35 @content-click="toPath('/pages/sub_mine/billsDetails?data='+JSON.stringify(v))">
36 <view class="item u-border-bottom">
37 <view class="title-wrap">
38 <u-cell-group :border="false">
39 <u-cell-item :title="v.content" :arrow="true" :label="v.date" value="查看详情" :center="true"></u-cell-item>
40 </u-cell-group>
41 </view>
42 </view>
43 </u-swipe-action>
44 <u-loadmore :status="status_system" :icon-type="iconType" :load-text="loadText" margin-top="30" />
45 </scroll-view>
46 </view>
47 <u-empty text="暂无消息" mode="message" margin-top="300" v-if="current ==2 "></u-empty>
guangchao.xu070005a2020-12-07 09:56:40 +080048 </view>
49
50 </view>
51</template>
52
53<script>
54 export default {
55 data() {
56 return {
57 tabs: [{
58 name: "推送消息"
59 }, {
60 name: "留言消息"
61 }, {
62 name: "其他消息"
63 }],
64 current: 1,
65 list: [],
66 loadText: {
67 loadmore: '轻轻上拉',
68 loading: '努力加载中',
69 nomore: '暂无更多'
70 },
71 status: "loadmore",
guangchao.xu6cdd45e2021-04-16 17:44:30 +080072 status_system:'nomore',
guangchao.xu070005a2020-12-07 09:56:40 +080073 iconType: 'circle',
guangchao.xu6cdd45e2021-04-16 17:44:30 +080074 pageno_system: 1,
75 pageno:1,
guangchao.xu070005a2020-12-07 09:56:40 +080076 leaveMsg: [],
guangchao.xu6cdd45e2021-04-16 17:44:30 +080077 system_list:[],
guangchao.xu070005a2020-12-07 09:56:40 +080078 options: [{
79 text: '删除',
80 style: {
81 backgroundColor: '#dd524d'
82 }
83 }]
84 }
85 },
86 methods: {
87 change(index) {
88 let that = this
89 that.current = index
90 that.leaveMsg.forEach(item => {
91 item.show = false
92 })
guangchao.xu6cdd45e2021-04-16 17:44:30 +080093 if(index==0 && that.system_list.length ==0){
94 this.getSystemMsgList(this.pageno_system)
95 }
guangchao.xu070005a2020-12-07 09:56:40 +080096 },
97 open(index) {
98 let that = this
99 that.leaveMsg.forEach(item => {
100 item.show = false
101 })
102 that.leaveMsg[index].show = true
103
104 },
105 close(index) {
106 let that = this
107 that.leaveMsg[index].show = false
108 },
109 click(index) {
110 let that = this
111 let fbid = that.leaveMsg[index].fbid
112 //console.log(that.leaveMsg)
113 uni.showModal({
114 title: "提示",
115 content: "确定要删除这条留言吗?",
116 success(res) {
117 if (res.confirm) {
118 that.$u.post('v1/feedback/delete/' + fbid, {}).then(res => {
119 that.leaveMsg[index].show = false
120 that.leaveMsg.splice(index, 1)
121 uni.showToast({
122 title: "您已成功删除此留言",
123 icon: "none",
124 duration: 1500
125 })
126 }).catch(res => {
127 that.leaveMsg[index].show = false
128 })
129 } else if (res.cancel) {
130 that.leaveMsg[index].show = false
131 }
132 }
133 })
134 },
135 getLeaveMsgList(no) {
136 let that = this
137 let params = {
138 pageno: no,
139 pagesize: 10
140 }
141 that.$u.get("/v1/feedback/list", params).then(res => {
142 let list = res.data.list
143 let total = res.data.totalCount
144 let page = res.data.totalPage
145 if (no > page) {
146 that.status = "nomore"
147 return false
148 }
149 //console.log(total,list.length)
150 if (list.length) {
151 if (list.length >= total) {
152 that.status = "nomore"
153 } else {
154 that.status = "loadmore"
155 that.pageno += 1
156 }
157 list.forEach(item => {
158 item.fbtime = item.fbtime.substr(0, 4) + "-" + item.fbtime.substr(4, 2) + "-" + item.fbtime.substr(6, 2) +
159 " " + item.fbtime.substr(8, 2) + ":" + item.fbtime.substr(10, 2) + ":" + item.fbtime.substr(12, 2);
160 item.show = false
161 })
162 that.leaveMsg = that.leaveMsg.concat(list)
163 //console.log(list)
164 } else {
165 that.leaveMsg = that.leaveMsg.concat(list)
166 that.status = "nomore"
167 }
168
169 })
170 },
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800171 getSystemMsgList(no) {
172 let that = this
173 let params = {
174 pageno: no,
175 pagesize: 10
176 }
177 that.$u.get("/v1/pushmsg/list", params).then(res => {
178 let list = res.data.data
179 let total = res.data.totalCount
180 let page = res.data.totalPages
181 if (no > page) {
182 that.status_system = "nomore"
183 return false
184 }
185 console.log(total,list.length)
186 if (list.length) {
187 if (list.length >= total) {
188 that.status_system = "nomore"
189 } else {
190 that.status_system = "loadmore"
191 that.pageno_system += 1
192 }
193 list.forEach(item => {
194 item.status = 'success'
195 item.date = item.lastupdate.substr(0, 4) + "-" + item.lastupdate.substr(4, 2) + "-" + item.lastupdate.substr(6, 2) +
196 " " + item.lastupdate.substr(8, 2) + ":" + item.lastupdate.substr(10, 2) + ":" + item.lastupdate.substr(12, 2);
197 item.show = false
198 })
199 that.system_list = that.system_list.concat(list)
200 //console.log(list)
201 } else {
202 that.system_list = that.system_list.concat(list)
203 that.status_system = "nomore"
204 }
205
206 }).catch(res=>{
207 that.system_list = []
208 })
209 },
guangchao.xu070005a2020-12-07 09:56:40 +0800210 getMoreLeaveList() {
211 let that = this
212 let pageno = that.pageno
213 if (that.status != "nomore") {
214 that.getLeaveMsgList(pageno)
215 }
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800216 },
217 getMoreSystemList() {
218 let that = this
219 let pageno = that.pageno_system
220 if (that.status_system != "nomore") {
221 that.getSystemMsgList(pageno)
222 }
guangchao.xu070005a2020-12-07 09:56:40 +0800223 }
224 },
225 onLoad() {
226 this.getLeaveMsgList(this.pageno)
227 }
228 }
229</script>
230
231<style scoped lang="scss">
232 .scrollView {
233 height: calc(100vh - 80rpx);
234 }
235
236 .message {
237 height: 100vh;
238 background-color: #FFFFFF;
239
240 &-list {
241 &-item {
242 font-size: 40rpx;
243 font-weight: bold;
244 font-family: "PingFang-SC-Medium";
245 display: flex;
246 justify-content: center;
247 margin-top: 50rpx;
248 }
249 }
250 }
251</style>