add.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!-- 评价 -->
  2. <template>
  3. <s-layout title="评价">
  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">商品质量</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">服务态度</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="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~" />
  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. 发布
  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. const state = reactive({
  58. orderInfo: {},
  59. commentList: [],
  60. id: null
  61. });
  62. async function onSubmit() {
  63. uni.showModal({
  64. title: '提示',
  65. content: '是否评论?',
  66. success: async function(res) {
  67. if (!res.confirm) {
  68. return;
  69. }
  70. // 顺序提交评论
  71. for (const comment of state.commentList) {
  72. await OrderApi.createOrderItemComment(comment);
  73. }
  74. // 都评论好,返回
  75. sheep.$router.back();
  76. },
  77. });
  78. }
  79. onLoad(async (options) => {
  80. if (!options.id) {
  81. sheep.$helper.toast(`缺少订单信息,请检查`);
  82. return
  83. }
  84. state.id = options.id;
  85. const {
  86. code,
  87. data
  88. } = await OrderApi.getOrder(state.id);
  89. if (code !== 0) {
  90. sheep.$helper.toast('无待评价订单');
  91. return
  92. }
  93. // 处理评论
  94. data.items.forEach((item) => {
  95. state.commentList.push({
  96. anonymous: false,
  97. orderItemId: item.id,
  98. descriptionScores: 5,
  99. benefitScores: 5,
  100. content: '',
  101. picUrls: []
  102. });
  103. });
  104. state.orderInfo = data;
  105. });
  106. </script>
  107. <style lang="scss" scoped>
  108. // 评价商品
  109. .goods-card {
  110. margin: 10rpx 0;
  111. padding: 20rpx;
  112. background: #fff;
  113. }
  114. // 评论,选择图片
  115. .form-item {
  116. background: #fff;
  117. .star-box {
  118. height: 100rpx;
  119. padding: 0 25rpx;
  120. }
  121. .star-title {
  122. font-weight: 600;
  123. }
  124. }
  125. .area-box {
  126. width: 690rpx;
  127. min-height: 306rpx;
  128. background: rgba(249, 250, 251, 1);
  129. border-radius: 20rpx;
  130. padding: 28rpx;
  131. margin: auto;
  132. .img-box {
  133. margin-top: 20rpx;
  134. }
  135. }
  136. .post-btn {
  137. width: 690rpx;
  138. line-height: 80rpx;
  139. border-radius: 40rpx;
  140. color: rgba(#fff, 0.9);
  141. margin-bottom: 20rpx;
  142. }
  143. </style>