| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <template>
- <view class="container">
- <!-- 顶部导航栏 -->
- <view class="header">
- <view class="back-btn" @click="goBack">
- <text class="back-icon">←</text>
- </view>
- <text class="header-title">开通VIP记录</text>
- <view class="header-right"></view>
- </view>
-
- <!-- VIP记录列表 -->
- <scroll-view class="scroll-content" scroll-y>
- <view
- class="record-item"
- v-for="(record, index) in vipRecords"
- :key="index"
- >
- <view class="record-header">
- <text class="vip-type">{{ record.type }}</text>
- <text class="vip-price">¥{{ record.price }}</text>
- </view>
- <view class="record-details">
- <text class="detail-label">开通时间:</text>
- <text class="detail-value">{{ record.activateTime }}</text>
- </view>
- <view class="record-details">
- <text class="detail-label">有效期至:</text>
- <text class="detail-value">{{ record.expireTime }}</text>
- </view>
- </view>
-
- <!-- 空状态 -->
- <view class="empty-state" v-if="vipRecords.length === 0">
- <text class="empty-text">暂无VIP记录</text>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import { getVipRecords } from '@/utils/api.js'
-
- export default {
- data() {
- return {
- vipRecords: [],
- loading: false,
- page: 1,
- size: 20,
- hasMore: true
- }
- },
- onLoad() {
- this.loadVipRecords()
- },
- onPullDownRefresh() {
- this.page = 1
- this.vipRecords = []
- this.hasMore = true
- this.loadVipRecords().finally(() => {
- uni.stopPullDownRefresh()
- })
- },
- onReachBottom() {
- if (this.hasMore && !this.loading) {
- this.page++
- this.loadVipRecords()
- }
- },
- methods: {
- async loadVipRecords() {
- const userInfo = uni.getStorageSync('userInfo')
- if (!userInfo || !userInfo.id) {
- uni.showToast({
- title: '请先登录',
- icon: 'none'
- })
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }, 1500)
- return
- }
-
- if (this.loading) return
- this.loading = true
-
- try {
- const res = await getVipRecords(userInfo.id, 1, this.page, this.size) // 只查询已支付的记录
-
- if (res && res.code === 200 && res.data) {
- const newRecords = res.data.list || []
-
- if (this.page === 1) {
- this.vipRecords = newRecords
- } else {
- this.vipRecords = this.vipRecords.concat(newRecords)
- }
-
- // 判断是否还有更多数据
- this.hasMore = newRecords.length >= this.size
- } else {
- if (this.page === 1) {
- this.vipRecords = []
- }
- this.hasMore = false
- }
- } catch (error) {
- console.error('加载VIP记录失败:', error)
- if (this.page === 1) {
- this.vipRecords = []
- }
- if (this.page > 1) {
- this.page--
- }
- } finally {
- this.loading = false
- }
- },
- goBack() {
- uni.navigateBack()
- }
- }
- }
- </script>
- <style scoped>
- .container {
- width: 100%;
- height: 100vh;
- min-height: 100vh;
- background-color: #FFFFFF;
- display: flex;
- padding-top: 30px;
- box-sizing: border-box;
- flex-direction: column;
- box-sizing: border-box;
- overflow: hidden;
- }
-
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20rpx 30rpx;
- padding-top: calc(20rpx + env(safe-area-inset-top));
- background-color: #FFFFFF;
- border-bottom: 1rpx solid #F0F0F0;
- position: relative;
- flex-shrink: 0;
- box-sizing: border-box;
- }
-
- .back-btn {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 10;
- }
-
- .back-icon {
- font-size: 40rpx;
- color: #333333;
- font-weight: bold;
- }
-
- .header-title {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- font-size: 36rpx;
- font-weight: bold;
- color: #333333;
- }
-
- .header-right {
- width: 60rpx;
- }
-
- .scroll-content {
- flex: 1;
- width: 100%;
- height: 0;
- overflow: hidden;
- padding: 20rpx 30rpx;
- padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
- background-color: #FFFFFF;
- box-sizing: border-box;
- }
-
- .record-item {
- padding: 30rpx 0;
- border-bottom: 1rpx solid #F0F0F0;
- width: 100%;
- box-sizing: border-box;
- }
-
- .record-item:last-child {
- border-bottom: none;
- }
-
- .record-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
-
- .vip-type {
- font-size: 32rpx;
- font-weight: bold;
- color: #FF1744;
- }
-
- .vip-price {
- font-size: 32rpx;
- font-weight: bold;
- color: #FF1744;
- }
-
- .record-details {
- display: flex;
- align-items: center;
- margin-bottom: 10rpx;
- }
-
- .record-details:last-child {
- margin-bottom: 0;
- }
-
- .detail-label {
- font-size: 26rpx;
- color: #999999;
- margin-right: 10rpx;
- }
-
- .detail-value {
- font-size: 26rpx;
- color: #999999;
- }
-
- .empty-state {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 200rpx 0;
- }
-
- .empty-text {
- font-size: 28rpx;
- color: #999999;
- }
- </style>
|