cloudroam
2025-08-12 8dd9360a0e4cfd22ea9e261bec3821eff3f57fe8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
<template>
  <view class="page">
    <view class="profile-section" :style="backgroundStyle">
      <up-sticky bgColor="#000">
        <view class="top-bar">
          <up-icon name="setting" size="60rpx" color="#D0E1E9" @click="onSettingClick" />
<!--          <up-icon name="list" size="60rpx" color="#D0E1E9" @click="showUnderDevelopment" />-->
          <view class="top-bar-right">
<!--            <up-icon name="share" size="60rpx" color="#D0E1E9" @click="showUnderDevelopment" />-->
          </view>
        </view>
      </up-sticky>
      <view class="profile-content">
        <view class="profile-header">
          <view class="avatar-container">
            <image v-if="userStore?.userInfo?.customerDTO?.cover" class="avatar"
              :src="userStore?.userInfo?.customerDTO?.cover" mode="aspectFill" />
            <image v-else class="avatar"
              src="https://ai-public.mastergo.com/ai/img_res/e8ae645c666c247b895b488e60b048f5.jpg" mode="aspectFill" />
            <view class="add-icon">
              <up-icon name="plus" size="20rpx" color="#333" />
            </view>
          </view>
          <view class="user-info">
            <view class="username">影游四方 {{ userStore?.userInfo?.customerDTO?.name }}</view>
            <view class="user-id">影游四方号:{{ userStore?.userInfo?.customerDTO?.id }}</view>
            <view class="location">IP 属地:{{ userStore.address?.ad_info?.province }}</view>
          </view>
        </view>
 
<!--        <view class="edit-profile" >点击这里,填写简介</view>-->
 
        <view class="stats">
          <view class="stat-row">
<!--            <view class="stat-item">-->
<!--              <text class="number">0</text>-->
<!--              <text class="label">关注</text>-->
<!--            </view>-->
<!--            <view class="stat-item">-->
<!--              <text class="number">0</text>-->
<!--              <text class="label">粉丝</text>-->
<!--            </view>-->
<!--            <view class="stat-item">
              <text class="number">1</text>
              <text class="label">获赞与收藏</text>
            </view> -->
          </view>
          <view class="action-buttons">
            <up-button text="编辑资料" size="mini" type="info" plain hairline @click="navigateTo('/sub-pages/mine/profile-edit')"
              :custom-style="{ backgroundColor: 'transparent', borderColor: '#B1ABA9' }" />
<!--            <up-icon name="setting" size="40rpx" @click="navigateTo('/sub-pages/mine/settings')" />-->
          </view>
        </view>
      </view>
 
<!--      <scroll-view class="function-cards" scroll-x show-scrollbar="false">-->
<!--        <view class="card" v-for="item in cardList" :key="item.title"  @click="showUnderDevelopment">-->
<!--          <view class="card-content">-->
<!--            <text class="card-title">{{ item.title }}</text>-->
<!--            <text class="card-subtitle">{{ item.subtitle }}</text>-->
<!--          </view>-->
<!--        </view>-->
<!--      </scroll-view>-->
    </view>
 
    <view class="tab-section">
      <up-sticky bgColor="#fff">
        <up-tabs :list="tabList" :current="current" @change="onTabChange" lineColor="#2979ff"
          activeStyle="color: #2979ff" />
      </up-sticky>
 
 
