<template>
|
<view class="evaluate-page">
|
<view class="content-wrap">
|
<view class="rate-block">
|
<view class="title-row">
|
<text class="title-label">寄件门店:</text>
|
<text class="title-value">{{info.depositShopName||''}}</text>
|
</view>
|
<view class="star-row">
|
<view class="star-list">
|
<view
|
v-for="n in 5"
|
:key="'shop-' + n"
|
class="star-item"
|
:class="{ active: n < form.depositScore, dashed: n === 1 || n === 3 }"
|
@tap="form.depositScore = n+1"
|
>★</view>
|
</view>
|
<text class="rate-text">{{ form.depositScore }}星</text>
|
</view>
|
</view>
|
|
<view class="divider"></view>
|
|
<view class="rate-block">
|
<view class="title-row">
|
<text class="title-label">配送司机:</text>
|
<text class="title-value">{{info.driverName || ''}}</text>
|
</view>
|
<view class="star-row">
|
<view class="star-list">
|
<view
|
v-for="n in 5"
|
:key="'driver-' + n"
|
class="star-item"
|
:class="{ active: n < form.driverScore, dashed: n === 1 }"
|
@tap=" form.driverScore = n+1"
|
>★</view>
|
</view>
|
<text class="rate-text">{{ form.driverScore }}星</text>
|
</view>
|
</view>
|
<view class="divider"></view>
|
<view class="rate-block" v-if="info.type ===1 && info.takeShopId ">
|
<view class="title-row">
|
<text class="title-label">收件门店:</text>
|
<text class="title-value">{{info.takeShopName || 0}}</text>
|
</view>
|
<view class="star-row">
|
<view class="star-list">
|
<view
|
v-for="n in 5"
|
:key="'receive-' + n"
|
class="star-item"
|
:class="{ active: n < form.takeScore, dashed: n === 1 }"
|
@tap="form.takeScore = n+1"
|
>★</view>
|
</view>
|
<text class="rate-text">{{ form.takeScore }}星</text>
|
</view>
|
</view>
|
|
<view class="divider"></view>
|
|
<view class="upload-row">
|
<view class="upload-box" @click="chooseAndUploadImage(9)">
|
<view class="upload-plus">+</view>
|
<text class="upload-text">上传照片</text>
|
</view>
|
<view v-for="(item, index) in photoList" :key="index" class="photo-box">
|
<image class="photo-image" :src="item.url" mode="aspectFill"></image>
|
<text class="photo-delete" @click="deleteImage(index)">删除</text>
|
</view>
|
</view>
|
|
<view class="textarea-box">
|
<view class="textarea-placeholder-wrap">
|
<view class="textarea-icon"></view>
|
<textarea v-model="form.content" class="textarea" maxlength="200" placeholder="请说说您对本次服务的感受" placeholder-class="textarea-placeholder"></textarea>
|
</view>
|
<text class="textarea-count">{{ form.content.length }}/200</text>
|
</view>
|
</view>
|
|
<view class="submit-wrap">
|
<view class="submit-btn" @click="orderComment">提交评价</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
id:null,
|
info:{},
|
form:{
|
content: "",
|
depositScore: 5,
|
driverScore: 5,
|
orderId: null,
|
takeScore: 5,
|
fileList:[]
|
},
|
photoList: [
|
'/static/icon/nav_home_sel@2x.png',
|
'/static/icon/nav_xingcheng_sel@2x.png'
|
]
|
}
|
},
|
onShow() {
|
this.info={}
|
this.getUserDetail()
|
},
|
onLoad(options) {
|
this.id = options.id
|
this.photoList=[]
|
this.form={
|
content: "",
|
depositScore: 5,
|
driverScore: 5,
|
orderId: this.id,
|
takeScore: 5,
|
images:[]
|
}
|
},
|
methods:{
|
deleteImage(index) {
|
this.photoList.splice(index, 1)
|
this.form.images.splice(index, 1)
|
},
|
async uploadFiles(filePaths, maxCount = 9) {
|
if (!filePaths || filePaths.length === 0) {
|
return []
|
}
|
const limitedPaths = filePaths.slice(0, maxCount)
|
const uploadTasks = limitedPaths.map(filePath => {
|
return new Promise((resolve, reject) => {
|
uni.uploadFile({
|
url: this.$baseUrl + '/web/public/upload',
|
filePath: filePath,
|
name: 'file',
|
formData: {
|
folder: 'orders'
|
},
|
success: (res) => {
|
if (res.statusCode === 200) {
|
const data = JSON.parse(res.data)
|
if (data.code === 200) {
|
resolve(data.data)
|
} else {
|
reject(new Error(data.msg || '上传失败'))
|
}
|
} else {
|
reject(new Error('上传失败'))
|
}
|
},
|
fail: (err) => {
|
reject(err)
|
}
|
})
|
})
|
})
|
try {
|
const results = await Promise.all(uploadTasks)
|
return results
|
} catch (error) {
|
uni.showToast({
|
title: '上传失败',
|
icon: 'none'
|
})
|
throw error
|
}
|
},
|
async chooseAndUploadImage(maxCount = 9) {
|
const currentCount = this.form.images.length
|
const remainingCount = maxCount - currentCount
|
if (remainingCount <= 0) {
|
uni.showToast({
|
title: `最多上传${maxCount}张图片`,
|
icon: 'none'
|
})
|
return
|
}
|
var that = this
|
uni.chooseImage({
|
count: remainingCount,
|
sizeType: ['compressed'],
|
sourceType: ['album', 'camera'],
|
success: async (res) => {
|
const tempFilePaths = res.tempFilePaths
|
uni.showLoading({
|
title: '上传中...',
|
mask: true
|
})
|
try {
|
const uploadResults = await that.uploadFiles(tempFilePaths, maxCount)
|
const addrs = uploadResults.map(item => item.imgaddr)
|
const fullPaths = uploadResults.map(item => item.url || item.path || item)
|
that.photoList = [...that.photoList, ...fullPaths.map(url => ({ url }))]
|
that.form.images = [...that.form.images, ...addrs]
|
uni.hideLoading()
|
uni.showToast({
|
title: '上传成功',
|
icon: 'success'
|
})
|
} catch (error) {
|
uni.hideLoading()
|
}
|
}
|
})
|
},
|
async orderComment(){
|
var that =this
|
let res = await that.$u.api.orderComment(this.form);
|
if (res.code === 200 ) {
|
this.info.commentStatus == 1
|
uni.$emit('updateOrder',{info:this.info,delete:0})
|
uni.navigateBack({delta:-1})
|
}
|
},
|
async getUserDetail(){
|
var that =this
|
let res = await this.$u.api.getOrderDetail( this.id )
|
if (res.code === 200) {
|
this.info = res.data
|
uni.$emit('updateOrder',{info:this.info,delete:0})
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.evaluate-page {
|
background: #ffffff;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
}
|
|
.content-wrap {
|
padding-bottom: 40rpx;
|
}
|
|
.rate-block {
|
padding: 40rpx 0;
|
box-sizing: border-box;
|
}
|
|
.title-row {
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
}
|
|
.title-label,
|
.title-value {
|
font-weight: 400;
|
font-size: 30rpx;
|
color: #222222;
|
}
|
|
.title-label {
|
font-weight: 500;
|
}
|
|
.title-value {
|
font-weight: 500;
|
}
|
|
.star-row {
|
margin-top: 30rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
|
.no-text-row {
|
justify-content: flex-start;
|
}
|
|
.star-list {
|
display: flex;
|
align-items: center;
|
}
|
|
.star-item {
|
width: 54rpx;
|
height: 54rpx;
|
margin-right: 10rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 50rpx;
|
line-height: 1;
|
color: #e5e7eb;
|
position: relative;
|
}
|
|
.star-item.active {
|
color: #ffc533;
|
}
|
|
.rate-text {
|
font-size: 30rpx;
|
color: #666666;
|
}
|
|
.divider {
|
height: 1rpx;
|
background: #f0f1f4;
|
margin-bottom: 26rpx;
|
}
|
|
.upload-row {
|
display: flex;
|
align-items: flex-start;
|
gap: 10rpx;
|
margin-bottom: 22rpx;
|
}
|
|
.upload-box,
|
.photo-box {
|
width: 122rpx;
|
height: 122rpx;
|
border-radius: 0;
|
overflow: hidden;
|
position: relative;
|
box-sizing: border-box;
|
}
|
|
.upload-box {
|
border: 1rpx dashed #c8ccd4;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.upload-plus {
|
font-size: 54rpx;
|
line-height: 1;
|
color: #999999;
|
}
|
|
.upload-text {
|
margin-top: 8rpx;
|
font-size: 24rpx;
|
color: #999999;
|
}
|
|
.photo-image {
|
width: 100%;
|
height: 100%;
|
}
|
|
.photo-delete {
|
position: absolute;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
height: 32rpx;
|
line-height: 32rpx;
|
text-align: center;
|
font-size: 22rpx;
|
color: #ffffff;
|
background: rgba(0, 0, 0, 0.45);
|
}
|
|
.textarea-box {
|
background: #f6f8fb;
|
border-radius: 18rpx;
|
padding: 18rpx 18rpx 16rpx;
|
box-sizing: border-box;
|
}
|
|
.textarea-placeholder-wrap {
|
display: flex;
|
align-items: flex-start;
|
}
|
|
.textarea-icon {
|
width: 26rpx;
|
height: 26rpx;
|
border: 2rpx solid #b9bec7;
|
margin-top: 8rpx;
|
margin-right: 12rpx;
|
box-sizing: border-box;
|
position: relative;
|
}
|
|
.textarea-icon::before,
|
.textarea-icon::after {
|
content: '';
|
position: absolute;
|
background: #b9bec7;
|
}
|
|
.textarea-icon::before {
|
width: 20rpx;
|
height: 2rpx;
|
left: 2rpx;
|
top: 11rpx;
|
transform: rotate(-45deg);
|
}
|
|
.textarea-icon::after {
|
width: 2rpx;
|
height: 12rpx;
|
right: 4rpx;
|
top: 3rpx;
|
transform: rotate(-45deg);
|
}
|
|
.textarea {
|
flex: 1;
|
min-height: 260rpx;
|
font-size: 28rpx;
|
line-height: 1.6;
|
color: #333333;
|
background: transparent;
|
}
|
|
.textarea-placeholder {
|
font-size: 28rpx;
|
color: #b9bec7;
|
}
|
|
.textarea-count {
|
display: block;
|
margin-top: 8rpx;
|
text-align: right;
|
font-size: 20rpx;
|
color: #999999;
|
}
|
|
.submit-wrap {
|
position: fixed;
|
left: 18rpx;
|
right: 18rpx;
|
bottom: calc(16rpx + env(safe-area-inset-bottom));
|
}
|
|
.submit-btn {
|
height: 78rpx;
|
border-radius: 39rpx;
|
background: #22abf4;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 34rpx;
|
font-weight: 500;
|
color: #ffffff;
|
}
|
</style>
|