| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <template>
- <view class="container">
- <!-- 头部 -->
- <view class="header">
- <text class="title">服务评价</text>
- <text class="subtitle">请对我们的服务进行评价</text>
- </view>
- <!-- 加载状态 -->
- <view v-if="loading" class="loading">
- <text>加载中...</text>
- </view>
- <!-- 评价表单 -->
- <view v-if="!loading && execution" class="rating-form">
- <!-- 评估师评价 -->
- <view v-if="execution.assessorId" class="rating-section">
- <view class="section-header">
- <view class="section-icon assessor-section-icon"></view>
- <text class="section-title">评估师服务评价</text>
- </view>
- <view class="rating-stars">
- <text class="star-label">评分:</text>
- <view class="stars">
- <text
- v-for="i in 5"
- :key="i"
- class="star"
- :class="{ active: assessorRating >= i }"
- @click="setAssessorRating(i)">
- ★
- </text>
- </view>
- <text v-if="assessorRating > 0" class="rating-text">{{ ratingTexts[assessorRating - 1] }}</text>
- </view>
- <view class="comment-input">
- <textarea
- v-model="assessorComment"
- placeholder="请分享您的服务体验(选填)"
- maxlength="500"
- class="textarea"
- />
- </view>
- </view>
- <!-- 规划师评价 -->
- <view v-if="execution.plannerId" class="rating-section">
- <view class="section-header">
- <view class="section-icon planner-section-icon"></view>
- <text class="section-title">规划师服务评价</text>
- </view>
- <view class="rating-stars">
- <text class="star-label">评分:</text>
- <view class="stars">
- <text
- v-for="i in 5"
- :key="i"
- class="star"
- :class="{ active: plannerRating >= i }"
- @click="setPlannerRating(i)">
- ★
- </text>
- </view>
- <text v-if="plannerRating > 0" class="rating-text">{{ ratingTexts[plannerRating - 1] }}</text>
- </view>
- <view class="comment-input">
- <textarea
- v-model="plannerComment"
- placeholder="请分享您的服务体验(选填)"
- maxlength="500"
- class="textarea"
- />
- </view>
- </view>
- <!-- 提交按钮 -->
- <view class="actions">
- <button class="btn-primary" @click="submitRating" :disabled="!canSubmit">
- 提交评价
- </button>
- <button class="btn-outline" @click="goBack">
- 返回
- </button>
- </view>
- </view>
- <!-- 无数据 -->
- <view v-if="!loading && !execution" class="empty">
- <text>暂无可评价的服务</text>
- </view>
- </view>
- </template>
- <script>
- import config from '@/config.js'
- export default {
- data() {
- return {
- executionId: null,
- execution: null,
- loading: true,
- assessorRating: 0,
- assessorComment: '',
- plannerRating: 0,
- plannerComment: '',
- ratingTexts: ['很差', '较差', '一般', '满意', '非常满意']
- }
- },
- computed: {
- canSubmit() {
- // 至少评估师评分必须填写
- return this.assessorRating > 0
- }
- },
- onLoad(options) {
- if (options.executionId) {
- this.executionId = options.executionId
- this.loadExecution()
- }
- },
- methods: {
- async loadExecution() {
- this.loading = true
- try {
- const res = await uni.request({
- url: `${config.API_BASE_URL}/api/dan-execution/detail/${this.executionId}`,
- method: 'GET',
- header: {
- 'Authorization': `Bearer ${uni.getStorageSync('token')}`
- }
- })
- if (res.data.code === 200) {
- this.execution = res.data.data
- } else {
- uni.showToast({ title: res.data.message || '加载失败', icon: 'none' })
- }
- } catch (e) {
- console.error('加载执行记录失败', e)
- uni.showToast({ title: '网络错误', icon: 'none' })
- } finally {
- this.loading = false
- }
- },
- setAssessorRating(rating) {
- this.assessorRating = rating
- },
- setPlannerRating(rating) {
- this.plannerRating = rating
- },
- async submitRating() {
- if (!this.canSubmit) {
- uni.showToast({ title: '请至少为评估师评分', icon: 'none' })
- return
- }
- try {
- const data = {
- executionId: this.executionId,
- assessorId: this.execution.assessorId,
- assessorRating: this.assessorRating,
- assessorComment: this.assessorComment
- }
- if (this.execution.plannerId) {
- data.plannerId = this.execution.plannerId
- data.plannerRating = this.plannerRating
- data.plannerComment = this.plannerComment
- }
- const res = await uni.request({
- url: `${config.API_BASE_URL}/api/dan-execution/rate`,
- method: 'POST',
- header: {
- 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
- 'Content-Type': 'application/json'
- },
- data: data
- })
- if (res.data.code === 200) {
- uni.showToast({ title: '评价成功', icon: 'success' })
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- } else {
- uni.showToast({ title: res.data.message || '评价失败', icon: 'none' })
- }
- } catch (e) {
- console.error('提交评价失败', e)
- uni.showToast({ title: '网络错误', icon: 'none' })
- }
- },
- goBack() {
- uni.navigateBack()
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 40rpx;
- background: #f5f5f5;
- min-height: 100vh;
- }
- .header {
- margin-bottom: 40rpx;
- }
- .title {
- font-size: 40rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 10rpx;
- }
- .subtitle {
- font-size: 28rpx;
- color: #999;
- }
- .loading, .empty {
- text-align: center;
- padding: 100rpx 0;
- color: #999;
- }
- .rating-section {
- background: white;
- border-radius: 20rpx;
- padding: 40rpx;
- margin-bottom: 30rpx;
- }
- .section-header {
- display: flex;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .section-icon {
- width: 48rpx;
- height: 48rpx;
- border-radius: 12rpx;
- margin-right: 16rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- }
- .assessor-section-icon {
- background: linear-gradient(135deg, #e3f2fd, #bbdefb);
- }
- .assessor-section-icon::after {
- content: '';
- width: 20rpx;
- height: 20rpx;
- border: 4rpx solid #2196f3;
- border-radius: 50%;
- position: absolute;
- }
- .planner-section-icon {
- background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
- }
- .planner-section-icon::after {
- content: '';
- width: 20rpx;
- height: 20rpx;
- border: 4rpx solid #4caf50;
- border-radius: 50%;
- position: absolute;
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- }
- .rating-stars {
- display: flex;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .star-label {
- font-size: 28rpx;
- color: #666;
- margin-right: 20rpx;
- }
- .stars {
- display: flex;
- gap: 12rpx;
- }
- .star {
- font-size: 60rpx;
- color: #e0e0e0;
- transition: color 0.2s ease, text-shadow 0.2s ease;
- line-height: 1;
- }
- .star:active {
- transform: scale(1.15);
- }
- .star.active {
- color: #ffc107;
- text-shadow: 0 0 8rpx rgba(255, 193, 7, 0.4);
- }
- .rating-text {
- font-size: 24rpx;
- color: #ff9800;
- margin-left: 16rpx;
- font-weight: bold;
- }
- .comment-input {
- margin-top: 20rpx;
- }
- .textarea {
- width: 100%;
- min-height: 200rpx;
- padding: 20rpx;
- border: 2rpx solid #e0e0e0;
- border-radius: 10rpx;
- font-size: 28rpx;
- box-sizing: border-box;
- }
- .actions {
- display: flex;
- flex-direction: column;
- gap: 20rpx;
- margin-top: 40rpx;
- }
- .btn-primary, .btn-outline {
- border-radius: 20rpx;
- font-size: 32rpx;
- padding: 30rpx;
- text-align: center;
- }
- .btn-primary {
- background: #1E3A5F;
- color: white;
- border: none;
- }
- .btn-primary:disabled {
- background: #ccc;
- }
- .btn-outline {
- background: white;
- color: #666;
- border: 2rpx solid #ddd;
- }
- </style>
|