196 lines
4.5 KiB
JavaScript
196 lines
4.5 KiB
JavaScript
|
// pages/caseHandle/caseHandle.js
|
||
|
const app = getApp()
|
||
|
var util = require('../../utils/WSCoordinate.js')
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
reportId: '',
|
||
|
baseUrl: app.baseUrls.caseUrl,
|
||
|
imgUrl: app.baseUrls.baseImgUrl,
|
||
|
handleSummary: '',
|
||
|
handleImg: [],
|
||
|
markers: []
|
||
|
},
|
||
|
getDetail: function () {
|
||
|
var self = this
|
||
|
app.restAjax.get(app.restAjax.path(app.apis.myCaseDetail, [app.baseUrls.caseTypeUrl, self.data.reportId]), {}, {
|
||
|
headers: {
|
||
|
token: app.globalData.token
|
||
|
}
|
||
|
}, function (code, data) {
|
||
|
data.reportPhotos = data.reportPhotos.split(',')
|
||
|
if (data.reportPhotos.length > 0) {
|
||
|
if (data.reportPhotos.length == 1 && data.reportPhotos[0] != "") {
|
||
|
for (let i = 0; i < data.reportPhotos.length; i++) {
|
||
|
data.reportPhotos[i] = self.data.baseUrl + self.data.imgUrl + data.reportPhotos[i]
|
||
|
}
|
||
|
} else {
|
||
|
data.reportPhotos = []
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var marker = [
|
||
|
{
|
||
|
iconPath: "../../images/marker_red.png",
|
||
|
id: 1,
|
||
|
latitude: data.reportLat,
|
||
|
longitude: data.reportLng,
|
||
|
height: 30
|
||
|
}
|
||
|
]
|
||
|
console.log(data)
|
||
|
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,
|
||
|
})
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.setData({
|
||
|
reportId: options.reportId
|
||
|
})
|
||
|
this.getDetail()
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
}
|
||
|
})
|