<!--      <swiper class="swiper-box" :current="current" @change="onSwiperChange" duration="300">-->
<!--        <swiper-item v-for="(item, index) in tabList" :key="index">-->
<!--          <view v-if="!userStore.hasLogin" class="empty-state">-->
<!--            <text class="empty-text">请登录后查看{{ item.name }}</text>-->
<!--          </view>-->
<!--          <view v-else-if="getCurrentList.length === 0" class="empty-state">-->
<!--            <text class="empty-text">暂无{{ item.name }}内容</text>-->
<!--          </view>-->
<!--          <view v-else class="list-view">-->
<!--            <up-waterfall v-model="getCurrentList">-->
<!--              <template #left="{ leftList }">-->
<!--                <FlowCard-->
<!--                    v-for="(item, index) in leftList"-->
<!--                    :key="index"-->
<!--                    :item="item"-->
<!--                    @click="handleDetailClick"-->
<!--                />-->
<!--              </template>-->
<!--              <template #right="{ rightList }">-->
<!--                <FlowCard-->
<!--                    v-for="(item, index) in rightList"-->
<!--                    :key="index"-->
<!--                    :item="item"-->
<!--                    @click="handleDetailClick"-->
<!--                />-->
<!--              </template>-->
<!--            </up-waterfall>-->
<!--            <up-loadmore :status="loading ? 'loading' : 'nomore'" :line="true" />-->
<!--          </view>-->
<!--        </swiper-item>-->
<!--      </swiper>-->
      <swiper class="swiper-box" :current="current" @change="onSwiperChange" duration="300">
        <swiper-item v-for="(item, index) in tabList" :key="index">
          <scroll-view scroll-y style="height: 60vh; min-height: 400rpx; background: #fff;">
            <view class="list-view">
              <up-waterfall v-model="getCurrentList">
                <template #left="{ leftList }">
                  <FlowCard
                      v-for="(item, index) in leftList"
                      :key="index"
                      :item="item"
                      @click="handleDetailClick"
                  />
                </template>
                <template #right="{ rightList }">
                  <FlowCard
                      v-for="(item, index) in rightList"
                      :key="index"
                      :item="item"
                      @click="handleDetailClick"
                  />
                </template>
              </up-waterfall>
              <up-loadmore :status="current.value === 0 ? collectStatus : likeStatus" :line="true" />
            </view>
          </scroll-view>
        </swiper-item>
      </swiper>
    </view>
 
    <common-footer flg="0" />
<!--    <setting-popup v-model="settingShow" />-->
  </view>
</template>
 
