123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- var app = getApp()
- var that;
- import moment from 'moment' // 时间库
- Page({
- data: {
- date: app.globalData.month,
- activeIndex: 1,
- array: ['编辑任务', '删除任务'],
- isPublisher: true,//是不是发布者
- userId: '',
- id: '',
- isCreator: false,
- date:'',
- works:[],
- },
- onLoad(e) {
- that = this;
- dd.setNavigationBar({ title: "抢单详情" });
- this.setData({
- isCreator: app.globalData.isCreator,
- date:moment().format('YYYY-MM-DD HH:mm')
- })
- if (e.id) {
- this.setData({
- id: e.id,
- userId: app.globalData.userData.id
- })
- }
- },
- onShow() {
- if (app.globalData.userData) {
- dd.hideLoading();
- that.getDetail(that.data.id);
- } else {
- app.login(app.globalData.corpId, function (is) {
- if (is) {
- dd.hideLoading();
- that.setData({
- userId: app.globalData.userData.id
- })
- that.getDetail(that.data.id);
- } else {
- dd.reLaunch({
- url: '../../noJurisdiction/noJurisdiction'
- })
- }
- }, function () { })
- }
- },
- openUser(){
- dd.navigateTo({
- url: '../userList/userList?list=' + JSON.stringify(this.data.works)
- })
- },
- onShareAppMessage() {
- return {
- title: '任务详情',
- desc:'积分任务:'+ this.data.dataDetail.task_name,
- path: 'pages/statistics/taskDetail/taskDetail?id=' + this.data.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() {
- this.setData({ disabled: true })
- app.$post('/api/integral/task/exist',{task_id:this.data.dataDetail.id}).then(res => {
- let exist=res.data.data.exist
- if(exist){
- that.setData({ disabled: false })
- app.globalData.showToast("你已经抢到该任务了,请前往【我抢到的】查看");
- }else{
- app.$post("api/integral/task", { task_id: this.data.dataDetail.id }).then((res) => {
- app.globalData.showToast('抢单成功!');
- setTimeout(() => {
- dd.navigateBack({ delta: 1 })
- }, 1000);
- }).finally(() => {
- that.setData({ disabled: false })
- });
- }
- })
- },
- //显示图片
- 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 })
- },
- 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.composite_state==1&&data.total_chance == data.chance ) {
- this.setData({
- array: ['编辑任务', '删除任务'],
- })
- } else {
- this.setData({
- array: ['删除任务'],
- })
- }
- this.setData({
- dataDetail: data,
- works:data.works,
- isPublisher: data.owner_id == this.data.userId ? true : false
- })
- })
- },
- openSchedule() {
- dd.navigateTo({
- url: '../schedule/schedule'
- })
- },
- });
|