evaluation.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <!-- 商品评价页面 -->
  2. <template>
  3. <view class="evaluation" v-if="statistics">
  4. <!-- 商品评价数量 start -->
  5. <view class="evaluation_num">
  6. <view class="evaluation_title">
  7. <view class="evaluation_title_left">
  8. {{$L('商品评价')}}<text>({{statistics.commentsCount}})</text>
  9. </view>
  10. <view class="evaluation_title_right">
  11. {{$L('好评率')}}<text>{{statistics.highPercent}}</text>
  12. </view>
  13. </view>
  14. <view class="evaluation_con">
  15. <view class="evaluation_nav_pre" :class="{active:curnav == 0 || !curnav}" @click="getEvaluation('',0)">
  16. {{$L('全部')}}({{statistics.commentsCount?statistics.commentsCount:0}})
  17. </view>
  18. <view class="evaluation_nav_pre" :class="{active:curnav == 1}" @click="getEvaluation('hasPic',1)">
  19. {{$L('有图')}}({{statistics.hasPicCount?statistics.hasPicCount:0}})
  20. </view>
  21. <view class="evaluation_nav_pre" :class="{active:curnav == 2}" @click="getEvaluation('high',2)">
  22. {{$L('好评')}}({{statistics.highCount?statistics.highCount:0}})
  23. </view>
  24. <view class="evaluation_nav_pre" :class="{active:curnav == 3}" @click="getEvaluation('middle',3)">
  25. {{$L('中评')}}({{statistics.middleCount?statistics.middleCount:0}})
  26. </view>
  27. <view class="evaluation_nav_pre" :class="{active:curnav == 4}" @click="getEvaluation('low',4)">
  28. {{$L('差评')}}({{statistics.lowCount?statistics.lowCount:0}})
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 商品评价数量 end -->
  33. <!-- 商品评价列表 start -->
  34. <view class="evaluation_list" v-if="evaluationList.length > 0">
  35. <view class="evaluation_pre" v-for="(item,index) in evaluationList" :key="index">
  36. <view class="evaluation_pre_top">
  37. <view class="evaluation_pre_avator">
  38. <image :src="item.memberAvatar" mode="aspectFill"></image>
  39. </view>
  40. <view class="evaluation_pre_name">
  41. {{filters.toAnonymous(item.memberName)}}
  42. </view>
  43. <!-- 只读状态 -->
  44. <uni-rate :readonly="true" :value="item.score" active-color="red" disabledColor="#ccc" :size="18"/>
  45. </view>
  46. <view class="evaluation_pre_time">{{item.createTime}} {{item.specValues}}</view>
  47. <view class="evaluation_des" v-if="item.content">{{item.content}}</view>
  48. <text class="evaluation_des" v-else>{{item.score>=4? $L("好评"):(item.score<2? $L("差评"): $L("中评"))}}</text>
  49. <view class="evaluation_pre_images">
  50. <image :src="item1" mode="aspectFill" @click="previewImg(item.images,item1,$event)" v-for="(item1,index1) in item.images" :key="index1"></image>
  51. </view>
  52. <view class="business_reply" v-if="item.replyContent">
  53. <view class="business_reply_tips">{{$L('商家回复')}}</view>
  54. <view class="business_reply_content">{{item.replyContent}}</view>
  55. </view>
  56. </view>
  57. <loadingState v-if="loadingState == 'first_loading'||evaluationList.length > 0" :state='loadingState' />
  58. </view>
  59. <view class="no_data" v-if="evaluationList.length == 0&&!loading">
  60. <image :src="imgUrl + '/empty_evaluate.png'" mode=""></image>
  61. <text>{{$L('该商品暂无评价')}}</text>
  62. </view>
  63. <!-- 商品评价列表 end -->
  64. </view>
  65. </template>
  66. <script module="filters" lang="wxs" src="../../utils/filter.wxs"></script>
  67. <script>
  68. import uniEvaluate from '../../components/xiujun-evaluate/uni-evaluate.vue';
  69. import loadingState from "@/components/loading-state.vue";
  70. import {
  71. mapState
  72. } from 'vuex';
  73. export default {
  74. components: {
  75. uniEvaluate,
  76. loadingState
  77. },
  78. data() {
  79. return {
  80. current:1, //当前为第1页
  81. loadingState: 'first_loading',
  82. pageSize: 20,
  83. loading: false,//是否加载数据
  84. hasMore: true,//是否还有数据
  85. productId:'', //货品id
  86. statistics:{}, //商品评价信息
  87. evaluationList:[], //评价列表
  88. curnav:0, //评价默认显示全部
  89. imgUrl: getApp().globalData.imgUrl,
  90. loading:false
  91. };
  92. },
  93. computed: {
  94. ...mapState(['hasLogin', 'userInfo'])
  95. },
  96. async onLoad(options) {
  97. this.productId = options.productId; //货品id
  98. this.getEvaluation();
  99. },
  100. methods: {
  101. //获取评论信息
  102. getEvaluation(type,curnav){
  103. uni.showLoading({
  104. title:'加载中'
  105. })
  106. let that = this;
  107. that.curnav = curnav;
  108. that.loading=true
  109. let param = {};
  110. param.url = 'v3/goods/front/goods/comment';
  111. param.method = 'GET';
  112. param.data = {};
  113. param.data.productId = that.productId;
  114. param.data.pageSize = that.pageSize; //分页大小 默认 ==20
  115. param.data.current = that.current; //当前页面位置 默认 ==1
  116. param.data.type = type ? type : ''; //评价等级[(好评)high,(中评)middle,(差评)low],(有图)hasPic
  117. this.loadingState = this.loadingState == 'first_loading' ? this.loadingState : 'loading';
  118. this.$request(param).then(res => {
  119. if (res.state == 200) {
  120. this.statistics = res.data;
  121. if(this.current == 1){
  122. this.evaluationList = res.data.list;
  123. }else{
  124. this.evaluationList = this.evaluationList.concat(res.data.list);
  125. }
  126. this.hasMore = this.$checkPaginationHasMore(res.data.pagination);//是否还有数据
  127. if(this.hasMore){
  128. this.current++;
  129. this.loadingState = 'allow_loading_more';
  130. }else{
  131. this.loadingState = 'no_more_data';
  132. }
  133. that.loading=false
  134. uni.hideLoading()
  135. } else {
  136. that.loading=false
  137. uni.hideLoading()
  138. this.$api.msg(res.msg);
  139. }
  140. }).catch((e) => {
  141. //异常处理
  142. })
  143. },
  144. //触底
  145. onReachBottom(){
  146. if(this.hasMore){
  147. this.getEvaluation();
  148. }
  149. },
  150. //多张图片点击预览
  151. previewImg(images,curImg,e) {
  152. let src = curImg;
  153. let imgList = images;
  154. imgList && imgList.map((item,index)=>{
  155. imgList[index]= item
  156. })
  157. uni.previewImage({
  158. current:src,
  159. // 当前显示图片的http链接
  160. urls: imgList ,// 需要预览的图片http链接列表
  161. indicator: 'number',
  162. loop: true
  163. });
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. .evaluation{
  170. width: 750rpx;
  171. height: 100%;
  172. margin: 0 auto;
  173. .evaluation_num{
  174. border-top: 20rpx solid #F8F8F8;
  175. .evaluation_title{
  176. width: 100%;
  177. display: flex;
  178. justify-content: space-between;
  179. padding: 20rpx;
  180. box-sizing: border-box;
  181. align-items: center;
  182. .evaluation_title_left{
  183. font-size: 28rpx;
  184. font-family: PingFang SC;
  185. font-weight: 600;
  186. color: #333333;
  187. line-height: 45rpx;
  188. text{
  189. color: #949494;
  190. margin-left: 20rpx;
  191. font-weight: 400;
  192. }
  193. }
  194. .evaluation_title_right{
  195. font-size: 22rpx;
  196. font-family: PingFang SC;
  197. font-weight: 500;
  198. color: #949494;
  199. line-height: 45rpx;
  200. text{
  201. color: #333333;
  202. margin-left: 10rpx;
  203. }
  204. }
  205. }
  206. .evaluation_con{
  207. display: flex;
  208. flex-wrap: wrap;
  209. padding: 0 20rpx;
  210. box-sizing: border-box;
  211. .evaluation_nav_pre{
  212. width: 180rpx;
  213. height: 50rpx;
  214. background: #F5F5F5;
  215. border-radius: 25rpx;
  216. paddding:14rpx 37rpx;
  217. box-sizing: border-box;
  218. font-size: 24rpx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #333333;
  222. line-height: 50rpx;
  223. text-align: center;
  224. margin-right: 20rpx;
  225. margin-bottom: 20rpx;
  226. }
  227. .active{
  228. width: 180rpx;
  229. height: 50rpx;
  230. background: #FFF3F3;
  231. border-radius: 25rpx;
  232. font-size: 24rpx;
  233. font-family: PingFang SC;
  234. font-weight: 500;
  235. color: #FC4141;
  236. line-height: 50rpx;
  237. paddding:14rpx 37rpx;
  238. box-sizing: border-box;
  239. text-align: center;
  240. }
  241. }
  242. }
  243. .evaluation_list{
  244. border-top: 20rpx solid #F8F8F8;
  245. padding-bottom: 20rpx;
  246. .evaluation_pre{
  247. padding: 20rpx 20rpx 20rpx 20rpx;
  248. // margin-left: 20rpx;
  249. box-sizing: border-box;
  250. border-bottom: 1rpx solid #F5F5F5;
  251. .evaluation_pre_top{
  252. display: flex;
  253. align-items: center;
  254. .evaluation_pre_avator{
  255. width: 50rpx;
  256. height: 50rpx;
  257. border-radius: 50%;
  258. image{
  259. width: 50rpx;
  260. height: 50rpx;
  261. border-radius: 50%;
  262. }
  263. }
  264. .evaluation_pre_name{
  265. font-size: 26rpx;
  266. font-family: PingFang SC;
  267. font-weight: 500;
  268. color: #333333;
  269. line-height: 45rpx;
  270. margin: 0 20rpx;
  271. }
  272. }
  273. .evaluation_pre_time{
  274. font-size: 22rpx;
  275. font-family: PingFang SC;
  276. font-weight: 400;
  277. color: #949494;
  278. line-height: 39rpx;
  279. }
  280. .evaluation_des{
  281. width: 710rpx;
  282. font-size: 26rpx;
  283. font-family: PingFang SC;
  284. font-weight: 500;
  285. color: #333333;
  286. line-height: 39rpx;
  287. // text-overflow: -o-ellipsis-lastline;
  288. // overflow: hidden;
  289. // text-overflow: ellipsis;
  290. display: -webkit-box;
  291. // -webkit-line-clamp: 2;
  292. // line-clamp: 2;
  293. // -webkit-box-orient: vertical;
  294. // margin: 20rpx;
  295. padding: 20rpx 0;
  296. // max-height: 100rpx;
  297. }
  298. .evaluation_pre_images{
  299. width: 100%;
  300. display: flex;
  301. flex-wrap: wrap;
  302. image{
  303. width: 223rpx;
  304. height: 223rpx;
  305. border-radius: 15rpx;
  306. margin-right: 20rpx;
  307. margin-bottom: 20rpx;
  308. }
  309. image:nth-child(3n){
  310. margin-right: 0;
  311. }
  312. }
  313. .business_reply{
  314. width: 710rpx;
  315. margin: 0 auto;
  316. background: #F8F8F8;
  317. border-radius: 6px;
  318. padding: 23rpx 19rpx 19rpx 17rpx;
  319. box-sizing: border-box;
  320. .business_reply_tips{
  321. font-size: 26rpx;
  322. font-family: PingFang SC;
  323. font-weight: 500;
  324. color: #2D2D2D;
  325. line-height: 36rpx;
  326. }
  327. .business_reply_content{
  328. font-size: 26rpx;
  329. font-family: PingFang SC;
  330. font-weight: 500;
  331. color: #666666;
  332. line-height: 36rpx;
  333. }
  334. }
  335. }
  336. }
  337. .no_data{
  338. border-top: 20rpx solid #F8F8F8;
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. padding-top: 100rpx;
  343. image{
  344. width: 212rpx;
  345. height: 210rpx;
  346. }
  347. text{
  348. font-size: 26rpx;
  349. font-family: Source Han Sans CN;
  350. font-weight: 400;
  351. color: #999999;
  352. margin-top: 30rpx;
  353. }
  354. }
  355. }
  356. </style>