| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <template>
- <view class="task-list-container">
- <view class="task-list-header">
- <text class="task-list-title">做任务赚积分</text>
- </view>
- <!-- 加载状态 -->
- <view v-if="loading" class="task-list-loading">
- <u-loading-icon text="加载中..." mode="circle"></u-loading-icon>
- </view>
- <!-- 任务数据 -->
- <view v-else-if="taskData && taskData.length > 0">
- <view class="task-list">
- <view
- v-for="(task,index) in taskData"
- :key="index"
- class="task-item">
- <view class="task-item-left">
- <view class="task-icon">
- <ImageItem :src="getTaskIcon(task.taskName)" />
- </view>
- <view class="task-info">
- <view class="task-name">{{ task.taskName }}</view>
- <view class="task-reward">
- <ImageItem src="/static/points/point.png"/>
- <text>+{{ task.rewardPoints }}</text>
- </view>
- </view>
- </view>
- <view class="task-item-right">
- <text class="progress-text">{{ task.completedCount }}/{{ task.triggerValue }}</text>
- <button
- :class="Number(task.completedCount) >= Number(task.triggerValue) ? 'task-btn' : 'no-task-btn'"
- @click.stop="handleTask(task)"
- :disabled="Number(task.completedCount) >= Number(task.triggerValue)">
- {{Number(task.completedCount) >= Number(task.triggerValue) ? '已完成' : '去完成' }}
- </button>
- </view>
- </view>
- </view>
- <view class="more-tasks" @click="handleMoreTasks">赚更多积分 ></view>
- </view>
- <!-- 空状态 -->
- <view v-else class="task-list-empty">暂无任务活动</view>
- </view>
- </template>
- <script>
- import ImageItem from "@/components/swiper/components/image.vue";
- import { handleServiceShare } from '@/utils/share'
- export default {
- components: { ImageItem },
- props: {
- taskData: {
- type: Array,
- default: () => []
- },
- loading: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- // 任务类型配置
- taskConfig: {
- order: {
- icon: '/static/points/task_order.png',
- action: this.handleOrderTask
- },
- merchant: {
- icon: '/static/points/task_shop.png',
- action: this.handleMerchantTask
- },
- dynamic: {
- icon: '/static/points/task_trend.png',
- action: this.handleDynamicTask
- },
- service: {
- icon: '/static/points/task_wx.png',
- action: this.handleServiceTask
- },
- recharge: {
- icon: '/static/points/task_account.png',
- action: this.handleRechargeTask
- }
- }
- }
- },
- methods: {
- // 获取任务图标
- getTaskIcon(taskName) {
- if (taskName.includes('订单')) return this.taskConfig.order.icon;
- if (taskName.includes('商户')) return this.taskConfig.merchant.icon;
- if (taskName.includes('动态')) return this.taskConfig.dynamic.icon;
- if (taskName.includes('服务号')) return this.taskConfig.service.icon;
- if (taskName.includes('充值')) return this.taskConfig.recharge.icon;
- return '';
- },
- // 处理任务点击
- handleTask(task) {
- if (task.completedStatus === 1) return;
- if (task.taskName.includes('订单')) {
- this.taskConfig.order.action();
- } else if (task.taskName.includes('商户')) {
- this.taskConfig.merchant.action();
- } else if (task.taskName.includes('动态')) {
- this.taskConfig.dynamic.action();
- } else if (task.taskName.includes('服务号')) {
- this.taskConfig.service.action();
- } else if (task.taskName.includes('充值')) {
- this.taskConfig.recharge.action();
- }
- },
- // 处理订单任务
- handleOrderTask() {
- uni.switchTab({
- url: '/pages/index/index'
- });
- },
- // 处理商户任务
- handleMerchantTask() {
- uni.switchTab({
- url: '/pages/identify/identify'
- });
- },
- // 处理动态任务
- handleDynamicTask() {
- uni.switchTab({
- url: '/pages/discover/discover'
- });
- },
- // 处理服务号任务
- handleServiceTask() {
- // 调用微信服务号分享功能
- handleServiceShare({
- title: '广誉远 - 关注服务号123123',
- desc: '关注广誉远服务号,获取更多积分和优惠123123123',
- link: window.location.href,
- imgUrl: '/static/points/task_wx.png'
- });
- },
- // 处理账号充值任务
- handleRechargeTask() {
- uni.navigateTo({
- url: '/pages/my/pay'
- });
- },
- // 处理查看更多任务
- handleMoreTasks() {
- uni.navigateTo({
- url: '/points/pointInfo/taskList'
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .task-list-container {
- background-color: #fff;
- border-radius: 20rpx;
- padding: 24rpx;
- height: 360rpx;
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
-
- .task-list-header {
- margin-bottom: 26rpx;
-
- .task-list-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #333;
- }
- }
-
- .task-list-loading {
- display: flex;
- justify-content: center;
- align-items: center;
- min-height: 230rpx;
- }
-
- .task-list {
- .task-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
-
- .task-item-left {
- display: flex;
- align-items: center;
-
- .task-icon {
- width: 72rpx;
- height: 72rpx;
- margin-right: 18rpx;
-
- image {
- width: 72rpx;
- height: 72rpx;
- }
- }
-
- .task-info {
- .task-name {
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #333333;
- line-height: 28rpx;
- margin-bottom: 12rpx;
- }
-
- .task-reward {
- display: inline-flex;
- height: 32rpx;
- background: #FBF2E1;
- border-radius: 22rpx;
- padding-right: 12rpx;
-
- image {
- width: 32rpx;
- height: 32rpx;
- margin-right: 4rpx;
- }
-
- text {
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 24rpx;
- color: #FF9F00;
- line-height: 32rpx;
- }
- }
- }
- }
-
- .task-item-right {
- display: flex;
- flex-direction: row;
- .progress-text{
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 28rpx;
- color: #999999;
- line-height: 28rpx;
- margin-right: 8rpx;
- margin-top: 10rpx;
- }
- .task-btn {
- height: 48rpx;
- background: #EEEEEE;
- border-radius: 98rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 26rpx;
- color: #999999;
- line-height: 48rpx;
- border: 1px solid #EEEEEE;
- }
-
- .no-task-btn {
- height: 48rpx;
- background: #03C1B8;
- border-radius: 98rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 26rpx;
- color: #FFFFFF;
- line-height: 48rpx;
- }
- }
- }
- }
-
- .more-tasks {
- text-align: center;
- font-weight: 500;
- font-size: 28rpx;
- color: #999999;
- }
-
- .task-list-empty {
- display: flex;
- justify-content: center;
- align-items: center;
- min-height: 230rpx;
- color: #8f9ca2;
- font-size: 28rpx;
- }
- }
- </style>
|