| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <template>
- <u-popup :show="show" @close="handleClose" @open="handleOpen" round="32rpx" bgColor="#ffffff" zIndex="10077">
- <view class="content">
- <!-- 头部 -->
- <view class="header">
- <view class="row bg">
- <image class="w40 h40" src="/static/images/answer_icon.png"></image>
- <image class="w428 h64" src="/static/images/collecting_coins_title.png"></image>
- <!-- 修改这里:改为调用 handleClose 方法 -->
- <image class="w40 h40" src="/static/images/pop_close_icon.png" @click="handleClose"></image>
- </view>
- <!-- 积分信息 -->
- <view class="row mtb48 plr24">
- <view class="points row">
- <text class="lable">我的积分</text>
- <text class="num">3688</text>
- </view>
- <view class="shop row">
- <image class="w48 h48" src="/static/images/fanghua_coin_icon.png"></image>
- <text class="shop-txt">芳华币商城</text>
- <image class="w24 h24" src="/static/images/coin_arrow.png"></image>
- </view>
- </view>
- </view>
- <!-- 可滚动列表区域 -->
- <scroll-view scroll-y class="list" :style="{ height: scrollHeight + 'px' }" @scroll="handleScroll">
- <!-- 列表项 -->
- <view v-for="(item, index) in taskList" :key="index" class="list-item">
- <view class="row">
- <view class="left">
- <image class="w88 h88 mr24" src="/static/images/img.png"></image>
- <view>
- <view class="mb8 row">
- <text class="title">{{ item.title }}({{ item.current }}/{{ item.total }})</text>
- <image class="w40 h40 mr4 ml8" src="/static/images/fanghua_coin_icon.png"></image>
- <text class="num">+{{ item.points }}</text>
- </view>
- <view class="txt">{{ item.desc }}</view>
- </view>
- </view>
- <view class="button" @click="handleTaskClick(item)">
- {{ item.buttonText }}
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </u-popup>
- </template>
- <script>
- export default {
- props: {
- show: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- scrollHeight: 400,
- scrollTop: 0,
- showBackTop: false,
- loadingMore: false,
- hasMore: true,
- taskList: [
- {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- }, {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- }, {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- }, {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- }, {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- }, {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- }, {
- title: '点赞内容',
- current: 0,
- total: 1,
- points: 1,
- desc: '最多1条得芳华币',
- buttonText: '去完成'
- },
- // ... 其他数据项
- ]
- }
- },
- mounted() {
- this.calcScrollHeight();
- },
- methods: {
- handleClose() {
- // 通知父组件关闭弹窗
- console.log("关闭弹窗");
- this.$emit('close');
- },
-
- handleOpen() {
- // 弹窗打开时的逻辑
- console.log("弹窗打开");
- },
-
- handleScroll(event) {
- // 更新当前滚动位置
- this.scrollTop = event.detail.scrollTop;
-
- // 判断是否显示返回顶部按钮
- this.showBackTop = this.scrollTop > 300;
-
- // 判断是否滚动到底部(需要加载更多)
- if (!this.loadingMore && this.hasMore) {
- const { scrollHeight } = event.detail;
- const scrollViewHeight = this.scrollHeight;
-
- // 距离底部50rpx时触发加载
- if (scrollHeight - this.scrollTop - scrollViewHeight < 50) {
- this.loadMoreData();
- }
- }
- },
-
- async loadMoreData() {
- if (this.loadingMore || !this.hasMore) return;
-
- this.loadingMore = true;
- try {
- // 调用API加载更多数据
- // const newData = await this.fetchMoreTasks();
- // 这里模拟加载数据
- const newData = await new Promise(resolve => {
- setTimeout(() => {
- resolve([
- {
- title: '新任务',
- current: 0,
- total: 1,
- points: 2,
- desc: '新增任务',
- buttonText: '去完成'
- }
- ]);
- }, 1000);
- });
-
- if (newData.length > 0) {
- this.taskList.push(...newData);
- } else {
- this.hasMore = false;
- }
- } catch (error) {
- console.error('加载失败:', error);
- } finally {
- this.loadingMore = false;
- }
- },
-
- calcScrollHeight() {
- // 计算屏幕可用高度
- const systemInfo = uni.getSystemInfoSync();
- // 弹窗高度设置为屏幕高度的70%
- this.scrollHeight = systemInfo.windowHeight * 0.7;
- },
-
- handleTaskClick(item) {
- console.log('点击任务:', item);
- // 处理任务点击逻辑
- uni.showToast({
- title: `点击了${item.title}`,
- icon: 'none'
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- height: 1000rpx;
- background: #FFFFFF;
- border-radius: 32rpx 32rpx 0rpx 0rpx;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- .bg {
- padding: 36rpx 24rpx;
- background: linear-gradient(180deg, #FFDFCD 0%, #FFFFFF 100%);
- }
- .row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- .mtb48 {
- margin-top: 48rpx;
- margin-bottom: 48rpx;
- }
-
- .plr24 {
- padding-left: 24rpx;
- padding-right: 24rpx;
- }
-
- .mr24 {
- margin-right: 24rpx;
- }
-
- .mr4 {
- margin-right: 4rpx;
- }
-
- .ml8 {
- margin-left: 8rpx;
- }
-
- .mb8 {
- margin-bottom: 8rpx;
- }
- .points {
- font-weight: 400;
- font-size: 28rpx;
- color: #333333;
- .num {
- font-weight: 500;
- font-size: 40rpx;
- color: #222426;
- margin-left: 4rpx;
- }
- }
- .shop {
- .shop-txt {
- font-weight: 500;
- font-size: 28rpx;
- color: #FF5C03;
- margin: 0 12rpx;
- }
- }
- .list {
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- padding: 0 24rpx;
- box-sizing: border-box;
- flex: 1;
- overflow: hidden;
- .list-item {
- width: 100%;
- margin-bottom: 32rpx;
- .button {
- width: 132rpx;
- height: 64rpx;
- background: #FF5C03;
- border-radius: 32rpx 32rpx 32rpx 32rpx;
- text-align: center;
- line-height: 64rpx;
- color: #FFFFFF;
- font-weight: 500;
- font-size: 28rpx;
- }
- .left {
- display: flex;
- .title {
- font-weight: 500;
- font-size: 30rpx;
- color: #333333;
- }
- .num {
- font-weight: 600;
- font-size: 28rpx;
- color: #FF5C03;
- }
- .txt {
- font-size: 24rpx;
- color: #999999;
- }
- }
- }
- }
-
- // 添加图标尺寸类
- .w40 { width: 40rpx; }
- .h40 { height: 40rpx; }
- .w428 { width: 428rpx; }
- .h64 { height: 64rpx; }
- .w48 { width: 48rpx; }
- .h48 { height: 48rpx; }
- .w24 { width: 24rpx; }
- .h24 { height: 24rpx; }
- .w88 { width: 88rpx; }
- .h88 { height: 88rpx; }
- }
- </style>
|