add.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!-- 评价 -->
  2. <template>
  3. <s-layout title="评价">
  4. <view>
  5. <view v-for="(item, index) in state.orderInfo.items" :key="item.id">
  6. <view v-if="item.btns.includes('comment')">
  7. <view class="commont-from-wrap">
  8. <!-- 评价商品 -->
  9. <s-goods-item
  10. :img="item.goods_image"
  11. :title="item.goods_title"
  12. :skuText="item.goods_sku_text"
  13. :price="item.goods_price"
  14. :num="item.goods_num"
  15. ></s-goods-item>
  16. </view>
  17. <view class="form-item">
  18. <!-- 评分 -->
  19. <view class="star-box ss-flex ss-col-center">
  20. <view class="star-title ss-m-r-40">
  21. {{ rateMap[state.commentList[index].level] }}
  22. </view>
  23. <uni-rate v-model="state.commentList[index].level" />
  24. </view>
  25. <!-- 评价 -->
  26. <view class="area-box">
  27. <uni-easyinput
  28. :inputBorder="false"
  29. type="textarea"
  30. maxlength="120"
  31. autoHeight
  32. v-model="state.commentList[index].content"
  33. placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~"
  34. ></uni-easyinput>
  35. <view class="img-box">
  36. <s-uploader
  37. v-model:url="state.commentList[index].images"
  38. fileMediatype="image"
  39. limit="9"
  40. mode="grid"
  41. :imageStyles="{ width: '168rpx', height: '168rpx' }"
  42. />
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <su-fixed bottom placeholder>
  50. <view class="foot_box ss-flex ss-row-center ss-col-center">
  51. <button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
  52. 发布
  53. </button>
  54. </view>
  55. </su-fixed>
  56. </s-layout>
  57. </template>
  58. <script setup>
  59. import sheep from '@/sheep';
  60. import { onLoad } from '@dcloudio/uni-app';
  61. import { computed, reactive } from 'vue';
  62. const state = reactive({
  63. orderInfo: {},
  64. commentList: [],
  65. });
  66. const rateMap = {
  67. 1: '糟糕',
  68. 2: '差评',
  69. 3: '一般',
  70. 4: '良好',
  71. 5: '好评',
  72. };
  73. async function onSubmit() {
  74. const { error } = await sheep.$api.order.comment(state.orderInfo.id, {
  75. comments: state.commentList,
  76. });
  77. if (error === 0) {
  78. sheep.$router.back();
  79. }
  80. }
  81. onLoad(async (options) => {
  82. let id = '';
  83. if (options.orderSN) {
  84. id = options.orderSN;
  85. }
  86. if (options.id) {
  87. id = options.id;
  88. }
  89. const { data, error } = await sheep.$api.order.detail(id);
  90. if (error === 0) {
  91. if (data.btns.includes('comment')) {
  92. state.orderInfo = data;
  93. state.orderInfo.items.forEach((item) => {
  94. if (item.btns.includes('comment')) {
  95. state.commentList.push({
  96. item_id: item.id,
  97. level: 5,
  98. content: '',
  99. images: [],
  100. });
  101. }
  102. });
  103. return;
  104. }
  105. }
  106. sheep.$helper.toast('无待评价订单');
  107. });
  108. </script>
  109. <style lang="scss" scoped>
  110. // 评价商品
  111. .goods-card {
  112. margin: 10rpx 0;
  113. padding: 20rpx;
  114. background: #fff;
  115. }
  116. // 评论,选择图片
  117. .form-item {
  118. background: #fff;
  119. .star-box {
  120. height: 100rpx;
  121. padding: 0 25rpx;
  122. }
  123. .star-title {
  124. font-weight: 600;
  125. }
  126. }
  127. .area-box {
  128. width: 690rpx;
  129. min-height: 306rpx;
  130. background: rgba(249, 250, 251, 1);
  131. border-radius: 20rpx;
  132. padding: 28rpx;
  133. margin: auto;
  134. .img-box {
  135. margin-top: 20rpx;
  136. }
  137. }
  138. .post-btn {
  139. width: 690rpx;
  140. line-height: 80rpx;
  141. border-radius: 40rpx;
  142. color: rgba(#fff, 0.9);
  143. margin-bottom: 20rpx;
  144. }
  145. </style>