Files
RentWeAppFront/pages-biz/myrent/myLease.vue

130 lines
2.9 KiB
Vue
Raw Normal View History

2026-01-15 17:18:24 +08:00
<template>
<view class="page">
<!-- 顶部自定义导航栏 -->
<customNavbar title="我的租赁资产" />
<!-- 租赁资产列表组件 -->
<scroll-view
scroll-y
class="scroll-content"
@scrolltolower="loadMore"
>
<asset-list
:list="assetList"
@click="goDetail"
/>
2026-05-14 14:42:51 +08:00
<!-- 加载更多 -->
<u-loadmore :status="loadStatus" />
2026-01-15 17:18:24 +08:00
</scroll-view>
</view>
</template>
<script>
import AssetList from '@/components/asset/assetList.vue'
export default {
name: 'MyLease',
2026-05-14 14:42:51 +08:00
components: { AssetList },
2026-01-15 17:18:24 +08:00
data() {
return {
assetList: [],
pageNo: 1,
pageSize: 10,
2026-05-14 14:42:51 +08:00
loadStatus: 'more', // ✅ 修复为官方正确值
cusNo: ''
2026-01-15 17:18:24 +08:00
};
},
onLoad(options) {
2026-05-14 14:42:51 +08:00
this.cusNo = options.cusNo;
2026-06-03 16:02:11 +08:00
// loadAssets 移到 onShow 中,等 token 校验通过后再加载
2026-01-15 17:18:24 +08:00
},
2026-06-03 16:02:11 +08:00
async onShow() {
try {
await this.$checkToken(this.$getToken())
this.checkOaAuth()
this.loadAssets()
} catch (e) {
return
}
2026-01-15 17:18:24 +08:00
},
2026-05-14 14:42:51 +08:00
// ✅ 删除和 scroll-view 冲突的 onReachBottom
computed: {
staticHost() {
return this.$config.staticUrl
}
2026-01-15 17:18:24 +08:00
},
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' })
}
})
}
},
2026-01-15 17:18:24 +08:00
loadAssets() {
2026-05-14 14:42:51 +08:00
// ✅ 正确判断加载状态
if (this.loadStatus !== 'more') return;
this.loadStatus = 'loading';
this.$u.post('/assets/getMyAssetsList', {
pageNo: this.pageNo,
pageSize: this.pageSize
}, {
WT: this.$getToken()
}).then(res => {
const rows = res.data.result || [];
if (this.pageNo === 1) this.assetList = [];
this.assetList = this.assetList.concat(rows);
// ✅ 判断是否还有更多数据
if (rows.length < this.pageSize) {
this.loadStatus = 'nomore';
} else {
this.pageNo++;
this.loadStatus = 'more';
}
}).catch(err => {
console.error(err);
this.loadStatus = 'more'; // ✅ 异常恢复
});
2026-01-15 17:18:24 +08:00
},
loadMore() {
this.loadAssets();
},
goDetail(item) {
uni.navigateTo({
url: `/pages-assets/assets/assetsDetail?assetsNo=${item.assetsNo}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.page {
display: flex;
flex-direction: column;
2026-05-14 14:42:51 +08:00
min-height: 100vh;
2026-01-15 17:18:24 +08:00
background: #f7f8fa;
padding-top: 175rpx;
2026-05-14 14:42:51 +08:00
box-sizing: border-box;
2026-01-15 17:18:24 +08:00
}
.scroll-content {
flex: 1;
2026-05-14 14:42:51 +08:00
height: calc(100vh - 175rpx); /* ✅ 正确高度,不超出屏幕 */
box-sizing: border-box;
2026-01-15 17:18:24 +08:00
}
</style>