taskDetail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. date: app.globalData.month,
  6. activeIndex: 1,
  7. array: ['编辑任务', '删除任务'],
  8. isPublisher: true,//是不是发布者
  9. userId: '',
  10. id: '',
  11. isCreator:false,
  12. },
  13. onLoad(e) {
  14. that = this;
  15. dd.setNavigationBar({ title: "任务详情" });
  16. this.setData({
  17. isCreator:app.globalData.isCreator
  18. })
  19. if (e.id) {
  20. that.getDetail(e.id);
  21. this.setData({
  22. id: e.id,
  23. userId: app.globalData.userData.id
  24. })
  25. }
  26. },
  27. bindPickerChange(e) {
  28. if (this.data.array[e.detail.value] == '删除任务') {
  29. dd.confirm({
  30. title: '删除任务',
  31. content: '删除此任务将会删除其相关记录和积分数据,确认删除吗?',
  32. confirmButtonText: '确定',
  33. cancelButtonText: '取消',
  34. success: (result) => {
  35. if (result.confirm) {
  36. app.$get("api/integral/task/delete", { task_id: this.data.id }).then((res) => {
  37. app.globalData.showToast(res.data.msg);
  38. setTimeout(() => {
  39. dd.navigateBack({ delta: 1 })
  40. }, 1000);
  41. })
  42. }
  43. },
  44. });
  45. } else if (this.data.array[e.detail.value] == '编辑任务') {//编辑任务
  46. dd.navigateTo({
  47. url: '../offerAreward_set/offerAreward_set?item=' + JSON.stringify(this.data.dataDetail)
  48. })
  49. }
  50. },
  51. //领取任务
  52. formSubmit() {
  53. app.$post("api/integral/task", { task_id: this.data.dataDetail.id }).then((res) => {
  54. app.globalData.showToast('已领取');
  55. setTimeout(() => {
  56. dd.navigateBack({ delta: 1 })
  57. }, 1000);
  58. })
  59. },
  60. //显示图片
  61. showImg(e) {
  62. var index = e.target.dataset.index;
  63. var item = e.target.dataset.item
  64. dd.previewImage({
  65. current: index,
  66. urls: item
  67. });
  68. },
  69. activeItem(e) {
  70. var index = e.target.dataset.index;
  71. this.setData({ activeIndex: index })
  72. },
  73. openSearch() {
  74. app.globalData.showToast("暂不支持筛选");
  75. },
  76. getDetail(id, func = function () { }) {
  77. app.$get("api/integral/task", { task_id: id }).then((res) => {
  78. func();
  79. var data = res.data.data;
  80. data.pt_name = app.getTypesItem(data.pt_id).name;
  81. if (data.status == 1 && data.status_mark == '待领取') {
  82. this.setData({
  83. array: ['编辑任务', '删除任务'],
  84. })
  85. } else {
  86. this.setData({
  87. array: ['删除任务'],
  88. })
  89. }
  90. this.setData({
  91. dataDetail: data,
  92. isPublisher: data.owner_id == this.data.userId ? true : false
  93. })
  94. })
  95. },
  96. openSchedule() {
  97. dd.navigateTo({
  98. url: '../schedule/schedule'
  99. })
  100. },
  101. });