This commit is contained in:
SelfRidicule 2024-08-15 14:59:35 +08:00
parent 9e63e27468
commit 3331f1cbf8
10 changed files with 213 additions and 77 deletions

View File

@ -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 已评价

View File

@ -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',
})
}
}
})

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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) {

View File

@ -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() {
}
})

View File

@ -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"
}
}

View File

@ -2,21 +2,25 @@
<view class="regionView">
<view class="topTitle">服务评价</view>
<view class="itemView" wx:for="{{3}}">
<view class="label">维修速度</view>
<van-icon class="star" wx:for="{{5}}" wx:for-item="index" wx:key="*this" name="{{index < 3 ? 'star' : 'star-o'}}" color="{{index < 3 ? '#f9d24e' : '#c9c9c9'}}" size="50rpx" />
<view class="itemView">
<view class="label">评价</view>
<van-icon class="star" wx:for="{{5}}" wx:for-item="index" wx:key="*this" name="{{index < form.evalService ? 'star' : 'star-o'}}" color="{{index < form.evalService ? '#f9d24e' : '#c9c9c9'}}" size="50rpx" data-index="{{index}}" bind:tap="selectStar" />
</view>
</view>
<view class="regionView">
<view class="topTitle">留言反馈</view>
<van-field model:value="{{ value }}" type="textarea" placeholder="请输入用户名" maxlength="{{100}}" show-word-limit border="{{false}}" autosize input-class="selfTextarea" />
<van-field model:value="{{ form.feedback }}" bind:input="fieldInput" data-name="feedback" clearable type="textarea" placeholder="请输入" maxlength="{{100}}" show-word-limit border="{{false}}" autosize input-class="selfTextarea" />
<!-- 上传图片 -->
<view class="uploadImgView">
<van-uploader file-list="{{ fileList }}" upload-text="点击上传照片" use-before-read bind:before-read="beforeRead" bind:after-read="afterRead" deletable="{{ true }}" bind:delete="deleteImg" max-count="1" />
<van-uploader file-list="{{ fileList }}" upload-text="点击上传" bind:after-read="fileAfterRead" deletable="{{ true }}" bind:delete="deleteImg" max-count="6" accept="media" multiple />
</view>
</view>
<view class="submitBtn">提交</view>
<view class="submitBtn" bind:tap="submitData">提交</view>
</view>
</view>
<!-- 消息通知 -->
<van-notify id="van-notify" />

View File

@ -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)
}

View File

@ -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)
}