diff --git a/miniprogram/api/repair/repair.js b/miniprogram/api/repair/repair.js index 232d58f..6f5b22b 100644 --- a/miniprogram/api/repair/repair.js +++ b/miniprogram/api/repair/repair.js @@ -104,6 +104,14 @@ export function faultTypeListRq() { }); } +// 评价 +export function repairEvalRq(data) { + return request({ + url: `/app/repair/eval`, + method: "post", + data + }); +} // 返回订单状态 // 状态:1 待派单,3 重新派单,5 已派单,7 处理中, 9已完成 待评价, 11 已关闭 13 已评价 diff --git a/miniprogram/app.js b/miniprogram/app.js index 76a0687..42a9ffa 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -332,4 +332,19 @@ App({ vantNotifyErrTop(Notify, msg) { this.vantNotify(Notify, msg, 'danger', 90) }, + // 自定义后退 + selfBackPage(step) { + let currentPages = getCurrentPages(); + // 大于就后退,否则直接跳转首页 + if (currentPages.length > step) { + wx.navigateBack({ + delta: step + }) + } else { + // 跳转首页 + wx.reLaunch({ + url: '/pages/index/index', + }) + } + } }) \ No newline at end of file diff --git a/miniprogram/pages/reportRepair/assign/affirm/affirm.js b/miniprogram/pages/reportRepair/assign/affirm/affirm.js index 7ffc4c0..df01866 100644 --- a/miniprogram/pages/reportRepair/assign/affirm/affirm.js +++ b/miniprogram/pages/reportRepair/assign/affirm/affirm.js @@ -175,9 +175,7 @@ Page({ console.log('flowHandleRq', res); if (res.code == 0) { app.vantNotifySuccessTop(Notify, res.msg) - wx.navigateBack({ - delta: 2 - }) + app.selfBackPage(2) } else { app.vantNotifyErrTop(Notify, res.msg) } diff --git a/miniprogram/pages/reportRepair/assign/again/again.js b/miniprogram/pages/reportRepair/assign/again/again.js index b0d231c..607a14a 100644 --- a/miniprogram/pages/reportRepair/assign/again/again.js +++ b/miniprogram/pages/reportRepair/assign/again/again.js @@ -197,9 +197,7 @@ Page({ console.log('flowHandleRq', res); if (res.code == 0) { app.vantNotifySuccessTop(Notify, res.msg) - wx.navigateBack({ - delta: 2 - }) + app.selfBackPage(2) } else { app.vantNotifyErrTop(Notify, res.msg) } diff --git a/miniprogram/pages/reportRepair/assign/detail/detail.js b/miniprogram/pages/reportRepair/assign/detail/detail.js index a212a40..b0cd41c 100644 --- a/miniprogram/pages/reportRepair/assign/detail/detail.js +++ b/miniprogram/pages/reportRepair/assign/detail/detail.js @@ -38,17 +38,7 @@ Page({ }, back() { - let currentPages = getCurrentPages(); - console.log('currentPages', currentPages); - // 大于一个页面就后退,否则直接跳转首页 - if (currentPages.length > 1) { - wx.navigateBack() - } else { - // 跳转首页 - wx.reLaunch({ - url: '/pages/index/index', - }) - } + app.selfBackPage(1) }, getDetail(id) { diff --git a/miniprogram/pages/reportRepair/assign/evaluate/evaluate.js b/miniprogram/pages/reportRepair/assign/evaluate/evaluate.js index b869e2f..438c870 100644 --- a/miniprogram/pages/reportRepair/assign/evaluate/evaluate.js +++ b/miniprogram/pages/reportRepair/assign/evaluate/evaluate.js @@ -1,66 +1,192 @@ -// pages/reportRepair/reportEvaluate/evaluate.js +const app = getApp() + +import Notify from '@vant/weapp/notify/notify'; + +import { + repairAttachUpload, +} from "../../../../utils/util.js" + +import { + repairEvalRq, +} from "../../../../api/repair/repair.js" + Page({ - /** - * 页面的初始数据 - */ - data: { + /** + * 页面的初始数据 + */ + data: { + IMG_NAME: app.IMG_NAME, + id: null, + form: { + "evalService": 0, + "feedback": "" + }, + fileList: [] + }, - }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + let _this = this + _this.setData({ + ...options + }) + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { + // 选择评价 + selectStar(e) { + console.log('selectStar', e); + let _this = this + let form = _this.data.form + form.evalService = e.currentTarget.dataset.index + 1 + _this.setData({ + form + }) + }, - }, + // input输入内容监听 + fieldInput(e) { + console.log('fieldInput', e); + let _this = this; + let form = _this.data.form; + form[e.currentTarget.dataset.name] = e.detail + _this.setData({ + form + }) + }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { + // 图片-上传前校验 + beforeRead(event) { + // const { + // file, + // callback + // } = event.detail; + // callback(file.type === 'image'); + }, - }, + // 文件-上传后 + 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; + await repairAttachUpload({ + url, + repairId: _this.data.id, + operate: 'eval' + }).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 + }) + }, - /** - * 生命周期函数--监听页面显示 - */ - onShow() { + // 删除图片 + deleteImg(event) { + console.log('deleteImg', event); + let _this = this; + let fileList = _this.data.fileList; + fileList.splice(event.detail.index, 1); + _this.setData({ + fileList + }) + }, - }, + // 提交数据 + submitData() { + let _this = this; + // 数据 + let form = _this.data.form; + // + // 校验数据 + // + // 报修名称 + if (!form.evalService) { + app.vantNotifyErr(Notify, '请选择服务评价!') + return; + } + // + // 评价 + repairEvalRq({ + repair: { + "id": _this.data.id, + ..._this.data.form + }, + }).then(res => { + console.log('repairEvalRq', res); + // + if (res.code == 0) { + app.vantNotifySuccess(Notify, res.msg) + app.selfBackPage(2) + } else { + app.vantNotifyErr(Notify, res.msg) + } + }) + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { - }, + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { + /** + * 生命周期函数--监听页面显示 + */ + onShow() { - }, + }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { - }, + }, - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { - }, + }, - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { - } + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } }) \ No newline at end of file diff --git a/miniprogram/pages/reportRepair/assign/evaluate/evaluate.json b/miniprogram/pages/reportRepair/assign/evaluate/evaluate.json index 04ba22f..85c7946 100644 --- a/miniprogram/pages/reportRepair/assign/evaluate/evaluate.json +++ b/miniprogram/pages/reportRepair/assign/evaluate/evaluate.json @@ -3,6 +3,7 @@ "usingComponents": { "van-icon": "@vant/weapp/icon/index", "van-field": "@vant/weapp/field/index", - "van-uploader": "@vant/weapp/uploader/index" + "van-uploader": "@vant/weapp/uploader/index", + "van-notify": "@vant/weapp/notify/index" } } \ No newline at end of file diff --git a/miniprogram/pages/reportRepair/assign/evaluate/evaluate.wxml b/miniprogram/pages/reportRepair/assign/evaluate/evaluate.wxml index e8a7606..08ae9b1 100644 --- a/miniprogram/pages/reportRepair/assign/evaluate/evaluate.wxml +++ b/miniprogram/pages/reportRepair/assign/evaluate/evaluate.wxml @@ -2,21 +2,25 @@ 服务评价 - - 维修速度 - + + 评价 + 留言反馈 - + - + - 提交 + 提交 - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/miniprogram/pages/reportRepair/assign/feedback/feedback.js b/miniprogram/pages/reportRepair/assign/feedback/feedback.js index fe96f07..31114f7 100644 --- a/miniprogram/pages/reportRepair/assign/feedback/feedback.js +++ b/miniprogram/pages/reportRepair/assign/feedback/feedback.js @@ -53,9 +53,7 @@ Page({ console.log('flowHandleRq', res); if (res.code == 0) { app.vantNotifySuccess(Notify, res.msg) - wx.navigateBack({ - delta: 2 - }) + app.selfBackPage(2) } else { app.vantNotifyErr(Notify, res.msg) } diff --git a/miniprogram/pages/reportRepair/assign/nullify/nullify.js b/miniprogram/pages/reportRepair/assign/nullify/nullify.js index 5da5ced..a3cf582 100644 --- a/miniprogram/pages/reportRepair/assign/nullify/nullify.js +++ b/miniprogram/pages/reportRepair/assign/nullify/nullify.js @@ -53,9 +53,7 @@ Page({ console.log('flowHandleRq', res); if (res.code == 0) { app.vantNotifySuccess(Notify, res.msg) - wx.navigateBack({ - delta: 2 - }) + app.selfBackPage(2) } else { app.vantNotifyErr(Notify, res.msg) }