191 lines
4.3 KiB
JavaScript
191 lines
4.3 KiB
JavaScript
// pages/caseCheck/caseCheck.js
|
|
var bmap = require('../../lib/bmap-wx.js');
|
|
var app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
caseId: '',
|
|
longitude: '111.759608',
|
|
latitude: '40.860318',
|
|
markers: [],
|
|
caseDetail: {},
|
|
token: '',
|
|
requestUrl: app.requestUrl,
|
|
evaluateContent: '',
|
|
isPass: 1,
|
|
grade: '',
|
|
photoList: [],
|
|
scrollHeight: 0,
|
|
},
|
|
getDetail: function () {
|
|
var self = this
|
|
app.restAjax.get(app.restAjax.path('{reqesutUrl}app/reportcase/getreportcase/' + self.data.caseId, [app.requestUrl]), {}, {
|
|
headers: {
|
|
token: self.data.token
|
|
}
|
|
}, function (code, data) {
|
|
var imgArr, handleArr
|
|
imgArr = data.casePhotos.split(',')
|
|
handleArr = data.handlePhotos.split(',')
|
|
var arr = [{ longitude: data.caseLongitude, latitude: data.caseLatitude, iconPath: '../../images/marker_red.png', width: '25px', height: '30px', id: 0 }]
|
|
self.setData({
|
|
markers: arr
|
|
});
|
|
self.setData({
|
|
caseDetail: data,
|
|
longitude: data.caseLongitude,
|
|
latitude: data.caseLatitude,
|
|
imageList: imgArr,
|
|
handleList: handleArr
|
|
})
|
|
});
|
|
},
|
|
isQualified: function (e) {
|
|
this.setData({
|
|
isPass: e.detail.value
|
|
})
|
|
},
|
|
isSatisfied: function (e) {
|
|
this.setData({
|
|
grade: e.detail.value
|
|
})
|
|
},
|
|
// 选择图片
|
|
chooseImage: function () {
|
|
var self = this
|
|
wx.chooseImage({
|
|
count: 9 - self.data.photoList.length,
|
|
sourceType: ['album', 'camera'],
|
|
success: function (res) {
|
|
self.setData({
|
|
showPhotoList: self.data.photoList.concat(res.tempFiles)
|
|
})
|
|
wx.showToast({
|
|
title: '上传中',
|
|
icon: 'loading'
|
|
})
|
|
var arr = []
|
|
for (let i = 0; i < res.tempFiles.length; i++) {
|
|
var path = res.tempFiles[i].path;
|
|
app.restAjax.file(app.restAjax.path('{requestUrl}app/file/uploadimage', [app.requestUrl]), path, 'image', {
|
|
headers: {
|
|
token: self.data.token
|
|
}
|
|
}, function (code, data) {
|
|
var id = JSON.parse(data).data
|
|
arr.push(id)
|
|
if (arr.length == res.tempFiles.length) {
|
|
self.setData({
|
|
photoList: arr
|
|
})
|
|
wx.hideToast()
|
|
}
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
// 删除图片
|
|
deleteImg: function (e) {
|
|
var idx = e.currentTarget.dataset.num
|
|
var self = this
|
|
self.data.photoList.splice(idx, 1)
|
|
self.data.showPhotoList.splice(idx, 1)
|
|
self.setData({
|
|
showPhotoList: self.data.showPhotoList,
|
|
photoList: self.data.photoList
|
|
})
|
|
},
|
|
// 确认处理
|
|
submitHandle: function () {
|
|
var photo = '', self = this
|
|
if (!self.data.evaluateContent) {
|
|
wx.showToast({
|
|
title: '请输入评价内容',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (!self.data.grade) {
|
|
wx.showToast({
|
|
title: '请选择满意度',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.data.photoList.length == 0) {
|
|
wx.showToast({
|
|
title: '请至少上传一张照片',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
for (let i = 0; i < this.data.photoList.length; i++) {
|
|
if (i == this.data.photoList.length - 1) {
|
|
photo += this.data.photoList[i]
|
|
} else {
|
|
photo += this.data.photoList[i] + ','
|
|
}
|
|
}
|
|
var info = {
|
|
inspectPhotos: photo,
|
|
inspectOpinion: self.data.evaluateContent,
|
|
isPass: self.data.isPass,
|
|
grade: self.data.grade
|
|
}
|
|
app.restAjax.post(app.restAjax.path('{reqesutUrl}app/reportcase/savereportcaseinspect/' + self.data.caseId, [app.requestUrl]), info, {
|
|
headers: {
|
|
token: self.data.token
|
|
}
|
|
}, function (code, data) {
|
|
if (code == '200') {
|
|
wx.showToast({
|
|
title: '处理成功',
|
|
duration: 2000,
|
|
success: function () {
|
|
setTimeout(function () {
|
|
const eventChannel = self.getOpenerEventChannel();
|
|
eventChannel.emit('doNeedRefresh', { data: 'test' });
|
|
wx.navigateBack();
|
|
}, 2000)
|
|
}
|
|
})
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
caseId: options.id
|
|
})
|
|
var self = this
|
|
wx.getStorage({
|
|
key: 'token',
|
|
success: function (res) {
|
|
self.setData({
|
|
token: res.data
|
|
})
|
|
self.getDetail()
|
|
}
|
|
})
|
|
|
|
var BMap = new bmap.BMapWX({
|
|
ak: 'Zk732rbyjd327q7Zj9EOtRjUn2ED1GWK'
|
|
});
|
|
let screenHeight = wx.getSystemInfoSync().windowHeight;
|
|
this.setData({
|
|
scrollHeight: screenHeight - 75
|
|
})
|
|
},
|
|
|
|
}) |