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.

320 lines
6.8 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. comment: this.reviewContent, // 评价内容
  144. satisfaction: this.rating, // 满意度评分
  145. user2Id: 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. this.showSuccessAndBack();
  161. });
  162. },
  163. // 显示成功提示并返回
  164. showSuccessAndBack() {
  165. uni.showToast({
  166. title: '评价成功',
  167. icon: 'success'
  168. });
  169. // 1.5秒后返回订单列表页
  170. setTimeout(() => {
  171. uni.navigateBack();
  172. }, 1500);
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .order-review-page {
  179. background: linear-gradient(180deg, #FFBF60 0%, #FFF5E6 20%, #FFFFFF 50%);
  180. min-height: 100vh;
  181. display: flex;
  182. flex-direction: column;
  183. padding-bottom: 120rpx;
  184. }
  185. .companion-info-card {
  186. padding: 30rpx;
  187. margin-bottom: 20rpx;
  188. background-color: transparent;
  189. .profile-header {
  190. display: flex;
  191. align-items: center;
  192. }
  193. .companion-avatar {
  194. width: 100rpx;
  195. height: 100rpx;
  196. border-radius: 50%;
  197. overflow: hidden;
  198. margin-right: 20rpx;
  199. border: 2rpx solid #FFFFFF;
  200. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  201. image {
  202. width: 100%;
  203. height: 100%;
  204. }
  205. }
  206. .companion-detail {
  207. flex: 1;
  208. .companion-name {
  209. display: flex;
  210. align-items: center;
  211. font-size: 32rpx;
  212. font-weight: bold;
  213. color: #333;
  214. .gender-icon {
  215. width: 32rpx;
  216. height: 32rpx;
  217. margin-left: 10rpx;
  218. }
  219. .companion-tag {
  220. background-color: #FF9500;
  221. color: #FFFFFF;
  222. font-size: 20rpx;
  223. padding: 4rpx 10rpx;
  224. border-radius: 20rpx;
  225. margin-left: 16rpx;
  226. }
  227. }
  228. }
  229. }
  230. .review-content {
  231. background-color: #FFFFFF;
  232. padding: 30rpx;
  233. border-radius: 16rpx 16rpx 0 0;
  234. margin-top: 20rpx;
  235. .review-item {
  236. margin-bottom: 40rpx;
  237. .review-label {
  238. font-size: 28rpx;
  239. color: #333;
  240. margin-bottom: 20rpx;
  241. display: block;
  242. font-weight: bold;
  243. }
  244. .review-stars {
  245. display: flex;
  246. align-items: center;
  247. }
  248. .review-textarea-box {
  249. position: relative;
  250. .review-textarea {
  251. width: 100%;
  252. height: 200rpx;
  253. background-color: #F7F7F7;
  254. border-radius: 12rpx;
  255. padding: 20rpx;
  256. font-size: 28rpx;
  257. color: #666;
  258. box-sizing: border-box;
  259. }
  260. .word-count {
  261. position: absolute;
  262. bottom: 10rpx;
  263. right: 20rpx;
  264. font-size: 24rpx;
  265. color: #999;
  266. }
  267. }
  268. }
  269. }
  270. .review-footer {
  271. position: fixed;
  272. bottom: 0;
  273. left: 0;
  274. right: 0;
  275. background-color: #FFFFFF;
  276. padding: 20rpx 30rpx;
  277. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  278. .submit-btn {
  279. background-color: #FFAA48;
  280. color: #FFFFFF;
  281. height: 88rpx;
  282. line-height: 88rpx;
  283. border-radius: 44rpx;
  284. text-align: center;
  285. font-size: 32rpx;
  286. font-weight: bold;
  287. box-shadow: 0 4rpx 8rpx rgba(255, 170, 72, 0.3);
  288. }
  289. }
  290. </style>