Jacob
4 天以前 f564a64d3c99b4d300e54e038446227a440bba48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
   <view style="height: 100%;">
       <view class='evaluate-list'>
           <view class='generalComment acea-row row-between-wrapper'>
               <view class='acea-row row-middle font-color'>
                   <view class='evaluate'>评分</view>
                   <view class='start'
                       :class="'star'+ (replyData.sumCount===0?'3':Math.round(replyData.replyStar/replyData.sumCount))">
                   </view>
               </view>
               <view><text class='font-color'>{{(replyData.replyChance)*100}}%</text>好评率</view>
           </view>
           <view class='nav acea-row row-middle'>
               <view class='item' :class='type==0 ? "bg-color":""' @click='changeType(0)'>全部({{replyData.sumCount}})
               </view>
               <view class='item' :class='type==1 ? "bg-color":""' @click='changeType(1)'>好评({{replyData.goodCount}})
               </view>
               <view class='item' :class='type==2 ? "bg-color":""' @click='changeType(2)'>中评({{replyData.inCount}})
               </view>
               <view class='item' :class='type==3 ? "bg-color":""' @click='changeType(3)'>差评({{replyData.poorCount}})
               </view>
           </view>
           <userEvaluation :reply="reply"></userEvaluation>
       </view>
       <view class='loadingicon acea-row row-center-wrapper'>
           <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
       </view>
       <view class='noCommodity' v-if="!replyData.sumCount && page > 1">
           <view class='pictrue'>
               <image src='../static/noEvaluate.png'></image>
           </view>
       </view>
   </view>
</template>
 
<script>
   import {
       getReplyConfig
   } from '@/api/store.js';
   import userEvaluation from '@/components/userEvaluation';
   export default {
       components: {
           userEvaluation
       },
       data() {
           return {
               replyData: {},
               product_id: 0,
               reply: [],
               type: 0,
               loading: false,
               loadend: false,
               loadTitle: '加载更多',
               page: 1,
               limit: 20
           };
       },
       /**
        * 生命周期函数--监听页面加载
        */
       onLoad: function(options) {
           let that = this;
           if (!options.productId) return that.$util.Tips({
               title: '缺少参数'
           }, {
               tab: 3,
               url: 1
           });
           that.productId = options.productId;
       },
       onShow: function() {
           this.getProductReplyCount();
           this.getProductReplyList();
       },
       methods: {
           /**
            * 获取评论统计数据
            * 
            */
           getProductReplyCount: function() {
               let that = this;
               getReplyConfig(that.productId).then(res => {
                   that.$set(that, 'replyData', res.data);
               });
           },
           /**
            * 分页获取评论
            */
           /*
            * 点击事件切换
            * */
           changeType: function(e) {
               let type = parseInt(e);
               if (type == this.type) return;
               this.type = type;
               this.page = 1;
               this.loadend = false;
               this.$set(this, 'reply', []);
           }
       },
       /**
        * 页面上拉触底事件的处理函数
        */
       onReachBottom: function() {
           this.getProductReplyList();
       },
   }
</script>
 
<style lang="scss">
   page {
       background-color: #fff;
       height: 100%;
   }
    .evaluate-list{
       padding: 30rpx 0 0 0;
       background-color: #fff;
   }
   .evaluate-list .generalComment {
       padding: 0 30rpx;
       margin-top: 1rpx;
       background-color: #fff;
       font-size: 28rpx;
       color: #808080;
   }
 
   .evaluate-list .generalComment .evaluate {
       margin-right: 7rpx;
       color: #333333;
       font-size: 28rpx;
   }
 
   .evaluate-list .nav {
       font-size: 24rpx;
       color: #282828;
       padding: 30rpx;
       background-color: #fff;
       border-bottom: 1rpx solid #f5f5f5;
   }
 
   .evaluate-list .nav .item {
       font-size: 24rpx;
       color: #282828;
       border-radius: 27rpx;
       height: 54rpx;
       padding: 0 20rpx;
       background-color: #f4f4f4;
       line-height: 54rpx;
       margin-right: 17rpx;
   }
 
   .evaluate-list .nav .item.bg-color {
       color: #fff;
   }
</style>