342 lines
8.1 KiB
JavaScript
342 lines
8.1 KiB
JavaScript
// pages/caseReport/caseReport.js
|
|
const app = getApp()
|
|
var bmap = require('../../utils/bmap-wx.min.js');
|
|
var wxMarkerData = [];
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
baseImgUrl: app.baseUrls.baseImgUrl,
|
|
reportUrl: app.baseUrls.appealReportUrl,
|
|
uploadImgUrl: app.baseUrls.uploadImgUrl,
|
|
imageList: [],
|
|
videoId: '',
|
|
reportContent: '',
|
|
reportTitle: '',
|
|
visitsType: '',
|
|
hideName: '0',
|
|
// 区县
|
|
areaAll: [],
|
|
areaArray: [],
|
|
areaIdx: 0,
|
|
areaSelected: '',
|
|
areaSelectedName: '',
|
|
areaCode: '',
|
|
// 乡镇
|
|
villageAll: [],
|
|
villageArray: [],
|
|
villageIdx: 0,
|
|
villageSelected: '',
|
|
villageSelectedName: '',
|
|
villageCode: ''
|
|
},
|
|
hideName: function (e) {
|
|
this.setData({
|
|
hideName: e.detail.value
|
|
})
|
|
},
|
|
// 上传图片
|
|
uploadImage: function () {
|
|
var self = this
|
|
wx.chooseImage({
|
|
count: 9 - self.data.imageList.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.uploadImgUrl]), path, 'image', {
|
|
headers: {
|
|
token: app.globalData.token
|
|
}
|
|
}, function (code, data) {
|
|
if (code == '200') {
|
|
var id = JSON.parse(data).data
|
|
var arr = self.data.imageList
|
|
arr.push(id)
|
|
self.setData({
|
|
imageList: arr
|
|
})
|
|
wx.hideToast()
|
|
}
|
|
}, 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'
|
|
})
|
|
console.log(res.tempFilePath)
|
|
var path = res.tempFilePath
|
|
app.restAjax.file(app.restAjax.path(app.apis.uploadVideo, [app.baseUrls.uploadImgUrl]), path, 'video', {
|
|
headers: {
|
|
token: app.globalData.token
|
|
}
|
|
}, function (code, data) {
|
|
if (code == '200') {
|
|
console.log(data)
|
|
var id = JSON.parse(data).data
|
|
self.setData({
|
|
videoId: id
|
|
})
|
|
wx.hideToast()
|
|
}
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
}
|
|
})
|
|
},
|
|
editInfo: function (e) {
|
|
var type = e.currentTarget.dataset.type
|
|
if (type == 'title') {
|
|
this.setData({
|
|
reportTitle: e.detail.value
|
|
})
|
|
} else {
|
|
this.setData({
|
|
reportContent: e.detail.value
|
|
})
|
|
}
|
|
},
|
|
// 提交上报
|
|
submitReport: function () {
|
|
var self = this
|
|
if (!self.data.reportTitle) {
|
|
wx.showToast({
|
|
title: '请输入信访标题',
|
|
icon: 'error'
|
|
})
|
|
return
|
|
}
|
|
if (!self.data.reportContent) {
|
|
wx.showToast({
|
|
title: '请输入信访内容',
|
|
icon: 'error'
|
|
})
|
|
return
|
|
}
|
|
var photos = ''
|
|
for (let i = 0; i < self.data.imageList.length; i++) {
|
|
if (i == 0) {
|
|
photos += self.data.imageList[i]
|
|
} else {
|
|
photos += ',' + self.data.imageList[i]
|
|
}
|
|
}
|
|
var locationName = self.data.areaSelectedName
|
|
var locationCode = self.data.areaCode
|
|
if (self.data.villageCode) {
|
|
locationName += ',' + self.data.villageSelectedName
|
|
locationCode = self.data.villageCode
|
|
}
|
|
var info = {
|
|
visitsTitle: self.data.reportTitle,
|
|
visitsContent: self.data.reportContent,
|
|
visitsVideo: self.data.videoId,
|
|
visitsPhoto: photos,
|
|
visitsType: self.data.visitsType,
|
|
isAnonymous: self.data.hideName,
|
|
locationName: locationName,
|
|
locationCode: locationCode
|
|
}
|
|
app.restAjax.post(app.restAjax.path(app.apis.appealReport, [app.baseUrls.appealReportUrl]), info, {
|
|
headers: {
|
|
token: app.globalData.token
|
|
}
|
|
}, function (code, data) {
|
|
if (code == '200') {
|
|
wx.showToast({
|
|
title: '上报成功',
|
|
icon: 'success'
|
|
})
|
|
setTimeout(function () {
|
|
wx.reLaunch({
|
|
url: '../reportList/reportList?visitsType=' + self.data.visitsType,
|
|
})
|
|
}, 1500)
|
|
}
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
},
|
|
// 删除附件
|
|
deleteSource: function (e) {
|
|
var self = this
|
|
var type = e.currentTarget.dataset.type
|
|
if (type == 'video') {
|
|
self.setData({
|
|
videoId: ''
|
|
})
|
|
} else {
|
|
var cur = e.currentTarget.dataset.cur
|
|
self.data.imageList.splice(cur, 1)
|
|
self.setData({
|
|
imageList: self.data.imageList
|
|
})
|
|
}
|
|
},
|
|
// 获取区县
|
|
getArea: function () {
|
|
var self = this
|
|
app.restAjax.get(app.restAjax.path(app.apis.getArea, [app.baseUrls.caseUrl, '110889']), {}, {
|
|
headers: {
|
|
token: app.globalData.token
|
|
}
|
|
}, function (code, data) {
|
|
var arr = ['请选择区县']
|
|
for (let i = 0; i < data.length; i++) {
|
|
arr.push(data[i].areaName)
|
|
}
|
|
self.setData({
|
|
areaAll: data,
|
|
areaArray: arr
|
|
})
|
|
// self.getVillage()
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
},
|
|
// 获取乡镇
|
|
getVillage: function () {
|
|
var self = this
|
|
app.restAjax.get(app.restAjax.path(app.apis.getChildArea, [app.baseUrls.caseUrl, self.data.areaSelected]), {}, {
|
|
headers: {
|
|
token: app.globalData.token
|
|
}
|
|
}, function (code, data) {
|
|
var arr = ['请选择乡镇']
|
|
for (let i = 0; i < data.length; i++) {
|
|
arr.push(data[i].areaName)
|
|
}
|
|
self.setData({
|
|
villageAll: data,
|
|
villageArray: arr
|
|
})
|
|
// self.getCommittee()
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
},
|
|
// 选择区县
|
|
bindAreaPickerChange: function (e) {
|
|
var self = this
|
|
if (e.detail.value != 0) {
|
|
this.setData({
|
|
areaIdx: e.detail.value,
|
|
areaSelected: self.data.areaAll[e.detail.value - 1].areaId,
|
|
areaCode: self.data.areaAll[e.detail.value - 1].areaCode,
|
|
areaSelectedName: self.data.areaAll[e.detail.value - 1].areaName,
|
|
villageIdx: 0
|
|
})
|
|
this.getVillage()
|
|
} else {
|
|
this.setData({
|
|
areaIdx: 0,
|
|
areaSelected: '',
|
|
villageArray: [],
|
|
committeeArray: []
|
|
})
|
|
}
|
|
},
|
|
// 选择乡镇
|
|
bindVillagePickerChange: function (e) {
|
|
var self = this
|
|
if (e.detail.value != 0) {
|
|
this.setData({
|
|
villageIdx: e.detail.value,
|
|
villageSelected: self.data.villageAll[e.detail.value - 1].areaId,
|
|
villageCode: self.data.villageAll[e.detail.value - 1].areaCode,
|
|
villageSelectedName: self.data.villageAll[e.detail.value - 1].areaName
|
|
})
|
|
// this.getVillage()
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
visitsType: options.typeId
|
|
})
|
|
var title = ''
|
|
if (options.typeId == '355507a7-9d5a-4bad-9059-90975efbe754') {
|
|
title = '诉求上报'
|
|
} else if (options.typeId == 'e4b1db45-4e15-46b5-8d46-c9f70b30a1c0') {
|
|
title = '公众咨询'
|
|
} else {
|
|
title = '社情民意'
|
|
}
|
|
wx.setNavigationBarTitle({
|
|
title: title,
|
|
})
|
|
this.getArea()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |