Showing
9 changed files
with
164 additions
and
9 deletions
@@ -206,4 +206,33 @@ exports.queryGlobalOrder = (req, res) => { | @@ -206,4 +206,33 @@ exports.queryGlobalOrder = (req, res) => { | ||
206 | }); | 206 | }); |
207 | }; | 207 | }; |
208 | 208 | ||
209 | +/** | ||
210 | + * Request: 获取评价原因 | ||
211 | + * type: GET | ||
212 | + * params: | ||
213 | + * cvId 会话id | ||
214 | + */ | ||
215 | +exports.queryReasons = (req, res) => { | ||
216 | + let uid = req.user.uid; | ||
217 | + | ||
218 | + if (!uid) { | ||
219 | + uid = req.body.uid; | ||
220 | + } | ||
221 | + | ||
222 | + const cvId = req.query.conversationId; | ||
223 | + | ||
224 | + console.log('body', cvId); | ||
225 | + | ||
226 | + imApi.queryReasons(cvId) | ||
227 | + .then(result=> { | ||
228 | + res.json(result); | ||
229 | + }) | ||
230 | + .catch(() => { | ||
231 | + return res.json({ | ||
232 | + code: 500, | ||
233 | + message: '拉取评价原因失败' | ||
234 | + }); | ||
235 | + }); | ||
236 | +}; | ||
237 | + | ||
209 | 238 |
@@ -133,3 +133,15 @@ exports.queryGlobalOrder = uid => { | @@ -133,3 +133,15 @@ exports.queryGlobalOrder = uid => { | ||
133 | 133 | ||
134 | return ImService.get('/api/order/queryGlobalOrder', params); | 134 | return ImService.get('/api/order/queryGlobalOrder', params); |
135 | }; | 135 | }; |
136 | + | ||
137 | +/** | ||
138 | + * 获取评价原因 | ||
139 | + * @param cvId 会话ID | ||
140 | + */ | ||
141 | +exports.queryReasons = cvId => { | ||
142 | + let params = { | ||
143 | + conversationId: cvId | ||
144 | + }; | ||
145 | + | ||
146 | + return ImService.get('/api/evalute/queryReasonByConversationId', params); | ||
147 | +}; |
@@ -24,6 +24,7 @@ router.get('/im/fetchHistory', chat.fetchHistory); | @@ -24,6 +24,7 @@ router.get('/im/fetchHistory', chat.fetchHistory); | ||
24 | router.get('/getOrders', chat.getOrders); | 24 | router.get('/getOrders', chat.getOrders); |
25 | router.get('/im/global-list', chat.queryGlobalOrder); | 25 | router.get('/im/global-list', chat.queryGlobalOrder); |
26 | router.get('/im/order-list', chat.fetchOrders); | 26 | router.get('/im/order-list', chat.fetchOrders); |
27 | +router.get('/im/queryReasons', chat.queryReasons); | ||
27 | router.post('/leavemsg/save.json', chat.saveMSG); | 28 | router.post('/leavemsg/save.json', chat.saveMSG); |
28 | router.post('/im/saveEvalute', chat.saveEvalute); | 29 | router.post('/im/saveEvalute', chat.saveEvalute); |
29 | 30 |
@@ -9,8 +9,15 @@ | @@ -9,8 +9,15 @@ | ||
9 | <i></i> | 9 | <i></i> |
10 | <i></i> | 10 | <i></i> |
11 | </div> | 11 | </div> |
12 | - <div class="rank"> </div> | ||
13 | - <textarea class="words-to-say" maxlength="50" placeholder="还想吐槽下(选填)"></textarea> | 12 | + <div class="rank"></div> |
13 | + <div class="more-comment"> | ||
14 | + <div class="cause"> | ||
15 | + {{#each causeList}} | ||
16 | + <span>{{value}}</span> | ||
17 | + {{/each}} | ||
18 | + </div> | ||
19 | + <textarea class="words-to-say" maxlength="50" placeholder="还想吐槽下(选填)"></textarea> | ||
20 | + </div> | ||
14 | <button class="submit">提交</button> | 21 | <button class="submit">提交</button> |
15 | </div> | 22 | </div> |
16 | </div> | 23 | </div> |
public/img/service/chat/cause-select.png
0 → 100644

1.26 KB
@@ -109,7 +109,7 @@ var chat = { | @@ -109,7 +109,7 @@ var chat = { | ||
109 | // 组件 | 109 | // 组件 |
110 | this.leaveMSGView = new LeaveMSGView('#leave-msg'); | 110 | this.leaveMSGView = new LeaveMSGView('#leave-msg'); |
111 | this.orderListView = new OrderListView('#order-list'); | 111 | this.orderListView = new OrderListView('#order-list'); |
112 | - this.ratingView = new RatingView('#chat-comment'); | 112 | + this.ratingView = new RatingView('#chat-comment', cmEntity); |
113 | 113 | ||
114 | const self = this; | 114 | const self = this; |
115 | 115 |
@@ -86,6 +86,11 @@ let api = { | @@ -86,6 +86,11 @@ let api = { | ||
86 | saveEvalute: function(data) { | 86 | saveEvalute: function(data) { |
87 | data.uid = uid; | 87 | data.uid = uid; |
88 | return $.post('/service/im/saveEvalute', data); | 88 | return $.post('/service/im/saveEvalute', data); |
89 | + }, | ||
90 | + | ||
91 | + // 获取评价原因 | ||
92 | + queryReasons: function(data) { | ||
93 | + return $.get('/service/im/queryReasons', data); | ||
89 | } | 94 | } |
90 | }; | 95 | }; |
91 | 96 |
@@ -87,14 +87,16 @@ LeaveMSGView.prototype.constructer = LeaveMSGView; | @@ -87,14 +87,16 @@ LeaveMSGView.prototype.constructer = LeaveMSGView; | ||
87 | /* | 87 | /* |
88 | 评价view | 88 | 评价view |
89 | */ | 89 | */ |
90 | -const RatingView = function(elem, socket) { | 90 | +const RatingView = function(elem, cmEntity) { |
91 | this.elem = $(elem); | 91 | this.elem = $(elem); |
92 | this.$ranks = this.elem.find('.stars i'); | 92 | this.$ranks = this.elem.find('.stars i'); |
93 | this.$label = this.elem.find('.rank'); | 93 | this.$label = this.elem.find('.rank'); |
94 | + this.$more = this.elem.find('.more-comment'); | ||
95 | + this.cmEntity = cmEntity; | ||
94 | this.rank = 3; | 96 | this.rank = 3; |
95 | this.bindEvents(); | 97 | this.bindEvents(); |
96 | - this.socket = socket; | ||
97 | this.isSending = false; | 98 | this.isSending = false; |
99 | + this.reasonsRendered = false; | ||
98 | }; | 100 | }; |
99 | 101 | ||
100 | RatingView.prototype = $.extend({}, EventEmitter.prototype, { | 102 | RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
@@ -110,7 +112,66 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -110,7 +112,66 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
110 | 112 | ||
111 | self.rating(starVal); | 113 | self.rating(starVal); |
112 | }) | 114 | }) |
113 | - .on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false)); | 115 | + .on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false)) |
116 | + .on('moreComment.toggle', '.more-comment', function(event, starVal) { | ||
117 | + let $this = $(this); | ||
118 | + let visible = $this.is(':visible'); | ||
119 | + | ||
120 | + if (starVal < 3 && visible) { | ||
121 | + return; | ||
122 | + } | ||
123 | + | ||
124 | + $this.find('.words-to-say').val(''); | ||
125 | + $this.find('.cause span').removeClass('select'); | ||
126 | + | ||
127 | + if (starVal < 3) { | ||
128 | + let cvId = self.cmEntity.conversationId; | ||
129 | + | ||
130 | + return self.renderReasons(cvId); | ||
131 | + } | ||
132 | + | ||
133 | + $this.hide(); | ||
134 | + }) | ||
135 | + .on('click.CauseItem.SelectToggle', '.cause span', function() { | ||
136 | + let $this = $(this); | ||
137 | + | ||
138 | + $this.toggleClass('select'); | ||
139 | + }); | ||
140 | + }, | ||
141 | + | ||
142 | + renderReasons(cvId) { | ||
143 | + let self = this; | ||
144 | + | ||
145 | + if (self.reasonsRendered) { | ||
146 | + self.$more.show(); | ||
147 | + return; | ||
148 | + } | ||
149 | + | ||
150 | + // 评价原因渲染 | ||
151 | + api.queryReasons({ | ||
152 | + conversationId: cvId | ||
153 | + }) | ||
154 | + .done(res => { | ||
155 | + if (res && res.code === 200) { | ||
156 | + let $html; | ||
157 | + let cause = []; | ||
158 | + | ||
159 | + res.data.forEach((item) => { | ||
160 | + cause.push(`<span data-id="${item.id}">${item.content}</span>`); | ||
161 | + }); | ||
162 | + | ||
163 | + $html = cause.join(''); | ||
164 | + self.$more.find('.cause').append($html); | ||
165 | + self.reasonsRendered = true; | ||
166 | + self.$more.show(); | ||
167 | + return; | ||
168 | + } | ||
169 | + | ||
170 | + tip.show('拉取评价原因失败'); | ||
171 | + }) | ||
172 | + .fail(()=> { | ||
173 | + tip.show('拉取评价原因失败'); | ||
174 | + }); | ||
114 | }, | 175 | }, |
115 | 176 | ||
116 | rating(starVal) { | 177 | rating(starVal) { |
@@ -130,6 +191,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -130,6 +191,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
130 | this.$ranks.toggleClass(index => { | 191 | this.$ranks.toggleClass(index => { |
131 | return index <= starVal ? 'rated' : null; | 192 | return index <= starVal ? 'rated' : null; |
132 | }); | 193 | }); |
194 | + | ||
195 | + // added for customer service v1.2 optimization | ||
196 | + this.$more.trigger('moreComment.toggle', starVal); | ||
133 | }, | 197 | }, |
134 | 198 | ||
135 | post(data) { | 199 | post(data) { |
@@ -144,9 +208,18 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -144,9 +208,18 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
144 | var params = { | 208 | var params = { |
145 | stars: ++this.rank, | 209 | stars: ++this.rank, |
146 | promoter: 1, | 210 | promoter: 1, |
211 | + reasonIds: '', | ||
147 | reasonMsg: elem.find('.words-to-say').val(), | 212 | reasonMsg: elem.find('.words-to-say').val(), |
148 | }; | 213 | }; |
149 | 214 | ||
215 | + let temp = []; | ||
216 | + let $select = self.$more.find('.cause span.select'); | ||
217 | + | ||
218 | + [].forEach.call($select, (item) => { | ||
219 | + temp.push($(item).data('id')); | ||
220 | + }); | ||
221 | + params.reasonIds = temp.join(':'); | ||
222 | + | ||
150 | Object.assign(params, data); | 223 | Object.assign(params, data); |
151 | 224 | ||
152 | api.saveEvalute(params) | 225 | api.saveEvalute(params) |
@@ -12,7 +12,6 @@ | @@ -12,7 +12,6 @@ | ||
12 | &-inner { | 12 | &-inner { |
13 | position: absolute; | 13 | position: absolute; |
14 | bottom: 0; | 14 | bottom: 0; |
15 | - height: 586px; | ||
16 | width: 100%; | 15 | width: 100%; |
17 | background: #fff; | 16 | background: #fff; |
18 | padding: 0 30px; | 17 | padding: 0 30px; |
@@ -61,10 +60,39 @@ | @@ -61,10 +60,39 @@ | ||
61 | color: #b0b0b0; | 60 | color: #b0b0b0; |
62 | } | 61 | } |
63 | 62 | ||
63 | + .cause { | ||
64 | + font-size: 0; | ||
65 | + | ||
66 | + span { | ||
67 | + position: relative; | ||
68 | + display: inline-block; | ||
69 | + margin: 10px; | ||
70 | + width: 328px; | ||
71 | + width: calc(50% - 20px); | ||
72 | + font-size: 28px; | ||
73 | + border: 1px solid #000; | ||
74 | + line-height: 70px; | ||
75 | + text-align: center; | ||
76 | + border-radius: 5px; | ||
77 | + } | ||
78 | + | ||
79 | + .select:after { | ||
80 | + position: absolute; | ||
81 | + bottom: -1px; | ||
82 | + right: -1px; | ||
83 | + width: 30px; | ||
84 | + height: 30px; | ||
85 | + content: ""; | ||
86 | + display: inline-block; | ||
87 | + background: resolve("service/chat/cause-select.png"); | ||
88 | + background-size: cover; | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
64 | .words-to-say { | 92 | .words-to-say { |
65 | height: 110px; | 93 | height: 110px; |
66 | width: 100%; | 94 | width: 100%; |
67 | - margin: 50px 0 0; | 95 | + margin: 10px 0 0; |
68 | padding: 16px; | 96 | padding: 16px; |
69 | resize: none; | 97 | resize: none; |
70 | border: 1px solid #e0e0e0; | 98 | border: 1px solid #e0e0e0; |
@@ -74,7 +102,7 @@ | @@ -74,7 +102,7 @@ | ||
74 | .submit { | 102 | .submit { |
75 | height: 85px; | 103 | height: 85px; |
76 | width: 100%; | 104 | width: 100%; |
77 | - margin: 25px 0 0; | 105 | + margin: 25px 0; |
78 | color: #fff; | 106 | color: #fff; |
79 | background: #444; | 107 | background: #444; |
80 | font-size: 32px; | 108 | font-size: 32px; |
-
Please register or login to post a comment