city_card/pages/center/case/caseHandle.js
2023-07-15 14:25:28 +08:00

266 lines
9.2 KiB
JavaScript

var t = getApp();
require("../../../utils/WSCoordinate.js");
Page({
data: {
reportId: "",
baseUrl: t.baseUrls.serviceUrl,
imgUrl: t.baseUrls.baseImgUrl,
sourceUrl: t.baseUrls.sourceUrl,
handleSummary: "",
handleImg: [],
markers: [],
caseDetail: {},
content: "",
videoId: "",
handleDetail: {}
},
getDetail: function() {
var e = this;
t.restAjax.get(t.restAjax.path(t.apis.myCaseDetail, [ t.baseUrls.requestUrl, e.data.reportId ]), {}, {
headers: {
token: t.globalData.token
}
}, function(t, a) {
a.reportPhotos ? a.reportPhotos = a.reportPhotos.split(",") : a.reportPhotos = [],
"1" == a.handleStatus && e.getHandleList();
var o = [ {
iconPath: e.data.sourceUrl + "marker_red.png",
id: 1,
latitude: a.reportLat,
longitude: a.reportLng,
width: "30",
height: "30"
} ];
e.setData({
caseDetail: a,
markers: o
});
}, function(t, e) {
console.log(e);
});
},
playRecord: function() {
var t = wx.createInnerAudioContext();
t.src = this.data.caseUrl + this.data.imgUrl + this.data.caseDetail.reportAudio,
t.play();
},
handleCase: function() {
for (var e, a = 0; a < this.data.handleImg.length; a++) 0 == a ? e = this.data.handleImg[a] : e += "," + this.data.handleImg[a];
var o = {
handleSummary: this.data.handleSummary,
taskId: this.data.reportId,
handlePhotos: e
};
t.restAjax.post(t.restAjax.path(t.apis.handleCase, [ t.baseUrls.caseUrl ]), o, {
headers: {
token: t.globalData.token
}
}, function(t, e) {
console.log(e);
}, function(t, e) {
console.log(e);
});
},
uploadImage: function() {
var e = this;
wx.chooseImage({
count: 9 - e.data.handleImg.length,
sourceType: [ "album", "camera" ],
success: function(a) {
wx.showToast({
title: "上传中",
icon: "loading"
});
for (var o = 0; o < a.tempFiles.length; o++) {
var s = a.tempFiles[o].path;
t.restAjax.file(t.restAjax.path(t.apis.uploadImg, [ t.baseUrls.caseUrl ]), s, "image", {
headers: {
token: t.globalData.token
}
}, function(t, a) {
if ("200" == t) {
console.log(a);
var o = JSON.parse(a).data, s = e.data.handleImg;
s.push(o), e.setData({
handleImg: s
}), wx.hideToast();
}
}, function(t, e) {
console.log(e);
});
}
}
});
},
deleteSource: function(t) {
var e = t.currentTarget.dataset.cur;
this.data.handleImg.splice(e, 1), this.setData({
handleImg: this.data.handleImg
});
},
previewImg: function(t) {
var e = t.currentTarget.dataset.src;
wx.previewImage({
current: e,
urls: this.data.caseDetail.reportPhotos
});
},
acceptance: function() {
for (var e = this, a = e.data.caseDetail, o = "", s = 0; s < a.reportPhotos.length; s++) s < a.reportPhotos.length - 1 ? o += a.reportPhotos[s] + "," : o += a.reportPhotos[s];
a.reportPhotos = o, a.isAccept = "1", t.restAjax.put(t.restAjax.path(t.apis.updateCaseStatus, [ t.baseUrls.requestUrl, e.data.reportId ]), a, {
headers: {
token: t.globalData.token
}
}, function(t, a) {
"200" == t && (wx.showToast({
title: "受理成功",
icon: "success"
}), e.getDetail());
}, function(t, e) {
console.log(e);
});
},
notAcceptance: function() {
var e = this;
wx.showModal({
cancelColor: "cancelColor",
content: "确认不予受理该事件?",
success: function(a) {
if (a.confirm) {
for (var o = e.data.caseDetail, s = "", n = 0; n < o.reportPhotos.length; n++) n < o.reportPhotos.length - 1 ? s += o.reportPhotos[n] + "," : s += o.reportPhotos[n];
o.reportPhotos = s, console.log(o), o.isAccept = "-1", t.restAjax.put(t.restAjax.path(t.apis.updateCaseStatus, [ t.baseUrls.requestUrl, e.data.reportId ]), o, {
headers: {
token: t.globalData.token
}
}, function(t, a) {
"200" == t && (wx.showToast({
title: "不予受理成功",
icon: "success"
}), e.getDetail());
}, function(t, e) {
console.log(e);
});
}
}
});
},
uploadVideo: function() {
var e = this;
wx.chooseVideo({
sourceType: [ "album", "camera" ],
maxDuration: 60,
camera: "back",
success: function(a) {
wx.showToast({
title: "上传中",
icon: "loading"
});
var o = a.tempFilePath;
t.restAjax.file(t.restAjax.path(t.apis.uploadVideo, [ t.baseUrls.caseUrl ]), o, "video", {
headers: {
token: t.globalData.token
}
}, function(t, a) {
if ("200" == t) {
var o = JSON.parse(a).data;
e.setData({
videoId: o
}), wx.hideToast();
}
}, function(t, e) {
console.log(e);
});
}
});
},
deleteVideo: function() {
this.setData({
videoId: ""
});
},
handleComplete: function() {
if (this.data.content) {
for (var e = "", a = 0; a < this.data.handleImg.length; a++) a < this.data.handleImg.length - 1 ? e += this.data.handleImg[a] + "," : e += this.data.handleImg[a];
var o = {
content: this.data.content,
photo: e,
reportId: this.data.reportId,
video: this.data.videoId
};
t.restAjax.post(t.restAjax.path(t.apis.handleCase, [ t.baseUrls.requestUrl ]), o, {
headers: {
token: t.globalData.token
}
}, function(t, e) {
"200" == t && (wx.showToast({
title: "处理成功!",
icon: "success"
}), setTimeout(function() {
wx.navigateBack({
delta: 1
});
}, 1500));
}, function(t, e) {
console.log(e);
});
} else wx.showToast({
title: "请输入事件处理说明",
icon: "error"
});
},
getHandleList: function() {
var e = this;
t.restAjax.get(t.restAjax.path(t.apis.getHandleList, [ t.baseUrls.requestUrl ]), {
reportId: e.data.reportId
}, {
headers: {
token: t.globalData.token
}
}, function(t, a) {
a[0].photo && (a[0].photo = a[0].photo.split(",")), e.setData({
handleDetail: a[0]
});
}, function(t, e) {
console.log(e);
});
},
caseRedundancies: function() {
var e = this;
wx.showModal({
cancelColor: "cancelColor",
content: "确认转派该事件?",
success: function(a) {
a.confirm && t.restAjax.put(t.restAjax.path(t.apis.caseRedundancies, [ t.baseUrls.requestUrl, e.data.reportId ]), {}, {
headers: {
token: t.globalData.token
}
}, function(t, e) {
"200" == t && (wx.showToast({
title: "转派成功!",
icon: "success"
}), setTimeout(function() {
wx.navigateBack({
delta: 1
});
}, 1500));
}, function(t, e) {
console.log(e);
});
}
});
},
onLoad: function(t) {
this.setData({
reportId: t.reportId
}), this.getDetail();
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {}
});