123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- var app = getApp()
- var that;
- Page({
- data: {
- date: app.globalData.month,
- activeIndex: 1,
- array: ['编辑任务', '删除任务'],
- isPublisher: true,//是不是发布者
- userId: '',
- id: '',
- isCreator:false,
- },
- onLoad(e) {
- that = this;
- dd.setNavigationBar({ title: "任务详情" });
- this.setData({
- isCreator:app.globalData.isCreator
- })
- if (e.id) {
- that.getDetail(e.id);
- this.setData({
- id: e.id,
- userId: app.globalData.userData.id
- })
- }
- },
- bindPickerChange(e) {
- if (this.data.array[e.detail.value] == '删除任务') {
- dd.confirm({
- title: '删除任务',
- content: '删除此任务将会删除其相关记录和积分数据,确认删除吗?',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- success: (result) => {
- if (result.confirm) {
- app.$get("api/integral/task/delete", { task_id: this.data.id }).then((res) => {
- app.globalData.showToast(res.data.msg);
- setTimeout(() => {
- dd.navigateBack({ delta: 1 })
- }, 1000);
- })
- }
- },
- });
- } else if (this.data.array[e.detail.value] == '编辑任务') {//编辑任务
- dd.navigateTo({
- url: '../offerAreward_set/offerAreward_set?item=' + JSON.stringify(this.data.dataDetail)
- })
- }
- },
- //领取任务
- formSubmit() {
- app.$post("api/integral/task", { task_id: this.data.dataDetail.id }).then((res) => {
- app.globalData.showToast('已领取');
- setTimeout(() => {
- dd.navigateBack({ delta: 1 })
- }, 1000);
- })
- },
- //显示图片
- showImg(e) {
- var index = e.target.dataset.index;
- var item = e.target.dataset.item
- dd.previewImage({
- current: index,
- urls: item
- });
- },
- activeItem(e) {
- var index = e.target.dataset.index;
- this.setData({ activeIndex: index })
- },
- openSearch() {
- app.globalData.showToast("暂不支持筛选");
- },
- getDetail(id, func = function () { }) {
- app.$get("api/integral/task", { task_id: id }).then((res) => {
- func();
- var data = res.data.data;
- data.pt_name = app.getTypesItem(data.pt_id).name;
- if (data.status == 1 && data.status_mark == '待领取') {
- this.setData({
- array: ['编辑任务', '删除任务'],
- })
- } else {
- this.setData({
- array: ['删除任务'],
- })
- }
- this.setData({
- dataDetail: data,
- isPublisher: data.owner_id == this.data.userId ? true : false
- })
- })
- },
- openSchedule() {
- dd.navigateTo({
- url: '../schedule/schedule'
- })
- },
- });
|