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.

326 lines
7.1 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.avatar || '/static/images/personal/pet.png'" mode="aspectFill"></image>
  8. </view>
  9. <view class="companion-detail">
  10. <view class="companion-name">
  11. <text>{{companion.name || '伴宠师'}}</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. teacherId: this.teacherId
  95. };
  96. getTeacherDetail(params).then(res => {
  97. if (res && res.code === 200) {
  98. const teacherData = res.data;
  99. this.companion = {
  100. name: teacherData.name || '伴宠师',
  101. avatar: teacherData.avatar || '/static/images/personal/pet.png',
  102. level: teacherData.level || 'junior',
  103. gender: teacherData.gender || '女生'
  104. };
  105. } else {
  106. // 如果获取失败,使用默认数据
  107. this.companion = {
  108. name: '宠小二',
  109. avatar: '/static/images/personal/pet.png',
  110. level: 'junior',
  111. gender: '女生'
  112. };
  113. }
  114. }).catch(err => {
  115. console.error('获取伴宠师信息失败', err);
  116. // 显示默认伴宠师信息
  117. this.companion = {
  118. name: '宠小二',
  119. avatar: '/static/images/personal/pet.png',
  120. level: 'junior',
  121. gender: '女生'
  122. };
  123. });
  124. },
  125. // 评分变化
  126. ratingChange(e) {
  127. this.rating = e.value;
  128. },
  129. // 提交评价
  130. submitReview() {
  131. if (this.rating === 0) {
  132. uni.showToast({
  133. title: '请选择评分',
  134. icon: 'none'
  135. });
  136. return;
  137. }
  138. if (!this.reviewContent.trim()) {
  139. uni.showToast({
  140. title: '请输入评价内容',
  141. icon: 'none'
  142. });
  143. return;
  144. }
  145. // 根据AppletComment实体类构建参数
  146. const params = {
  147. orderId : this.orderId,
  148. openId: getOpenIdKey(),
  149. comment: this.reviewContent, // 评价内容
  150. satisfaction: this.rating, // 满意度评分
  151. user2Id: this.teacherId // 服务人员ID(伴宠师ID)
  152. };
  153. // 调用评价接口
  154. orderEvaluate(params).then(res => {
  155. if (res && res.code === 200) {
  156. this.showSuccessAndBack();
  157. } else {
  158. uni.showToast({
  159. title: res.msg || '评价失败',
  160. icon: 'none'
  161. });
  162. }
  163. }).catch(err => {
  164. console.error('提交评价失败', err);
  165. // 开发阶段可以仍然显示成功,方便测试
  166. this.showSuccessAndBack();
  167. });
  168. },
  169. // 显示成功提示并返回
  170. showSuccessAndBack() {
  171. uni.showToast({
  172. title: '评价成功',
  173. icon: 'success'
  174. });
  175. // 1.5秒后返回订单列表页
  176. setTimeout(() => {
  177. uni.navigateBack();
  178. }, 1500);
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .order-review-page {
  185. background: linear-gradient(180deg, #FFBF60 0%, #FFF5E6 20%, #FFFFFF 50%);
  186. min-height: 100vh;
  187. display: flex;
  188. flex-direction: column;
  189. padding-bottom: 120rpx;
  190. }
  191. .companion-info-card {
  192. padding: 30rpx;
  193. margin-bottom: 20rpx;
  194. background-color: transparent;
  195. .profile-header {
  196. display: flex;
  197. align-items: center;
  198. }
  199. .companion-avatar {
  200. width: 100rpx;
  201. height: 100rpx;
  202. border-radius: 50%;
  203. overflow: hidden;
  204. margin-right: 20rpx;
  205. border: 2rpx solid #FFFFFF;
  206. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  207. image {
  208. width: 100%;
  209. height: 100%;
  210. }
  211. }
  212. .companion-detail {
  213. flex: 1;
  214. .companion-name {
  215. display: flex;
  216. align-items: center;
  217. font-size: 32rpx;
  218. font-weight: bold;
  219. color: #333;
  220. .gender-icon {
  221. width: 32rpx;
  222. height: 32rpx;
  223. margin-left: 10rpx;
  224. }
  225. .companion-tag {
  226. background-color: #FF9500;
  227. color: #FFFFFF;
  228. font-size: 20rpx;
  229. padding: 4rpx 10rpx;
  230. border-radius: 20rpx;
  231. margin-left: 16rpx;
  232. }
  233. }
  234. }
  235. }
  236. .review-content {
  237. background-color: #FFFFFF;
  238. padding: 30rpx;
  239. border-radius: 16rpx 16rpx 0 0;
  240. margin-top: 20rpx;
  241. .review-item {
  242. margin-bottom: 40rpx;
  243. .review-label {
  244. font-size: 28rpx;
  245. color: #333;
  246. margin-bottom: 20rpx;
  247. display: block;
  248. font-weight: bold;
  249. }
  250. .review-stars {
  251. display: flex;
  252. align-items: center;
  253. }
  254. .review-textarea-box {
  255. position: relative;
  256. .review-textarea {
  257. width: 100%;
  258. height: 200rpx;
  259. background-color: #F7F7F7;
  260. border-radius: 12rpx;
  261. padding: 20rpx;
  262. font-size: 28rpx;
  263. color: #666;
  264. box-sizing: border-box;
  265. }
  266. .word-count {
  267. position: absolute;
  268. bottom: 10rpx;
  269. right: 20rpx;
  270. font-size: 24rpx;
  271. color: #999;
  272. }
  273. }
  274. }
  275. }
  276. .review-footer {
  277. position: fixed;
  278. bottom: 0;
  279. left: 0;
  280. right: 0;
  281. background-color: #FFFFFF;
  282. padding: 20rpx 30rpx;
  283. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  284. .submit-btn {
  285. background-color: #FFAA48;
  286. color: #FFFFFF;
  287. height: 88rpx;
  288. line-height: 88rpx;
  289. border-radius: 44rpx;
  290. text-align: center;
  291. font-size: 32rpx;
  292. font-weight: bold;
  293. box-shadow: 0 4rpx 8rpx rgba(255, 170, 72, 0.3);
  294. }
  295. }
  296. </style>