You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

406 lines
11 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. <template>
  2. <view class="task-center">
  3. <!-- <u-subsection :list="tabList"
  4. active-color="#ffaa48"
  5. bg-color="#fff"
  6. inactive-color="#aaaaaa"
  7. font-size="16"
  8. :current="curNow"
  9. @change="sectionChange"></u-subsection> -->
  10. <!-- <u-tabs :list="list1" @click="sectionChange"></u-tabs> -->
  11. <view class="container-tabs">
  12. <u-tabs :list="tabList"
  13. :scrollable="false"
  14. lineWidth="68rpx" :activeStyle="{
  15. color: '#fff',
  16. fontWeight: 'bold',
  17. transform: 'scale(1.05)'
  18. }" :inactiveStyle="{
  19. color: '#eee',
  20. transform: 'scale(1)'
  21. }" :itemStyle="{height:'88rpx',padding:'0 52rpx'}" lineColor="#fff" @click="sectionChange"></u-tabs>
  22. </view>
  23. <!-- 待接受任务列表 -->
  24. <view v-if="curNow === 0">
  25. <view v-for="(item,index) in pendingTasks" style="padding:28rpx 36rpx 0;" :key="index">
  26. <view class="task-card">
  27. <view class="task-header">
  28. <view class="task-image">
  29. <image src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/point.png" mode="heightFix"></image>
  30. </view>
  31. <view class="task-type">{{item.taskType}}</view>
  32. <view class="task-reward">酬劳 <text> ¥{{item.reward}}</text> </view>
  33. </view>
  34. <view class="task-content">
  35. <view class="task-icon">
  36. <image :src="item.icon" style="width: 150rpx; height: 150rpx;" mode="aspectFill"></image>
  37. </view>
  38. <view class="task-info">
  39. <view class="task-title">{{item.title}}</view>
  40. <view class="task-desc">{{item.description}}</view>
  41. <view class="task-deadline">任务截止日期: {{item.deadline}}</view>
  42. </view>
  43. </view>
  44. <view class="task-footer">
  45. <u-button shape="circle" plain text="查看详情" @click="viewTaskDetail(item)"></u-button>
  46. <u-button shape="circle" color="#ffaa48" text="立即接受" @click="acceptTaskHandler(item)"></u-button>
  47. </view>
  48. </view>
  49. </view>
  50. <view v-if="pendingTasks.length === 0" class="empty-tip">
  51. <text>暂无待接受任务</text>
  52. </view>
  53. </view>
  54. <!-- 已接收任务列表 -->
  55. <view v-else>
  56. <view v-for="(item,index) in acceptedTasks" style="padding:28rpx 36rpx 0;" :key="index">
  57. <view class="task-card">
  58. <view class="task-header">
  59. <view class="task-image">
  60. <image src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/point.png" mode="heightFix"></image>
  61. </view>
  62. <view class="task-type">{{item.taskType}}</view>
  63. <!-- <view class="task-reward">酬劳 <text> ¥{{item.reward}}</text> </view> -->
  64. <view class="task-status-tag" :class="{'status-pending': item.status === 'ACCEPTED', 'status-reviewing': item.status === 'SUBMITTED', 'status-rejected': item.status === 'REJECTED', 'status-approved': item.status === 'APPROVED'}">{{getStatusText(item.status)}}</view>
  65. </view>
  66. <view class="task-content">
  67. <view class="task-icon">
  68. <image :src="item.icon" style="width: 150rpx; height: 150rpx;" mode="aspectFill"></image>
  69. </view>
  70. <view class="task-info">
  71. <view class="task-title">{{item.title}}</view>
  72. <view class="task-desc">{{item.description}}</view>
  73. <view class="task-deadline">任务截止日期: {{item.deadline}}</view>
  74. <!-- <view class="task-status-tag" :class="{'status-pending': item.status === 'ACCEPTED', 'status-reviewing': item.status === 'SUBMITTED', 'status-rejected': item.status === 'REJECTED', 'status-approved': item.status === 'APPROVED'}">{{getStatusText(item.status)}}</view> -->
  75. </view>
  76. </view>
  77. <view class="task-footer">
  78. <u-button shape="circle" plain text="查看详情" @click="viewTaskDetail(item)"></u-button>
  79. <u-button v-if="item.status === 'REJECTED'" shape="circle" type="error" text="驳回原因" @click="showRejectReason(item)"></u-button>
  80. <u-button v-if="item.status === 'ACCEPTED'" shape="circle" color="#ffaa48" text="立即上传" @click="uploadTask(item)"></u-button>
  81. <u-button v-if="item.status === 'SUBMITTED'" shape="circle" disabled text="审核中"></u-button>
  82. <u-button v-if="item.status === 'REJECTED'" shape="circle" color="#ffaa48" text="重新上传" @click="uploadTask(item)"></u-button>
  83. <view v-if="item.status === 'APPROVED'" class="task-status task-status-approved">已通过</view>
  84. </view>
  85. </view>
  86. </view>
  87. <view v-if="acceptedTasks.length === 0" class="empty-tip">
  88. <text>暂无已接收任务</text>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. getTaskList,
  96. getTaskDetail,
  97. acceptTask
  98. } from "@/api/order/task.js"
  99. export default {
  100. data() {
  101. return {
  102. tabList: [
  103. {
  104. name: '待接受',
  105. badge: {
  106. value: 1,
  107. }
  108. },
  109. {
  110. name: '已接受',
  111. badge: {
  112. value: 0,
  113. }
  114. },
  115. ],
  116. curNow: 0,
  117. pendingTasks: [],
  118. acceptedTasks: []
  119. }
  120. },
  121. onShow() {
  122. // 加载任务列表数据
  123. this.getTaskList()
  124. },
  125. methods: {
  126. sectionChange({index}) {
  127. this.curNow = index;
  128. this.getTaskList()
  129. },
  130. getTaskList() {
  131. // 调用API获取任务列表
  132. getTaskList({
  133. status : this.curNow
  134. }).then(res=>{
  135. if (res && res.code === 200) {
  136. let rows = res.rows || []
  137. console.log(rows)
  138. // 根据status字段分类:0为待接受,1为已接受
  139. this.pendingTasks = rows.filter(item => item.status === 0).map(item => this.formatTaskItem(item))
  140. this.acceptedTasks = rows.filter(item => item.status === 1).map(item => this.formatTaskItem(item))
  141. this.updateBadgeCount()
  142. }
  143. })
  144. },
  145. // 格式化任务项
  146. formatTaskItem(item) {
  147. return {
  148. id: item.id,
  149. taskType: item.taskName || '任务',
  150. reward: item.taskMoney || '0',
  151. icon: item.taskIcon || 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/point.png',
  152. title: item.title || '',
  153. description: item.theme || '',
  154. deadline: item.taskEndTime ? this.formatDate(item.taskEndTime) : '',
  155. status: this.getTaskStatus(item.taskState, item.examineState),
  156. rejectReason: item.examineText || ''
  157. }
  158. },
  159. // 根据任务进度和审核状态获取任务状态
  160. getTaskStatus(taskState, examineState) {
  161. // taskState: 任务进度,examineState: 审核状态
  162. if (taskState === 0) return 'ACCEPTED'; // 待上传
  163. if (taskState === 1 && examineState === 0) return 'SUBMITTED'; // 审核中
  164. if (taskState === 1 && examineState === 1) return 'APPROVED'; // 已通过
  165. if (taskState === 1 && examineState === 2) return 'REJECTED'; // 驳回
  166. return 'ACCEPTED'; // 默认状态
  167. },
  168. // 格式化日期
  169. formatDate(dateStr) {
  170. if (!dateStr) return '';
  171. let date = new Date(dateStr);
  172. let year = date.getFullYear();
  173. let month = (date.getMonth() + 1).toString().padStart(2, '0');
  174. let day = date.getDate().toString().padStart(2, '0');
  175. return `${year}-${month}-${day}`;
  176. },
  177. updateBadgeCount() {
  178. // 更新标签页的徽标数量
  179. this.tabList[0].badge.value = this.pendingTasks.length
  180. this.tabList[1].badge.value = this.acceptedTasks.length
  181. },
  182. viewTaskDetail(task) {
  183. // 查看任务详情,跳转到任务详情页面
  184. uni.navigateTo({
  185. url: `/pages_order/task/taskDetail?id=${task.id}`
  186. });
  187. },
  188. acceptTaskHandler(task) {
  189. // 接受任务
  190. uni.showModal({
  191. title: '接受任务',
  192. content: `确定接受任务: ${task.title}`,
  193. success: res => {
  194. if (res.confirm) {
  195. acceptTask({id : task.id}).then(res => {
  196. if (res && res.code === 200) {
  197. uni.showToast({
  198. title: '任务接受成功',
  199. icon: 'success'
  200. });
  201. // 刷新任务列表
  202. this.getTaskList();
  203. }
  204. });
  205. }
  206. }
  207. });
  208. },
  209. uploadTask(task) {
  210. // 上传任务
  211. uni.navigateTo({
  212. url: `/pages_order/task/taskUpload?id=${task.id}&status=${task.status}`
  213. });
  214. },
  215. showRejectReason(task) {
  216. // 显示驳回原因
  217. if (task.rejectReason) {
  218. uni.showModal({
  219. title: '驳回原因',
  220. content: task.rejectReason,
  221. showCancel: false
  222. });
  223. } else {
  224. uni.showToast({
  225. title: '暂无驳回原因',
  226. icon: 'none'
  227. });
  228. }
  229. },
  230. getStatusText(status) {
  231. // 获取状态文本
  232. const statusMap = {
  233. 'ACCEPTED': '待上传',
  234. 'SUBMITTED': '审核中',
  235. 'REJECTED': '未通过',
  236. 'APPROVED': '已通过'
  237. };
  238. return statusMap[status] || status;
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss">
  244. .task-center {
  245. background-color: #f5f5f7;
  246. min-height: 100vh;
  247. .container-tabs{
  248. background-color: #FFBF60;
  249. }
  250. .task-status-tag {
  251. display: inline-block;
  252. font-size: 24rpx;
  253. padding: 6rpx 20rpx;
  254. border-radius: 20rpx;
  255. margin-top: 10rpx;
  256. margin-left: auto;
  257. &.status-pending {
  258. // background-color: #E6F7FF;
  259. color: #1890FF;
  260. }
  261. &.status-reviewing {
  262. // background-color: #FFF7E6;
  263. color: #FA8C16;
  264. }
  265. &.status-rejected {
  266. // background-color: #FFF1F0;
  267. color: #F5222D;
  268. }
  269. &.status-approved {
  270. // background-color: #F6FFED;
  271. color: #52C41A;
  272. }
  273. }
  274. .task-card {
  275. background-color: #FFFFFF;
  276. border-radius: 16rpx;
  277. margin-bottom: 30rpx;
  278. overflow: hidden;
  279. .task-header {
  280. display: flex;
  281. align-items: center;
  282. margin-bottom: 20rpx;
  283. background-color: #FFF4E599;
  284. padding: 15rpx;
  285. .task-image {
  286. margin-right: 30rpx;
  287. display: flex;
  288. align-items: center;
  289. image {
  290. height: 50rpx;
  291. width: 50rpx;
  292. }
  293. }
  294. .task-type {
  295. color: #C68C5B;
  296. font-size: 26rpx;
  297. background-color: #FFE4BB;
  298. padding: 10rpx 30rpx;
  299. border-radius: 30rpx;
  300. }
  301. .task-reward {
  302. font-size: 26rpx;
  303. margin-left: auto;
  304. text {
  305. color: #FF5722;
  306. font-weight: bold;
  307. margin-left: 10rpx;
  308. font-size: 30rpx;
  309. }
  310. }
  311. }
  312. .task-content {
  313. display: flex;
  314. margin-bottom: 30rpx;
  315. padding: 0 30rpx 0 30rpx;
  316. .task-icon {
  317. margin-right: 30rpx;
  318. }
  319. .task-info {
  320. flex: 1;
  321. position: relative;
  322. display: flex;
  323. flex-direction: column;
  324. gap: 10rpx;
  325. .task-title {
  326. font-size: 32rpx;
  327. font-weight: bold;
  328. color: #333;
  329. margin-bottom: 10rpx;
  330. }
  331. .task-desc {
  332. font-size: 28rpx;
  333. color: #666;
  334. margin-bottom: 10rpx;
  335. color: #FFC673;
  336. }
  337. .task-deadline {
  338. font-size: 24rpx;
  339. color: #999;
  340. margin-bottom: 10rpx;
  341. }
  342. }
  343. }
  344. .task-footer {
  345. padding-bottom: 30rpx;
  346. display: flex;
  347. justify-content: center;
  348. align-items: flex-end;
  349. gap: 20rpx;
  350. flex-wrap: wrap;
  351. .u-button {
  352. width: 200rpx;
  353. height: 60rpx;
  354. font-size: 28rpx;
  355. }
  356. .task-status {
  357. height: 60rpx;
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. width: 200rpx;
  362. font-size: 28rpx;
  363. &.task-status-approved {
  364. color: #52C41A;
  365. }
  366. }
  367. }
  368. }
  369. .empty-tip {
  370. text-align: center;
  371. padding: 60rpx 0;
  372. color: #999;
  373. font-size: 28rpx;
  374. }
  375. }
  376. </style>