syshxcx/pages/center/case/caseHandle.js

402 lines
9.8 KiB
JavaScript
Raw Normal View History

2022-06-07 15:43:05 +08:00
// pages/caseHandle/caseHandle.js
const app = getApp()
var util = require('../../../utils/WSCoordinate.js')
Page({
/**
* 页面的初始数据
*/
data: {
reportId: '',
baseUrl: app.baseUrls.serviceUrl,
imgUrl: app.baseUrls.baseImgUrl,
sourceUrl: app.baseUrls.sourceUrl,
handleSummary: '',
handleImg: [],
markers: [],
caseDetail: {},
content: '',
videoId: '',
handleDetail: {}
},
getDetail: function () {
var self = this
app.restAjax.get(app.restAjax.path(app.apis.myCaseDetail, [app.baseUrls.requestUrl, self.data.reportId]), {}, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (data.reportPhotos) {
data.reportPhotos = data.reportPhotos.split(',')
} else {
data.reportPhotos = []
}
if (data.handleStatus == '1') {
self.getHandleList()
}
var marker = [
{
iconPath: self.data.sourceUrl + "marker_red.png",
id: 1,
latitude: data.reportLat,
longitude: data.reportLng,
width: '30',
height: '30'
}
]
self.setData({
caseDetail: data,
markers: marker
})
}, function (code, data) {
console.log(data)
})
},
// 播放录音
playRecord: function () {
var innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.src = this.data.caseUrl + this.data.imgUrl + this.data.caseDetail.reportAudio
innerAudioContext.play()
},
// 提交申请
handleCase: function () {
var self = this
var photo
for (let i = 0; i < self.data.handleImg.length; i++) {
if (i == 0) {
photo = self.data.handleImg[i]
} else {
photo += ',' + self.data.handleImg[i]
}
}
var info = {
handleSummary: self.data.handleSummary,
taskId: self.data.reportId,
handlePhotos: photo
}
app.restAjax.post(app.restAjax.path(app.apis.handleCase, [app.baseUrls.caseUrl]), info, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
console.log(data)
}, function (code, data) {
console.log(data)
})
},
// 上传图片
uploadImage: function () {
var self = this
wx.chooseImage({
count: 9 - self.data.handleImg.length,
sourceType: ['album', 'camera'],
success: function (res) {
wx.showToast({
title: '上传中',
icon: 'loading'
})
for (let i = 0; i < res.tempFiles.length; i++) {
var path = res.tempFiles[i].path;
app.restAjax.file(app.restAjax.path(app.apis.uploadImg, [app.baseUrls.caseUrl]), path, 'image', {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (code == '200') {
console.log(data)
var id = JSON.parse(data).data
var arr = self.data.handleImg
arr.push(id)
self.setData({
handleImg: arr
})
wx.hideToast()
}
}, function (code, data) {
console.log(data)
})
}
}
})
},
// 删除附件
deleteSource: function (e) {
var self = this
var cur = e.currentTarget.dataset.cur
self.data.handleImg.splice(cur, 1)
self.setData({
handleImg: self.data.handleImg
})
},
// 预览图片
previewImg: function (e) {
var self = this
var url = e.currentTarget.dataset.src
wx.previewImage({
current: url,
urls: self.data.caseDetail.reportPhotos,
})
},
// 受理
acceptance: function () {
var self = this
var info = self.data.caseDetail
var photo = ''
for (let i = 0; i < info.reportPhotos.length; i++) {
if (i < info.reportPhotos.length - 1) {
photo += info.reportPhotos[i] + ','
} else {
photo += info.reportPhotos[i]
}
}
info.reportPhotos = photo
info.isAccept = '1'
app.restAjax.put(app.restAjax.path(app.apis.updateCaseStatus, [app.baseUrls.requestUrl, self.data.reportId]), info, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (code == '200') {
wx.showToast({
title: '受理成功',
icon: 'success'
})
self.getDetail()
}
}, function (code, data) {
console.log(data)
})
},
// 不予受理
notAcceptance: function () {
var self = this
wx.showModal({
cancelColor: 'cancelColor',
// title: '',
content: '确认不予受理该事件?',
success: function (res) {
if (res.confirm) {
var info = self.data.caseDetail
var photo = ''
for (let i = 0; i < info.reportPhotos.length; i++) {
if (i < info.reportPhotos.length - 1) {
photo += info.reportPhotos[i] + ','
} else {
photo += info.reportPhotos[i]
}
}
info.reportPhotos = photo
console.log(info)
info.isAccept = '-1'
app.restAjax.put(app.restAjax.path(app.apis.updateCaseStatus, [app.baseUrls.requestUrl, self.data.reportId]), info, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (code == '200') {
wx.showToast({
title: '不予受理成功',
icon: 'success'
})
self.getDetail()
}
}, function (code, data) {
console.log(data)
})
}
}
})
},
// 上传视频
uploadVideo: function () {
var self = this
wx.chooseVideo({
sourceType: ['album','camera'],
maxDuration: 60,
camera: 'back',
success: function (res) {
wx.showToast({
title: '上传中',
icon: 'loading'
})
var path = res.tempFilePath
app.restAjax.file(app.restAjax.path(app.apis.uploadVideo, [app.baseUrls.caseUrl]), path, 'video', {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (code == '200') {
var id = JSON.parse(data).data
self.setData({
videoId: id
})
wx.hideToast()
}
}, function (code, data) {
console.log(data)
})
}
})
},
// 删除视频
deleteVideo: function () {
this.setData({
videoId: ''
})
},
// 处理完成
handleComplete: function () {
var self = this
if (self.data.content) {
var photo = ''
for (let i = 0; i < self.data.handleImg.length; i++) {
if (i < self.data.handleImg.length - 1) {
photo += self.data.handleImg[i] + ','
} else {
photo += self.data.handleImg[i]
}
}
var info = {
content: self.data.content,
photo: photo,
reportId: self.data.reportId,
video: self.data.videoId
}
app.restAjax.post(app.restAjax.path(app.apis.handleCase, [app.baseUrls.requestUrl]), info, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (code == '200') {
wx.showToast({
title: '处理成功!',
icon: 'success'
})
setTimeout(function () {
wx.navigateBack({
delta: 1
})
}, 1500)
}
}, function (code, data) {
console.log(data)
})
} else {
wx.showToast({
title: '请输入事件处理说明',
icon: 'error'
})
}
},
// 获取列表
getHandleList: function () {
var self = this
app.restAjax.get(app.restAjax.path(app.apis.getHandleList, [app.baseUrls.requestUrl]), {
reportId: self.data.reportId
}, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (data[0].photo) {
data[0].photo = data[0].photo.split(',')
}
self.setData({
handleDetail: data[0]
})
}, function (code, data) {
console.log(data)
})
},
// 事件转派
caseRedundancies: function () {
var self = this
wx.showModal({
cancelColor: 'cancelColor',
content: '确认转派该事件?',
success: function (res) {
if (res.confirm) {
app.restAjax.put(app.restAjax.path(app.apis.caseRedundancies, [app.baseUrls.requestUrl, self.data.reportId]), {}, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
if (code == '200') {
wx.showToast({
title: '转派成功!',
icon: 'success'
})
setTimeout(function () {
wx.navigateBack({
delta: 1
})
}, 1500)
}
}, function (code, data) {
console.log(data)
})
}
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
reportId: options.reportId
})
this.getDetail()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})