<script setup lang="ts">
import { ref, computed, watch } from 'vue';
import { onShow, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import SettingPopup from '@/components/setting/setting-popup.vue';
import { usePlatformLoginType } from '@/composables/usePlatformLoginType'
import { useUserStore } from '@/store/user'
import { useLocation } from '@/composables/useLocation'
import { useNavigator } from '@/composables/useNavigator'
import { FilmWorks } from '@/types/index'
import{ getFilmCollectList, getFilmLikeList} from '@/sub-pages/utils/api'
 
const { apitype } = usePlatformLoginType()
const userStore = useUserStore()
const { navigateTo } = useNavigator()
const {getLocation,province } = useLocation()
 
 
watch(
  () => userStore.userInfo,      // 监听 userInfo 这个响应式属性
  (newVal, oldVal) => {
    console.log('userInfo 发生变化:', newVal)
    if (newVal && userStore.hasLogin) {
      fetchList();
    } else {
      // 用户未登录,清空列表
      likeList.value = [];
      collectList.value = [];
    }
  },
  { deep: true } // 如果 userInfo 是对象,需要深度监听其属性变化
)
 
onShow(() => {
  getLocation()
  if (userStore.hasLogin) {
    // 强制刷新用户信息
    userStore.getCurrentInfo().then(() => {
      fetchList();
    });
  }else {
    // 用户未登录,清空列表
    likeList.value = [];
    collectList.value = [];
  }
});
 
onPullDownRefresh(async () => {
  if (current.value === 0) {
    collectPage.value = 1;
    collectList.value = [];
    collectStatus.value = 'loadmore';
  } else {
    likePage.value = 1;
    likeList.value = [];
    likeStatus.value = 'loadmore';
  }
  await fetchList(true);
  uni.stopPullDownRefresh();
});
 
onReachBottom(() => {
  fetchList();
});
 
 
// 当前 tab 索引
const current = ref(0);
 
// 背景图
const backgroundUrl = ref('');
 
// 控制设置弹窗显示
const settingShow = ref(false);
 
const likeList = ref<FilmWorks[]>([]);
const collectList = ref<FilmWorks[]>([]);
const loading = ref(false);
const noMore = ref(false);
// 分页相关状态
const collectPage = ref(1);
const collectSize = 10;
const collectStatus = ref('loadmore');
const likePage = ref(1);
const likeSize = 10;
const likeStatus = ref('loadmore');
// tab 列表
const tabList = ref([
  // { name: '笔记' },
  { name: '收藏' },
  { name: '赞过' },
]);
 
// 横向滑动卡片
const cardList = ref([
  { title: '购物车', subtitle: '查看推荐好物' },
  { title: '创作灵感', subtitle: '学创作找灵感' },
  { title: '浏览记录', subtitle: '看过的笔记' },
  { title: '浏览记录', subtitle: '看过的笔记' },
]);
 
// 背景样式
const backgroundStyle = computed(() => {
  return backgroundUrl.value
    ? `background: url(${backgroundUrl.value}) center center / cover no-repeat;`
    : 'background-color: #1e1e1e;';
});
 
// 方法定义
const onSettingClick= ()=> {
  // settingShow.value = true;
  uni.navigateTo({ url: '/sub-pages/mine/settings' })
}
 
const onTabChange=(item: { index: number })=> {
  // 如果切到相同的 tab,直接返回,避免重复触发
  if (current.value === item.index) return;
  current.value = item.index;
  // 切换tab时重置对应列表和页码,防止数据重复
  if (current.value === 0) {
    collectPage.value = 1;
    collectList.value = [];
    collectStatus.value = 'loadmore';
  } else {
    likePage.value = 1;
    likeList.value = [];
    likeStatus.value = 'loadmore';
  }
  if (userStore.hasLogin) {
    fetchList(true); // 强制刷新
  }
}
 
const onSwiperChange=(e: any) => {
  current.value = e.detail.current;
  onTabChange({ index: e.detail.current });
}
 
const handleDetailClick = (item: FilmWorks) => {
  navigateTo(`/sub-pages/film-list/film-detail?id=${item.id}`);
};
 
const getCurrentList = computed(() => {
  return current.value === 0 ? collectList.value : likeList.value;
});
const fetchList = async (isRefresh = false) => {
  if (!userStore.hasLogin) return;
  // 并发加载守卫:防止切换或多事件同时触发导致重复请求
  if (loading.value) return;
  loading.value = true;
  try {
    if (current.value === 0) {
      // 收藏分页
      if (isRefresh) {
        collectPage.value = 1;
        collectList.value = [];
        collectStatus.value = 'loadmore';
      }
      if (collectStatus.value === 'nomore') return;
      const res = await getFilmCollectList({
        userId: userStore.userInfo?.customerDTO?.id,
        current: collectPage.value,
        size: collectSize
      });
      if (res && res.length > 0) {
        // 去重
        const existingIds = new Set(collectList.value.map(item => item.id));
        const uniqueRecords = res.filter(item => !existingIds.has(item.id));
        if (uniqueRecords.length > 0) {
          collectList.value = [...collectList.value, ...uniqueRecords];
        }
        if (res.length < collectSize) {
          collectStatus.value = 'nomore';
        }
        // 无论是否有去重,当前页已消费,推进页码,避免下一次重复拉取相同页
        collectPage.value++;
      } else {
        collectStatus.value = 'nomore';
      }
    } else {
      // 点赞分页
      if (isRefresh) {
        likePage.value = 1;
        likeList.value = [];
        likeStatus.value = 'loadmore';
      }
      if (likeStatus.value === 'nomore') return;
      const res = await getFilmLikeList({
        userId: userStore.userInfo?.customerDTO?.id,
        current: likePage.value,
        size: likeSize
      });
      if (res && res.length > 0) {
        // 去重
        const existingIds = new Set(likeList.value.map(item => item.id));
        const uniqueRecords = res.filter(item => !existingIds.has(item.id));
        if (uniqueRecords.length > 0) {
          likeList.value = [...likeList.value, ...uniqueRecords];
        }
        if (res.length < likeSize) {
          likeStatus.value = 'nomore';
        }
        // 同理,推进页码,避免重复拉取相同页
        likePage.value++;
      } else {
        likeStatus.value = 'nomore';
      }
    }
  } catch (error) {
    console.error('获取列表失败:', error);
    uni.showToast({ title: '获取数据失败', icon: 'none' });
  } finally {
    loading.value = false;
  }
};
const goToProfile=  ()=> {
  navigateTo('/sub-pages/mine/edit-profile');
};
 
const showUnderDevelopment = () => {
  uni.showToast({
    title: '功能正在开发中',
    icon: 'none'
  });
}
 
defineExpose({
  onShareAppMessage() {
    return {
      title: '影视地标推荐',
      path: '/pages/home/home',
      imageUrl: '', // 可以设置默认分享图片
      desc: '发现全球影视拍摄地,探索电影背后的故事'
    }
  },
  // 分享到朋友圈
  onShareTimeline() {
    return {
      title: '影视地标推荐',
      query: '',
      imageUrl: '', // 可以设置默认分享图片
      desc: '发现全球影视拍摄地,探索电影背后的故事'
    }
  }
})
</script>
 
 
<style>
.page {
  height: 100vh;
  overflow-y: auto;
}
 
.top-bar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24rpx 32rpx;
}
 
