var e = getApp(), t = require("../../utils/WSCoordinate.js"); Page({ data: { sourceUrl: e.baseUrls.sourceUrl, typeAll: [], typeArray: [], typeIdx: 0, typeSelected: "", typeSelectedCode: "", typeSelectedName: "", type2All: [], type2Array: [ "请选择上级类型" ], type2Idx: 0, type2Selected: "", type2SelectedName: "", areaAll: [], areaArray: [], areaIdx: 0, areaSelected: "", areaSelectedName: "", villageAll: [], villageArray: [], villageIdx: 0, villageSelected: "", villageSelectedName: "", committeeAll: [], committeeArray: [], committeeIdx: 0, committeeSelected: "", committeeSelectedName: "", recodePath: "", recorderManager: wx.getRecorderManager(), baseImgUrl: e.baseUrls.baseImgUrl, caseUrl: e.baseUrls.caseUrl, imageList: [], videoId: "", audioId: "", latitude: "", longitude: "", reportAddress: "", reportContent: "", reportInfo: { bGId: "", casePartsObjId: "123", casePartsObjName: "123", caseTypeCode1: "", caseTypeCode2: "", caseTypeName1: "", caseTypeName2: "", reportAddress: "", reportAreaCod: "", reportAreaName: "例如北京市 / xx区 / xx街道 / xx", reportAudio: "", reportContent: "", reportLat: "", reportLng: "", reportPhotos: "", reportVideo: "" }, isLoading: !1 }, getArea: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getArea, [ e.baseUrls.caseUrl, "110889" ]), {}, { headers: { token: e.globalData.token } }, function(e, a) { for (var o = [ "请选择区县" ], i = 0; i < a.length; i++) o.push(a[i].areaName); t.setData({ areaAll: a, areaArray: o }); }, function(e, t) { console.log(t); }); }, getVillage: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getChildArea, [ e.baseUrls.caseUrl, t.data.areaSelected ]), {}, { headers: { token: e.globalData.token } }, function(e, a) { for (var o = [ "请选择乡镇" ], i = 0; i < a.length; i++) o.push(a[i].areaName); t.setData({ villageAll: a, villageArray: o }); }, function(e, t) { console.log(t); }); }, getCommittee: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getChildArea, [ e.baseUrls.caseUrl, t.data.villageSelected ]), {}, { headers: { token: e.globalData.token } }, function(e, a) { for (var o = [ "请选择委员会" ], i = 0; i < a.length; i++) o.push(a[i].areaName); t.setData({ committeeAll: a, committeeArray: o }); }, function(e, t) { console.log(t); }); }, getCaseType: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.caseType, [ e.baseUrls.caseUrl ]), {}, { headers: { token: e.globalData.token } }, function(e, a) { for (var o = [ "请选择事件类型" ], i = 0; i < a.length; i++) o.push(a[i].name); t.setData({ typeAll: a, typeArray: o }); }, function(e, t) { console.log(t); }); }, getCaseTypeChild: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.caseTypeChild + "/" + t.data.typeSelected, [ e.baseUrls.caseUrl ]), {}, { headers: { token: e.globalData.token } }, function(e, a) { for (var o = [ "请选择事件类型" ], i = 0; i < a.length; i++) o.push(a[i].typeName); t.setData({ type2All: a, type2Array: o }); }, function(e, t) { console.log(t); }); }, bindPickerChange: function(e) { 0 != e.detail.value ? (this.setData({ typeIdx: e.detail.value, typeSelected: this.data.typeAll[e.detail.value - 1].id, typeSelectedCode: this.data.typeAll[e.detail.value - 1].code, typeSelectedName: this.data.typeAll[e.detail.value - 1].name }), this.getCaseTypeChild()) : this.setData({ typeIdx: 0, typeSelected: "", type2Array: [] }); }, bindCaseTypeChange: function(e) { 0 != e.detail.value ? this.setData({ type2Idx: e.detail.value, type2Selected: this.data.type2All[e.detail.value - 1].typeCode, type2SelectedName: this.data.type2All[e.detail.value - 1].typeName }) : this.setData({ type2Idx: 0, type2Selected: "" }); }, bindAreaPickerChange: function(e) { 0 != e.detail.value ? (this.setData({ areaIdx: e.detail.value, areaSelected: this.data.areaAll[e.detail.value - 1].areaCode, areaSelectedName: this.data.areaAll[e.detail.value - 1].areaName }), this.getVillage()) : this.setData({ areaIdx: 0, areaSelected: "", villageArray: [], committeeArray: [] }); }, bindVillagePickerChange: function(e) { 0 != e.detail.value ? (this.setData({ villageIdx: e.detail.value, villageSelected: this.data.villageAll[e.detail.value - 1].areaId, villageSelectedName: this.data.villageAll[e.detail.value - 1].areaName }), this.getCommittee()) : this.setData({ villageIdx: 0, villageSelected: "", committeeArray: [] }); }, bindCommitteePickerChange: function(e) { 0 != e.detail.value ? this.setData({ committeeIdx: e.detail.value, committeeSelected: this.data.committeeAll[e.detail.value - 1].areaId, committeeSelectedName: this.data.committeeAll[e.detail.value - 1].areaName }) : this.setData({ committeeIdx: 0, committeeSelected: "" }); }, recordVoice: function(e) { this.setData({ startTouch: e.touches[0] }); this.data.recorderManager.start({ format: "mp3" }), wx.showToast({ title: "正在录音", icon: "none", duration: 6e4 }); }, recordEnd: function() { var t = this; this.data.recorderManager.stop(), this.data.recorderManager.onStop(function(a) { var o = a.tempFilePath; wx.showToast({ title: "上传中", icon: "loading" }), e.restAjax.file(e.restAjax.path(e.apis.uploadAudio, [ e.baseUrls.caseUrl ]), o, "audio", { headers: { token: e.globalData.token } }, function(e, a) { var o = JSON.parse(a).data; t.setData({ audioId: o }), wx.hideToast(); }, function(e, t) { console.log(t); }); }); t = this; wx.hideToast(); }, playRecord: function() { var e = wx.createInnerAudioContext(); e.src = this.data.caseUrl + this.data.baseImgUrl + this.data.audioId, e.play(); }, doLogin: function() { wx.login({ success: function(t) { e.restAjax.post(e.restAjax.path(e.apis.login, [ e.baseUrls.loginUrl ]), { jsCode: t.code }, null, function(e, t) { console.log(t); }, function(t, a) { e.dialog.msg(a.msg); }); } }); }, uploadImage: function() { var t = this; t.data.isLoading || (t.setData({ isLoading: !0 }), wx.chooseImage({ count: 9 - t.data.imageList.length, sourceType: [ "album", "camera" ], success: function(a) { wx.showToast({ title: "上传中", icon: "loading" }); for (var o = 0; o < a.tempFiles.length; o++) { var i = a.tempFiles[o].path; e.restAjax.file(e.restAjax.path(e.apis.uploadImg, [ e.baseUrls.caseUrl ]), i, "image", { headers: { token: e.globalData.token } }, function(e, a) { if ("200" == e) { t.setData({ isLoading: !1 }); var o = JSON.parse(a).data, i = t.data.imageList; i.push(o), t.setData({ imageList: i }), wx.hideToast(); } }, function(e, a) { console.log(a), t.setData({ isLoading: !1 }); }); } } })); }, uploadVideo: function() { var t = this; t.data.isLoading || (t.setData({ isLoading: !0 }), wx.chooseVideo({ sourceType: [ "album", "camera" ], maxDuration: 60, camera: "back", success: function(a) { wx.showToast({ title: "上传中", icon: "loading" }); var o = a.tempFilePath; e.restAjax.file(e.restAjax.path(e.apis.uploadVideo, [ e.baseUrls.caseUrl ]), o, "video", { headers: { token: e.globalData.token } }, function(e, a) { if ("200" == e) { var o = JSON.parse(a).data; t.setData({ videoId: o, isLoading: !1 }), wx.hideToast(); } }, function(e, a) { console.log(a), t.setData({ isLoading: !1 }); }); } })); }, chooseLocation: function() { var e = this; wx.chooseLocation({ success: function(a) { console.log(a); var o = t.transformFromGCJToWGS(a.latitude, a.longitude); console.log(o), e.setData({ longitude: o.longitude, latitude: o.latitude }); } }); }, editInfo: function(e) { "location" == e.currentTarget.dataset.type ? this.setData({ reportAddress: e.detail.value }) : this.setData({ reportContent: e.detail.value }); }, submitReport: function() { var t = this; if (!t.data.isLoading) { if (!this.data.typeSelected) return void wx.showToast({ title: "请选择事件类型", icon: "error" }); if (!this.data.type2Selected) return void wx.showToast({ title: "请选择事件类型", icon: "error" }); if (!this.data.reportAddress) return void wx.showToast({ title: "请输入事发位置", icon: "error" }); if (!this.data.longitude && !this.data.latitude) return void wx.showToast({ title: "请选择事发坐标", icon: "error" }); if (!this.data.reportContent) return void wx.showToast({ title: "请输入事件说明", icon: "error" }); for (var a, o = "内蒙古自治区 / 乌兰察布市 / " + wx.getStorageSync("curCommunityName"), i = 0; i < t.data.imageList.length; i++) 0 == i ? a = t.data.imageList[i] : a += "," + t.data.imageList[i]; var s = wx.getStorageSync("areaCode"), r = { bGId: "", casePartsObjId: "", casePartsObjName: "", caseTypeCode1: t.data.typeSelectedCode, caseTypeCode2: t.data.type2Selected, caseTypeName1: t.data.typeSelectedName, caseTypeName2: t.data.type2SelectedName, reportAddress: t.data.reportAddress, reportAreaCode: s, isSelf: "0", reportAreaName: o, reportAudio: t.data.audioId, reportContent: t.data.reportContent, reportLat: t.data.latitude, reportLng: t.data.longitude, reportPhotos: a, reportVideo: t.data.videoId, gridMiniId: wx.getStorageSync("gridMiniId") }; t.setData({ isLoading: !0 }), e.restAjax.post(e.restAjax.path(e.apis.submitReport, [ e.baseUrls.requestUrl ]), r, { headers: { token: "cVJWWXQ1UWpQWTQ1TDZMbEVtTmxiMlJVNkdvTzUwSTNHYzZaK3VTZmF0RXNITnQ3RXUxZ2F6eVU4dGpZWjFqWm5Pc0Fqd2l6MzAvMlZSckZaTkZITFZmVXk4YVNWVVErcEJ5SGZzVFRGeGFEenBMaDhZU0FFc1hnZ2RGc2hLUWZvMTJtWHRkcENmWThROTZFL2d5WDJxc0RBY2RzUkUzUzIyNlBmblFhUGdPZWdFY3JOeU5mME5veEk1aVU4a1hNMFNlaW1BemFwRjhRbXVRUUt1MTlObEViSTlhMUVoSEJDZ2ZFVTFYZlJNNGFoMTVOTXgyYytBdE96SUVmWmpYRQ==" } }, function(e, a) { "200" == e && (wx.showToast({ title: "上报成功", icon: "success" }), setTimeout(function() { t.setData({ isLoading: !1 }), wx.navigateBack({ delta: 1 }); }, 1500)); }, function(e, a) { console.log(a), t.setData({ isLoading: !1 }); }); } }, deleteSource: function(e) { if ("video" == e.currentTarget.dataset.type) this.setData({ videoId: "" }); else { var t = e.currentTarget.dataset.cur; this.data.imageList.splice(t, 1), this.setData({ imageList: this.data.imageList }); } }, onLoad: function(t) { this.setData({ token: e.globalData.token }), this.getCaseType(), this.getArea(); }, onReady: function() {}, onShow: function() {}, onHide: function() {}, onUnload: function() {}, onPullDownRefresh: function() {}, onReachBottom: function() {}, onShareAppMessage: function() {} });