Files
RentWeAppFront/pages-assets/fallback/fallback.vue

358 lines
8.6 KiB
Vue
Raw Normal View History

<template>
<view class="page-view">
<customNavbar title="留言板" :is-transparent="navbarStyle.isTransparent" :bg-color="navbarStyle.bgColor"
2026-01-15 17:18:24 +08:00
:text-color="navbarStyle.textColor" :opacity="navbarStyle.opacity" :show-home="true" />
2026-05-14 14:42:51 +08:00
<scroll-view scroll-y class="scroll-view" @scrolltolower="loadMore" @refresherrefresh="refresh"
2026-01-15 17:18:24 +08:00
:refresher-enabled="true" :refresher-triggered="isRefreshing">
<view class="message-item" v-for="(item, index) in flowList" :key="index" @click="navigateToDetail(item)">
<view class="message-header">
<text :class="['status-tag', item.status]">{{ item.statusText }}</text>
<text class="message-title">留言内容</text>
</view>
<view class="message-content">
<text class="content-text">{{ item.content }}</text>
</view>
<view class="message-footer">
2026-01-15 17:18:24 +08:00
<text class="message-time">留言时间{{ item.summitDate }}</text>
</view>
</view>
2026-05-14 14:42:51 +08:00
<u-loadmore :status="loadStatus" />
</scroll-view>
<view class="add-btn-container">
2026-01-15 17:18:24 +08:00
<button class="add-btn" @click="goToSubmit()">新增留言</button>
</view>
2026-05-14 14:42:51 +08:00
<!-- 修复后的弹窗 -->
<u-popup v-model="showAddPopup" mode="center">
2026-01-15 17:18:24 +08:00
<view class="popup-content">
2026-05-14 14:42:51 +08:00
<view class="asset-select" @click="openAssetPopup">
<text class="select-text">{{selectedAsset.assetsName || '请选择资产'}}</text>
<u-icon name="arrow-right" size="26" color="#999"></u-icon>
2026-01-30 09:01:38 +08:00
</view>
2026-05-14 14:42:51 +08:00
2026-01-15 17:18:24 +08:00
<textarea v-model="newMessageContent" placeholder="请输入留言内容" class="textarea" />
2026-05-14 14:42:51 +08:00
2026-01-15 17:18:24 +08:00
<button class="popup-btn" @click="addFallback()">提交留言</button>
</view>
</u-popup>
2026-05-14 14:42:51 +08:00
<u-popup v-model="showAssetPopup" mode="bottom">
<view class="asset-popup-wrap">
<view class="popup-title">选择资产</view>
<scroll-view scroll-y class="asset-list">
<view class="asset-item" v-for="item in assetsList" :key="item.assetsNo" @click="selectAsset(item)">
{{ item.assetsName }}
</view>
</scroll-view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
2026-01-15 17:18:24 +08:00
showAddPopup: false,
newMessageContent: '',
flowList: [],
2026-05-14 14:42:51 +08:00
pageNo: 1,
pageSize: 10,
navbarStyle: {
isTransparent: true,
bgColor: '#ffffff',
textColor: '#000000',
2026-01-15 17:18:24 +08:00
opacity: 0
},
2026-05-14 14:42:51 +08:00
loadStatus: 'more',
2026-01-15 17:18:24 +08:00
isRefreshing: false,
2026-01-30 09:01:38 +08:00
scrollTop: 0,
2026-05-14 14:42:51 +08:00
showAssetPopup: false,
2026-01-30 09:01:38 +08:00
assetsList: [],
2026-05-14 14:42:51 +08:00
selectedAsset: null
}
},
onPageScroll(e) {
this.scrollTop = e.scrollTop;
this.updateNavbarStyle(e.scrollTop);
},
2026-01-15 17:18:24 +08:00
onShow() {
this.$checkToken(this.$getToken())
2026-06-02 16:23:56 +08:00
this.checkOaAuth()
2026-01-15 17:18:24 +08:00
},
onLoad() {
this.fetchFallback();
},
methods: {
2026-06-02 16:23:56 +08:00
checkOaAuth() {
const token = this.$getToken()
if (!token) return
2026-06-02 16:23:56 +08:00
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo || !userInfo.oaAuth) {
uni.showModal({
title: '提示',
content: '您还未实名认证,请先完成实名认证',
showCancel: false,
confirmText: '去认证',
success: () => {
uni.redirectTo({ url: '/pages-biz/profile/profile' })
}
})
}
},
navigateToDetail(item) {
uni.navigateTo({
2026-05-14 14:42:51 +08:00
url: "/pages-assets/fallback/fallbackDetail?id=" + item.id
});
},
2026-05-14 14:42:51 +08:00
openAssetPopup() {
this.showAssetPopup = true;
this.getAssetsList();
},
getAssetsList() {
this.$u.post('/assets/queryPage', {
pageNo: 1,
pageSize: 100
}, {
WT: this.$getToken()
}).then(res => {
this.assetsList = res.data.result || [];
}).catch(err => {
console.log("获取资产失败", err);
})
},
selectAsset(item) {
this.selectedAsset = item;
this.showAssetPopup = false;
},
2026-01-15 17:18:24 +08:00
fetchFallback() {
2026-05-14 14:42:51 +08:00
if (this.loadStatus !== 'more') return;
2026-01-15 17:18:24 +08:00
this.loadStatus = 'loading';
2026-05-14 14:42:51 +08:00
this.$u.post('/fallback/queryPage', {
2026-01-15 17:18:24 +08:00
pageNo: this.pageNo,
pageSize: this.pageSize
}, {
2026-05-14 14:42:51 +08:00
WT: this.$getToken()
2026-01-15 17:18:24 +08:00
}).then(res => {
const rows = res.data.result || [];
if (this.pageNo === 1) this.flowList = [];
this.flowList = this.flowList.concat(rows)
if (rows.length < this.pageSize) {
this.loadStatus = 'nomore';
} else {
this.pageNo++;
2026-05-14 14:42:51 +08:00
this.loadStatus = 'more';
2026-01-15 17:18:24 +08:00
}
}).catch(err => {
2026-05-14 14:42:51 +08:00
console.log("获取留言失败", err)
this.loadStatus = 'more';
2026-01-15 17:18:24 +08:00
})
},
loadMore() {
2026-05-14 14:42:51 +08:00
if (this.loadStatus !== 'more') return;
this.fetchFallback()
2026-01-15 17:18:24 +08:00
},
goToSubmit() {
this.showAddPopup = true;
2026-05-14 14:42:51 +08:00
this.selectedAsset = null;
this.newMessageContent = '';
2026-01-15 17:18:24 +08:00
},
addFallback() {
const content = this.newMessageContent.trim();
const token = this.$getToken()
if (!token) {
uni.showToast({ title: '请先登录', icon: 'none' });
return
}
2026-01-30 09:01:38 +08:00
let userInfo = uni.getStorageSync('userInfo');
if(!userInfo || !userInfo.cusNo) {
2026-05-14 14:42:51 +08:00
uni.showToast({ title: '您还未实名', icon: 'none' });
return;
}
if (!this.selectedAsset) {
uni.showToast({ title: '请选择资产', icon: 'none' });
2026-01-30 09:01:38 +08:00
return;
}
2026-01-15 17:18:24 +08:00
if (!content) {
2026-05-14 14:42:51 +08:00
uni.showToast({ title: '请输入留言内容', icon: 'none' });
2026-01-15 17:18:24 +08:00
return;
}
this.$u.post('/fallback/submit', {
2026-05-14 14:42:51 +08:00
content: content,
assetsNo: this.selectedAsset.assetsNo
}, {
WT: this.$getToken()
}).then(res => {
uni.showToast({ title: '留言成功', icon: 'success' });
this.showAddPopup = false;
this.refresh();
}).catch(err => {
uni.showToast({ title: '提交失败', icon: 'none' });
this.showAddPopup = false;
});
2026-01-15 17:18:24 +08:00
},
refresh() {
this.isRefreshing = true;
2026-05-14 14:42:51 +08:00
this.pageNo = 1;
this.flowList = [];
this.loadStatus = 'more';
this.fetchFallback();
setTimeout(()=>{
2026-01-15 17:18:24 +08:00
this.isRefreshing = false;
2026-05-14 14:42:51 +08:00
},800)
},
updateNavbarStyle(scrollTop) {
const threshold = 200;
let opacity = scrollTop / threshold;
opacity = Math.min(opacity, 1);
opacity = Math.max(opacity, 0);
this.navbarStyle.opacity = opacity;
2026-05-14 14:42:51 +08:00
this.navbarStyle.isTransparent = opacity <= 0.5;
2026-01-15 17:18:24 +08:00
}
}
}
</script>
<style scoped>
.page-view {
2026-01-15 17:18:24 +08:00
padding-top: 175rpx;
min-height: 100vh;
position: relative;
background: linear-gradient(0deg, #F3F1ED 43%, #F5E9DB 100%);
2026-05-14 14:42:51 +08:00
box-sizing: border-box;
}
.scroll-view {
2026-05-14 14:42:51 +08:00
height: calc(100vh - 175rpx - 140rpx);
2026-01-15 17:18:24 +08:00
padding: 5% 0;
2026-05-14 14:42:51 +08:00
box-sizing: border-box;
}
.message-item {
background-color: #ffffff;
border-radius: 10rpx;
padding: 32rpx;
padding-left: 95rpx;
width: 92%;
margin: auto;
margin-bottom: 20rpx;
2026-05-14 14:42:51 +08:00
position: relative;
}
.message-header {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.status-tag {
font-size: 24rpx;
padding: 6rpx 16rpx;
border-radius: 21rpx;
margin-right: 20rpx;
color: #ffffff;
position: absolute;
left: 10rpx;
}
.status-tag.processed {
background: linear-gradient(90deg, #F34038 0%, #FF7C76 100%);
}
.status-tag.processing {
background: linear-gradient(90deg, #FEAF04 0%, #FFC145 100%);
}
.status-tag.pending {
background: linear-gradient(90deg, #6688FC 0%, #809BFB 100%);
}
.message-title {
font-size: 30rpx;
font-weight: 500;
color: #2D2B2C;
}
.content-text {
font-size: 24rpx;
color: #86868C;
line-height: 44rpx;
}
.message-time {
font-size: 24rpx;
color: #ADADB1;
}
2026-01-30 09:01:38 +08:00
2026-05-14 14:42:51 +08:00
/* 核心修复:弹窗宽度与排版 */
.popup-content {
background: #fff;
padding: 30rpx;
border-radius: 8rpx;
width: 70%; /* 扩大弹窗宽度,避免文字竖排 */
min-width: 400rpx;
}
.asset-select {
padding: 20rpx;
background: #f7f7f7;
border-radius: 8rpx;
font-size: 28rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
white-space: nowrap; /* 强制文字不换行 */
}
.select-text {
color: #999;
}
.textarea {
width: 100%;
min-height: 200rpx;
padding: 20rpx;
background: #f7f7f7;
border-radius: 8rpx;
font-size: 28rpx;
box-sizing: border-box;
}
.popup-btn {
margin-top: 20rpx;
width: 100%;
height: 80rpx;
background: #FF6F63;
color: #fff;
border-radius: 8rpx;
font-size: 30rpx;
border: none;
white-space: nowrap; /* 按钮文字不换行 */
}
.asset-popup-wrap {
padding: 30rpx;
background: #fff;
}
.popup-title {
font-size: 32rpx;
font-weight: 500;
text-align: center;
margin-bottom: 20rpx;
}
.asset-list {
max-height: 400rpx;
}
.asset-item {
padding: 24rpx;
font-size: 28rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.add-btn-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 30rpx 40rpx;
background-color: #f5f5f5;
}
.add-btn {
width: 100%;
height: 80rpx;
background: linear-gradient(90deg, #FF6F63 0%, #FB392A 100%);
border-radius: 10rpx;
color: #ffffff;
font-size: 32rpx;
border: none;
2026-01-15 17:18:24 +08:00
}
</style>