index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <!-- 评价列表 -->
  3. <view>
  4. <scroll-view ref="scroll" scroll-x="true" class="scroll w-690 mt-24 pl-20" show-scrollbar="true" @scroll="scroll">
  5. <view id="scrollBox" ref="scrollBox" class="scrll-box">
  6. <view class="inline-block mr-20" v-for="item in reply" :key="item.id" @click.stop="details(item)">
  7. <view class="h-192 rd-16rpx bg--w111-f5f5f5 flex justify-between">
  8. <view class="flex-1 p-24">
  9. <view class="flex-y-center">
  10. <image class="w-64 h-64 rd-50-p111-" :src="item.avatar" mode="aspectFill"></image>
  11. <view class="flex-col pl-16">
  12. <text class="text--w111-333 fs-24">{{ item.nickname }}</text>
  13. <view class="flex">
  14. <text class="iconfont icon-ic_star1 fs-18 text-primary-con" v-for="star in Number(item.star)" :key="star"></text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="w-324 mt-12 text--w111-333 fs-24 break_word line2">{{ item.comment }}</view>
  19. </view>
  20. <image v-if="item.pics.length" class="w-192 h-192 rd-16rpx" :src="item.pics[0]"></image>
  21. </view>
  22. </view>
  23. </view>
  24. </scroll-view>
  25. <view class="flex-center mt-24" v-if="reply.length > 1">
  26. <view class="w-64 h-6 rd-3px bg--w111-eee scrpll-l">
  27. <view class="w-32 h-6 rd-3px scrpll-line" :style="{ left: srollLeft + '%' }"></view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { mapGetters } from 'vuex';
  34. import { getReplyPraise, getUnReplyPraise } from '@/api/store.js';
  35. export default {
  36. computed: mapGetters(['isLogin']),
  37. props: {
  38. reply: {
  39. type: Array,
  40. default: () => []
  41. },
  42. fromTo: {
  43. type: Number,
  44. default: 0
  45. }
  46. },
  47. data() {
  48. return {
  49. srollLeft: 0, // 距离左边
  50. srollBoxWidth: 0, //内部宽度
  51. boxWidth: 0 //容器宽度
  52. };
  53. },
  54. mounted() {
  55. this.$nextTick((e) => {
  56. this.srollLeft = 0;
  57. const query = wx.createSelectorQuery().in(this);
  58. query
  59. .select('.scrll-box')
  60. .boundingClientRect((res) => {
  61. this.srollBoxWidth = res.width;
  62. })
  63. .exec();
  64. query
  65. .select('.scroll')
  66. .boundingClientRect((res) => {
  67. this.boxWidth = res.width - 10;
  68. })
  69. .exec();
  70. });
  71. },
  72. methods: {
  73. scroll(e) {
  74. this.srollLeft = ((e.detail.scrollLeft / (this.srollBoxWidth - this.boxWidth)) * 100).toFixed(0) / 2;
  75. },
  76. details(item) {
  77. if (this.isLogin) {
  78. uni.navigateTo({
  79. url: '/pages/goods/goods_comment_con/comment_con?id=' + item.id
  80. });
  81. } else {
  82. this.$emit('changeLogin');
  83. }
  84. },
  85. getpreviewImage: function (indexw, indexn) {
  86. uni.previewImage({
  87. urls: this.reply[indexw].pics,
  88. current: this.reply[indexw].pics[indexn]
  89. });
  90. },
  91. praise(item, indexw) {
  92. if (this.isLogin) {
  93. if (item.is_praise) {
  94. getUnReplyPraise(item.id).then((res) => {
  95. item.is_praise = !item.is_praise;
  96. item.praise = item.praise - 1;
  97. this.$emit('replyFun', this.reply);
  98. return this.$util.Tips({
  99. title: res.msg
  100. });
  101. });
  102. } else {
  103. getReplyPraise(item.id).then((res) => {
  104. item.is_praise = !item.is_praise;
  105. item.praise = item.praise + 1;
  106. this.$emit('replyFun', this.reply);
  107. return this.$util.Tips({
  108. title: res.msg
  109. });
  110. });
  111. }
  112. } else {
  113. this.$emit('changeLogin');
  114. }
  115. }
  116. }
  117. };
  118. </script>
  119. <style lang="scss">
  120. .scrll-box {
  121. display: flex;
  122. flex-wrap: nowrap;
  123. width: max-content;
  124. }
  125. .scrpll-l {
  126. position: relative;
  127. }
  128. .scrpll-line {
  129. position: absolute;
  130. background-color: var(--view-theme);
  131. left: 0;
  132. top: 0;
  133. }
  134. .text-primary-con {
  135. color: var(--view-theme);
  136. }
  137. </style>