diff --git a/miniprogram/api/repair/repair.js b/miniprogram/api/repair/repair.js
index 3ae1f7b..042fff6 100644
--- a/miniprogram/api/repair/repair.js
+++ b/miniprogram/api/repair/repair.js
@@ -40,7 +40,7 @@ export function selectRoomListRq(data) {
// 保存工单
export function repairSaveRq(data) {
return request({
- url: '/repair/save',
+ url: '/app/repair/flow/start',
method: "post",
data
});
diff --git a/miniprogram/app.js b/miniprogram/app.js
index 6bebe4d..8770cdd 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -302,21 +302,4 @@ App({
}
})
},
- selfUploadFile(url) {
- let _this = this
- return new Promise((resolve, reject) => {
- wx.uploadFile({
- url: _this.DOMAIN_NAME + '/api/dfs/upload',
- filePath: url,
- name: 'file',
- formData: {},
- success: res => {
- resolve(JSON.parse(res.data));
- },
- fail: err => {
- reject(err);
- }
- })
- })
- },
})
\ No newline at end of file
diff --git a/miniprogram/pages/reportRepair/report/report.js b/miniprogram/pages/reportRepair/report/report.js
index 33b631f..3efccff 100644
--- a/miniprogram/pages/reportRepair/report/report.js
+++ b/miniprogram/pages/reportRepair/report/report.js
@@ -3,7 +3,9 @@ let app = getApp();
import Notify from '@vant/weapp/notify/notify';
import {
- selfFormatTimeYMDHMS
+ selfFormatTimeYMDHMS,
+ repairAttachUpload,
+ uploadVoice
} from "../../../utils/util.js"
import {
@@ -37,11 +39,9 @@ Page({
}, {
name: '三级',
}, ],
- failureDateShow: false, // 故障时间show
- failureDate: new Date().getTime(), // 故障时间-当前
- failureMinDate: new Date().getTime(), // 故障时间-最小
+ repairTimeVisible: false, // 故障时间show
+ repairTime: new Date().getTime(), // 故障时间-当前
typeVisible: false,
- typeName: '',
typeColumns: [{
values: [],
className: 'column1',
@@ -52,7 +52,6 @@ Page({
},
],
addressVisible: false,
- addressName: '',
addressColumns: [{
values: [],
className: 'column1',
@@ -66,17 +65,19 @@ Page({
detail: {
"repairName": "", //维修名称
"repairLevel": "", //维修等级
- "failureDate": null, //故障时间
+ "repairTime": null, //故障时间
"typeId": null, //故障类型
- "repairDevice": null, //维修设备
+ "typeName": "", //故障名称
+ "deviceId": null, //设备
+ "deviceName": "", //设备名称
"name": "", //用户名
"phone": "", //手机号码
"addressId": null, // 地点id
- "roomId": null, // 楼层id
- "area": "", // 门牌号
- "content": "", // 描述
- "repairVoice": "", // 语音文件
- "repairImages": "", //故障图片
+ "address": null, // 地点
+ "floorId": null, // 楼层id
+ "floor": null, // 楼层id
+ "room": "", // 门牌号
+ "explain": "", // 描述
},
},
@@ -141,30 +142,30 @@ Page({
},
// 显示-故障时间
- showFailureDate() {
+ showRepairTime() {
let _this = this;
_this.setData({
- failureDateShow: true
+ repairTimeVisible: true
})
},
// 关闭-故障时间
- hideFailureDate() {
+ hideRepairTime() {
let _this = this;
_this.setData({
- failureDateShow: false
+ repairTimeVisible: false
})
},
// 确认-故障时间
- confirmFailureDate(e) {
- console.log('confirmFailureDate', e);
+ confirmRepairTime(e) {
+ console.log('confirmRepairTime', e);
let _this = this;
let detail = _this.data.detail;
- detail.failureDate = selfFormatTimeYMDHMS(e.detail);
+ detail.repairTime = selfFormatTimeYMDHMS(e.detail);
_this.setData({
- failureDateShow: false,
- failureDate: e.detail,
+ repairTimeVisible: false,
+ repairTime: e.detail,
detail
})
},
@@ -253,11 +254,11 @@ Page({
} = e.detail;
let detail = _this.data.detail
detail.typeId = value[0].id
- detail.repairDevice = value[1].id
- let typeName = value[0].text + '/' + value[1].text
+ detail.typeName = value[0].text
+ detail.deviceId = value[1].id
+ detail.deviceName = value[1].text
_this.setData({
detail,
- typeName,
typeVisible: false
})
},
@@ -347,11 +348,11 @@ Page({
} = e.detail;
let detail = _this.data.detail
detail.addressId = value[0].id
- detail.roomId = value[1].id
- let addressName = value[0].text + '/' + value[1].text
+ detail.address = value[0].text
+ detail.floorId = value[1].id
+ detail.floor = value[1].text
_this.setData({
detail,
- addressName,
addressVisible: false
})
},
@@ -453,37 +454,34 @@ Page({
},
// 文件-上传后
- fileAfterRead(event) {
+ async fileAfterRead(event) {
let _this = this;
console.log('fileAfterRead', event);
+ // 上传完成需要更新 fileList
+ let fileList = _this.data.fileList;
+ //
const {
file
} = event.detail;
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
for (let i = 0; i < file.length; i++) {
let url = file[i].url;
- wx.uploadFile({
- url: app.DOMAIN_NAME + '/api/dfs/upload',
- filePath: url,
- name: 'file',
- formData: {},
- success(res) {
- console.log('upload file ', res);
- let fileData = JSON.parse(res.data)
- // 上传完成需要更新 fileList
- let fileList = _this.data.fileList;
- fileList.push({
- relativeUrl: fileData.fileName,
- url: app.IMG_NAME + fileData.fileName,
- name: fileData.fileName,
- deletable: true,
- })
- _this.setData({
- fileList
- })
- },
- });
+ await repairAttachUpload({
+ url,
+ operate: 'repair'
+ }).then(res => {
+ console.log('upload file ', res);
+ fileList.push({
+ id: res.id,
+ relativeUrl: res.url,
+ url: app.IMG_NAME + res.url,
+ deletable: true,
+ })
+ })
}
+ _this.setData({
+ fileList
+ })
},
@@ -519,6 +517,7 @@ Page({
// 数据
let detail = _this.data.detail;
//
+ //
// 校验数据
//
// 报修名称
@@ -532,7 +531,7 @@ Page({
return;
}
// 故障时间
- if (!detail.failureDate) {
+ if (!detail.repairTime) {
_this.showErrMsg('请选择故障时间!')
return;
}
@@ -547,7 +546,7 @@ Page({
return;
}
// 门牌号
- if (!detail.area) {
+ if (!detail.room) {
_this.showErrMsg('请输入门牌号!')
return;
}
@@ -567,33 +566,29 @@ Page({
return;
}
// 故障描述
- if (!detail.content) {
+ if (!detail.explain) {
_this.showErrMsg('请输入故障描述!')
return;
}
+ //
+ let fileIdList = []
// 图片上传
if (fileList && fileList.length > 0) {
- detail.repairImages = JSON.stringify(fileList.map(item => {
- return {
- name: item.relativeUrl,
- url: item.relativeUrl,
- uid: item.relativeUrl,
- }
- }))
+ fileIdList = fileList.map(item => item.id)
}
// 音频
if (voiceObj && voiceObj.tempFilePath) {
- await app.selfUploadFile(voiceObj.tempFilePath).then(res => {
- console.log('selfUploadFile', res);
- detail.repairVoice = JSON.stringify({
- url: res.fileName,
- time: voiceObj.duration
- })
+ await uploadVoice(voiceObj.tempFilePath).then(res => {
+ console.log('uploadVoice', res);
+ fileIdList.push(res.id)
})
}
//
// 添加数据
- repairSaveRq(detail).then(res => {
+ repairSaveRq({
+ repair: detail,
+ files: fileIdList
+ }).then(res => {
console.log('visitorPersonRq', res);
//
if (res.code == 0) {
diff --git a/miniprogram/pages/reportRepair/report/report.wxml b/miniprogram/pages/reportRepair/report/report.wxml
index 15bc7b9..e225bc2 100644
--- a/miniprogram/pages/reportRepair/report/report.wxml
+++ b/miniprogram/pages/reportRepair/report/report.wxml
@@ -8,21 +8,21 @@
故障等级
-
+
故障时间
-
+
故障类型
-
+
故障地点
-
+
门牌号
-
+
联系电话
@@ -35,7 +35,7 @@
故障描述
-
+
@@ -71,8 +71,8 @@
-
-
+
+
diff --git a/miniprogram/utils/util.js b/miniprogram/utils/util.js
index 534db56..2e1802e 100644
--- a/miniprogram/utils/util.js
+++ b/miniprogram/utils/util.js
@@ -1,3 +1,6 @@
+let app = getApp();
+
+
//返回 例 2017
const formatYear = data => {
var date = data.date;
@@ -220,15 +223,15 @@ function getUrlParamsObj(url) {
// 通过 ? 分割获取后面的参数字符串
let urlStr = url.split('?')[1]
// 创建空对象存储参数
- let obj = {};
+ let obj = {};
// 再通过 & 将每一个参数单独分割出来
- let paramsArr = urlStr.split('&')
- for(let i = 0,len = paramsArr.length;i < len;i++){
+ let paramsArr = urlStr.split('&')
+ for (let i = 0, len = paramsArr.length; i < len; i++) {
// 再通过 = 将每一个参数分割为 key:value 的形式
- let arr = paramsArr[i].split('=')
- obj[arr[0]] = arr[1];
- }
- return obj
+ let arr = paramsArr[i].split('=')
+ obj[arr[0]] = arr[1];
+ }
+ return obj
}
// 判断是否是图片
@@ -240,6 +243,82 @@ function checkIsImg(url) {
}
}
+function uploadFile(url) {
+ let _this = this
+ return new Promise((resolve, reject) => {
+ wx.uploadFile({
+ url: app.DOMAIN_NAME + '/api/dfs/upload',
+ filePath: url,
+ name: 'file',
+ header: {
+ "Authorization": 'Bearer ' + wx.getStorageSync('token')
+ },
+ formData: {},
+ success: res => {
+ resolve(JSON.parse(res.data));
+ },
+ fail: err => {
+ reject(err);
+ }
+ })
+ })
+}
+
+
+// 报修上传图片视频
+// url: localhost:9227/app/repairAttach/upload?repairId=&operate=repair\feedback\eval
+// repairId : 工单id,报修人不传
+// operate : repair报修,feedback维修,eval评价
+function repairAttachUpload(data) {
+ let _this = this
+ let paramUrl = "?a=a"
+ if (data.repairId) {
+ paramUrl = paramUrl + '&repairId=' + data.repairId
+ }
+ if (data.operate) {
+ paramUrl = paramUrl + '&operate=' + data.operate
+ }
+ return new Promise((resolve, reject) => {
+ wx.uploadFile({
+ url: app.DOMAIN_NAME + '/app/repairAttach/upload' + paramUrl,
+ filePath: data.url,
+ name: 'file',
+ header: {
+ "Authorization": 'Bearer ' + wx.getStorageSync('token')
+ },
+ formData: {},
+ success: res => {
+ resolve(JSON.parse(res.data));
+ },
+ fail: err => {
+ reject(err);
+ }
+ })
+ })
+}
+
+// 报修上传语音
+// url: localhost:9227/app/repairAttach/upload/voice
+function uploadVoice(url) {
+ let _this = this
+ return new Promise((resolve, reject) => {
+ wx.uploadFile({
+ url: app.DOMAIN_NAME + '/app/repairAttach/upload/voice',
+ filePath: url,
+ name: 'file',
+ header: {
+ "Authorization": 'Bearer ' + wx.getStorageSync('token')
+ },
+ formData: {},
+ success: res => {
+ resolve(JSON.parse(res.data));
+ },
+ fail: err => {
+ reject(err);
+ }
+ })
+ })
+}
module.exports = {
formatTime: formatTime,
@@ -258,5 +337,8 @@ module.exports = {
twoTimeIntervalReturnHours,
selfArrSum,
getUrlParamsObj,
- checkIsImg
+ checkIsImg,
+ uploadFile,
+ repairAttachUpload,
+ uploadVoice
}
\ No newline at end of file