<template> <view class="container"> <scroll-view class="message-list-box" scroll-y="true" @scrolltolower="handleLoadMore()"> <view class="message-row" v-for="(item, index1) in messageList" :key="index1"> <image class="message-head" mode="aspectFill" :src="item.headImg"></image> <view class="message-info-box"> <view class="message-name">{{item.userName}}</view> <view class="message-date">{{item.leaMsgTime}}</view> <view class="message-text">{{item.leaMsgContent}}</view> <view class="message-img-box" v-for="(site, index2) in item.orderLeaImgResVOs" :key="index2"> <!-- <u-image :src="site.imgUrl" width:="76px" height="76px"></u-image> --> <image class="message-img" mode="aspectFill" :src="site.imgUrl"></image> </view> </view> </view> </scroll-view> <view class="message-handle"> <u-button type="success" shape="circle" :ripple="true" @click="addMessage" class="handle-custom">发布留言</u-button> </view> <u-top-tips ref="uTips"></u-top-tips> </view> </template> <script> const NET = require('@/utils/request') const API = require('@/config/api') export default { data() { return { orderId: '', tenantCode: '', pageIndex: 1, isOver: false, messageList: [], } }, onLoad(options) { this.orderId = options.orderId this.tenantCode = options.tenantCode }, onShow() { this.pageIndex = 1 this.messageList = [] this.getMessageList() }, onPullDownRefresh() { this.pageIndex = 1 this.messageList = [] this.getMessageList('refresh') }, methods: { // 懒加载 handleLoadMore() { if (!this.isOver) { this.pageIndex++ this.getMessageList() } }, // 获取全部留言 getMessageList(type) { NET.request(API.getMessageList + this.pageIndex + '/10', { flag: 2, orderId: this.orderId }, 'GET').then(res => { if (res.isSuccess) { if (type == 'refresh') { uni.stopPullDownRefresh(); } this.isOver = res.data.list.length != 10 this.messageList = this.messageList.concat(res.data.list) } else { this.$refs.uTips.show({ title: res.msg, type: 'warning', }) } }).catch(error => { console.log(error) this.$refs.uTips.show({ title: error.data.msg, type: 'warning', }) }) }, // 新增留言 addMessage() { uni.navigateTo({ url: '/pagesMain/messageForm?orderId=' + this.orderId + '&tenantCode=' + this.tenantCode }); }, } } </script> <style lang="less" scoped> page { width: 100%; height: 100%; } .container { width: 100%; height: 100%; float: left; position: relative; .message-list-box { width: 100%; height: calc(100% - 70px); float: left; .message-row { width: calc(100% - 30px); float: left; padding-bottom: 15px; border-bottom: 1px solid #F6F6F6; margin: 0 15px 15px 15px; .message-head { width: 50px; height: 50px; object-fit: cover; float: left; border-radius: 50%; overflow: hidden; } .message-info-box { width: calc(100% - 75px); float: right; .message-name { width: 50%; height: 30px; float: left; font-size: 15px; font-family: PingFang SC; color: #333333; line-height: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .message-date { width: 50%; height: 30px; float: left; font-size: 12px; font-family: PingFang SC; color: #666666; text-align: right; line-height: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .message-text { width: 100%; height: 20px; float: left; font-size: 12px; font-family: PingFang SC; color: #666666; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .message-img-box { width: 100%; float: left; .message-img { width: 76px; height: 76px; object-fit: cover; float: left; margin: 0 10px 10px 0; } } } } } .message-handle { width: calc(100% - 30px); height: 40px; position: fixed; bottom: 20px; left: 15px; .handle-custom { background-color: #51A539; /deep/button { background-color: #56a83a; } /deep/.u-btn--success--disabled { background-color: #74bd60 !important; } } } } </style>