add-comment.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <!-- 添加评论 -->
  2. <template>
  3. <view class="commont-from-wrap">
  4. <!-- 评价商品 -->
  5. <view class="goods-card">
  6. <shopro-mini-card :title="goodsDetail.goods_title" :image="goodsDetail.goods_image">
  7. <template #describe>
  8. <view class="order-sku u-ellipsis-1">
  9. <text class="order-num">数量:{{ goodsDetail.goods_num || 0 }};</text>
  10. {{ goodsDetail.goods_sku_text ? goodsDetail.goods_sku_text : '' }}
  11. </view>
  12. </template>
  13. <template #cardBottom>
  14. <view class="order-price-box u-flex ">
  15. <text class="order-price font-OPPOSANS">¥{{ goodsDetail.goods_price || 0 }}</text>
  16. <button class="u-reset-button status-btn" v-if="goodsDetail.status_name">{{ goodsDetail.status_name }}</button>
  17. </view>
  18. </template>
  19. </shopro-mini-card>
  20. </view>
  21. <view class="form-item">
  22. <view class="star-box u-flex">
  23. <view class="star-title u-m-r-40">{{ starTip }}</view>
  24. <u-rate v-model="star" minCount="1"></u-rate>
  25. </view>
  26. <view class="area-box">
  27. <textarea class="inp-area" v-model="message" placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~" placeholder-class="pl-style" />
  28. <view class="img-box">
  29. <u-upload
  30. :showProgress="false"
  31. @on-uploaded="uploadSuccess"
  32. @on-remove="uploadRemove"
  33. :action="`${$API_URL}index/upload`"
  34. width="138"
  35. height="138"
  36. maxCount="9"
  37. ></u-upload>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="foot_box u-flex u-row-center u-col-center u-m-t-60"><button class="u-reset-button post-btn" @tap="subComment">发布</button></view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. components: {},
  47. data() {
  48. return {
  49. imgList: [],
  50. star: 5,
  51. message: '',
  52. goodsDetail: {}
  53. };
  54. },
  55. computed: {
  56. starTip() {
  57. let text = '';
  58. if (this.star <= 1) {
  59. text = '差评';
  60. }
  61. if (this.star > 1 && this.star <= 3) {
  62. text = '中评';
  63. }
  64. if (this.star >= 4) {
  65. text = '好评';
  66. }
  67. return text;
  68. }
  69. },
  70. onLoad() {
  71. this.getOrderItemDetail();
  72. },
  73. methods: {
  74. // 订单详情
  75. getOrderItemDetail() {
  76. let that = this;
  77. that.$http('order.itemDetail', {
  78. id: that.$Route.query.orderId,
  79. order_item_id: that.$Route.query.orderItemId
  80. }).then(res => {
  81. if (res.code === 1) {
  82. that.goodsDetail = res.data;
  83. }
  84. });
  85. },
  86. // 上传图片成功
  87. uploadSuccess(e) {
  88. this.imgList = [];
  89. e.forEach(item => {
  90. this.imgList.push(item.response.data.url);
  91. });
  92. },
  93. // 移除图片
  94. uploadRemove(index) {
  95. this.imgList.splice(index, 1);
  96. },
  97. subComment() {
  98. let that = this;
  99. that.$http('order.comment', {
  100. id: that.$Route.query.orderId,
  101. order_item_id: that.goodsDetail.id,
  102. level: that.star,
  103. content: that.message,
  104. images: that.imgList
  105. }, '提交中...').then(res => {
  106. if (res.code === 1) {
  107. that.$u.toast('评论发表成功');
  108. that.$Router.back();
  109. }
  110. });
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss">
  116. // 评价商品
  117. .goods-card {
  118. margin: 10rpx 0;
  119. padding: 20rpx;
  120. background: #fff;
  121. .order-sku {
  122. font-size: 24rpx;
  123. font-weight: 400;
  124. color: rgba(153, 153, 153, 1);
  125. width: 450rpx;
  126. margin-bottom: 20rpx;
  127. .order-num {
  128. margin-right: 10rpx;
  129. }
  130. }
  131. .order-price-box {
  132. .status-btn {
  133. height: 32rpx;
  134. border: 1rpx solid rgba(207, 169, 114, 1);
  135. border-radius: 15rpx;
  136. font-size: 20rpx;
  137. font-weight: 400;
  138. color: rgba(168, 112, 13, 1);
  139. padding: 0 10rpx;
  140. margin-left: 20rpx;
  141. background: rgba(233, 183, 102, 0.16);
  142. }
  143. .order-price {
  144. font-size: 26rpx;
  145. font-weight: 600;
  146. color: rgba(51, 51, 51, 1);
  147. }
  148. }
  149. }
  150. // 评论,选择图片
  151. .form-item {
  152. background: #ffff;
  153. padding-bottom: 30rpx;
  154. .star-box {
  155. height: 100rpx;
  156. padding: 0 25rpx;
  157. }
  158. .star-title {
  159. font-weight: 600;
  160. }
  161. }
  162. .area-box {
  163. width: 690rpx;
  164. min-height: 306rpx;
  165. background: rgba(249, 250, 251, 1);
  166. border-radius: 20rpx;
  167. padding: 28rpx;
  168. margin: auto;
  169. .pl-style {
  170. font-size: 26rpx;
  171. font-weight: 400;
  172. color: rgba(153, 153, 153, 1);
  173. line-height: 42rpx;
  174. }
  175. .inp-area {
  176. font-size: 26rpx;
  177. font-weight: 500;
  178. color: #333;
  179. line-height: 50rpx;
  180. width: 100%;
  181. }
  182. .img-box {
  183. display: flex;
  184. align-items: center;
  185. flex-wrap: wrap;
  186. margin-top: 20rpx;
  187. }
  188. }
  189. .post-btn {
  190. width: 690rpx;
  191. line-height: 80rpx;
  192. background: linear-gradient(90deg, rgba(240, 199, 133, 1), rgba(246, 214, 157, 1));
  193. border-radius: 40rpx;
  194. color: rgba(#fff, 0.9);
  195. margin-bottom: 30rpx;
  196. }
  197. </style>