diff --git a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
index d9e105e..8086a57 100644
--- a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
+++ b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
@@ -1,214 +1,68 @@
-// // subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
-// const QQMapWX = require('../../../../utils/qqmap-wx-jssdk')
-// import addRecord from "../../../../utils/api"
-// import {securityCheckk} from "../../../../utils/api"
-// Page({
-
-// /**
-// * 页面的初始数据
-// */
-// data: {
-// pageNo: 1,
-// pageSize: 10,
-// id: 0,
-// addressContent:'',
-// fmData: {
-// gridId: '',
-// attachmentList:[],//图片
-// voiceList:[],
-// latitude:"",
-// longitude:"",
-// resiId:"",
-// happenTime:"",
-// content:"",//内容
-// address:"",//地址
-// namesArray:[],
-// checkPersons:''
-// },
-// },
-
-// /**
-// * 生命周期函数--监听页面加载
-// */
-// onLoad(options) {
-// this.data.qqMapWX = new QQMapWX({
-// key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ'
-// })
-// this.reverseLocation()
-// // this.ToaddRecord()
-// this.getList()
-
-// },
-// getList() {
-// securityCheckk({
-// pageNo: this.data.pageNo,
-// pageSize: this.data.pageSize,
-// }).then(({data}) => {
-// console.log("123131",data.list)
-// this.setData({
-// marsi: data.list,
-// total: data.total
-// })
-// this.setData({
-// 'fmData.namesArray': data.list.map(item => ({ id: item.id, name: item.name })),
-// 'fmData.checkPersons': data.list.map(item => item.checkPersons)
-// });
-// // console.log("123131", this.data.fmData.checkPersons);
-// });
-// },
-
-// /**
-// * 生命周期函数--监听页面初次渲染完成
-// */
-// onReady() {
-
-// },
-
-// /**
-// * 生命周期函数--监听页面显示
-// */
-// onShow() {
-// this.reverseLocation
-// },
-
-// /**
-// * 生命周期函数--监听页面隐藏
-// */
-// onHide() {
-
-// },
-
-// /**
-// * 生命周期函数--监听页面卸载
-// */
-// onUnload() {
-
-// },
-
-// /**
-// * 页面相关事件处理函数--监听用户下拉动作
-// */
-// onPullDownRefresh() {
-
-// },
-
-// /**
-// * 页面上拉触底事件的处理函数
-// */
-// onReachBottom() {
-
-// },
-
-// /**
-// * 用户点击右上角分享
-// */
-// onShareAppMessage() {},
-// //跳转地图选点
-// toughGetLocation() {
-// // this.getLocation(false);
-// wx.chooseLocation({
-// success: res => {
-// console.log('resadddres', res)
-// const {
-// fmData
-// } = this.data;
-// this.setData({
-// fmData: {
-// ...fmData,
-// address: res.address,
-// longitude: res.longitude,
-// latitude: res.latitude
-// },
-// addressContent: res.address
-// });
-// console.log(this.data.fmData);
-// }
-// })
-// },
-// //
-// reverseLocation() {
-// const _this = this
-// this.data.qqMapWX.reverseGeocoder({
-// success(res) {
-// console.log(res);
-// _this.setData({
-// addressContent:res.result.address,
-// 'fmData.address': res.result.address,
-// 'fmData.longitude':res.result.location.lng,
-// 'fmData.latitude':res.result.location.lat,
-// })
-// },
-// fail(err) {
-// console.debug(err)
-// }
-// })
-// },
-
-// ToaddRecord(){
-// addRecord().then(res=>{
-// console.log(res)
-// })
-// }
-
-// })
-
-
-
-// subpages/safetyinspection/pages/safetyinspection/safetyinspection.js
+import {
+ $wuxActionSheet
+} from '../../../../components/dist/index'
const QQMapWX = require('../../../../utils/qqmap-wx-jssdk')
const App = getApp()
-import {addRecord,securityCheckk,inspectionStaff} from "../../../../utils/api"
+
+import {
+ addRecord,
+ securityCheckk,
+ inspectionStaff
+} from "../../../../utils/api"
Page({
/**
* 页面的初始数据
*/
data: {
- addRecord:[],
- attachmentUrl:'',
- reviewTime:'',
- hazardDesc:'',
- checkResultFlag:'',
- checkPersonsIdList:[],
+ hiddenDangeList: [
+ ],
+ newObj:[],
+ addRecord: [],
+ attachmentUrl: '',
+ reviewTime: '',
+ checkResultFlag: '',
+ checkPersonsIdList: [],
pageNo: 1,
pageSize: 10,
id: 0,
- addressContent:'',
+ addressContent: '',
fmData: {
gridId: '',
- attachmentList:[],//图片
- voiceList:[],
- latitude:"",
- longitude:"",
- resiId:"",
- happenTime:"",
- content:"",//内容
- address:"",//地址
- namesArray:[],
- AllnamesArray:[],
- checkPersons:''
- },
- imageUrl:'',
- remarks:'',//备注
- getData:'',
- gridName:'',
+ attachmentList: [], //图片
+ voiceList: [],
+ latitude: "",
+ longitude: "",
+ resiId: "",
+ happenTime: "",
+ content: "", //内容
+ address: "", //地址
+ namesArray: [],
+ AllnamesArray: [],
+ checkPersons: ''
+ },
+ imageUrl: '',
+ remarks: '', //备注
+ getData: '',
+ gridName: '',
array: ['不合格', '合格'], // 选择器的数据源
- result: ['a', 'b', 'c'],
- arrlist:[],
+ arrlist: [],
fileList: [],
companyId: '',
showPopup: false, // 控制弹出层显示/隐藏的状态
selectedOptions: [], // 选中的复选框项
- selectedNames:[],//显示检察人员
- // 用于存放复选框选择的结果
- result: [],
- // 用于存放输入框的值
- newPassword: '',
- arr:[
+ selectedNames: [], //显示检察人员
+ // 用于存放复选框选择的结果
+ result: [],
+ // 用于存放输入框的值
+ newPassword: '',
+ uploadImageList: [],
+ imageId: 1,
+ arr: [
// {value:"1",name:'小王'},
// {value:"2",name:'李四'},
// {value:"3",name:'张三'}
],
- arr1:[
+ arr1: [
// {value:"1",name:'1.车间一些软件设备出现生锈断裂情况严重'},
// {value:"2",name:'2.还有部分货运车辆已过年检。'},
],
@@ -223,61 +77,77 @@ Page({
})
this.data.qqMapWX = new QQMapWX({
key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ'
- })
- this.reverseLocation()
- // this.ToaddRecord()
- this.getList()
+ })
+ this.reverseLocation()
+ // this.ToaddRecord()
+ this.getList()
+ },
+
+ submitBiao() {
+ console.log("122131")
+ const currentDate = new Date();
+ addRecord({
+ companyId: this.data.companyId,
+ checkTime: currentDate,
+ checkPersonsIdList: this.data.checkPersonsIdList,
+ checkResultFlag: this.data.checkResultFlag,
+ reviewTime: this.data.reviewTime,
+ hiddenDangeList: this.data.hiddenDangeList,
+ attachmentUrls: [{
+ fileName: '文件'
+ }, {
+ attachmentUrl: 'http://tmp/2JqHQVjACkEA00497265d7c287d505d1c20123e0470c.png'
+ }],
+ remark: '123'
+ }).then(({
+ data
+ }) => {
+ console.log('data', data)
+ });
+
},
-
-submitBiao(){
- console.log("122131")
- const currentDate = new Date();
- addRecord({
- companyId: this.data.companyId,
- checkTime:currentDate,
- checkPersonsIdList: this.data.checkPersonsIdList,
- checkResultFlag: this.data.checkResultFlag,
- reviewTime:this.data.reviewTime,
- hazardDesc:[{hazardStatus:2},{hazardDesc:this.data.hazardDesc}],
- attachmentUrls:[{fileName:'文件'},{attachmentUrl:'http://tmp/2JqHQVjACkEA00497265d7c287d505d1c20123e0470c.png'}],
- remark:'123'
-}).then(({data}) => {
- console.log('data',data)
-});
-
-},
getList() {
securityCheckk({
- pageNo: this.data.pageNo,
- pageSize: this.data.pageSize,
- }).then(({data}) => {
+ pageNo: this.data.pageNo,
+ pageSize: this.data.pageSize,
+ }).then(({
+ data
+ }) => {
// console.log("123131",data.list)
- this.setData({
- marsi: data.list,
- total: data.total
- })
- this.setData({
- 'fmData.AllnamesArray': data.list.map(item => ({ id: item.id, name: item.name })),
- 'fmData.namesArray': data.list.map(item => (item.name)),
-
- 'fmData.checkPersons': data.list.map((item, index) => ({ value: index, name: item.checkPersons })),
- });
- // console.log("123131", this.data.fmData.namesArray.map(item => item.name));
+ this.setData({
+ marsi: data.list,
+ total: data.total
+ })
+ this.setData({
+ 'fmData.AllnamesArray': data.list.map(item => ({
+ id: item.id,
+ name: item.name
+ })),
+ 'fmData.namesArray': data.list.map(item => (item.name)),
+
+ 'fmData.checkPersons': data.list.map((item, index) => ({
+ value: index,
+ name: item.checkPersons
+ })),
+ });
+ // console.log("123131", this.data.fmData.namesArray.map(item => item.name));
});
inspectionStaff({
- orgId: App.globalData.user.agencyId,
- orgType:'agency',
- pageNo:1,
- pageSize:100
- }).then(({data}) => {
- this.setData({
- arr: data.staffList
- })
- });
+ orgId: App.globalData.user.agencyId,
+ orgType: 'agency',
+ pageNo: 1,
+ pageSize: 100
+ }).then(({
+ data
+ }) => {
+ this.setData({
+ arr: data.staffList
+ })
+ });
///
-
-},
+
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
@@ -300,30 +170,29 @@ submitBiao(){
/**
* 生命周期函数--监听页面卸载
*/
- onUnload() {
- },
+ onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
- onPullDownRefresh() {
- },
+ onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
- onReachBottom() {
- },
+ onReachBottom() {},
/**
* 用户点击右上角分享
*/
- onShareAppMessage() {
- },
+ onShareAppMessage() {},
onChange(event) {
- console.log(event)
+ console.log("111", event)
this.setData({
- result: event.detail
+ result: event.detail
});
+
// event.detail 为当前输入的值
- console.log(this.data.selectedOptions);
+ console.log(this.data.result);
+ console.log(this.data.hiddenDangeList);
+
},
afterRead(event) {
const {
@@ -353,41 +222,46 @@ submitBiao(){
},
});
},
-
+
showPopup() {
- this.setData({ showPopup: true }); // 点击按钮显示弹出层
+ this.setData({
+ showPopup: true
+ }); // 点击按钮显示弹出层
},
onClose() {
- this.setData({ showPopup: false }); // 关闭弹出层
+ this.setData({
+ showPopup: false
+ }); // 关闭弹出层
},
onChange1(event) {
console.log(event)
this.setData({
- selectedOptions: event.detail
+ selectedOptions: event.detail
});
console.log(this.data.selectedOptions)
- },confirmSelection() {
+ },
+ confirmSelection() {
// 点击确定按钮后触发,处理选中的复选框项
console.log("选中的项:", this.data.selectedOptions);
const selectedName = this.data.selectedOptions;
this.setData({
- showPopup: false,
- selectedNames: selectedName
- });
+ showPopup: false,
+ selectedNames: selectedName
+ });
const matchedStaffIds = [];
this.data.arr.forEach(item => {
- if (selectedName.includes(item.name)) {
- matchedStaffIds.push(item.staffId);
- }
+ if (selectedName.includes(item.name)) {
+ matchedStaffIds.push(item.staffId);
+ }
});
this.setData({
checkPersonsIdList: matchedStaffIds
});
// 关闭弹出层
-},
- changeNewPassword(e){
+ },
+ changeNewPassword(e) {
console.log("执行了")
this.setData({
newPassword: e.detail.value
@@ -395,117 +269,286 @@ submitBiao(){
console.log(this.data.newPassword)
},
addAnother() {
- // // 获取输入框的值
- // const newPassword = this.data.newPassword;
- // // 将值添加到arr数组中
- // const arr = this.data.arr.concat(newPassword);
- // // 更新数据
- // this.setData({
- // arr: arr,
- // // 清空输入框的值
- // newPassword: ''
- // });
let newValue = this.data.arr1.length + 1; // 根据数组长度确定新值
- let newArr = this.data.arr1.concat({ value: newValue.toString(), name: this.data.newPassword });
+ let newArr = this.data.arr1.concat({
+ value: newValue.toString(),
+ name: this.data.newPassword
+ });
this.setData({
arr1: newArr,
newPassword: '', // 清空输入框的值
});
- console.log('添加后的数组:', this.data.arr1);
- },
-pickerChange: function(e) {
- // 更新当前选中的索引
- console.log(e.detail.value),
-
-
- this.setData({
- gridName: this.data.array[e.detail.value]
- });
- this.data.checkResultFlag = e.detail.value
- console.log(this.data.gridName)
- // 在这里可以根据选择的值进行相应的逻辑处理
-},
-pickerChange1: function(e) {
- // 更新当前选中的索引
- console.log(e.detail.value),
- this.setData({
- getData: e.detail.value
+ const nameArray = this.data.arr1.map(item => item.name);
+ console.log("111",nameArray)
+ nameArray.forEach(value => {
+ console.log( "qqq")
+ // 创建一个新的对象,设置 hazardDesc 属性为当前值
+ this.data.newObj = {
+ hazardStatus: '0', // 如果需要同时设置 hazardStatus 属性,可以在这里进行设置
+ hazardDesc: value
+ };
+ console.log( this.data.newObj)
+ // 将新对象添加到 hiddenDangeList 数组中
+ console.log(this.data.hiddenDangeList)
});
- this.data.reviewTime = e.detail.value
- console.log(this.data.getData)
- // 在这里可以根据选择的值进行相应的逻辑处理
-},
-pickerChange2: function(e) {
- // 更新当前选中的索引
- this.setData({
- gridNName: this.data.fmData.namesArray[e.detail.value]
- });
- this.data.addRecord = this.data.fmData.AllnamesArray[e.detail.value].id
-},
-bindRemarkInput(e){
- this.setData({
- remarks: e.detail.value
- });
- console.log(this.data.remarks)
-},
-chooseImage() {
- wx.chooseMedia({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- console.log(res)
- const tempFilePaths = res.tempFilePaths;
- // 将选定的图片显示在页面上
- this.setData({
- imageUrl: tempFilePaths[0]
- });
- console.log(this.data.imageUrl)
- }
- })
- },
-//跳转地图选点
-toughGetLocation() {
- // this.getLocation(false);
- wx.chooseLocation({
- success: res => {
- console.log('resadddres', res)
- const {
- fmData
- } = this.data;
+ this.data.hiddenDangeList.push(this.data.newObj);
+ console.log(this.data.hiddenDangeList)
+ },
+ pickerChange: function (e) {
+ // 更新当前选中的索引
+ console.log(e.detail.value),
this.setData({
- fmData: {
- ...fmData,
- address: res.address,
- longitude: res.longitude,
- latitude: res.latitude
- },
- addressContent: res.address
+ gridName: this.data.array[e.detail.value]
});
- console.log(this.data.fmData);
+ this.data.checkResultFlag = e.detail.value
+ console.log(this.data.gridName)
+ // 在这里可以根据选择的值进行相应的逻辑处理
+ },
+ pickerChange1: function (e) {
+ // 更新当前选中的索引
+ console.log(e.detail.value),
+ this.setData({
+ getData: e.detail.value
+ });
+ this.data.reviewTime = e.detail.value
+ console.log(this.data.getData)
+ // 在这里可以根据选择的值进行相应的逻辑处理
+ },
+ pickerChange2: function (e) {
+ // 更新当前选中的索引
+ this.setData({
+ gridNName: this.data.fmData.namesArray[e.detail.value]
+ });
+ this.data.addRecord = this.data.fmData.AllnamesArray[e.detail.value].id
+ },
+ bindRemarkInput(e) {
+ this.setData({
+ remarks: e.detail.value
+ });
+ console.log(this.data.remarks)
+ },
+ chooseImage() {
+ if (this.data.uploadImageList.length > 3) {
+ wx.showToast({
+ title: "最多上传3张照片",
+ icon: "none"
+ })
+ return
}
- })
-},
-//
-reverseLocation() {
- const _this = this
- this.data.qqMapWX.reverseGeocoder({
- success(res) {
- console.log(res);
+ const _this = this
+ $wuxActionSheet().showSheet({
+ buttons: [{
+ text: '拍照'
+ },
+ {
+ text: '从相册中获取',
+ openType: null,
+ },
+ ],
+ className: 'dialog-class',
+ buttonClicked(index) {
+ if (index === 0) {
+ wx.chooseMedia({
+ count: 1,
+ sizeType: ['original', 'compressed'],
+ sourceType: ['camera'],
+ success(res) {
+ console.log(res);
+ let deleteLength = _this.data.uploadImageList.length
+ const uploadImageList = [..._this.data.uploadImageList]
+ if (res.tempFiles[0].size <= 5 * 1024 * 1024) {
+ uploadImageList.push({
+ uploaded: false,
+ ossUrl: {
+ url:res.tempFiles[0].tempFilePath
+ },
+ imgUrl: res.tempFiles[0].tempFilePath,
+ imageId: ++_this.data.imageId,
+ type: res.tempFiles[0].tempFilePath.substr(res.tempFiles[0].tempFilePath.length - 3, 3),
+ format: "image",
+ name: 'wximage'
+ })
+ } else {
+ _this.showToast('图片上限5M,请压缩后重试~')
+ return false
+ }
_this.setData({
- addressContent:res.result.address,
- 'fmData.address': res.result.address,
- 'fmData.longitude':res.result.location.lng,
- 'fmData.latitude':res.result.location.lat,
+ uploadImageList
})
- },
- fail(err) {
- console.debug(err)
- }
+ wx.uploadFile({
+ url: `${config.BASEURL()}oss/file/uploadvariedfile`,
+ filePath: res.tempFiles[0].tempFilePath,
+ name: 'file',
+ header: {
+ 'Content-type': 'application/json;charset=UTF-8',
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success(fileRes) {
+ if (!JSON.parse(fileRes.data).data) {
+ _this.showToast('图片上传失败,请重试~')
+ // 删除
+ const index = _this.data.uploadImageList.findIndex(item => item.imageId === _this.data.imageId)
+ if (index > -1) {
+ _this.data.uploadImageList.splice(index, 1)
+ _this.setData({
+ uploadImageList: _this.data.uploadImageList
+ })
+ }
+ } else {
+ uploadImageList[uploadImageList.length - 1].uploaded = true
+ uploadImageList[uploadImageList.length - 1].ossUrl = JSON.parse(fileRes.data).data
+ _this.setData({
+ uploadImageList
+ })
+ }
+ },
+ fail(fileRes) {
+ _this.setData({
+ uploadImageList: []
+ })
+ _this.showToast('图片上传失败,请重试~')
+ }
+ })
+ }
+ })
+ } else if (index === 1) {
+ wx.chooseMedia({
+ count: 1,
+ type: 'image',
+ sourceType: ['album'],
+ success(res) {
+ console.log(res, '图片上传的res');
+ let deleteLength = _this.data.uploadImageList.length
+ const uploadImageList = []
+ const endIndex = _this.data.uploadImageList.length
+ res.tempFiles.forEach((item, index) => {
+ if (item.size <= 5 * 1024 * 1024) {
+ uploadImageList.push({
+ uploaded: false,
+ ossUrl: {
+ url: item.tempFilePath
+ },
+ imgUrl: item.tempFilePath,
+ imageId: ++_this.data.imageId,
+ format: "image",
+ type: item.tempFilePath.substr(item.tempFilePath.length - 3, 3),
+ originFileName: 'image' + index + 1
+ })
+ } else {
+ _this.showToast('图片上限5M,请压缩后重试~')
+ }
+ })
+ _this.setData({
+ uploadImageList: [..._this.data.uploadImageList, ...uploadImageList]
+ })
+ uploadImageList.forEach((item, index) => {
+ return (function (index) {
+ wx.uploadFile({
+ url: `${config.BASEURL()}oss/file/uploadvariedfile`,
+ filePath: res.tempFiles[index].tempFilePath,
+ name: 'file',
+ header: {
+ 'Content-type': 'application/json;charset=UTF-8',
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success(fileRes) {
+ if (!JSON.parse(fileRes.data).data) {
+ _this.showToast('图片上传失败,请重试~')
+ _this.data.uploadImageList.splice(deleteLength, _this.data.uploadImageList.length - deleteLength)
+ _this.setData({
+ uploadImageList: _this.data.uploadImageList
+ })
+ } else {
+ uploadImageList[index].uploaded = true
+ uploadImageList[index].ossUrl = JSON.parse(fileRes.data).data
+ _this.data.uploadImageList = _this.data.uploadImageList.slice(0, endIndex)
+ _this.setData({
+ uploadImageList: [..._this.data.uploadImageList, ...uploadImageList]
+ })
+ }
+ },
+ fail(fileRes) {
+ _this.setData({
+ uploadImageList: []
+ })
+ _this.showToast('图片上传失败,请重试~')
+ }
+ })
+ })(index)
+ })
+ }
+ })
+ }
+ return true
+ },
+ cancelText: '取消',
+ cancel() {},
+ destructiveButtonClicked() {},
+ })
+ // wx.chooseMedia({
+ // count: 1,
+ // sizeType: ['original', 'compressed'],
+ // sourceType: ['album', 'camera'],
+ // success(res) {
+ // console.log(res)
+ // const tempFilePaths = res.tempFilePaths;
+ // // 将选定的图片显示在页面上
+ // this.setData({
+ // imageUrl: tempFilePaths[0]
+ // });
+ // console.log(this.data.imageUrl)
+ // }
+ // })
+ },
+ // 删除选中的图片
+ deleteImage(e) {
+ const index = this.data.uploadImageList.findIndex(item => item.imageId === e.currentTarget.dataset.imageid)
+ if (index > -1) {
+ this.data.uploadImageList.splice(index, 1)
+ this.setData({
+ uploadImageList: this.data.uploadImageList
})
- },
-})
-
-
-
+ }
+ },
+ //跳转地图选点
+ toughGetLocation() {
+ // this.getLocation(false);
+ wx.chooseLocation({
+ success: res => {
+ console.log('resadddres', res)
+ const {
+ fmData
+ } = this.data;
+ this.setData({
+ fmData: {
+ ...fmData,
+ address: res.address,
+ longitude: res.longitude,
+ latitude: res.latitude
+ },
+ addressContent: res.address
+ });
+ console.log(this.data.fmData);
+ }
+ })
+ },
+ //
+ reverseLocation() {
+ const _this = this
+ this.data.qqMapWX.reverseGeocoder({
+ success(res) {
+ console.log(res);
+ _this.setData({
+ addressContent: res.result.address,
+ 'fmData.address': res.result.address,
+ 'fmData.longitude': res.result.location.lng,
+ 'fmData.latitude': res.result.location.lat,
+ })
+ },
+ fail(err) {
+ console.debug(err)
+ }
+ })
+ },
+})
\ No newline at end of file
diff --git a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml
index ff10194..ef614b6 100644
--- a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml
+++ b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml
@@ -1,99 +1,4 @@
-
-
-
-
+
附件
备注
diff --git a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxss b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxss
index 4217d2c..e1940a3 100644
--- a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxss
+++ b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxss
@@ -509,6 +509,9 @@ page {
margin-left: 50rpx;
margin-bottom: 20rpx;
}
+.group{
+ margin-top: 20rpx;
+}
.input1{
width: 650rpx;
height: 90rpx;
diff --git a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js
index d611bdc..a7c13b5 100644
--- a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js
+++ b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js
@@ -1,4 +1,6 @@
-import { $wuxActionSheet } from '../../../../../components/dist/index'
+import {
+ $wuxActionSheet
+} from '../../../../../components/dist/index'
const QQMapWX = require('../../../../../utils/qqmap-wx-jssdk')
const config = require('../../../../../utils/config')
const app = getApp()
@@ -8,1532 +10,1612 @@ import api from "../../../../../utils/api"
var timer;
Page({
- /**
- * 页面的初始数据
- */
- data: {
- optionsId:'',
- defaultMeasureNames:{label:'categoryName',value:'categoryCode',children:'childCateList'},
- fmData: {
- gridId: '',
- attachmentList:[],//图片
- voiceList:[],
- latitude:"",
- longitude:"",
- resiId:"",
- happenTime:"",
- content:"",//内容
- address:"",//地址
- },
- minDate: '2018-01-01 00:00:00',
-
- tabVal:"0",
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ optionsId: '',
+ defaultMeasureNames: {
+ label: 'categoryName',
+ value: 'categoryCode',
+ children: 'childCateList'
+ },
+ fmData: {
+ gridId: '',
+ attachmentList: [], //图片
+ voiceList: [],
+ latitude: "",
+ longitude: "",
+ resiId: "",
+ happenTime: "",
+ content: "", //内容
+ address: "", //地址
+ },
+ minDate: '2018-01-01 00:00:00',
- uploadImageList: [],//图片上传的数组
- streetList: [], // 街道
- imageId: 1,
- addressContent: '',
+ tabVal: "0",
+ uploadImageList: [], //图片上传的数组
+ streetList: [], // 街道
+ imageId: 1,
+ addressContent: '',
- overDuration: 600000,
- duration: 0,
- url: '',
- hasStop: false,
- hasStart: false, // 录音开始 暂停
- isStart: false, // 是否开启录音
- recordingTime: '00:00',
- recordingLength: 0,
- setInter: null,
- showRecord: false, // 是否显示录音sheet
- uploadRecord: {
- uploaded: true,
- url: ""
- },
- totalTime: "00:00", // 录音时长
- submitDisabled: false,
+ overDuration: 600000,
+ duration: 0,
+ url: '',
+ hasStop: false,
+ hasStart: false, // 录音开始 暂停
+ isStart: false, // 是否开启录音
+ recordingTime: '00:00',
+ recordingLength: 0,
+ setInter: null,
+ showRecord: false, // 是否显示录音sheet
+ uploadRecord: {
+ uploaded: true,
+ url: ""
+ },
+ totalTime: "00:00", // 录音时长
+ submitDisabled: false,
- // 时间组件
- visibleTime: false,
+ // 时间组件
+ visibleTime: false,
- angencyList: [],//组织下拉数据
- angencyId:"",
- totalMax: 0,
- stepValue: 0,
- hasPlay: false,
- playUrl: "",
+ angencyList: [], //组织下拉数据
+ angencyId: "",
+ totalMax: 0,
+ stepValue: 0,
+ hasPlay: false,
+ playUrl: "",
- // defaultFieldNames: { label: 'agencyName', value: 'agencyId', children: 'subAgencyList' },
- angencyVisible: false,
+ // defaultFieldNames: { label: 'agencyName', value: 'agencyId', children: 'subAgencyList' },
+ angencyVisible: false,
- measureList:[],
- measureValue:'',
- measureVisible:false,
+ measureList: [],
+ measureValue: '',
+ measureVisible: false,
- reportUserName:'',
- reportUserMobile:'',
+ reportUserName: '',
+ reportUserMobile: '',
- showWantServiceTimeTime:'',
+ showWantServiceTimeTime: '',
- reportTypeList:[],//上报类型
- reportTypeVisible:false
- },
+ reportTypeList: [], //上报类型
+ reportTypeVisible: false
+ },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- angencyId:app.globalData.user.agencyId,
- reportUserName:app.globalData.user.realName,
- reportUserMobile:app.globalData.user.phone,
- })
- this.getAgencygridtree()
- this.getDemandoption()
- this.getDictList()
- if(options.id){
- if(options.type === '0'){
- this.getIcEventOldDetail(options.id)
- }else{
- this.getDemandDetail(options.id)
- }
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+ this.setData({
+ angencyId: app.globalData.user.agencyId,
+ reportUserName: app.globalData.user.realName,
+ reportUserMobile: app.globalData.user.phone,
+ })
+ this.getAgencygridtree()
+ this.getDemandoption()
+ this.getDictList()
+ if (options.id) {
+ if (options.type === '0') {
+ this.getIcEventOldDetail(options.id)
+ } else {
+ this.getDemandDetail(options.id)
+ }
+ this.setData({
+ tabVal: options.type || 0,
+ optionsId: options.id
+ })
+ return
+ }
+ this.data.qqMapWX = new QQMapWX({
+ key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ'
+ })
+ // this.getLocation().then(() => {
+ // })
+ this.reverseLocation()
+ },
+ getDemandDetail(id) {
+ let parm = {
+ demandRecId: id
+ }
+ api.getDemandDetail(parm).then(res => {
+ console.log(res);
+ this.setData({
+ 'fmData.content': res.data.content,
+ // 'fmData.voiceList':res.data.voiceList,
+ 'fmData.gridId': res.data.gridId,
+ 'fmData.demandUserId': res.data.reportUserId,
+ 'fmData.categoryCode': res.data.categoryCode,
+ 'fmData.reportType': res.data.reportType,
+ 'fmData.happenTime': res.data.reportTime,
+ 'fmData.wantServiceTime': res.data.wantServiceTime,
+ 'fmData.resiId': res.data.icResiUserId,
+ categoryName: res.data.parentCategoryName + res.data.firstCategoryName,
+ agencyName: res.data.gridName,
+ reportTypeName: res.data.reportTypeName,
+ resiName: res.data.demandUserName,
+ resiMobile: res.data.demandUserMobile,
+ showTime: res.data.reportTime,
+ showWantServiceTimeTime: res.data.wantServiceTime,
+ // uploadImageList:res.data.imageList.map(item=>({ossUrl:{url:item},uploaded:true})),
+ // uploadRecord:res.data.voiceList[0],
+ // totalTime:this.format(res.data.voiceList[0].duration)
+ })
+ this.downLoadAudio()
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ getIcEventOldDetail(id) {
+ let parm = {
+ icEventId: id
+ }
+ api.getIcEventOld(parm).then(res => {
+ console.log(res);
+ this.setData({
+ 'fmData.content': res.data.eventContent,
+ 'fmData.voiceList': res.data.voiceList || [],
+ 'fmData.gridId': res.data.gridId,
+ 'fmData.happenTime': res.data.happenTime,
+ 'fmData.address': res.data.address,
+ 'fmData.resiId': res.data.reportUserId,
+ 'fmData.longitude': res.data.longitude,
+ 'fmData.latitude': res.data.latitude,
+ agencyName: res.data.gridName,
+ showTime: res.data.happenTime,
+ addressContent: res.data.address,
+ resiName: res.data.name,
+ resiMobile: res.data.mobile,
+ uploadImageList: res.data.imageList && res.data.imageList.length > 0 ? res.data.imageList.map(item => ({
+ ossUrl: {
+ url: item
+ },
+ uploaded: true
+ })) : [],
+ uploadRecord: res.data.voiceList && res.data.voiceList.length > 0 ? res.data.voiceList[0] : null,
+ totalTime: this.format(res.data.voiceList && res.data.voiceList.length > 0 ? res.data.voiceList[0].duration : 0)
+ })
+ if (this.data.uploadRecord) {
+ this.downLoadAudio()
+ }
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ update() {
+ this.submitPersonalInfo()
+ },
+ updateMeasure() {
+ this.setData({
+ submitDisabled: true
+ })
+ let {
+ categoryCode,
+ content,
+ happenTime,
+ resiId,
+ gridId,
+ attachmentList,
+ voiceList,
+ wantServiceTime,
+ parentCode,
+ reportType
+ } = this.data.fmData
+ const parm = {
+ categoryCode,
+ content,
+ reportUserName: this.data.reportUserName,
+ reportTime: happenTime,
+ reportUserMobile: this.data.reportUserMobile,
+ demandUserId: resiId,
+ gridId,
+ reportType,
+ // attachments:[...attachmentList,...voiceList],
+ wantServiceTime,
+ parentCode: parentCode,
+ demandRecId: this.data.optionsId
+ }
+ api.updateMeasure(parm).then(res => {
+ if (res.code === 0) {
+ wx.showModal({
+ title: '提示',
+ content: `提交成功`,
+ confirmText: '确认',
+ showCancel: false,
+ success: res => {
this.setData({
- tabVal:options.type || 0,
- optionsId:options.id
+ submitDisabled: false,
+ uploadImageList: [],
+ uploadRecord: {
+ uploaded: true,
+ url: ""
+ },
+ agencyName: '',
+ showTime: '',
+ resiName: '',
+ resiMobile: '',
+ 'fmData.gridId': '',
+ 'fmData.attachmentList': [], //图片
+ 'fmData.voiceList': [],
+ 'fmData.latitude': "",
+ 'fmData.longitude': "",
+ 'fmData.resiId': "",
+ 'fmData.happenTime': "",
+ 'fmData.content': "", //内容
+ 'fmData.wantServiceTime': "",
+ 'fmData.reportType': ''
})
- return
- }
- this.data.qqMapWX = new QQMapWX({
- key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ'
- })
- // this.getLocation().then(() => {
- // })
- this.reverseLocation()
- },
- getDemandDetail(id){
- let parm = {
- demandRecId:id
- }
- api.getDemandDetail(parm).then(res=>{
- console.log(res);
- this.setData({
- 'fmData.content':res.data.content,
- // 'fmData.voiceList':res.data.voiceList,
- 'fmData.gridId':res.data.gridId,
- 'fmData.demandUserId':res.data.reportUserId,
- 'fmData.categoryCode':res.data.categoryCode,
- 'fmData.reportType':res.data.reportType,
- 'fmData.happenTime':res.data.reportTime,
- 'fmData.wantServiceTime':res.data.wantServiceTime,
- 'fmData.resiId':res.data.icResiUserId,
- categoryName:res.data.parentCategoryName + res.data.firstCategoryName ,
- agencyName:res.data.gridName,
- reportTypeName:res.data.reportTypeName,
- resiName:res.data.demandUserName,
- resiMobile:res.data.demandUserMobile,
- showTime:res.data.reportTime,
- showWantServiceTimeTime:res.data.wantServiceTime,
- // uploadImageList:res.data.imageList.map(item=>({ossUrl:{url:item},uploaded:true})),
- // uploadRecord:res.data.voiceList[0],
- // totalTime:this.format(res.data.voiceList[0].duration)
+ wx.navigateBack({
+ delta: 1
})
- this.downLoadAudio()
- }).catch(err=>{
- console.log(err);
+ }
})
- },
- getIcEventOldDetail(id){
- let parm = {
- icEventId:id
- }
- api.getIcEventOld(parm).then(res=>{
- console.log(res);
- this.setData({
- 'fmData.content':res.data.eventContent,
- 'fmData.voiceList':res.data.voiceList||[],
- 'fmData.gridId':res.data.gridId,
- 'fmData.happenTime':res.data.happenTime,
- 'fmData.address':res.data.address,
- 'fmData.resiId':res.data.reportUserId,
- 'fmData.longitude':res.data.longitude,
- 'fmData.latitude':res.data.latitude,
- agencyName:res.data.gridName,
- showTime:res.data.happenTime,
- addressContent:res.data.address,
- resiName:res.data.name,
- resiMobile:res.data.mobile,
- uploadImageList:res.data.imageList&&res.data.imageList.length>0?res.data.imageList.map(item=>({ossUrl:{url:item},uploaded:true})):[],
- uploadRecord:res.data.voiceList&& res.data.voiceList.length>0?res.data.voiceList[0]:null,
- totalTime:this.format(res.data.voiceList&&res.data.voiceList.length>0?res.data.voiceList[0].duration:0)
- })
- if(this.data.uploadRecord){
- this.downLoadAudio()
- }
- }).catch(err=>{
- console.log(err);
+ wx.removeStorageSync('resiDetail')
+ } else {
+ console.log('提交失败');
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
})
- },
- update(){
- this.submitPersonalInfo()
- },
- updateMeasure(){
this.setData({
- submitDisabled: true
+ submitDisabled: false
})
- let {categoryCode,content,happenTime,resiId,gridId,attachmentList,voiceList,wantServiceTime,parentCode,reportType} = this.data.fmData
- const parm ={
- categoryCode,
- content,
- reportUserName:this.data.reportUserName,
- reportTime:happenTime,
- reportUserMobile:this.data.reportUserMobile,
- demandUserId:resiId,
- gridId,
- reportType,
- // attachments:[...attachmentList,...voiceList],
- wantServiceTime,
- parentCode:parentCode,
- demandRecId:this.data.optionsId
- }
- api.updateMeasure(parm).then(res=>{
- if (res.code === 0) {
- wx.showModal({
- title: '提示',
- content: `提交成功`,
- confirmText: '确认',
- showCancel: false,
- success: res => {
- this.setData({
- submitDisabled: false,
- uploadImageList: [],
- uploadRecord: {
- uploaded: true,
- url: ""
- },
- agencyName:'',
- showTime:'',
- resiName:'',
- resiMobile:'',
- 'fmData.gridId':'',
- 'fmData.attachmentList':[],//图片
- 'fmData.voiceList':[],
- 'fmData.latitude':"",
- 'fmData.longitude':"",
- 'fmData.resiId':"",
- 'fmData.happenTime':"",
- 'fmData.content':"",//内容
- 'fmData.wantServiceTime':"",
- 'fmData.reportType':''
- })
- wx.navigateBack({
- delta:1
- })
- }
- })
- wx.removeStorageSync('resiDetail')
- } else {
- console.log('提交失败');
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- submitDisabled: false
- })
- }
- }).catch(err=>{
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
+ }
+ }).catch(err => {
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
+ })
+ this.setData({
+ submitDisabled: false
+ })
+ })
+ setTimeout(function () {
+ wx.hideLoading()
+ }, 1000)
+ },
+ updateEvent() {
+ wx.showLoading({
+ title: '提交中...',
+ mask: true
+ })
+ this.setData({
+ submitDisabled: true
+ })
+ const parm = this.data.fmData
+ parm.icEventId = this.data.optionsId
+ console.log(parm, '事件更新');
+ api.updateEvent(parm).then(res => {
+ console.log(res);
+ if (res.code === 0) {
+ wx.showModal({
+ title: '提示',
+ content: `修改成功`,
+ confirmText: '确认',
+ showCancel: false,
+ success: res => {
this.setData({
- submitDisabled: false
+ submitDisabled: false,
+ uploadImageList: [],
+ uploadRecord: {
+ uploaded: true,
+ url: ""
+ },
+ agencyName: '',
+ showTime: '',
+ resiName: '',
+ resiMobile: '',
+ 'fmData.gridId': '',
+ 'fmData.attachmentList': [], //图片
+ 'fmData.voiceList': [],
+ 'fmData.latitude': "",
+ 'fmData.longitude': "",
+ 'fmData.resiId': "",
+ 'fmData.happenTime': "",
+ 'fmData.content': "", //内容
+ 'fmData.wantServiceTime': "",
+ 'fmData.reportType': ''
+ })
+ wx.navigateBack({
+ delta: 1
})
+ }
})
- setTimeout(function(){
- wx.hideLoading()
- },1000)
- },
- updateEvent(){
- wx.showLoading({
- title: '提交中...',
- mask: true
+ wx.removeStorageSync('resiDetail')
+ } else {
+ console.log('提交失败');
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
})
this.setData({
- submitDisabled: true
- })
- const parm = this.data.fmData
- parm.icEventId = this.data.optionsId
- console.log(parm,'事件更新');
- api.updateEvent(parm).then(res => {
- console.log(res);
- if (res.code === 0) {
- wx.showModal({
- title: '提示',
- content: `修改成功`,
- confirmText: '确认',
- showCancel: false,
- success: res => {
- this.setData({
- submitDisabled: false,
- uploadImageList: [],
- uploadRecord: {
- uploaded: true,
- url: ""
- },
- agencyName:'',
- showTime:'',
- resiName:'',
- resiMobile:'',
- 'fmData.gridId':'',
- 'fmData.attachmentList':[],//图片
- 'fmData.voiceList':[],
- 'fmData.latitude':"",
- 'fmData.longitude':"",
- 'fmData.resiId':"",
- 'fmData.happenTime':"",
- 'fmData.content':"",//内容
- 'fmData.wantServiceTime':"",
- 'fmData.reportType':''
- })
- wx.navigateBack({
- delta:1
- })
- }
- })
- wx.removeStorageSync('resiDetail')
- } else {
- console.log('提交失败');
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- submitDisabled: false
- })
- }
- }).catch(err => {
- console.log(err)
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- submitDisabled: false
- })
+ submitDisabled: false
})
- setTimeout(function(){
- wx.hideLoading()
- },1000)
- },
- delete(){
- let that = this
- wx.showModal({
- title: '提示',
- content: '确定要删除这条数据吗,删除后将无法找回,请谨慎操作',
- success (res) {
- if (res.confirm) {
- console.log(that.data.tabVal);
- if(that.data.tabVal == 0){
- that.icEventOldDelete()
- }else{
- that.userDemandCance()
- }
- } else if (res.cancel) {
- }
- }
- })
- },
- icEventOldDelete(){
- api.icEventOldDelete([this.data.optionsId]).then(res=>{
- if(res.code === 0){
- wx.showToast({
- title: '删除成功',
- icon:'none',
- success(){
- setTimeout(()=>{
- wx.navigateBack({
- delta: 1
- })
- },3000)
- }
- })
+ }
+ }).catch(err => {
+ console.log(err)
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
+ })
+ this.setData({
+ submitDisabled: false
+ })
+ })
+ setTimeout(function () {
+ wx.hideLoading()
+ }, 1000)
+ },
+ delete() {
+ let that = this
+ wx.showModal({
+ title: '提示',
+ content: '确定要删除这条数据吗,删除后将无法找回,请谨慎操作',
+ success(res) {
+ if (res.confirm) {
+ console.log(that.data.tabVal);
+ if (that.data.tabVal == 0) {
+ that.icEventOldDelete()
+ } else {
+ that.userDemandCance()
}
- }).catch(err=>{
- console.log(err);
- })
- },
- userDemandCance(){
- let parm ={
- demandRecId:this.data.optionsId
- }
- api.userDemandCance(parm).then(res=>{
- if(res.code === 0){
- wx.showToast({
- title: '删除成功',
- icon:'none'
+ } else if (res.cancel) {}
+ }
+ })
+ },
+ icEventOldDelete() {
+ api.icEventOldDelete([this.data.optionsId]).then(res => {
+ if (res.code === 0) {
+ wx.showToast({
+ title: '删除成功',
+ icon: 'none',
+ success() {
+ setTimeout(() => {
+ wx.navigateBack({
+ delta: 1
})
+ }, 3000)
}
- }).catch(err=>{
- console.log(err);
- })
- },
-
- // 组织树
- getAgencygridtree() {
- let parm ={
- agencyId:this.data.angencyId,
- purpose:'query'
- }
- api.getGridoptionDict(parm).then(res => {
- console.log(res);
- this.setData({
- angencyList: res.data
- })
- }).catch(err => {
- console.log(err);
- })
- },
- getDictList(){
- api.getDictList('user_demand_report_type').then(res=>{
- console.log(res);
- this.setData({
- reportTypeList:res.data
- })
- }).catch(err=>{
- console.log(err);
- })
- },
- getDemandoption(){
- api.getDemandoption().then(res=>{
- console.log(res);
- this.setData({
- measureList:res.data
- })
- }).catch(err=>{
- console.log(err);
- })
- },
- // 触底函数
- onReachBottom() {
- if (this.projectlist) {
- this.projectlist.onReachBottom()
- }
- },
- //跳转地图选点
- toughGetLocation() {
- // this.getLocation(false);
- wx.chooseLocation({
- success: res => {
- console.log('resadddres', res)
- const { fmData } = this.data;
- this.setData({
- fmData: {
- ...fmData,
- address:res.address,
- longitude: res.longitude,
- latitude: res.latitude
- },
- addressContent:res.address
- });
- console.log(this.data.fmData);
- }
})
- },
- showRecordSheet() {
- this.setData({
- showRecord: true,
- recorderData: {},
- recordingTime: "0:00",
- uploadRecord: {
- uploaded: true,
- url: ""
- }
+ }
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ userDemandCance() {
+ let parm = {
+ demandRecId: this.data.optionsId
+ }
+ api.userDemandCance(parm).then(res => {
+ if (res.code === 0) {
+ wx.showToast({
+ title: '删除成功',
+ icon: 'none'
})
- },
- // 获取经纬度
- // getLocation() {
- // return new Promise((resolve, reject) => {
- // const _this = this
- // wx.getLocation({
- // type: 'gcj02',
- // success(res) {
- // if (res.latitude && res.longitude) {
- // _this.setData({
- // 'personalInfo.issueLatitude': res.latitude,
- // 'personalInfo.issueLongitude': res.longitude
- // })
- // resolve(true)
- // }
- // },
- // fail(err) {
- // reject(err)
- // }
- // })
- // })
- // },
+ }
+ }).catch(err => {
+ console.log(err);
+ })
+ },
-
- // 提交按钮
- submitPersonalInfo() {
- const imagesList = []
- if (this.data.uploadImageList.length > 0) {
- const isUploadDown = this.data.uploadImageList.some(item => !item.uploaded)
- if (isUploadDown) {
- wx.showToast({
- title: '请等待图片上传完成',
- icon: 'none',
- duration: 1000
- })
- return false
- }
- }
- console.log(this.data.uploadImageList);
- if (this.data.uploadImageList.length > 0) {
- this.data.uploadImageList.forEach(item => {
- imagesList.push({format:item.format ||'png',originFileName:item.originFileName ||'',url:item.ossUrl.url,type:item.type})
- })
- }
+ // 组织树
+ getAgencygridtree() {
+ let parm = {
+ agencyId: this.data.angencyId,
+ purpose: 'query'
+ }
+ api.getGridoptionDict(parm).then(res => {
+ console.log(res);
+ this.setData({
+ angencyList: res.data
+ })
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ getDictList() {
+ api.getDictList('user_demand_report_type').then(res => {
+ console.log(res);
+ this.setData({
+ reportTypeList: res.data
+ })
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ getDemandoption() {
+ api.getDemandoption().then(res => {
+ console.log(res);
+ this.setData({
+ measureList: res.data
+ })
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 触底函数
+ onReachBottom() {
+ if (this.projectlist) {
+ this.projectlist.onReachBottom()
+ }
+ },
+ //跳转地图选点
+ toughGetLocation() {
+ // this.getLocation(false);
+ wx.chooseLocation({
+ success: res => {
+ console.log('resadddres', res)
+ const {
+ fmData
+ } = this.data;
this.setData({
- 'fmData.attachmentList': imagesList,
- })
- console.log(this.data.tabVal);
- if(!this.data.fmData.gridId){
- this.showToast('所属组织不能为空')
- return
- }
- if(this.data.tabVal === '1'){
- if(!this.data.fmData.content){
- this.showToast('需求描述不能为空')
- return
- }
- if(!this.data.fmData.content){
- this.showToast('需求描述不能为空')
- return
- }
- if(!this.data.fmData.categoryCode){
- this.showToast('需求类型不能为空')
- return
- }
- if(!this.data.fmData.reportType){
- this.showToast('上报类型不能为空')
- return
- }
- if(!this.data.fmData.happenTime){
- this.showToast('需求时间不能为空')
- return
- }
- if(!this.data.fmData.wantServiceTime){
- this.showToast('服务时间不能为空')
- return
- }
- if(!this.data.fmData.resiId){
- this.showToast('需求人不能为空')
- return
- }
- if(!this.data.resiMobile){
- this.showToast('需求人电话不能为空')
- return
- }
- }else{
- if(!this.data.fmData.content){
- this.showToast('事件描述不能为空')
- return
- }
- if(!this.data.fmData.happenTime){
- this.showToast('发生时间不能为空')
- return
- }
- if(!this.data.fmData.address){
- this.showToast('发生地点不能为空')
- return
- }
- if(!this.data.fmData.resiId){
- this.showToast('联系人不能为空')
- return
- }
- if(!this.data.resiMobile){
- this.showToast('联系人电话不能为空')
- return
- }
- }
- if (this.data.tabVal === '1') {
- this.data.optionsId ? this.updateMeasure() : this.submitMeasure();
- } else {
- this.data.optionsId ? this.updateEvent() : this.submitEven();
- }
- },
+ fmData: {
+ ...fmData,
+ address: res.address,
+ longitude: res.longitude,
+ latitude: res.latitude
+ },
+ addressContent: res.address
+ });
+ console.log(this.data.fmData);
+ }
+ })
+ },
+ showRecordSheet() {
+ this.setData({
+ showRecord: true,
+ recorderData: {},
+ recordingTime: "0:00",
+ uploadRecord: {
+ uploaded: true,
+ url: ""
+ }
+ })
+ },
+ // 获取经纬度
+ // getLocation() {
+ // return new Promise((resolve, reject) => {
+ // const _this = this
+ // wx.getLocation({
+ // type: 'gcj02',
+ // success(res) {
+ // if (res.latitude && res.longitude) {
+ // _this.setData({
+ // 'personalInfo.issueLatitude': res.latitude,
+ // 'personalInfo.issueLongitude': res.longitude
+ // })
+ // resolve(true)
+ // }
+ // },
+ // fail(err) {
+ // reject(err)
+ // }
+ // })
+ // })
+ // },
+
- // 事件提交接口
- submitEven() {
- wx.showLoading({
- title: '提交中...',
- mask: true
+ // 提交按钮
+ submitPersonalInfo() {
+ const imagesList = []
+ if (this.data.uploadImageList.length > 0) {
+ const isUploadDown = this.data.uploadImageList.some(item => !item.uploaded)
+ if (isUploadDown) {
+ wx.showToast({
+ title: '请等待图片上传完成',
+ icon: 'none',
+ duration: 1000
})
- this.setData({
- submitDisabled: true
+ return false
+ }
+ }
+ console.log(this.data.uploadImageList);
+ if (this.data.uploadImageList.length > 0) {
+ this.data.uploadImageList.forEach(item => {
+ imagesList.push({
+ format: item.format || 'png',
+ originFileName: item.originFileName || '',
+ url: item.ossUrl.url,
+ type: item.type
})
- const parm = this.data.fmData
- console.log(parm,'事件');
- api.addEvent(parm).then(res => {
- console.log(res);
- if (res.code === 0) {
- wx.showModal({
- title: '提示',
- content: `提交成功`,
- confirmText: '确认',
- showCancel: false,
- success: res => {
- this.setData({
- submitDisabled: false,
- uploadImageList: [],
- uploadRecord: {
- uploaded: true,
- url: ""
- },
- agencyName:'',
- showTime:'',
- resiName:'',
- resiMobile:'',
- 'fmData.gridId':'',
- 'fmData.attachmentList':[],//图片
- 'fmData.voiceList':[],
- 'fmData.latitude':"",
- 'fmData.longitude':"",
- 'fmData.resiId':"",
- 'fmData.happenTime':"",
- 'fmData.content':"",//内容
- 'fmData.wantServiceTime':"",
- 'fmData.reportType':''
- })
- wx.switchTab({
- url: '/pages/work/work',
- })
- }
- })
- wx.removeStorageSync('resiDetail')
- } else {
- console.log('提交失败');
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- submitDisabled: false
- })
- }
- }).catch(err => {
- console.log(err)
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
+ })
+ }
+ this.setData({
+ 'fmData.attachmentList': imagesList,
+ })
+ console.log(this.data.tabVal);
+ if (!this.data.fmData.gridId) {
+ this.showToast('所属组织不能为空')
+ return
+ }
+ if (this.data.tabVal === '1') {
+ if (!this.data.fmData.content) {
+ this.showToast('需求描述不能为空')
+ return
+ }
+ if (!this.data.fmData.content) {
+ this.showToast('需求描述不能为空')
+ return
+ }
+ if (!this.data.fmData.categoryCode) {
+ this.showToast('需求类型不能为空')
+ return
+ }
+ if (!this.data.fmData.reportType) {
+ this.showToast('上报类型不能为空')
+ return
+ }
+ if (!this.data.fmData.happenTime) {
+ this.showToast('需求时间不能为空')
+ return
+ }
+ if (!this.data.fmData.wantServiceTime) {
+ this.showToast('服务时间不能为空')
+ return
+ }
+ if (!this.data.fmData.resiId) {
+ this.showToast('需求人不能为空')
+ return
+ }
+ if (!this.data.resiMobile) {
+ this.showToast('需求人电话不能为空')
+ return
+ }
+ } else {
+ if (!this.data.fmData.content) {
+ this.showToast('事件描述不能为空')
+ return
+ }
+ if (!this.data.fmData.happenTime) {
+ this.showToast('发生时间不能为空')
+ return
+ }
+ if (!this.data.fmData.address) {
+ this.showToast('发生地点不能为空')
+ return
+ }
+ if (!this.data.fmData.resiId) {
+ this.showToast('联系人不能为空')
+ return
+ }
+ if (!this.data.resiMobile) {
+ this.showToast('联系人电话不能为空')
+ return
+ }
+ }
+ if (this.data.tabVal === '1') {
+ this.data.optionsId ? this.updateMeasure() : this.submitMeasure();
+ } else {
+ this.data.optionsId ? this.updateEvent() : this.submitEven();
+ }
+ },
+
+ // 事件提交接口
+ submitEven() {
+ wx.showLoading({
+ title: '提交中...',
+ mask: true
+ })
+ this.setData({
+ submitDisabled: true
+ })
+ const parm = this.data.fmData
+ console.log(parm, '事件');
+ api.addEvent(parm).then(res => {
+ console.log(res);
+ if (res.code === 0) {
+ wx.showModal({
+ title: '提示',
+ content: `提交成功`,
+ confirmText: '确认',
+ showCancel: false,
+ success: res => {
this.setData({
- submitDisabled: false
+ submitDisabled: false,
+ uploadImageList: [],
+ uploadRecord: {
+ uploaded: true,
+ url: ""
+ },
+ agencyName: '',
+ showTime: '',
+ resiName: '',
+ resiMobile: '',
+ 'fmData.gridId': '',
+ 'fmData.attachmentList': [], //图片
+ 'fmData.voiceList': [],
+ 'fmData.latitude': "",
+ 'fmData.longitude': "",
+ 'fmData.resiId': "",
+ 'fmData.happenTime': "",
+ 'fmData.content': "", //内容
+ 'fmData.wantServiceTime': "",
+ 'fmData.reportType': ''
})
+ wx.switchTab({
+ url: '/pages/work/work',
+ })
+ }
})
- setTimeout(function(){
- wx.hideLoading()
- },1000)
- },
- // 个性服务提交
- submitMeasure(){
- wx.showLoading({
- title: '提交中...',
- mask: true
+ wx.removeStorageSync('resiDetail')
+ } else {
+ console.log('提交失败');
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
})
this.setData({
- submitDisabled: true
+ submitDisabled: false
})
- let {categoryCode,content,happenTime,resiId,gridId,attachmentList,voiceList,wantServiceTime,parentCode,reportType} = this.data.fmData
- const parm ={
- categoryCode,
- content,
- reportUserName:this.data.reportUserName,
- reportTime:happenTime,
- reportUserMobile:this.data.reportUserMobile,
- demandUserId:resiId,
- gridId,
- reportType,
- // attachments:[...attachmentList],
- voices:[...voiceList],
- wantServiceTime,
- parentCode:parentCode
- }
- console.log(parm,'服务');
- api.addMeasure(parm).then(res => {
- console.log(res);
- if (res.data) {
- wx.showModal({
- title: '提示',
- content: `提交成功`,
- confirmText: '确认',
- showCancel: false,
- success: res => {
- this.setData({
- submitDisabled: false,
- uploadImageList: [],
- uploadRecord: {
- uploaded: true,
- url: ""
- },
- agencyName:'',
- showTime:'',
- resiName:'',
- resiMobile:'',
- categoryName:'',
- reportTypeName:'',
- showWantServiceTimeTime:'',
- 'fmData.gridId':'',
- 'fmData.attachmentList':[],//图片
- 'fmData.voiceList':[],
- 'fmData.latitude':"",
- 'fmData.longitude':"",
- 'fmData.resiId':"",
- 'fmData.happenTime':"",
- 'fmData.content':"",//内容
- 'fmData.wantServiceTime':"",
- 'fmData.reportType':''
- })
- wx.switchTab({
- url: '/pages/work/work',
- })
- }
- })
- wx.removeStorageSync('resiDetail')
- } else {
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- submitDisabled: false
- })
- }
- }).catch(err => {
- console.log(err)
- wx.showToast({
- title: "提交失败,请重试~",
- icon: "none",
- duration: 1500
- })
+ }
+ }).catch(err => {
+ console.log(err)
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
+ })
+ this.setData({
+ submitDisabled: false
+ })
+ })
+ setTimeout(function () {
+ wx.hideLoading()
+ }, 1000)
+ },
+ // 个性服务提交
+ submitMeasure() {
+ wx.showLoading({
+ title: '提交中...',
+ mask: true
+ })
+ this.setData({
+ submitDisabled: true
+ })
+ let {
+ categoryCode,
+ content,
+ happenTime,
+ resiId,
+ gridId,
+ attachmentList,
+ voiceList,
+ wantServiceTime,
+ parentCode,
+ reportType
+ } = this.data.fmData
+ const parm = {
+ categoryCode,
+ content,
+ reportUserName: this.data.reportUserName,
+ reportTime: happenTime,
+ reportUserMobile: this.data.reportUserMobile,
+ demandUserId: resiId,
+ gridId,
+ reportType,
+ // attachments:[...attachmentList],
+ voices: [...voiceList],
+ wantServiceTime,
+ parentCode: parentCode
+ }
+ console.log(parm, '服务');
+ api.addMeasure(parm).then(res => {
+ console.log(res);
+ if (res.data) {
+ wx.showModal({
+ title: '提示',
+ content: `提交成功`,
+ confirmText: '确认',
+ showCancel: false,
+ success: res => {
this.setData({
- submitDisabled: false
+ submitDisabled: false,
+ uploadImageList: [],
+ uploadRecord: {
+ uploaded: true,
+ url: ""
+ },
+ agencyName: '',
+ showTime: '',
+ resiName: '',
+ resiMobile: '',
+ categoryName: '',
+ reportTypeName: '',
+ showWantServiceTimeTime: '',
+ 'fmData.gridId': '',
+ 'fmData.attachmentList': [], //图片
+ 'fmData.voiceList': [],
+ 'fmData.latitude': "",
+ 'fmData.longitude': "",
+ 'fmData.resiId': "",
+ 'fmData.happenTime': "",
+ 'fmData.content': "", //内容
+ 'fmData.wantServiceTime': "",
+ 'fmData.reportType': ''
})
+ wx.switchTab({
+ url: '/pages/work/work',
+ })
+ }
})
- setTimeout(function(){
- wx.hideLoading()
- },1000)
- },
- // 双向绑定 内容输入框
- bindTextareaInput(e) {
- this.setData({
- 'fmData.content': e.detail.value
+ wx.removeStorageSync('resiDetail')
+ } else {
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
})
- console.log(this.data.fmData);
- },
-
- // 点击空白,隐藏sheet
- onHideSheet() {
this.setData({
- showRecord: false
+ submitDisabled: false
})
- },
+ }
+ }).catch(err => {
+ console.log(err)
+ wx.showToast({
+ title: "提交失败,请重试~",
+ icon: "none",
+ duration: 1500
+ })
+ this.setData({
+ submitDisabled: false
+ })
+ })
+ setTimeout(function () {
+ wx.hideLoading()
+ }, 1000)
+ },
+ // 双向绑定 内容输入框
+ bindTextareaInput(e) {
+ this.setData({
+ 'fmData.content': e.detail.value
+ })
+ console.log(this.data.fmData);
+ },
- // 选择图片 上传弹窗 - 上传图片方式 - 选择图片 - 上传图片 - 回调赋值
- chooseImage() {
- if (this.data.uploadImageList.length > 3) {
- wx.showToast({
- title: "最多上传3张照片",
- icon: "none"
- })
- return
- }
- const _this = this
- $wuxActionSheet().showSheet({
- buttons: [
- { text: '拍照' },
- { text: '从相册中获取',openType:null, },
- ],
- className: 'dialog-class',
- buttonClicked(index) {
- if (index === 0) {
- wx.chooseMedia({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['camera'],
- success(res) {
- console.log(res);
- let deleteLength = _this.data.uploadImageList.length
- const uploadImageList = [..._this.data.uploadImageList]
- if (res.tempFiles[0].size <= 5 * 1024 * 1024) {
- uploadImageList.push({
- uploaded: false,
- ossUrl: {url:res.tempFiles[0].tempFilePath},
- imgUrl: res.tempFiles[0].tempFilePath,
- imageId: ++_this.data.imageId,
- type:res.tempFiles[0].tempFilePath.substr(res.tempFiles[0].tempFilePath.length -3,3),
- format:"image",
- name:'wximage'
- })
- } else {
- _this.showToast('图片上限5M,请压缩后重试~')
- return false
- }
- _this.setData({
- uploadImageList
- })
- wx.uploadFile({
- url: `${config.BASEURL()}oss/file/uploadvariedfile`,
- filePath: res.tempFiles[0].tempFilePath,
- name: 'file',
- header: {
- 'Content-type': 'application/json;charset=UTF-8',
- 'Authorization': wx.getStorageSync('token')
- },
- success(fileRes) {
- if (!JSON.parse(fileRes.data).data) {
- _this.showToast('图片上传失败,请重试~')
- // 删除
- const index = _this.data.uploadImageList.findIndex(item => item.imageId === _this.data.imageId)
- if (index > -1) {
- _this.data.uploadImageList.splice(index, 1)
- _this.setData({
- uploadImageList: _this.data.uploadImageList
- })
- }
- } else {
- uploadImageList[uploadImageList.length - 1].uploaded = true
- uploadImageList[uploadImageList.length - 1].ossUrl = JSON.parse(fileRes.data).data
- _this.setData({
- uploadImageList
- })
- }
- },
- fail(fileRes) {
- _this.setData({
- uploadImageList: []
- })
- _this.showToast('图片上传失败,请重试~')
- }
- })
- }
- })
- } else if (index === 1) {
- wx.chooseMedia({
- count: 1,
- type:'image',
- sourceType: ['album'],
- success(res) {
- console.log(res,'图片上传的res');
- let deleteLength = _this.data.uploadImageList.length
- const uploadImageList = []
- const endIndex = _this.data.uploadImageList.length
- res.tempFiles.forEach((item,index) => {
- if (item.size <= 5 * 1024 * 1024) {
- uploadImageList.push({
- uploaded: false,
- ossUrl: {url:item.tempFilePath},
- imgUrl: item.tempFilePath,
- imageId: ++_this.data.imageId,
- format:"image",
- type:item.tempFilePath.substr(item.tempFilePath.length -3,3),
- originFileName:'image' + index + 1
- })
- } else {
- _this.showToast('图片上限5M,请压缩后重试~')
- }
- })
- _this.setData({
- uploadImageList: [..._this.data.uploadImageList, ...uploadImageList]
- })
- uploadImageList.forEach((item, index) => {
- return (function (index) {
- wx.uploadFile({
- url: `${config.BASEURL()}oss/file/uploadvariedfile`,
- filePath: res.tempFiles[index].tempFilePath,
- name: 'file',
- header: {
- 'Content-type': 'application/json;charset=UTF-8',
- 'Authorization': wx.getStorageSync('token')
- },
- success(fileRes) {
- if (!JSON.parse(fileRes.data).data) {
- _this.showToast('图片上传失败,请重试~')
- _this.data.uploadImageList.splice(deleteLength, _this.data.uploadImageList.length - deleteLength)
- _this.setData({
- uploadImageList: _this.data.uploadImageList
- })
- } else {
- uploadImageList[index].uploaded = true
- uploadImageList[index].ossUrl = JSON.parse(fileRes.data).data
- _this.data.uploadImageList = _this.data.uploadImageList.slice(0, endIndex)
- _this.setData({
- uploadImageList: [..._this.data.uploadImageList, ...uploadImageList]
- })
- }
- },
- fail(fileRes) {
- _this.setData({
- uploadImageList: []
- })
- _this.showToast('图片上传失败,请重试~')
- }
- })
- })(index)
- })
- }
+ // 点击空白,隐藏sheet
+ onHideSheet() {
+ this.setData({
+ showRecord: false
+ })
+ },
+
+ // 选择图片 上传弹窗 - 上传图片方式 - 选择图片 - 上传图片 - 回调赋值
+ chooseImage() {
+ if (this.data.uploadImageList.length > 3) {
+ wx.showToast({
+ title: "最多上传3张照片",
+ icon: "none"
+ })
+ return
+ }
+ const _this = this
+ $wuxActionSheet().showSheet({
+ buttons: [{
+ text: '拍照'
+ },
+ {
+ text: '从相册中获取',
+ openType: null,
+ },
+ ],
+ className: 'dialog-class',
+ buttonClicked(index) {
+ if (index === 0) {
+ wx.chooseMedia({
+ count: 1,
+ sizeType: ['original', 'compressed'],
+ sourceType: ['camera'],
+ success(res) {
+ console.log(res);
+ let deleteLength = _this.data.uploadImageList.length
+ const uploadImageList = [..._this.data.uploadImageList]
+ if (res.tempFiles[0].size <= 5 * 1024 * 1024) {
+ uploadImageList.push({
+ uploaded: false,
+ ossUrl: {
+ url: res.tempFiles[0].tempFilePath
+ },
+ imgUrl: res.tempFiles[0].tempFilePath,
+ imageId: ++_this.data.imageId,
+ type: res.tempFiles[0].tempFilePath.substr(res.tempFiles[0].tempFilePath.length - 3, 3),
+ format: "image",
+ name: 'wximage'
+ })
+ } else {
+ _this.showToast('图片上限5M,请压缩后重试~')
+ return false
+ }
+ _this.setData({
+ uploadImageList
+ })
+ wx.uploadFile({
+ url: `${config.BASEURL()}oss/file/uploadvariedfile`,
+ filePath: res.tempFiles[0].tempFilePath,
+ name: 'file',
+ header: {
+ 'Content-type': 'application/json;charset=UTF-8',
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success(fileRes) {
+ if (!JSON.parse(fileRes.data).data) {
+ _this.showToast('图片上传失败,请重试~')
+ // 删除
+ const index = _this.data.uploadImageList.findIndex(item => item.imageId === _this.data.imageId)
+ if (index > -1) {
+ _this.data.uploadImageList.splice(index, 1)
+ _this.setData({
+ uploadImageList: _this.data.uploadImageList
+ })
+ }
+ } else {
+ uploadImageList[uploadImageList.length - 1].uploaded = true
+ uploadImageList[uploadImageList.length - 1].ossUrl = JSON.parse(fileRes.data).data
+ _this.setData({
+ uploadImageList
})
+ }
+ },
+ fail(fileRes) {
+ _this.setData({
+ uploadImageList: []
+ })
+ _this.showToast('图片上传失败,请重试~')
}
- return true
- },
- cancelText: '取消',
- cancel() { },
- destructiveButtonClicked() { },
- })
- },
- // 删除选中的图片
- deleteImage(e) {
- const index = this.data.uploadImageList.findIndex(item => item.imageId === e.currentTarget.dataset.imageid)
- if (index > -1) {
- this.data.uploadImageList.splice(index, 1)
- this.setData({
- uploadImageList: this.data.uploadImageList
- })
+ })
+ }
+ })
+ } else if (index === 1) {
+ wx.chooseMedia({
+ count: 1,
+ type: 'image',
+ sourceType: ['album'],
+ success(res) {
+ console.log(res, '图片上传的res');
+ let deleteLength = _this.data.uploadImageList.length
+ const uploadImageList = []
+ const endIndex = _this.data.uploadImageList.length
+ res.tempFiles.forEach((item, index) => {
+ if (item.size <= 5 * 1024 * 1024) {
+ uploadImageList.push({
+ uploaded: false,
+ ossUrl: {
+ url: item.tempFilePath
+ },
+ imgUrl: item.tempFilePath,
+ imageId: ++_this.data.imageId,
+ format: "image",
+ type: item.tempFilePath.substr(item.tempFilePath.length - 3, 3),
+ originFileName: 'image' + index + 1
+ })
+ } else {
+ _this.showToast('图片上限5M,请压缩后重试~')
+ }
+ })
+ _this.setData({
+ uploadImageList: [..._this.data.uploadImageList, ...uploadImageList]
+ })
+ uploadImageList.forEach((item, index) => {
+ return (function (index) {
+ wx.uploadFile({
+ url: `${config.BASEURL()}oss/file/uploadvariedfile`,
+ filePath: res.tempFiles[index].tempFilePath,
+ name: 'file',
+ header: {
+ 'Content-type': 'application/json;charset=UTF-8',
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success(fileRes) {
+ if (!JSON.parse(fileRes.data).data) {
+ _this.showToast('图片上传失败,请重试~')
+ _this.data.uploadImageList.splice(deleteLength, _this.data.uploadImageList.length - deleteLength)
+ _this.setData({
+ uploadImageList: _this.data.uploadImageList
+ })
+ } else {
+ uploadImageList[index].uploaded = true
+ uploadImageList[index].ossUrl = JSON.parse(fileRes.data).data
+ _this.data.uploadImageList = _this.data.uploadImageList.slice(0, endIndex)
+ _this.setData({
+ uploadImageList: [..._this.data.uploadImageList, ...uploadImageList]
+ })
+ }
+ },
+ fail(fileRes) {
+ _this.setData({
+ uploadImageList: []
+ })
+ _this.showToast('图片上传失败,请重试~')
+ }
+ })
+ })(index)
+ })
+ }
+ })
}
- },
- // 代码简化,弹窗统一封装
- showToast(title) {
- wx.showToast({
- title: title,
- icon: 'none',
- duration: 2000
- })
- },
+ return true
+ },
+ cancelText: '取消',
+ cancel() {},
+ destructiveButtonClicked() {},
+ })
+ },
+ // 删除选中的图片
+ deleteImage(e) {
+ const index = this.data.uploadImageList.findIndex(item => item.imageId === e.currentTarget.dataset.imageid)
+ if (index > -1) {
+ this.data.uploadImageList.splice(index, 1)
+ this.setData({
+ uploadImageList: this.data.uploadImageList
+ })
+ }
+ },
+ // 代码简化,弹窗统一封装
+ showToast(title) {
+ wx.showToast({
+ title: title,
+ icon: 'none',
+ duration: 2000
+ })
+ },
- // 单选点击事件
- inputSyncPicker(e) {
- let {
- detail: { value },
- currentTarget: {
- dataset: { idKey, nameKey, listName, subname, subindex },
- },
- } = e;
- let item = this.data[listName][value];
- let { personalInfo } = this.data;
- if (subname && subindex !== undefined) {
- personalInfo[subname][subindex][idKey] = item.value;
- personalInfo[subname][subindex][nameKey] = item.label;
- } else {
- personalInfo[idKey] = item.value;
- personalInfo[nameKey] = item.label;
- }
+ // 单选点击事件
+ inputSyncPicker(e) {
+ let {
+ detail: {
+ value
+ },
+ currentTarget: {
+ dataset: {
+ idKey,
+ nameKey,
+ listName,
+ subname,
+ subindex
+ },
+ },
+ } = e;
+ let item = this.data[listName][value];
+ let {
+ personalInfo
+ } = this.data;
+ if (subname && subindex !== undefined) {
+ personalInfo[subname][subindex][idKey] = item.value;
+ personalInfo[subname][subindex][nameKey] = item.label;
+ } else {
+ personalInfo[idKey] = item.value;
+ personalInfo[nameKey] = item.label;
+ }
- this.setData({ personalInfo });
+ this.setData({
+ personalInfo
+ });
- this.dataHandle(listName)
+ this.dataHandle(listName)
- },
- dataHandle(listName) {
- if (listName == 'streetList') {
- this.setData({
- communityList: [],
- gridList: [],
- 'personalInfo.community': '', // 社区
- 'personalInfo.communityId': '', // 社区
-
- })
- } else if (listName == 'communityList') {
- this.setData({
- gridList: [],
- 'personalInfo.grid': '', // 网格
- 'personalInfo.gridId': '' // 网格
- })
- }
- if (this.data.personalInfo.streetId) { // 选择街道
- this.data.streetList.forEach((element, index) => {
- if (this.data.personalInfo.streetId == element.value) {
- this.setData({
- communityList: element.children
- })
- }
- });
+ },
+ dataHandle(listName) {
+ if (listName == 'streetList') {
+ this.setData({
+ communityList: [],
+ gridList: [],
+ 'personalInfo.community': '', // 社区
+ 'personalInfo.communityId': '', // 社区
+
+ })
+ } else if (listName == 'communityList') {
+ this.setData({
+ gridList: [],
+ 'personalInfo.grid': '', // 网格
+ 'personalInfo.gridId': '' // 网格
+ })
+ }
+ if (this.data.personalInfo.streetId) { // 选择街道
+ this.data.streetList.forEach((element, index) => {
+ if (this.data.personalInfo.streetId == element.value) {
+ this.setData({
+ communityList: element.children
+ })
}
- if (this.data.personalInfo.communityId) { // 选择社区
- this.data.communityList.forEach((element, index) => {
- if (this.data.personalInfo.communityId == element.value) {
- this.setData({
- gridList: element.children
- })
- }
- });
+ });
+ }
+ if (this.data.personalInfo.communityId) { // 选择社区
+ this.data.communityList.forEach((element, index) => {
+ if (this.data.personalInfo.communityId == element.value) {
+ this.setData({
+ gridList: element.children
+ })
}
- },
- // 逆地址解析
- reverseLocation() {
- const _this = this
- this.data.qqMapWX.reverseGeocoder({
- success(res) {
- console.log(res);
- _this.setData({
- addressContent:res.result.address,
- 'fmData.address': res.result.address,
- 'fmData.longitude':res.result.location.lng,
- 'fmData.latitude':res.result.location.lat,
- })
- },
- fail(err) {
- console.debug(err)
- }
+ });
+ }
+ },
+ // 逆地址解析
+ reverseLocation() {
+ const _this = this
+ this.data.qqMapWX.reverseGeocoder({
+ success(res) {
+ console.log(res);
+ _this.setData({
+ addressContent: res.result.address,
+ 'fmData.address': res.result.address,
+ 'fmData.longitude': res.result.location.lng,
+ 'fmData.latitude': res.result.location.lat,
})
- },
+ },
+ fail(err) {
+ console.debug(err)
+ }
+ })
+ },
- onConfirmDate(e) {
- this.setData({
- 'fmData.happenTime': e.detail.label + ':00',
- visibleTime: false,
- showTime:e.detail.label + ':00'
- })
- },
- onConfirmWantServiceTime(e){
- this.setData({
- 'fmData.wantServiceTime': e.detail.label + ':00',
- visibleTimeWantServiceTime: false,
- showWantServiceTimeTime:e.detail.label + ':00'
- })
- },
- //时间组件隐藏
- onCancel(e) {
- this.setData({
- visibleTime: false,
- visibleTimeWantServiceTime:false
- })
- },
- bindMobile(e){
- this.setData({
- resiMobile:e.detail.value
- })
- },
- getCurrentDateTime() {
- const date = new Date();
- const year = date.getFullYear();
- const month = (1 + date.getMonth()).toString().padStart(2, '0'); // Months are zero-based.
- const day = date.getDate().toString().padStart(2, '0');
- const hours = date.getHours().toString().padStart(2, '0');
- const minutes = date.getMinutes().toString().padStart(2, '0');
- const seconds = date.getSeconds().toString().padStart(2, '0');
- return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
- },
- showTimePicker(e) {
- this.setData({
- visibleTime: true,
- maxDate:this.getCurrentDateTime(),
- 'fmData.happenTime':this.getCurrentDateTime(),
- })
- },
- showTimePickerW(e) {
- this.setData({
- visibleTimeWantServiceTime: true,
- maxDate:this.getCurrentDateTime(),
- 'fmData.wantServiceTime':this.getCurrentDateTime(),
- })
- },
+ onConfirmDate(e) {
+ this.setData({
+ 'fmData.happenTime': e.detail.label + ':00',
+ visibleTime: false,
+ showTime: e.detail.label + ':00'
+ })
+ },
+ onConfirmWantServiceTime(e) {
+ this.setData({
+ 'fmData.wantServiceTime': e.detail.label + ':00',
+ visibleTimeWantServiceTime: false,
+ showWantServiceTimeTime: e.detail.label + ':00'
+ })
+ },
+ //时间组件隐藏
+ onCancel(e) {
+ this.setData({
+ visibleTime: false,
+ visibleTimeWantServiceTime: false
+ })
+ },
+ bindMobile(e) {
+ this.setData({
+ resiMobile: e.detail.value
+ })
+ },
+ getCurrentDateTime() {
+ const date = new Date();
+ const year = date.getFullYear();
+ const month = (1 + date.getMonth()).toString().padStart(2, '0'); // Months are zero-based.
+ const day = date.getDate().toString().padStart(2, '0');
+ const hours = date.getHours().toString().padStart(2, '0');
+ const minutes = date.getMinutes().toString().padStart(2, '0');
+ const seconds = date.getSeconds().toString().padStart(2, '0');
+ return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
+ },
+ showTimePicker(e) {
+ this.setData({
+ visibleTime: true,
+ maxDate: this.getCurrentDateTime(),
+ 'fmData.happenTime': this.getCurrentDateTime(),
+ })
+ },
+ showTimePickerW(e) {
+ this.setData({
+ visibleTimeWantServiceTime: true,
+ maxDate: this.getCurrentDateTime(),
+ 'fmData.wantServiceTime': this.getCurrentDateTime(),
+ })
+ },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
- },
+ },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- let resiDetail = wx.getStorageSync('resiDetail')
- if(resiDetail){
- this.setData({
- "fmData.resiId":resiDetail.resiId,
- resiName:resiDetail.resiName,
- resiMobile:resiDetail.resiMobile
- })
- }
- },
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
+ let resiDetail = wx.getStorageSync('resiDetail')
+ if (resiDetail) {
+ this.setData({
+ "fmData.resiId": resiDetail.resiId,
+ resiName: resiDetail.resiName,
+ resiMobile: resiDetail.resiMobile
+ })
+ }
+ },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- wx.removeStorageSync('resiDetail')
- },
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide() {
+ wx.removeStorageSync('resiDetail')
+ },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- wx.removeStorageSync('resiDetail')
- },
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload() {
+ wx.removeStorageSync('resiDetail')
+ },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh() {
- },
+ },
- /**
- * 用户点击右上角分享
- */
- // /page/user?id=123
- onShareAppMessage() {
-
- },
- handleRecordDel() {
- const { hasStop, isStart } = this.data
- console.log('hasStop---', this.data.hasStop)
- if (isStart && !hasStop) {
- recorderManager.stop()
- }
- if (!hasStop && isStart) recorderManager.stop();
- recorderManager.stop();
- clearInterval(timer)
- timer = null
- this.setData({
- recordingTime: '00:00',
- recordingLength: 0,
+ /**
+ * 用户点击右上角分享
+ */
+ // /page/user?id=123
+ onShareAppMessage() {
+
+ },
+ handleRecordDel() {
+ const {
+ hasStop,
+ isStart
+ } = this.data
+ console.log('hasStop---', this.data.hasStop)
+ if (isStart && !hasStop) {
+ recorderManager.stop()
+ }
+ if (!hasStop && isStart) recorderManager.stop();
+ recorderManager.stop();
+ clearInterval(timer)
+ timer = null
+ this.setData({
+ recordingTime: '00:00',
+ recordingLength: 0,
+ hasStart: false,
+ isStart: false,
+ hasStop: false,
+ url: '',
+ duration: 0
+ })
+ },
+ handleRecord() {
+ let {
+ hasStart
+ } = this.data
+ console.log(hasStart);
+ if (hasStart) this.recortPause()
+ else this.recortResume()
+ },
+ handleOpenRecord() {
+ this.setData({
+ isStart: true,
+ });
+ console.log('opppppp')
+ this.recordStart()
+ },
+ // 录音暂停
+ recortPause() {
+ recorderManager.pause();
+ this.setData({
+ hasStart: false
+ })
+ clearInterval(timer)
+ timer = null
+ },
+ // 录音继续
+ recortResume() {
+ this.recordingTimer()
+ recorderManager.resume();
+ this.setData({
+ hasStart: true
+ })
+
+ },
+ // 录音上传
+ uploadRecord(file, duration) {
+ wx.uploadFile({
+ url: `${config.BASEURL()}oss/file/uploadvoice`,
+ filePath: file,
+ name: "file",
+ header: {
+ "Content-type": "multipart/form-data",
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success: (fileRes) => {
+ wx.hideLoading()
+ console.log('ressss', fileRes)
+ if (!JSON.parse(fileRes.data).data) {
+ wx.showToast({
+ title: "录音上传失败,请重试~",
+ icon: "none",
+ duration: 1500
+ })
+ this.setData({
+ "uploadRecord.uploaded": true,
+ "uploadRecord.url": "",
+ totalTime: "",
+ showRecord: false,
hasStart: false,
isStart: false,
- hasStop: false,
- url: '',
- duration: 0
- })
- },
- handleRecord() {
- let { hasStart } = this.data
- console.log(hasStart);
- if (hasStart) this.recortPause()
- else this.recortResume()
- },
- handleOpenRecord() {
- this.setData({
- isStart: true,
- });
- console.log('opppppp')
- this.recordStart()
- },
- // 录音暂停
- recortPause() {
- recorderManager.pause();
- this.setData({
- hasStart: false
+ recordingTime: '00:00'
+ })
+ } else {
+ // let { recordingLength } = this.data
+ // if (duration - (recordingLength * 1000) > 1000 ) duration = recordingLength * 1000
+ let url = JSON.parse(fileRes.data).data.url
+ let fileName = Date.now() + Math.floor(Math.random() * 1000)
+ this.setData({
+ "uploadRecord.uploaded": true,
+ "uploadRecord.url": url,
+ 'fmData.voiceList': [{
+ url: url,
+ format: null,
+ type: 'mp3',
+ duration,
+ originFileName: fileName.toString()
+ }],
+ showRecord: false,
+ hasStart: false,
+ isStart: false,
+ recordingTime: '00:00',
+ })
+ this.downLoadAudio()
+ console.log(this.data.fmData.voiceList);
+ }
+ },
+ fail: (fileRes) => {
+ console.log(fileRes);
+ wx.showToast({
+ title: "录音上传失败,请重试~",
+ icon: "none",
+ duration: 1500
})
- clearInterval(timer)
- timer = null
- },
- // 录音继续
- recortResume() {
- this.recordingTimer()
- recorderManager.resume();
this.setData({
- hasStart: true
+ "uploadRecord.uploaded": true,
+ "uploadRecord.url": "",
+ totalTime: "",
})
+ }
+ })
+ },
+ // 录音开始
+ recordStart() {
+ this.setData({
+ hasStart: true,
+ });
+ const options = {
+ duration: this.data.overDuration,
+ format: 'mp3',
+ type: 'voice'
+ };
+ this.recordingTimer()
+ recorderManager.start(options);
+ recorderManager.onStart(res => {
+ console.log('recorder start', res);
+ });
+ recorderManager.onPause(res => {
+ console.log('onPause', res)
+ })
+ console.log(recorderManager);
+ recorderManager.onResume(res => {
+ console.log('onResume', res)
+ })
+ recorderManager.onStop((res) => {
+ console.log('recorder stop', res);
+ const {
+ tempFilePath,
+ duration
+ } = res;
+ this.setData({
+ hasStop: true,
+ url: tempFilePath,
+ duration
+ })
+ });
+ recorderManager.onFrameRecorded(res => {
+ console.log('onFrameRecorded', res)
+ })
+ recorderManager.onError((res) => {
+ console.log('recorder onError', res);
+ wx.showToast({
+ title: res.errMsg,
+ icon: 'none',
+ duration: 1500
+ })
+ });
+ },
+ // 录音暂停
+ recortPause() {
+ recorderManager.pause();
+ this.setData({
+ hasStart: false
+ })
+ clearInterval(timer)
+ timer = null
+ },
+ // 录音继续
+ recortResume() {
+ this.recordingTimer()
+ recorderManager.resume();
+ this.setData({
+ hasStart: true
+ })
- },
- // 录音上传
- uploadRecord(file, duration) {
- wx.uploadFile({
- url: `${config.BASEURL()}oss/file/uploadvoice`,
- filePath: file,
- name: "file",
- header: {
- "Content-type": "multipart/form-data",
- 'Authorization': wx.getStorageSync('token')
- },
- success: (fileRes) => {
- wx.hideLoading()
- console.log('ressss', fileRes)
- if (!JSON.parse(fileRes.data).data) {
- wx.showToast({
- title: "录音上传失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- "uploadRecord.uploaded": true,
- "uploadRecord.url": "",
- totalTime: "",
- showRecord: false,
- hasStart: false,
- isStart: false,
- recordingTime: '00:00'
- })
- } else {
- // let { recordingLength } = this.data
- // if (duration - (recordingLength * 1000) > 1000 ) duration = recordingLength * 1000
- let url = JSON.parse(fileRes.data).data.url
- let fileName = Date.now()+ Math.floor(Math.random() * 1000)
- this.setData({
- "uploadRecord.uploaded": true,
- "uploadRecord.url": url,
- 'fmData.voiceList':[{url:url,format:null,type:'mp3',duration,originFileName:fileName.toString()}],
- showRecord: false,
- hasStart: false,
- isStart: false,
- recordingTime: '00:00',
- })
- this.downLoadAudio()
- console.log(this.data.fmData.voiceList);
- }
- },
- fail: (fileRes) => {
- console.log(fileRes);
- wx.showToast({
- title: "录音上传失败,请重试~",
- icon: "none",
- duration: 1500
- })
- this.setData({
- "uploadRecord.uploaded": true,
- "uploadRecord.url": "",
- totalTime: "",
- })
- }
- })
- },
- // 录音开始
- recordStart() {
- this.setData({
- hasStart: true,
- });
- const options = {
- duration: this.data.overDuration,
- format: 'mp3',
- type: 'voice'
- };
- this.recordingTimer()
- recorderManager.start(options);
- recorderManager.onStart(res => {
- console.log('recorder start', res);
- });
- recorderManager.onPause(res => {
- console.log('onPause', res)
- })
- console.log(recorderManager);
- recorderManager.onResume(res => {
- console.log('onResume', res)
- })
- recorderManager.onStop((res) => {
- console.log('recorder stop', res);
- const { tempFilePath, duration } = res;
- this.setData({
- hasStop: true,
- url: tempFilePath,
- duration
- })
- });
- recorderManager.onFrameRecorded(res => {
- console.log('onFrameRecorded', res)
- })
- recorderManager.onError((res) => {
- console.log('recorder onError', res);
- wx.showToast({
- title: res.errMsg,
- icon: 'none',
- duration: 1500
- })
- });
- },
- // 录音暂停
- recortPause() {
- recorderManager.pause();
- this.setData({
- hasStart: false
- })
- clearInterval(timer)
- timer = null
- },
- // 录音继续
- recortResume() {
- this.recordingTimer()
- recorderManager.resume();
- this.setData({
- hasStart: true
- })
+ },
+ // 录音结束
+ recordStop() {
+ const {
+ url,
+ recordingLength,
+ hasStop
+ } = this.data
+ this.setData({
+ hasStart: false
+ })
+ wx.showLoading({
+ title: '录音上传中...'
+ })
- },
- // 录音结束
- recordStop() {
- const { url, recordingLength, hasStop } = this.data
+ console.log(url, recordingLength, hasStop)
+
+ if (hasStop) {
+ this.uploadRecord(url, 600000)
+ console.log('hasStop', hasStop)
+ } else {
+ console.log('hasStopeee', hasStop)
+ recorderManager.stop();
+ clearInterval(timer)
+ timer = null
+ recorderManager.onStop((res) => {
+ console.log('recorder stop1111', res);
+ const {
+ tempFilePath,
+ duration
+ } = res;
+ this.uploadRecord(tempFilePath, duration)
+ //
+ console.log(duration, '上传结束的语音时间');
this.setData({
- hasStart: false
+ recordingLength: 0,
+ totalTime: this.format(duration)
})
- wx.showLoading({
- title: '录音上传中...'
- })
-
- console.log(url, recordingLength, hasStop)
-
- if (hasStop) {
- this.uploadRecord(url, 600000)
- console.log('hasStop', hasStop)
- } else {
- console.log('hasStopeee', hasStop)
- recorderManager.stop();
- clearInterval(timer)
- timer = null
- recorderManager.onStop((res) => {
- console.log('recorder stop1111', res);
- const { tempFilePath, duration } = res;
- this.uploadRecord(tempFilePath, duration)
- //
- console.log(duration,'上传结束的语音时间');
- this.setData({
- recordingLength: 0,
- totalTime:this.format(duration)
- })
- });
- }
+ });
+ }
- },
+ },
- recordingTimer() {
+ recordingTimer() {
+ clearInterval(timer)
+ timer = null
+ timer = setInterval(() => {
+ let {
+ overDuration,
+ recordingLength
+ } = this.data
+ if (recordingLength * 1000 >= overDuration) {
+ wx.showToast({
+ title: '录音已超时,已停止录音',
+ icon: 'none',
+ duration: 1500
+ })
+ console.log('lllllllll超时了')
+ recorderManager.stop();
clearInterval(timer)
timer = null
- timer = setInterval(() => {
- let { overDuration, recordingLength } = this.data
- if (recordingLength * 1000 >= overDuration) {
- wx.showToast({
- title: '录音已超时,已停止录音',
- icon: 'none',
- duration: 1500
- })
- console.log('lllllllll超时了')
- recorderManager.stop();
- clearInterval(timer)
- timer = null
- this.setData({
- hasStart: false
- })
- return
- }
- let time = this.data.recordingLength + 1;
- this.setData({
- recordingLength: time,
- recordingTime: this.formatTime(time)
- });
- console.log('timer,还在执行',this.data.recordingLength)
- }, 1000);
- },
- formatTime(num) {
- let min = parseInt(num / 60)
- let second = num % 60
- min = min >= 10 ? min : '0' + min
- second = second >= 10 ? second : '0' + second
- return min + ':' + second
- },
- hancleCancle() {
- this.handleRecordDel()
- this.setData({
- showRecord: false
- })
- },
- hidePickerAngency() {
- this.setData({
- angencyVisible: false
- })
- },
- showPicker() {
- this.setData({
- angencyVisible: true
- })
- },
- onConfirmAngecy(e) {
- this.setData({
- agencyName: e.detail.label,
- 'fmData.gridId': e.detail.value[e.detail.value.length - 1],
- angencyVisible: false
- })
- },
- onConfirmReportType(e){
- console.log(e);
- this.setData({
- reportTypeName: e.detail.label,
- 'fmData.reportType': e.detail.value[0],
- reportTypeVisible: false
- })
- },
- hidePickerReportType(){
this.setData({
- reportTypeVisible: false
+ hasStart: false
})
- },
- // 播放逻辑
- initDuration() {
- var _a = this.data, duration = _a.duration;
- if (duration) {
- this.setData({
- totalMax: duration
- });
+ return
+ }
+ let time = this.data.recordingLength + 1;
+ this.setData({
+ recordingLength: time,
+ recordingTime: this.formatTime(time)
+ });
+ console.log('timer,还在执行', this.data.recordingLength)
+ }, 1000);
+ },
+ formatTime(num) {
+ let min = parseInt(num / 60)
+ let second = num % 60
+ min = min >= 10 ? min : '0' + min
+ second = second >= 10 ? second : '0' + second
+ return min + ':' + second
+ },
+ hancleCancle() {
+ this.handleRecordDel()
+ this.setData({
+ showRecord: false
+ })
+ },
+ hidePickerAngency() {
+ this.setData({
+ angencyVisible: false
+ })
+ },
+ showPicker() {
+ this.setData({
+ angencyVisible: true
+ })
+ },
+ onConfirmAngecy(e) {
+ this.setData({
+ agencyName: e.detail.label,
+ 'fmData.gridId': e.detail.value[e.detail.value.length - 1],
+ angencyVisible: false
+ })
+ },
+ onConfirmReportType(e) {
+ console.log(e);
+ this.setData({
+ reportTypeName: e.detail.label,
+ 'fmData.reportType': e.detail.value[0],
+ reportTypeVisible: false
+ })
+ },
+ hidePickerReportType() {
+ this.setData({
+ reportTypeVisible: false
+ })
+ },
+ // 播放逻辑
+ initDuration() {
+ var _a = this.data,
+ duration = _a.duration;
+ if (duration) {
+ this.setData({
+ totalMax: duration
+ });
+ }
+ console.log('totalMax', this.data.totalMax);
+ },
+ downLoadAudio() {
+ var _this = this;
+ wx.downloadFile({
+ url: this.data.uploadRecord.url,
+ success(res) {
+ console.log(res);
+ if (res.statusCode === 200) {
+ console.log('res2222222', res);
+ _this.setData({
+ playUrl: res.tempFilePath
+ });
+ _this.initAudio();
+ } else {
+ wx.showToast({
+ title: '音频加载失败',
+ icon: 'none',
+ duration: 1500
+ });
}
- console.log('totalMax', this.data.totalMax);
- },
- downLoadAudio() {
- var _this = this;
- wx.downloadFile({
- url: this.data.uploadRecord.url,
- success(res) {
- console.log(res);
- if (res.statusCode === 200) {
- console.log('res2222222', res);
- _this.setData({
- playUrl: res.tempFilePath
- });
- _this.initAudio();
- }
- else {
- wx.showToast({
- title: '音频加载失败',
- icon: 'none',
- duration: 1500
- });
- }
- },
- fail(err) {
- console.log(err);
- wx.showToast({
- title: '音频加载失败',
- icon: 'none',
- duration: 1500
- });
- }
- });
- },
- initAudio() {
- var _this = this;
- innerAudioContext.src = this.data.playUrl;
- innerAudioContext.autoplay = false;
- this.initDuration();
- console.log('ppppplllaaa', innerAudioContext);
- innerAudioContext.onCanplay(() => {
- console.log('初始化播放', innerAudioContext.duration);
- });
- innerAudioContext.onPlay(() => {
- console.log('开始播放', innerAudioContext.duration);
- });
- innerAudioContext.onTimeUpdate(() => {
- console.log("duration-onTimeUpdate", innerAudioContext.duration);
- console.log("currentTime", innerAudioContext.currentTime);
- if (innerAudioContext.duration) {
- _this.setData({
- totalMax: (innerAudioContext.duration * 1000),
- });
- }
- _this.setData({
- stepValue: (innerAudioContext.currentTime * 1000),
- });
- console.log('stepValue', _this.data.stepValue);
- console.log('totalTime', _this.data.totalTime);
- console.log('totalMax', _this.data.totalMax);
- });
- innerAudioContext.onEnded(function () {
- console.log("end");
- _this.setData({
- hasPlay: false
- });
- });
- innerAudioContext.onError((res) => {
- console.log("errMsg", res.errMsg);
- wx.showToast({
- title: res.errMsg,
- icon: 'none',
- duration: 1500
- });
- });
- },
- handlePlay() {
- var hasPlay = this.data.hasPlay;
- if (hasPlay)
- this.audioPause();
- else
- this.audioPlay();
- },
- audioPause() {
- innerAudioContext.pause();
- this.setData({
- hasPlay: false
+ },
+ fail(err) {
+ console.log(err);
+ wx.showToast({
+ title: '音频加载失败',
+ icon: 'none',
+ duration: 1500
});
- },
- audioPlay() {
- innerAudioContext.play();
- this.setData({
- hasPlay: true
+ }
+ });
+ },
+ initAudio() {
+ var _this = this;
+ innerAudioContext.src = this.data.playUrl;
+ innerAudioContext.autoplay = false;
+ this.initDuration();
+ console.log('ppppplllaaa', innerAudioContext);
+ innerAudioContext.onCanplay(() => {
+ console.log('初始化播放', innerAudioContext.duration);
+ });
+ innerAudioContext.onPlay(() => {
+ console.log('开始播放', innerAudioContext.duration);
+ });
+ innerAudioContext.onTimeUpdate(() => {
+ console.log("duration-onTimeUpdate", innerAudioContext.duration);
+ console.log("currentTime", innerAudioContext.currentTime);
+ if (innerAudioContext.duration) {
+ _this.setData({
+ totalMax: (innerAudioContext.duration * 1000),
});
- console.log('innerAudioContext', innerAudioContext);
- },
- // 需求分类
- onConfirmMeasure(e){
- console.log(e);
- this.setData({
- 'fmData.categoryCode':e.detail.selectedValue[1],
- 'fmData.parentCode':e.detail.selectedValue[0],
- categoryName:e.detail.label,
- measureVisible:false
- })
- },
- slideChange(e) {
- this.audioPause();
- var value = e.detail.value;
- console.log('slidechange', value);
- innerAudioContext.seek(value / 1000);
- this.setData({
- stepValue: value,
- });
- this.audioPlay();
- },
- handleSlideMove(e) {
- this.audioPause();
- },
- handleAudioDel() {
- innerAudioContext.stop();
- console.log('innerAudioContextdel', innerAudioContext);
-
- this.setData({
- totalTime:'00:00',
- 'fmData.voiceList':[]
- })
- },
+ }
+ _this.setData({
+ stepValue: (innerAudioContext.currentTime * 1000),
+ });
+ console.log('stepValue', _this.data.stepValue);
+ console.log('totalTime', _this.data.totalTime);
+ console.log('totalMax', _this.data.totalMax);
+ });
+ innerAudioContext.onEnded(function () {
+ console.log("end");
+ _this.setData({
+ hasPlay: false
+ });
+ });
+ innerAudioContext.onError((res) => {
+ console.log("errMsg", res.errMsg);
+ wx.showToast({
+ title: res.errMsg,
+ icon: 'none',
+ duration: 1500
+ });
+ });
+ },
+ handlePlay() {
+ var hasPlay = this.data.hasPlay;
+ if (hasPlay)
+ this.audioPause();
+ else
+ this.audioPlay();
+ },
+ audioPause() {
+ innerAudioContext.pause();
+ this.setData({
+ hasPlay: false
+ });
+ },
+ audioPlay() {
+ innerAudioContext.play();
+ this.setData({
+ hasPlay: true
+ });
+ console.log('innerAudioContext', innerAudioContext);
+ },
+ // 需求分类
+ onConfirmMeasure(e) {
+ console.log(e);
+ this.setData({
+ 'fmData.categoryCode': e.detail.selectedValue[1],
+ 'fmData.parentCode': e.detail.selectedValue[0],
+ categoryName: e.detail.label,
+ measureVisible: false
+ })
+ },
+ slideChange(e) {
+ this.audioPause();
+ var value = e.detail.value;
+ console.log('slidechange', value);
+ innerAudioContext.seek(value / 1000);
+ this.setData({
+ stepValue: value,
+ });
+ this.audioPlay();
+ },
+ handleSlideMove(e) {
+ this.audioPause();
+ },
+ handleAudioDel() {
+ innerAudioContext.stop();
+ console.log('innerAudioContextdel', innerAudioContext);
- showMeasurePicker(){
- this.setData({
- measureVisible:true
- })
- },
- showReportTypePicker(){
- this.setData({
- reportTypeVisible:true
- })
- },
- hidePickerMeasure(){
- this.setData({
- measureVisible:false
- })
- },
- handleChangeType(e){
- this.setData({
- tabVal:e.detail.value
- })
- },
- format(num) {
- let min = parseInt(num / 1000 / 60)
- let second = parseInt(num / 1000) % 60
- min = min >= 10 ? min : '0' + min
- second = second >= 10 ? second : '0' + second
- return min + ':' + second
- },
+ this.setData({
+ totalTime: '00:00',
+ 'fmData.voiceList': []
+ })
+ },
+
+ showMeasurePicker() {
+ this.setData({
+ measureVisible: true
+ })
+ },
+ showReportTypePicker() {
+ this.setData({
+ reportTypeVisible: true
+ })
+ },
+ hidePickerMeasure() {
+ this.setData({
+ measureVisible: false
+ })
+ },
+ handleChangeType(e) {
+ this.setData({
+ tabVal: e.detail.value
+ })
+ },
+ format(num) {
+ let min = parseInt(num / 1000 / 60)
+ let second = parseInt(num / 1000) % 60
+ min = min >= 10 ? min : '0' + min
+ second = second >= 10 ? second : '0' + second
+ return min + ':' + second
+ },
})
\ No newline at end of file