...
|
...
|
@@ -87,14 +87,16 @@ LeaveMSGView.prototype.constructer = LeaveMSGView; |
|
|
/*
|
|
|
评价view
|
|
|
*/
|
|
|
const RatingView = function(elem, socket) {
|
|
|
const RatingView = function(elem, cmEntity) {
|
|
|
this.elem = $(elem);
|
|
|
this.$ranks = this.elem.find('.stars i');
|
|
|
this.$label = this.elem.find('.rank');
|
|
|
this.$more = this.elem.find('.more-comment');
|
|
|
this.cmEntity = cmEntity;
|
|
|
this.rank = 3;
|
|
|
this.bindEvents();
|
|
|
this.socket = socket;
|
|
|
this.isSending = false;
|
|
|
this.reasonsRendered = false;
|
|
|
};
|
|
|
|
|
|
RatingView.prototype = $.extend({}, EventEmitter.prototype, {
|
...
|
...
|
@@ -110,7 +112,66 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
|
|
|
self.rating(starVal);
|
|
|
})
|
|
|
.on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false));
|
|
|
.on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false))
|
|
|
.on('moreComment.toggle', '.more-comment', function(event, starVal) {
|
|
|
let $this = $(this);
|
|
|
let visible = $this.is(':visible');
|
|
|
|
|
|
if (starVal < 3 && visible) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$this.find('.words-to-say').val('');
|
|
|
$this.find('.cause span').removeClass('select');
|
|
|
|
|
|
if (starVal < 3) {
|
|
|
let cvId = self.cmEntity.conversationId;
|
|
|
|
|
|
return self.renderReasons(cvId);
|
|
|
}
|
|
|
|
|
|
$this.hide();
|
|
|
})
|
|
|
.on('click.CauseItem.SelectToggle', '.cause span', function() {
|
|
|
let $this = $(this);
|
|
|
|
|
|
$this.toggleClass('select');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
renderReasons(cvId) {
|
|
|
let self = this;
|
|
|
|
|
|
if (self.reasonsRendered) {
|
|
|
self.$more.show();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 评价原因渲染
|
|
|
api.queryReasons({
|
|
|
conversationId: cvId
|
|
|
})
|
|
|
.done(res => {
|
|
|
if (res && res.code === 200) {
|
|
|
let $html;
|
|
|
let cause = [];
|
|
|
|
|
|
res.data.forEach((item) => {
|
|
|
cause.push(`<span data-id="${item.id}">${item.content}</span>`);
|
|
|
});
|
|
|
|
|
|
$html = cause.join('');
|
|
|
self.$more.find('.cause').append($html);
|
|
|
self.reasonsRendered = true;
|
|
|
self.$more.show();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
tip.show('拉取评价原因失败');
|
|
|
})
|
|
|
.fail(()=> {
|
|
|
tip.show('拉取评价原因失败');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
rating(starVal) {
|
...
|
...
|
@@ -130,6 +191,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
this.$ranks.toggleClass(index => {
|
|
|
return index <= starVal ? 'rated' : null;
|
|
|
});
|
|
|
|
|
|
// added for customer service v1.2 optimization
|
|
|
this.$more.trigger('moreComment.toggle', starVal);
|
|
|
},
|
|
|
|
|
|
post(data) {
|
...
|
...
|
@@ -144,9 +208,18 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
var params = {
|
|
|
stars: ++this.rank,
|
|
|
promoter: 1,
|
|
|
reasonIds: '',
|
|
|
reasonMsg: elem.find('.words-to-say').val(),
|
|
|
};
|
|
|
|
|
|
let temp = [];
|
|
|
let $select = self.$more.find('.cause span.select');
|
|
|
|
|
|
[].forEach.call($select, (item) => {
|
|
|
temp.push($(item).data('id'));
|
|
|
});
|
|
|
params.reasonIds = temp.join(':');
|
|
|
|
|
|
Object.assign(params, data);
|
|
|
|
|
|
api.saveEvalute(params)
|
...
|
...
|
|