task_common.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {
  2. onSubmitCheck_Api
  3. } from "@/api/task.js"
  4. /**
  5. * 跳转任务提交/查看页面
  6. * type : 0 - 单任务 , 1 - 多任务
  7. * receiveTaskId: 单任务领取ID,
  8. * receiveChildTaskId: 多任务领取子ID
  9. * checkPage: 是否查看详情
  10. */
  11. const pageList = {
  12. taskAuditDetails: '/pages/task/task-audit',
  13. submitDetails: '/pages/task/submit-task',
  14. }
  15. let onSubmint_val_loading = false;
  16. export const onSubmint_val = async (type = null, task_info = null, checkPage = false, page = 'taskAuditDetails') => {
  17. console.log('task_info = ', task_info, onSubmint_val_loading, pageList[page])
  18. if (!pageList[page]) {
  19. uni.showToast({
  20. title: '跳转页面错误',
  21. icon: 'none'
  22. })
  23. return
  24. }
  25. if (type !== null && task_info && !onSubmint_val_loading) {
  26. onSubmint_val_loading = true
  27. let path = `${pageList[page]}?&checkPage=${checkPage}`;
  28. try {
  29. if (!checkPage) {
  30. const Check_val = await onSubmitCheck_Api(task_info.receiveChildTaskId)
  31. if (!Check_val || Check_val.code !== 200) {
  32. throw new Error('编辑审核不通过')
  33. }
  34. }
  35. if (type === 0) {
  36. // 单任务
  37. path = `${path}&receiveTaskId=${task_info.receiveTaskId}`
  38. } else {
  39. // 多任务下子任务
  40. path = `${path}&receiveChildTaskId=${task_info.receiveChildTaskId}`
  41. };
  42. console.log('checkPage = ' , checkPage , path)
  43. if (checkPage) {
  44. uni.navigateTo({
  45. url: path
  46. })
  47. } else {
  48. uni.navigateTo({
  49. url: path
  50. })
  51. }
  52. onSubmint_val_loading = false
  53. } catch (e) {
  54. onSubmint_val_loading = false
  55. //TODO handle the exception
  56. }
  57. }
  58. }