task_common.js 1.5 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. if (!pageList[page]) {
  18. uni.showToast({
  19. title: '跳转页面错误',
  20. icon: 'none'
  21. })
  22. return
  23. }
  24. if (type !== null && task_info && !onSubmint_val_loading) {
  25. onSubmint_val_loading = true
  26. let path = `${pageList[page]}?&checkPage=${checkPage}`;
  27. try {
  28. if (!checkPage) {
  29. const Check_val = await onSubmitCheck_Api(task_info.receiveChildTaskId)
  30. if (!Check_val || Check_val.code !== 200) {
  31. throw new Error('编辑审核不通过')
  32. }
  33. }
  34. if (type === 0) {
  35. // 单任务
  36. path = `${path}&receiveTaskId=${task_info.receiveTaskId}`
  37. } else {
  38. // 多任务下子任务
  39. path = `${path}&receiveChildTaskId=${task_info.receiveChildTaskId}`
  40. };
  41. console.log('checkPage = ' , checkPage , path)
  42. if (checkPage) {
  43. uni.navigateTo({
  44. url: path
  45. })
  46. } else {
  47. uni.navigateTo({
  48. url: path
  49. })
  50. }
  51. onSubmint_val_loading = false
  52. } catch (e) {
  53. onSubmint_val_loading = false
  54. //TODO handle the exception
  55. }
  56. }
  57. }