.top-bar-right {
  display: flex;
  align-items: center;
}
 
.icon-margin {
  margin-right: 32rpx;
}
 
.profile-section {
  position: relative;
  /* height: 680rpx; */
}
 
.bg-image {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
}
 
.profile-content {
  position: relative;
  z-index: 2;
  padding: 30rpx;
}
 
.profile-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 24rpx;
}
 
.avatar-container {
  position: relative;
  margin-right: 24rpx;
}
 
.avatar {
  width: 120rpx;
  height: 120rpx;
  border-radius: 60rpx;
  border: 2px solid #ffffff;
}
 
.add-icon {
  position: absolute;
  right: -8rpx;
  bottom: -8rpx;
  width: 40rpx;
  height: 40rpx;
  background-color: #FFE411;
  border-radius: 20rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.user-info {
  flex: 1;
}
 
.username {
  font-size: 30rpx;
  color: #FCFFFE;
  font-weight: bold;
  margin-bottom: 8rpx;
}
 
.user-id,
.location {
  font-size: 26rpx;
  color: #666666;
  margin-bottom: 4rpx;
}
 
.edit-profile {
  color: #999999;
  font-size: 26rpx;
  margin-bottom: 20rpx;
}
 
.stats {
  display: flex;
  /* margin-bottom: 20rpx; */
  align-items: center;
  justify-content: space-between;
}
 
.stat-row {
  display: flex;
}
 
.stat-item {
  margin-right: 48rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
}
 
.stat-item:last-child {
  margin-right: auto;
}
 
.number {
  font-size: 30rpx;
  color: #A19B99;
  font-weight: bold;
  margin-bottom: 4rpx;
}
 
.label {
  font-size: 24rpx;
  color: #B1ABA9;
}
 
.action-buttons {
  display: flex;
  gap: 16rpx;
}
 
.edit-btn {
  padding: 0 24rpx !important;
  background-color: #f5f5f5 !important;
  color: #333333 !important;
  border: none !important;
}
 
.settings-btn {
  width: 80rpx !important;
  background-color: #f5f5f5 !important;
  color: #333333 !important;
  border: none !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.function-cards {
  /* padding: 32rpx 0; */
  white-space: nowrap;
  overflow: auto;
  padding-bottom: 20rpx;
}
 
.card {
  display: inline-block;
  width: 100%;
  height: 80rpx;
  margin-left: 20rpx;
  background-color: rgba(60, 60, 60, 0.4);
  /* 灰色 + 20% 透明度 */
  border-radius: 16rpx;
  padding: 10rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
 
.card:last-child {
  margin-right: 24rpx;
}
 
.card-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
 
.card-title {
  font-size: 30rpx;
  color: #E7E1DF;
  font-weight: bold;
}
 
.card-subtitle {
  font-size: 20rpx;
  color: #BEBBB8;
}
 
.tab-section {
  padding: 0 32rpx;
}
 
.tab-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 48rpx;
}
 
.tab {
  position: relative;
  padding: 16rpx 0;
  display: flex;
  align-items: center;
}
 
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48rpx;
  height: 4rpx;
  background-color: #333;
  border-radius: 2rpx;
}
 
.tab-text {
  font-size: 16px;
  color: #333;
  margin-right: 8rpx;
}
 
.tab-count {
  font-size: 16px;
  color: #999;
}
 
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48rpx 0;
  min-height: 600rpx;
}
 
.empty-icon {
  width: 200rpx;
  height: 200rpx;
  margin-bottom: 24rpx;
}
 
.empty-text {
  font-size: 14px;
  color: #999;
  /* margin-bottom: 24rpx; */
}
 
.publish-btn {
  background-color: #ffe411 !important;
  color: #333 !important;
  border: none !important;
  border-radius: 32rpx !important;
  padding: 0 48rpx !important;
}
.swiper-box {
  min-height: calc(100vh - 200rpx);
  /*padding: 20rpx 0;*/
}
 
.list-view {
  /*padding: 0 20rpx;*/
  background-color: #fff;
}
</style>
<style lang="scss" scoped>
//.swiper-box {
//  // min-height: 600rpx;
//  /* 或 100vh,或具体 px */
//  min-height: 800px;
//}
 
</style>