318 lines
6.2 KiB
Vue
318 lines
6.2 KiB
Vue
<!-- 任务中心 -->
|
|
<template>
|
|
<view class="container">
|
|
<view class="task_bg ">
|
|
<image class="task_bg" src="@/static/task/member_bg.png" mode=""></image>
|
|
<view class="title ">每月打卡免费领</view>
|
|
</view>
|
|
<view class="content" v-if="datas.list.length">
|
|
<view class="title">
|
|
<view>打卡奖励</view>
|
|
<view class="tip">每月免费领</view>
|
|
</view>
|
|
<view class="cell " v-for="(item, index) in datas.list" :key="index">
|
|
<view class="cell_left ">
|
|
<image class="cell_icon" :src="item.img"></image>
|
|
<view class="cell_title ">
|
|
<view class=" title">{{ item.name }}</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="cell_right" v-if="datas.standard=='true'">
|
|
<viwe v-if="!datas.receive">
|
|
<view class="btn" @click="taskReceive(item)">领取</view>
|
|
</viwe>
|
|
<view v-else>
|
|
<view v-if="item.disabled">
|
|
<view class="btn disabled">领取</view>
|
|
</view>
|
|
<view v-else>
|
|
<view v-if="!item.targetId" class="btn" @click="toDuiHuan(item)">去兑换</view>
|
|
<view v-else class="btn receive">已兑换</view>
|
|
<u-image v-if="!item.targetId" class="icon"
|
|
style=" width: 32rpx!important;height: 36rpx!important;position: absolute; right: 0;bottom: 0;"
|
|
src="@/static/task/receive2.png"></u-image>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
<image v-else src="@/static/task/receive1.png"
|
|
style="width: 130rpx!important;height: 130rpx!important;position: absolute; right: 0;bottom: 0;"
|
|
mode=""></image>
|
|
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {
|
|
reactive,
|
|
ref,
|
|
onMounted,
|
|
onUnmounted,
|
|
getCurrentInstance
|
|
} from 'vue'
|
|
import {
|
|
onLoad,onShow
|
|
} from '@dcloudio/uni-app'
|
|
import {
|
|
selectTaskCenterUserReward,
|
|
receiveGoods
|
|
} from '@/api/task/index.js'
|
|
let datas = reactive({
|
|
list: [],
|
|
source: null,
|
|
standard: true,
|
|
receive: null,
|
|
record: null,
|
|
taskId: "",
|
|
|
|
})
|
|
onLoad(options => {
|
|
console.log(options, '调试1')
|
|
if (options.source) {
|
|
datas.source = options.source
|
|
}
|
|
if (options.standard) {
|
|
datas.standard = options.standard
|
|
}
|
|
if (options.taskId) {
|
|
datas.taskId = options.taskId
|
|
}
|
|
})
|
|
onShow(()=>{
|
|
getList()
|
|
})
|
|
// 去兑换
|
|
function toDuiHuan(item) {
|
|
uni.navigateTo({
|
|
url: `/pages/index/prizeDraw/duihuan?id=${datas.record}&foreignType=task`
|
|
})
|
|
}
|
|
/**
|
|
* 领取
|
|
*/
|
|
async function taskReceive(item) {
|
|
let res = await receiveGoods({
|
|
taskId: datas.taskId,
|
|
sourceId: item.id
|
|
})
|
|
uni.showToast({
|
|
title: '领取成功',
|
|
icon: 'none'
|
|
})
|
|
getList()
|
|
}
|
|
async function getList() {
|
|
let res = await selectTaskCenterUserReward({
|
|
taskId: datas.taskId
|
|
})
|
|
if (res.code == 0) {
|
|
datas.list = res.data
|
|
datas.list.map(item => {
|
|
item.disabled = true
|
|
})
|
|
datas.receive = res.receive
|
|
datas.record = res.record
|
|
if (datas.receive) {
|
|
datas.list.map(item => {
|
|
if (item.id == datas.receive) {
|
|
item.disabled = false
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.container {
|
|
width: 100%;
|
|
height: 100vh;
|
|
position: relative;
|
|
|
|
// display: flex;
|
|
// flex-direction: column;
|
|
.task_bg {
|
|
width: 100% !important;
|
|
height: 470rpx !important;
|
|
position: relative;
|
|
|
|
.title {
|
|
width: 314rpx;
|
|
height: 72rpx;
|
|
line-height: 72rpx;
|
|
text-align: center;
|
|
border-radius: 108rpx 108rpx 108rpx 108rpx;
|
|
border: 6rpx solid #3D6DC6;
|
|
font-weight: bold;
|
|
font-size: 34rpx;
|
|
color: #3D6DC6;
|
|
position: absolute;
|
|
top: 210rpx;
|
|
left: 26rpx;
|
|
}
|
|
}
|
|
|
|
.content {
|
|
color: #666666;
|
|
height: calc(100% - 410rpx);
|
|
border-radius: 16rpx;
|
|
top: -60rpx;
|
|
z-index: 9;
|
|
padding: 64rpx 28rpx;
|
|
background: linear-gradient(-45deg, #DDEAFC 0%, #FFFFFF 100%);
|
|
border-radius: 32rpx 32rpx 0rpx 0rpx;
|
|
overflow-y: auto;
|
|
position: relative;
|
|
|
|
>.title {
|
|
display: flex;
|
|
align-items: center;
|
|
font-weight: bold;
|
|
font-size: 32rpx;
|
|
color: #333333;
|
|
margin-bottom: 22rpx;
|
|
|
|
.tip {
|
|
font-weight: 400;
|
|
font-size: 24rpx;
|
|
color: #666666;
|
|
margin-left: 10rpx;
|
|
}
|
|
}
|
|
|
|
.cell {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
background: linear-gradient(90deg, #FFF4E0 0%, #FFFBF5 100%);
|
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
|
margin-bottom: 32rpx;
|
|
padding: 32rpx 28rpx;
|
|
position: relative;
|
|
|
|
.cell_left {
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
align-items: center;
|
|
|
|
.cell_icon {
|
|
width: 84rpx !important;
|
|
height: 84rpx !important;
|
|
margin-right: 30rpx;
|
|
border-radius: 4rpx !important;
|
|
}
|
|
|
|
.cell_title {
|
|
display: flex;
|
|
align-items: center;
|
|
color: #333;
|
|
|
|
.title {
|
|
font-weight: bold;
|
|
font-size: 28rpx;
|
|
color: #333333;
|
|
|
|
}
|
|
|
|
.tip {
|
|
font-weight: 400;
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
.cell_right {
|
|
flex-direction: column;
|
|
align-items: center;
|
|
flex-shrink: 0;
|
|
margin-left: 20rpx;
|
|
|
|
.btn {
|
|
width: 148rpx;
|
|
height: 56rpx;
|
|
line-height: 56rpx;
|
|
text-align: center;
|
|
background: #6DA9F7;
|
|
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #FFFFFF;
|
|
border: 2rpx solid transparent;
|
|
}
|
|
|
|
.opt {
|
|
color: #D39B7E;
|
|
background-color: #FBF3EB;
|
|
}
|
|
|
|
.disabled {
|
|
color: #999999;
|
|
background-color: #E2E2E2;
|
|
}
|
|
|
|
.receive {
|
|
background: rgba(178, 223, 255, 0.62);
|
|
border: 2rpx solid #6DA9F7;
|
|
color: #6DA9F7;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
.cell:last-child {
|
|
border-bottom: none;
|
|
}
|
|
}
|
|
|
|
|
|
.cell_right {
|
|
flex-direction: column;
|
|
align-items: center;
|
|
flex-shrink: 0;
|
|
margin-left: 20rpx;
|
|
|
|
.btn {
|
|
width: 148rpx;
|
|
height: 56rpx;
|
|
line-height: 56rpx;
|
|
text-align: center;
|
|
background: #6DA9F7;
|
|
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #FFFFFF;
|
|
border: 2rpx solid transparent;
|
|
position: relative;
|
|
z-index: 99;
|
|
}
|
|
|
|
.opt {
|
|
color: #D39B7E;
|
|
background-color: #FBF3EB;
|
|
}
|
|
|
|
.disabled {
|
|
color: #999999;
|
|
background-color: #E2E2E2;
|
|
}
|
|
|
|
.receive {
|
|
background: rgba(178, 223, 255, 0.62);
|
|
border: 2rpx solid #6DA9F7;
|
|
color: #6DA9F7;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
</style> |