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.

307 lines
6.2 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" 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.isOfficial">
  14. <text>初级伴宠师</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. export default {
  65. data() {
  66. return {
  67. orderId: null,
  68. rating: 5,
  69. reviewContent: '',
  70. companion: {
  71. name: '宠小二',
  72. avatar: '/static/images/personal/pet.png',
  73. isOfficial: true,
  74. gender: '女生'
  75. }
  76. };
  77. },
  78. onLoad(options) {
  79. if (options.id) {
  80. this.orderId = options.id;
  81. this.getOrderInfo();
  82. }
  83. },
  84. methods: {
  85. // 获取订单信息
  86. getOrderInfo() {
  87. // 实际项目中应调用API获取订单详情和伴宠师信息
  88. // 示例代码:
  89. /*
  90. const params = {
  91. openId: getOpenIdKey(),
  92. orderId: this.orderId
  93. };
  94. getOrderDetail(params).then(res => {
  95. if (res && res.code === 200) {
  96. this.companion = res.data.companion;
  97. }
  98. }).catch(err => {
  99. console.error('获取订单详情失败', err);
  100. });
  101. */
  102. // 这里使用模拟数据
  103. console.log('获取订单详情,ID:', this.orderId);
  104. },
  105. // 评分变化
  106. ratingChange(e) {
  107. this.rating = e.value;
  108. },
  109. // 提交评价
  110. submitReview() {
  111. if (this.rating === 0) {
  112. uni.showToast({
  113. title: '请选择评分',
  114. icon: 'none'
  115. });
  116. return;
  117. }
  118. if (!this.reviewContent.trim()) {
  119. uni.showToast({
  120. title: '请输入评价内容',
  121. icon: 'none'
  122. });
  123. return;
  124. }
  125. // 实际项目中应调用API提交评价
  126. // 示例代码:
  127. /*
  128. const params = {
  129. openId: getOpenIdKey(),
  130. orderId: this.orderId,
  131. rating: this.rating,
  132. content: this.reviewContent
  133. };
  134. submitOrderReview(params).then(res => {
  135. if (res && res.code === 200) {
  136. uni.showToast({
  137. title: '评价成功',
  138. icon: 'success'
  139. });
  140. // 评价成功后返回订单列表页
  141. setTimeout(() => {
  142. uni.navigateBack();
  143. }, 1500);
  144. }
  145. }).catch(err => {
  146. console.error('提交评价失败', err);
  147. });
  148. */
  149. // 这里使用模拟数据,显示评价成功提示
  150. uni.showToast({
  151. title: '评价成功',
  152. icon: 'success'
  153. });
  154. // 1.5秒后返回订单列表页
  155. setTimeout(() => {
  156. uni.navigateBack();
  157. }, 1500);
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .order-review-page {
  164. background: linear-gradient(180deg, #FFBF60 0%, #FFF5E6 20%, #FFFFFF 50%);
  165. min-height: 100vh;
  166. display: flex;
  167. flex-direction: column;
  168. padding-bottom: 120rpx;
  169. }
  170. .companion-info-card {
  171. padding: 30rpx;
  172. margin-bottom: 20rpx;
  173. background-color: transparent;
  174. .profile-header {
  175. display: flex;
  176. align-items: center;
  177. }
  178. .companion-avatar {
  179. width: 100rpx;
  180. height: 100rpx;
  181. border-radius: 50%;
  182. overflow: hidden;
  183. margin-right: 20rpx;
  184. border: 2rpx solid #FFFFFF;
  185. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  186. image {
  187. width: 100%;
  188. height: 100%;
  189. }
  190. }
  191. .companion-detail {
  192. flex: 1;
  193. .companion-name {
  194. display: flex;
  195. align-items: center;
  196. font-size: 32rpx;
  197. font-weight: bold;
  198. color: #333;
  199. .gender-icon {
  200. width: 32rpx;
  201. height: 32rpx;
  202. margin-left: 10rpx;
  203. }
  204. .companion-tag {
  205. background-color: #FF9500;
  206. color: #FFFFFF;
  207. font-size: 20rpx;
  208. padding: 4rpx 10rpx;
  209. border-radius: 20rpx;
  210. margin-left: 16rpx;
  211. }
  212. }
  213. }
  214. }
  215. .review-content {
  216. background-color: #FFFFFF;
  217. padding: 30rpx;
  218. border-radius: 16rpx 16rpx 0 0;
  219. margin-top: 20rpx;
  220. .review-item {
  221. margin-bottom: 40rpx;
  222. .review-label {
  223. font-size: 28rpx;
  224. color: #333;
  225. margin-bottom: 20rpx;
  226. display: block;
  227. font-weight: bold;
  228. }
  229. .review-stars {
  230. display: flex;
  231. align-items: center;
  232. }
  233. .review-textarea-box {
  234. position: relative;
  235. .review-textarea {
  236. width: 100%;
  237. height: 200rpx;
  238. background-color: #F7F7F7;
  239. border-radius: 12rpx;
  240. padding: 20rpx;
  241. font-size: 28rpx;
  242. color: #666;
  243. box-sizing: border-box;
  244. }
  245. .word-count {
  246. position: absolute;
  247. bottom: 10rpx;
  248. right: 20rpx;
  249. font-size: 24rpx;
  250. color: #999;
  251. }
  252. }
  253. }
  254. }
  255. .review-footer {
  256. position: fixed;
  257. bottom: 0;
  258. left: 0;
  259. right: 0;
  260. background-color: #FFFFFF;
  261. padding: 20rpx 30rpx;
  262. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  263. .submit-btn {
  264. background-color: #FFAA48;
  265. color: #FFFFFF;
  266. height: 88rpx;
  267. line-height: 88rpx;
  268. border-radius: 44rpx;
  269. text-align: center;
  270. font-size: 32rpx;
  271. font-weight: bold;
  272. box-shadow: 0 4rpx 8rpx rgba(255, 170, 72, 0.3);
  273. }
  274. }
  275. </style>