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.

393 lines
13 KiB

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