|
|
const loading = require('../../plugin/loading'),
|
|
|
tip = require('plugin/tip'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
|
|
|
require('../../common');
|
|
|
|
|
|
import {EventEmitter, bus, api} from './store';
|
|
|
import {EventEmitter, api} from './store';
|
|
|
|
|
|
|
|
|
const LeaveMSGView = function(elem) {
|
...
|
...
|
@@ -47,7 +48,11 @@ LeaveMSGView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
*/
|
|
|
submit() {
|
|
|
let self = this;
|
|
|
let content = this.$input.val();
|
|
|
let content = $.trim(this.$input.val());
|
|
|
|
|
|
if (!content) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
api.leaveMsg(content)
|
|
|
.done(function() {
|
...
|
...
|
@@ -83,12 +88,14 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
|
|
|
this.elem
|
|
|
.on('click.RatingView.rating', '.stars i', function(event) {
|
|
|
self.rating($(event.target));
|
|
|
let starVal = $(this).index();
|
|
|
|
|
|
self.rating(starVal);
|
|
|
})
|
|
|
.on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false));
|
|
|
},
|
|
|
|
|
|
rating($rank) {
|
|
|
rating(starVal) {
|
|
|
const rankMap = {
|
|
|
0: '非常不满意',
|
|
|
1: '不满意',
|
...
|
...
|
@@ -97,14 +104,13 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
4: '非常满意',
|
|
|
};
|
|
|
|
|
|
const curVal = this.rank = $rank.index();
|
|
|
|
|
|
this.rankText = rankMap[curVal];
|
|
|
this.$label.text(rankMap[curVal]);
|
|
|
this.rank = starVal;
|
|
|
this.rankText = rankMap[starVal] || rankMap[3];
|
|
|
this.$label.text(this.rankText);
|
|
|
|
|
|
this.$ranks.removeClass('rated');
|
|
|
this.$ranks.toggleClass(index => {
|
|
|
return index <= curVal ? 'rated' : null;
|
|
|
return index <= starVal ? 'rated' : null;
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -118,24 +124,26 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
};
|
|
|
|
|
|
Object.assign(params, data);
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: 'http://192.168.102.18:60101/api/evalute/saveEvalute',
|
|
|
data: params,
|
|
|
success: function(res) {
|
|
|
|
|
|
api.saveEvalute(params)
|
|
|
.done(res => {
|
|
|
if (res && res.code === 200) {
|
|
|
elem.hide();
|
|
|
elem.trigger('rating-success', [self.rankText]);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
tip.show('评价失败');
|
|
|
})
|
|
|
.fail(()=> {
|
|
|
tip.show('评价失败');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
toggle(willShow) {
|
|
|
this.elem.toggle(willShow);
|
|
|
this.rating(3);
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
|