add.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!-- 评价 -->
  2. <template>
  3. <s-layout :title="t('order.review_order')">
  4. <view>
  5. <view v-for="(item, index) in state.orderInfo.items" :key="item.id">
  6. <view>
  7. <view class="commont-from-wrap">
  8. <!-- 评价商品 -->
  9. <s-goods-item :img="item.picUrl" :title="item.spuName"
  10. :skuText="item.properties.map((property) => property.valueName).join(' ')"
  11. :price="item.payPrice" :num="item.count" />
  12. </view>
  13. <view class="form-item">
  14. <!-- 评分 -->
  15. <view class="star-box ss-flex ss-col-center">
  16. <view class="star-title ss-m-r-40">{{ t('order.product_quality') }}</view>
  17. <uni-rate v-model="state.commentList[index].descriptionScores" />
  18. </view>
  19. <view class="star-box ss-flex ss-col-center">
  20. <view class="star-title ss-m-r-40">{{ t('order.service_attitude') }}</view>
  21. <uni-rate v-model="state.commentList[index].benefitScores" />
  22. </view>
  23. <!-- 评价 -->
  24. <view class="area-box">
  25. <uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight
  26. v-model="state.commentList[index].content"
  27. :placeholder="t('order.meet_expectations')" />
  28. <!-- TODO 非繁人:文件上传 -->
  29. <view class="img-box">
  30. <s-uploader v-model:url="state.commentList[index].picUrls" fileMediatype="image"
  31. limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" />
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- TODO 非繁人:是否匿名 -->
  39. <su-fixed bottom placeholder>
  40. <view class="foot_box ss-flex ss-row-center ss-col-center">
  41. <button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
  42. {{ t('common.post') }}
  43. </button>
  44. </view>
  45. </su-fixed>
  46. </s-layout>
  47. </template>
  48. <script setup>
  49. import sheep from '@/sheep';
  50. import {
  51. onLoad
  52. } from '@dcloudio/uni-app';
  53. import {
  54. reactive
  55. } from 'vue';
  56. import OrderApi from '@/sheep/api/trade/order';
  57. import { t } from '@/locale'
  58. const state = reactive({
  59. orderInfo: {},
  60. commentList: [],
  61. id: null
  62. });
  63. async function onSubmit() {
  64. uni.showModal({
  65. title: t('setting.prompt'),
  66. content: t('order.confirm_post_review'),
  67. success: async function(res) {
  68. if (!res.confirm) {
  69. return;
  70. }
  71. // 顺序提交评论
  72. for (const comment of state.commentList) {
  73. await OrderApi.createOrderItemComment(comment);
  74. }
  75. // 都评论好,返回
  76. sheep.$router.back();
  77. },
  78. });
  79. }
  80. onLoad(async (options) => {
  81. if (!options.id) {
  82. sheep.$helper.toast(t('order.missing_order_info'));
  83. return
  84. }
  85. state.id = options.id;
  86. const {
  87. code,
  88. data
  89. } = await OrderApi.getOrder(state.id);
  90. if (code !== 0) {
  91. sheep.$helper.toast(t('order.no_reviews_pending'));
  92. return
  93. }
  94. // 处理评论
  95. data.items.forEach((item) => {
  96. state.commentList.push({
  97. anonymous: false,
  98. orderItemId: item.id,
  99. descriptionScores: 5,
  100. benefitScores: 5,
  101. content: '',
  102. picUrls: []
  103. });
  104. });
  105. state.orderInfo = data;
  106. });
  107. </script>
  108. <style lang="scss" scoped>
  109. // 评价商品
  110. .goods-card {
  111. margin: 10rpx 0;
  112. padding: 20rpx;
  113. background: #fff;
  114. }
  115. // 评论,选择图片
  116. .form-item {
  117. background: #fff;
  118. .star-box {
  119. height: 100rpx;
  120. padding: 0 25rpx;
  121. }
  122. .star-title {
  123. font-weight: 600;
  124. }
  125. }
  126. .area-box {
  127. width: 690rpx;
  128. min-height: 306rpx;
  129. background: rgba(249, 250, 251, 1);
  130. border-radius: 20rpx;
  131. padding: 28rpx;
  132. margin: auto;
  133. .img-box {
  134. margin-top: 20rpx;
  135. }
  136. }
  137. .post-btn {
  138. width: 690rpx;
  139. line-height: 80rpx;
  140. border-radius: 40rpx;
  141. color: rgba(#fff, 0.9);
  142. margin-bottom: 20rpx;
  143. }
  144. </style>