detail.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div id="form-1">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <el-col class="top-btn">
  6. <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
  7. </el-col>
  8. <el-col :span="24" v-if="total == 0">
  9. <el-empty description="该商品暂无评价"></el-empty>
  10. </el-col>
  11. <el-col :span="24" class="one" v-else-if="!total == 0">
  12. <el-col :span="24" class="one_2">
  13. <el-col :span="24" class="cont" v-for="(item, index) in list" :key="index">
  14. <el-col :span="3" class="name">
  15. <el-image class="icon" :src="item.customer.icon[0].url"></el-image>
  16. <el-col>{{ item.customer.name }}</el-col>
  17. </el-col>
  18. <el-col :span="21">
  19. <el-col :span="24">
  20. <el-col :span="5">
  21. <el-col :span="8">商品评分:</el-col>
  22. <el-col :span="15"><el-rate v-model="item.goods_score" disabled score-template="{item.goods_score}" :colors="colors"> </el-rate></el-col>
  23. </el-col>
  24. <el-col :span="5">
  25. <el-col :span="8">店铺评分:</el-col>
  26. <el-col :span="15"><el-rate v-model="item.shop_score" disabled score-template="{item.shop_score}" :colors="colors"> </el-rate></el-col>
  27. </el-col>
  28. <el-col :span="5">
  29. <el-col :span="8">快递评分:</el-col>
  30. <el-col :span="15">
  31. <el-rate v-model="item.transport_score" disabled score-template="{item.transport_score}" :colors="colors"> </el-rate>
  32. </el-col>
  33. </el-col>
  34. </el-col>
  35. <el-col>已购规格:{{ item.goodsSpec.name }}</el-col>
  36. <el-col v-for="(replys, index) in item.reply" :key="index">
  37. <el-col :span="22" class="rate">买家评价: {{ replys.content }}</el-col>
  38. <el-col v-for="(file, index) in replys.file" :key="index" :span="3">
  39. <el-image :src="file.url" class="image" :preview-src-list="replys.url"></el-image>
  40. </el-col>
  41. <el-col :span="22" class="rates">商家回复:{{ replys.reply }}</el-col>
  42. <el-col style="color: #999">{{ replys.time }}</el-col>
  43. </el-col>
  44. </el-col>
  45. </el-col>
  46. </el-col>
  47. <el-col :span="24" class="pag">
  48. <el-pagination
  49. @current-change="currentChange"
  50. :current-page.sync="skip"
  51. :page-size="limit"
  52. background
  53. layout="total, prev, pager, next"
  54. :total="total"
  55. >
  56. </el-pagination>
  57. </el-col>
  58. </el-col>
  59. </el-col>
  60. </el-row>
  61. </div>
  62. </template>
  63. <script>
  64. const _ = require('lodash');
  65. const moment = require('moment');
  66. import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
  67. const { mapActions } = createNamespacedHelpers('goodsRate');
  68. export default {
  69. name: 'form-1',
  70. props: {},
  71. components: {},
  72. data: function () {
  73. return {
  74. list: [],
  75. goods: {},
  76. skip: 1,
  77. total: 0,
  78. limit: 5,
  79. // 评分颜色
  80. colors: ['#99A9BF', '#F7BA2A', '#FF0000'],
  81. };
  82. },
  83. async created() {
  84. await this.search();
  85. },
  86. methods: {
  87. ...mapActions(['query', 'fetch', 'create', 'update']),
  88. // 查询
  89. async search({ skip = 0, limit = 5, ...info } = {}) {
  90. info.goods = this.id;
  91. let res;
  92. res = await this.query({ skip, limit, ...info });
  93. if (this.$checkRes(res)) {
  94. for (const p1 of res.data) {
  95. for (const p2 of p1.reply) {
  96. let url = [];
  97. if (p2.file) {
  98. for (const p3 of p2.file) {
  99. url.push(p3.url);
  100. }
  101. p2.url = url;
  102. }
  103. }
  104. }
  105. this.$set(this, 'list', res.data);
  106. this.$set(this, 'total', res.total);
  107. }
  108. },
  109. // 分页
  110. currentChange(val) {
  111. this.search({ skip: (val - 1) * this.limit });
  112. },
  113. // 返回
  114. toBack() {
  115. window.history.go('-1');
  116. },
  117. },
  118. computed: {
  119. id() {
  120. return this.$route.query.id;
  121. },
  122. },
  123. metaInfo() {
  124. return { title: this.$route.meta.title };
  125. },
  126. watch: {
  127. test: {
  128. deep: true,
  129. immediate: true,
  130. handler(val) {},
  131. },
  132. },
  133. };
  134. </script>
  135. <style lang="less" scoped>
  136. .el-col {
  137. margin: 2px 0;
  138. }
  139. .one {
  140. margin: 20px 0 0 0;
  141. .one_1 {
  142. margin: 15px 0;
  143. padding: 10px;
  144. }
  145. .one_2 {
  146. border: 1px solid #ccc;
  147. padding: 10px;
  148. .cont {
  149. border-bottom: 1px solid rgb(238, 237, 237);
  150. margin: 10px 0;
  151. padding: 0 10px 10px 10px;
  152. .name {
  153. text-align: center;
  154. .icon {
  155. border-radius: 50%;
  156. width: 100px;
  157. height: 100px;
  158. }
  159. }
  160. .image {
  161. width: 100px;
  162. height: 100px;
  163. border: 1px solid #ccc;
  164. }
  165. .rate {
  166. width: 91%;
  167. color: red;
  168. word-break: break-all;
  169. }
  170. .rates {
  171. width: 91%;
  172. word-break: break-all;
  173. }
  174. .btn {
  175. margin: 8px 15px;
  176. }
  177. }
  178. }
  179. .pag {
  180. text-align: right;
  181. margin: 10px 0;
  182. }
  183. }
  184. </style>