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.

266 lines
5.5 KiB

  1. <template>
  2. <view class="task-upload">
  3. <!-- 驳回原因提示 -->
  4. <view class="reject-tip" v-if="isRejected">
  5. <text>拒绝原因:{{taskInfo.rejectReason || '部分任务要求不符合'}}</text>
  6. </view>
  7. <!-- 任务头部信息 -->
  8. <view class="task-header">
  9. <view class="task-title">{{taskInfo.title}}</view>
  10. <view class="task-deadline">请于{{taskInfo.deadline}}之前上传任务超时将自动取消</view>
  11. </view>
  12. <!-- 上传表单 -->
  13. <view class="upload-form">
  14. <view class="form-title">任务完成凭证</view>
  15. <!-- 笔记链接 -->
  16. <view class="form-item">
  17. <view class="item-label">笔记链接</view>
  18. <view class="item-content">
  19. <u-textarea v-model="formData.noteLink" placeholder="猫妈狗爸" maxlength="300" height="120"></u-textarea>
  20. <view class="word-count">{{formData.noteLink.length || 0}}/300</view>
  21. </view>
  22. </view>
  23. <!-- 笔记截图 -->
  24. <view class="form-item">
  25. <view class="item-label">笔记截图 <text class="required">*</text></view>
  26. <view class="item-content">
  27. <u-upload
  28. :fileList="fileList"
  29. @afterRead="afterRead"
  30. @delete="deletePic"
  31. :maxCount="6"
  32. name="1"
  33. :multiple="true"
  34. :maxSize="10 * 1024 * 1024"
  35. ></u-upload>
  36. <view class="upload-tips">请上传任务完成的截图凭证最多6张每张不超过10MB</view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 提交按钮 -->
  41. <view class="submit-btn">
  42. <u-button type="primary" color="#ffaa48" text="确认上传" @click="submitTaskHandler"></u-button>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import { getTaskDetail, submitTask } from "@/api/system/task.js"
  48. export default {
  49. data() {
  50. return {
  51. taskId: null,
  52. taskStatus: '',
  53. isRejected: false,
  54. taskInfo: {
  55. id: 0,
  56. title: '',
  57. deadline: '',
  58. rejectReason: ''
  59. },
  60. formData: {
  61. noteLink: '',
  62. images: []
  63. },
  64. fileList: []
  65. }
  66. },
  67. onLoad(options) {
  68. if (options.id) {
  69. this.taskId = options.id
  70. this.taskStatus = options.status || ''
  71. this.isRejected = this.taskStatus === 'REJECTED'
  72. this.getTaskDetail()
  73. } else {
  74. uni.showToast({
  75. title: '任务ID不存在',
  76. icon: 'none'
  77. })
  78. setTimeout(() => {
  79. uni.navigateBack()
  80. }, 1500)
  81. }
  82. },
  83. methods: {
  84. getTaskDetail() {
  85. // 获取任务详情
  86. // 实际项目中取消注释下面的代码
  87. /*
  88. getTaskDetail(this.taskId).then(res => {
  89. if (res && res.code === 200) {
  90. this.taskInfo = res.data
  91. }
  92. })
  93. */
  94. // 模拟数据
  95. const mockData = {
  96. id: this.taskId,
  97. title: '发布小红书宣传笔记',
  98. deadline: '2025-03-28',
  99. rejectReason: this.isRejected ? '图片不清晰,请重新上传高清图片' : ''
  100. }
  101. this.taskInfo = mockData
  102. },
  103. afterRead(event) {
  104. // 读取文件后的处理
  105. const { file } = event
  106. this.fileList.push({
  107. url: file.url,
  108. status: 'success',
  109. message: '上传成功',
  110. name: file.name
  111. })
  112. this.formData.images.push(file.url)
  113. },
  114. deletePic(event) {
  115. // 删除图片
  116. const index = event.index
  117. this.fileList.splice(index, 1)
  118. this.formData.images.splice(index, 1)
  119. },
  120. submitTaskHandler() {
  121. // 提交任务
  122. if (this.formData.images.length === 0) {
  123. uni.showToast({
  124. title: '请上传任务完成凭证',
  125. icon: 'none'
  126. })
  127. return
  128. }
  129. // 实际项目中取消注释下面的代码
  130. /*
  131. submitTask({
  132. taskId: this.taskId,
  133. noteLink: this.formData.noteLink,
  134. images: this.formData.images
  135. }).then(res => {
  136. if (res && res.code === 200) {
  137. uni.showToast({
  138. title: '任务提交成功',
  139. icon: 'success'
  140. })
  141. setTimeout(() => {
  142. uni.navigateBack()
  143. }, 1500)
  144. }
  145. })
  146. */
  147. // 模拟提交
  148. uni.showLoading({
  149. title: '提交中...'
  150. })
  151. setTimeout(() => {
  152. uni.hideLoading()
  153. uni.showToast({
  154. title: '任务提交成功',
  155. icon: 'success'
  156. })
  157. setTimeout(() => {
  158. uni.navigateBack()
  159. }, 1500)
  160. }, 1500)
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss">
  166. .task-upload {
  167. background-color: #f5f5f7;
  168. min-height: 100vh;
  169. padding-bottom: 120rpx;
  170. .reject-tip {
  171. background-color: #FFF1F0;
  172. padding: 20rpx 30rpx;
  173. text {
  174. color: #FF5722;
  175. font-size: 28rpx;
  176. }
  177. }
  178. .task-header {
  179. background-color: #FFFFFF;
  180. padding: 30rpx;
  181. .task-title {
  182. font-size: 32rpx;
  183. font-weight: bold;
  184. color: #333;
  185. margin-bottom: 20rpx;
  186. }
  187. .task-deadline {
  188. font-size: 26rpx;
  189. color: #999;
  190. }
  191. }
  192. .upload-form {
  193. background-color: #FFFFFF;
  194. margin-top: 20rpx;
  195. padding: 30rpx;
  196. .form-title {
  197. font-size: 30rpx;
  198. font-weight: bold;
  199. color: #333;
  200. margin-bottom: 30rpx;
  201. border-left: 8rpx solid #ffaa48;
  202. padding-left: 20rpx;
  203. }
  204. .form-item {
  205. margin-bottom: 30rpx;
  206. .item-label {
  207. font-size: 28rpx;
  208. color: #333;
  209. margin-bottom: 20rpx;
  210. .required {
  211. color: #f56c6c;
  212. margin-left: 4rpx;
  213. }
  214. }
  215. .item-content {
  216. position: relative;
  217. .word-count {
  218. position: absolute;
  219. bottom: 10rpx;
  220. right: 10rpx;
  221. font-size: 24rpx;
  222. color: #999;
  223. }
  224. .upload-tips {
  225. font-size: 24rpx;
  226. color: #999;
  227. margin-top: 20rpx;
  228. }
  229. }
  230. }
  231. }
  232. .submit-btn {
  233. position: fixed;
  234. bottom: 0;
  235. left: 0;
  236. right: 0;
  237. background-color: #FFFFFF;
  238. padding: 20rpx 30rpx;
  239. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  240. }
  241. }
  242. </style>