|
|
@@ -10,30 +10,30 @@
|
|
|
<view v-for="(task, index) in tasks" :key="index" class="task-card">
|
|
|
<view class="task-header">
|
|
|
<text class="task-label">任务目标:</text>
|
|
|
- <text class="task-content">{{task.title}}</text>
|
|
|
+ <text class="task-content">{{task.name}}</text>
|
|
|
</view>
|
|
|
<view class="task-desc">
|
|
|
<text class="task-label">任务描述:</text>
|
|
|
- <text class="task-content">{{task.description}}</text>
|
|
|
+ <text class="task-content">{{task.content}}</text>
|
|
|
</view>
|
|
|
<view class="task-rewards">
|
|
|
<text class="task-label">任务奖励:</text>
|
|
|
<view class="reward-list">
|
|
|
- <view v-for="(reward, rIndex) in task.rewards" :key="rIndex" class="reward-item">
|
|
|
+ <view v-for="(prize, pIndex) in task.prize_list" :key="pIndex" class="reward-item">
|
|
|
<view class="reward-box">
|
|
|
- <image :src="reward.icon" class="reward-icon"></image>
|
|
|
+ <image :src="prize.shop.image || '/static/island/items/default.png'" class="reward-icon"></image>
|
|
|
</view>
|
|
|
- <text class="reward-text">{{reward.text}}</text>
|
|
|
+ <text class="reward-text">{{prize.shop.name.length > 3 ? prize.shop.name.substring(0, 3) + '' : prize.shop.name}}x{{ prize.num }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="task-footer">
|
|
|
- <text class="task-date">{{task.date}}</text>
|
|
|
+ <text class="task-date">{{task.create_time}}</text>
|
|
|
<view
|
|
|
- :class="['task-button', task.status === 'completed' ? 'completed' : 'uncompleted']"
|
|
|
+ :class="['task-button', task.state === 1 ? 'completed' : 'uncompleted']"
|
|
|
@click="handleTaskAction(task)"
|
|
|
>
|
|
|
- {{task.status === 'completed' ? '完成任务' : '未完成'}}
|
|
|
+ {{task.state === 1 ? '已完成' : '未完成'}}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="card-divider"></view>
|
|
|
@@ -59,94 +59,87 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- tasks: [
|
|
|
- {
|
|
|
- title: '负债累累的冒险家',
|
|
|
- description: '终极目标就是偿还移民的债务,做一个无债一身轻的玩家',
|
|
|
- rewards: [
|
|
|
- {
|
|
|
- icon: '/static/icons/coin.png',
|
|
|
- text: '金币×3000'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static/icons/exp.png',
|
|
|
- text: '经验×3000'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static/icons/blueprint.png',
|
|
|
- text: '升级房屋图纸×1'
|
|
|
- }
|
|
|
- ],
|
|
|
- date: '2024/04/08',
|
|
|
- status: 'completed'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '负债累累的冒险家',
|
|
|
- description: '终极目标就是偿还移民的债务,做一个无债一身轻的玩家',
|
|
|
- rewards: [
|
|
|
- {
|
|
|
- icon: '/static/icons/coin.png',
|
|
|
- text: '金币×3000'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static/icons/exp.png',
|
|
|
- text: '经验×3000'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static/icons/blueprint.png',
|
|
|
- text: '升级房屋图纸×1'
|
|
|
- }
|
|
|
- ],
|
|
|
- date: '2024/04/08',
|
|
|
- status: 'available'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '负债累累的冒险家',
|
|
|
- description: '终极目标就是偿还移民的债务,做一个无债一身轻的玩家',
|
|
|
- rewards: [
|
|
|
- {
|
|
|
- icon: '/static/icons/coin.png',
|
|
|
- text: '金币×3000'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static/icons/exp.png',
|
|
|
- text: '经验×3000'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static/icons/blueprint.png',
|
|
|
- text: '升级房屋图纸×1'
|
|
|
- }
|
|
|
- ],
|
|
|
- date: '2024/04/08',
|
|
|
- status: 'available'
|
|
|
- }
|
|
|
- ]
|
|
|
+ tasks: [],
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ visible(val) {
|
|
|
+ if (val) {
|
|
|
+ this.fetchTaskData()
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
onClose() {
|
|
|
this.$emit('close')
|
|
|
},
|
|
|
+ // 获取任务数据
|
|
|
+ async fetchTaskData() {
|
|
|
+ if (this.loading) return
|
|
|
+ this.loading = true
|
|
|
+
|
|
|
+ try {
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + '/Game/get_task_list',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ type: 'main'
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
+ 'sign': getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log("任务数据:", res.data)
|
|
|
+ if (res.data && res.data.code === 0) {
|
|
|
+ this.tasks = res.data.list || []
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.data?.msg || '获取任务数据失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('获取任务数据异常', err)
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络异常,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取任务数据异常', error)
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络异常,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
handleTaskAction(task) {
|
|
|
- if (task.status === 'completed') {
|
|
|
- // 处理完成任务的逻辑
|
|
|
+ if (task.state === 1) {
|
|
|
+ // 处理已完成任务的逻辑
|
|
|
uni.showToast({
|
|
|
title: '任务已完成!',
|
|
|
icon: 'success'
|
|
|
})
|
|
|
} else {
|
|
|
- // 处理领取任务的逻辑
|
|
|
- // uni.showToast({
|
|
|
- // title: '已领取任务',
|
|
|
- // icon: 'success'
|
|
|
- // })
|
|
|
+ // 处理未完成任务的逻辑
|
|
|
+ uni.showToast({
|
|
|
+ title: '任务未完成',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</script>
|
|
|
-
|
|
|
-
|
|
|
+</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
@import './TaskDialog.scss';
|