You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

318 lines
6.7 KiB

  1. <template>
  2. <view class="order-review-page">
  3. <!-- 伴宠师信息区域 -->
  4. <view class="companion-info-card">
  5. <view class="profile-header">
  6. <view class="companion-avatar">
  7. <image :src="companion.userImage || '/static/images/personal/pet.png'" mode="aspectFill"></image>
  8. </view>
  9. <view class="companion-detail">
  10. <view class="companion-name">
  11. <text>{{companion.userName || '伴宠师'}}</text>
  12. <image v-if="companion.gender" :src="companion.gender === '男生' ? '/static/images/details/boy.svg' : '/static/images/details/girl.svg'" class="gender-icon"></image>
  13. <view class="companion-tag" v-if="companion.level">
  14. <text>{{companion.level === 'junior' ? '初级伴宠师' : '高级伴宠师'}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 评价内容区域 -->
  21. <view class="review-content">
  22. <!-- 评分 -->
  23. <view class="review-item">
  24. <text class="review-label">评价星级</text>
  25. <view class="review-stars">
  26. <uni-rate
  27. v-model="rating"
  28. :size="24"
  29. :value="rating"
  30. :max="5"
  31. :margin="5"
  32. :is-fill="true"
  33. :touchable="true"
  34. @change="ratingChange"
  35. ></uni-rate>
  36. </view>
  37. </view>
  38. <!-- 评价内容 -->
  39. <view class="review-item">
  40. <text class="review-label">评价内容</text>
  41. <view class="review-textarea-box">
  42. <textarea
  43. class="review-textarea"
  44. v-model="reviewContent"
  45. placeholder="服务态度,态度满意,环境满意"
  46. maxlength="500"
  47. ></textarea>
  48. <view class="word-count">
  49. <text>{{reviewContent.length}}/500</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 底部按钮区域 -->
  55. <view class="review-footer">
  56. <view class="submit-btn" @click="submitReview">
  57. <text>提交评价</text>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import { getOpenIdKey } from '@/utils/auth'
  64. import { getTeacherDetail, orderEvaluate } from '@/api/order/order.js'
  65. export default {
  66. data() {
  67. return {
  68. teacherId: null,
  69. rating: 5,
  70. reviewContent: '',
  71. companion: {
  72. name: '',
  73. avatar: '',
  74. level: '',
  75. gender: ''
  76. },
  77. orderInfo: null,
  78. orderId : 0,
  79. };
  80. },
  81. onLoad(options) {
  82. if (options.id) {
  83. this.teacherId = options.id;
  84. this.orderId = options.orderId;
  85. this.getCompanionInfo();
  86. }
  87. },
  88. methods: {
  89. // 获取伴宠师信息
  90. getCompanionInfo() {
  91. // 调用获取伴宠师详情的API
  92. const params = {
  93. openId: getOpenIdKey(),
  94. userId: this.teacherId
  95. };
  96. getTeacherDetail(params).then(res => {
  97. if (res) {
  98. this.companion = res
  99. } else {
  100. // 如果获取失败,使用默认数据
  101. this.companion = {
  102. name: '宠小二',
  103. avatar: '/static/images/personal/pet.png',
  104. level: 'junior',
  105. gender: '女生'
  106. };
  107. }
  108. }).catch(err => {
  109. console.error('获取伴宠师信息失败', err);
  110. // 显示默认伴宠师信息
  111. this.companion = {
  112. name: '宠小二',
  113. avatar: '/static/images/personal/pet.png',
  114. level: 'junior',
  115. gender: '女生'
  116. };
  117. });
  118. },
  119. // 评分变化
  120. ratingChange(e) {
  121. this.rating = e.value;
  122. },
  123. // 提交评价
  124. submitReview() {
  125. if (this.rating === 0) {
  126. uni.showToast({
  127. title: '请选择评分',
  128. icon: 'none'
  129. });
  130. return;
  131. }
  132. if (!this.reviewContent.trim()) {
  133. uni.showToast({
  134. title: '请输入评价内容',
  135. icon: 'none'
  136. });
  137. return;
  138. }
  139. // 根据AppletComment实体类构建参数
  140. const params = {
  141. orderId : this.orderId,
  142. openId: getOpenIdKey(),
  143. content: this.reviewContent, // 评价内容
  144. num: this.rating, // 满意度评分
  145. technicianId: this.teacherId // 服务人员ID(伴宠师ID)
  146. };
  147. // 调用评价接口
  148. orderEvaluate(params).then(res => {
  149. if (res && res.code == 200) {
  150. this.showSuccessAndBack();
  151. } else {
  152. uni.showToast({
  153. title: res.msg || '评价失败',
  154. icon: 'none'
  155. });
  156. }
  157. }).catch(err => {
  158. console.error('提交评价失败', err);
  159. });
  160. },
  161. // 显示成功提示并返回
  162. showSuccessAndBack() {
  163. uni.showToast({
  164. title: '评价成功',
  165. icon: 'success'
  166. });
  167. // 1.5秒后返回订单列表页
  168. setTimeout(() => {
  169. uni.navigateBack();
  170. }, 1500);
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .order-review-page {
  177. background: linear-gradient(180deg, #FFBF60 0%, #FFF5E6 20%, #FFFFFF 50%);
  178. min-height: 100vh;
  179. display: flex;
  180. flex-direction: column;
  181. padding-bottom: 120rpx;
  182. }
  183. .companion-info-card {
  184. padding: 30rpx;
  185. margin-bottom: 20rpx;
  186. background-color: transparent;
  187. .profile-header {
  188. display: flex;
  189. align-items: center;
  190. }
  191. .companion-avatar {
  192. width: 100rpx;
  193. height: 100rpx;
  194. border-radius: 50%;
  195. overflow: hidden;
  196. margin-right: 20rpx;
  197. border: 2rpx solid #FFFFFF;
  198. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  199. image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. .companion-detail {
  205. flex: 1;
  206. .companion-name {
  207. display: flex;
  208. align-items: center;
  209. font-size: 32rpx;
  210. font-weight: bold;
  211. color: #333;
  212. .gender-icon {
  213. width: 32rpx;
  214. height: 32rpx;
  215. margin-left: 10rpx;
  216. }
  217. .companion-tag {
  218. background-color: #FF9500;
  219. color: #FFFFFF;
  220. font-size: 20rpx;
  221. padding: 4rpx 10rpx;
  222. border-radius: 20rpx;
  223. margin-left: 16rpx;
  224. }
  225. }
  226. }
  227. }
  228. .review-content {
  229. background-color: #FFFFFF;
  230. padding: 30rpx;
  231. border-radius: 16rpx 16rpx 0 0;
  232. margin-top: 20rpx;
  233. .review-item {
  234. margin-bottom: 40rpx;
  235. .review-label {
  236. font-size: 28rpx;
  237. color: #333;
  238. margin-bottom: 20rpx;
  239. display: block;
  240. font-weight: bold;
  241. }
  242. .review-stars {
  243. display: flex;
  244. align-items: center;
  245. }
  246. .review-textarea-box {
  247. position: relative;
  248. .review-textarea {
  249. width: 100%;
  250. height: 200rpx;
  251. background-color: #F7F7F7;
  252. border-radius: 12rpx;
  253. padding: 20rpx;
  254. font-size: 28rpx;
  255. color: #666;
  256. box-sizing: border-box;
  257. }
  258. .word-count {
  259. position: absolute;
  260. bottom: 10rpx;
  261. right: 20rpx;
  262. font-size: 24rpx;
  263. color: #999;
  264. }
  265. }
  266. }
  267. }
  268. .review-footer {
  269. position: fixed;
  270. bottom: 0;
  271. left: 0;
  272. right: 0;
  273. background-color: #FFFFFF;
  274. padding: 20rpx 30rpx;
  275. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  276. .submit-btn {
  277. background-color: #FFAA48;
  278. color: #FFFFFF;
  279. height: 88rpx;
  280. line-height: 88rpx;
  281. border-radius: 44rpx;
  282. text-align: center;
  283. font-size: 32rpx;
  284. font-weight: bold;
  285. box-shadow: 0 4rpx 8rpx rgba(255, 170, 72, 0.3);
  286. }
  287. }
  288. </style>