Showing
7 changed files
with
98 additions
and
18 deletions
@@ -85,3 +85,37 @@ exports.fetchOrderList = (uid, createTimeBegin) => { | @@ -85,3 +85,37 @@ exports.fetchOrderList = (uid, createTimeBegin) => { | ||
85 | 85 | ||
86 | return ImAPI.get('/api/order/queryLastTenOrder', params); | 86 | return ImAPI.get('/api/order/queryLastTenOrder', params); |
87 | }; | 87 | }; |
88 | + | ||
89 | + | ||
90 | + | ||
91 | +/** | ||
92 | + * | ||
93 | +新建评价信息 | ||
94 | +### url | ||
95 | +``` | ||
96 | +{host}/evalute/saveEvalute | ||
97 | +``` | ||
98 | +### 请求参数说明 | ||
99 | +| 名称 | 类型 | 是否必须 | 描述 | | ||
100 | +| -------------- | ------ | ---- | --------------- | | ||
101 | +| conversationId | long | Y | 会话id | | ||
102 | +| uid | int | Y | 用户ID | | ||
103 | +|encryptedUid | String |Y |加密的用户标识 | | ||
104 | +| promoter | int | Y | 评价发起者 1 用户 2 客服 | | ||
105 | +| stars | int | Y | 评分星级 | | ||
106 | +| reasonIds | string | N | 固定原因Id用冒号隔开 | | ||
107 | +| reasonMsgs | string | N | 固定原因用分号隔开 | | ||
108 | +| reasonMsg | string | N | 其他原因 | | ||
109 | + | ||
110 | + */ | ||
111 | +exports.saveEvalute = (uid, conversationId, promoter, stars) => { | ||
112 | + let params = { | ||
113 | + conversationId, | ||
114 | + uid, | ||
115 | + encryptedUid: encryptedUid(uid), | ||
116 | + promoter, | ||
117 | + stars | ||
118 | + }; | ||
119 | + | ||
120 | + return ImAPI.post('/api/evalute/saveEvalute', params); | ||
121 | +}; |
@@ -111,3 +111,22 @@ exports.fetchOrders = (req, res) => { | @@ -111,3 +111,22 @@ exports.fetchOrders = (req, res) => { | ||
111 | }); | 111 | }); |
112 | }; | 112 | }; |
113 | 113 | ||
114 | +exports.saveEvalute = (req, res) => { | ||
115 | + const uid = req.user.uid; | ||
116 | + | ||
117 | + const conversationId = req.body.conversationId; | ||
118 | + const promoter = req.body.promoter; | ||
119 | + const stars = req.body.stars; | ||
120 | + | ||
121 | + imApi.saveEvalute(uid, conversationId, promoter, stars) | ||
122 | + .then(result => { | ||
123 | + return res.json(result); | ||
124 | + }, () => { | ||
125 | + return res.json({ | ||
126 | + code: 500, | ||
127 | + message: '评价失败' | ||
128 | + }); | ||
129 | + }); | ||
130 | +}; | ||
131 | + | ||
132 | + |
@@ -23,6 +23,7 @@ router.get('/im/fetchHistory', chat.fetchHistory); | @@ -23,6 +23,7 @@ router.get('/im/fetchHistory', chat.fetchHistory); | ||
23 | router.get('/getOrders', chat.getOrders); | 23 | router.get('/getOrders', chat.getOrders); |
24 | router.get('/order-list', chat.fetchOrders); | 24 | router.get('/order-list', chat.fetchOrders); |
25 | router.post('/leavemsg/save.json', chat.saveMSG); | 25 | router.post('/leavemsg/save.json', chat.saveMSG); |
26 | +router.post('/im/saveEvalute', chat.saveEvalute); | ||
26 | 27 | ||
27 | router.get('/chatQaList', chatQa.qaList); // 问题搜索列表页 | 28 | router.get('/chatQaList', chatQa.qaList); // 问题搜索列表页 |
28 | router.get('/qaSearch', chatQa.qaSearch); // 问题搜索页 | 29 | router.get('/qaSearch', chatQa.qaSearch); // 问题搜索页 |
@@ -19,6 +19,15 @@ module.exports = () => { | @@ -19,6 +19,15 @@ module.exports = () => { | ||
19 | req.user.uid = cookie.getUid(req); | 19 | req.user.uid = cookie.getUid(req); |
20 | } | 20 | } |
21 | 21 | ||
22 | + // app 特殊读法 | ||
23 | + if (!req.user.uid && req.yoho.isApp) { | ||
24 | + let userAgent = _.get(req.headers, 'user-agent', ''); | ||
25 | + | ||
26 | + if (userAgent.indexOf('YohoBuy') >= 0) { | ||
27 | + req.user.uid = req.cookies._YOHOUID || 0; | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
22 | next(); | 31 | next(); |
23 | }; | 32 | }; |
24 | }; | 33 | }; |
@@ -199,6 +199,7 @@ var chat = { | @@ -199,6 +199,7 @@ var chat = { | ||
199 | 199 | ||
200 | this.$ratingView.on('click', '.submit', function() { | 200 | this.$ratingView.on('click', '.submit', function() { |
201 | self.ratingView.post({ | 201 | self.ratingView.post({ |
202 | + uid, | ||
202 | encryptedUid, | 203 | encryptedUid, |
203 | conversationId: cmEntity.conversationId, | 204 | conversationId: cmEntity.conversationId, |
204 | }); | 205 | }); |
@@ -35,6 +35,10 @@ EventEmitter.prototype = { | @@ -35,6 +35,10 @@ EventEmitter.prototype = { | ||
35 | 35 | ||
36 | EventEmitter.prototype.constructer = EventEmitter; | 36 | EventEmitter.prototype.constructer = EventEmitter; |
37 | 37 | ||
38 | +function buildAPPUid(data) { | ||
39 | + | ||
40 | +} | ||
41 | + | ||
38 | 42 | ||
39 | // api interface | 43 | // api interface |
40 | //-------------------------------------------------------- | 44 | //-------------------------------------------------------- |
@@ -72,6 +76,10 @@ let api = { | @@ -72,6 +76,10 @@ let api = { | ||
72 | endTime && (data.endTime = endTime); | 76 | endTime && (data.endTime = endTime); |
73 | 77 | ||
74 | return $.get(url, data); | 78 | return $.get(url, data); |
79 | + }, | ||
80 | + | ||
81 | + saveEvalute: function(data) { | ||
82 | + return $.post('/service/im/saveEvalute', data); | ||
75 | } | 83 | } |
76 | }; | 84 | }; |
77 | 85 |
1 | const loading = require('../../plugin/loading'), | 1 | const loading = require('../../plugin/loading'), |
2 | + tip = require('plugin/tip'), | ||
2 | lazyLoad = require('yoho-jquery-lazyload'); | 3 | lazyLoad = require('yoho-jquery-lazyload'); |
3 | 4 | ||
4 | require('../../common'); | 5 | require('../../common'); |
5 | 6 | ||
6 | -import {EventEmitter, bus, api} from './store'; | 7 | +import {EventEmitter, api} from './store'; |
7 | 8 | ||
8 | 9 | ||
9 | const LeaveMSGView = function(elem) { | 10 | const LeaveMSGView = function(elem) { |
@@ -47,7 +48,11 @@ LeaveMSGView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -47,7 +48,11 @@ LeaveMSGView.prototype = $.extend({}, EventEmitter.prototype, { | ||
47 | */ | 48 | */ |
48 | submit() { | 49 | submit() { |
49 | let self = this; | 50 | let self = this; |
50 | - let content = this.$input.val(); | 51 | + let content = $.trim(this.$input.val()); |
52 | + | ||
53 | + if (!content) { | ||
54 | + return; | ||
55 | + } | ||
51 | 56 | ||
52 | api.leaveMsg(content) | 57 | api.leaveMsg(content) |
53 | .done(function() { | 58 | .done(function() { |
@@ -83,12 +88,14 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -83,12 +88,14 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
83 | 88 | ||
84 | this.elem | 89 | this.elem |
85 | .on('click.RatingView.rating', '.stars i', function(event) { | 90 | .on('click.RatingView.rating', '.stars i', function(event) { |
86 | - self.rating($(event.target)); | 91 | + let starVal = $(this).index(); |
92 | + | ||
93 | + self.rating(starVal); | ||
87 | }) | 94 | }) |
88 | .on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false)); | 95 | .on('click.RatingView.close', '.close', $.proxy(this.toggle, this, false)); |
89 | }, | 96 | }, |
90 | 97 | ||
91 | - rating($rank) { | 98 | + rating(starVal) { |
92 | const rankMap = { | 99 | const rankMap = { |
93 | 0: '非常不满意', | 100 | 0: '非常不满意', |
94 | 1: '不满意', | 101 | 1: '不满意', |
@@ -97,14 +104,13 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -97,14 +104,13 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
97 | 4: '非常满意', | 104 | 4: '非常满意', |
98 | }; | 105 | }; |
99 | 106 | ||
100 | - const curVal = this.rank = $rank.index(); | ||
101 | - | ||
102 | - this.rankText = rankMap[curVal]; | ||
103 | - this.$label.text(rankMap[curVal]); | 107 | + this.rank = starVal; |
108 | + this.rankText = rankMap[starVal] || rankMap[3]; | ||
109 | + this.$label.text(this.rankText); | ||
104 | 110 | ||
105 | this.$ranks.removeClass('rated'); | 111 | this.$ranks.removeClass('rated'); |
106 | this.$ranks.toggleClass(index => { | 112 | this.$ranks.toggleClass(index => { |
107 | - return index <= curVal ? 'rated' : null; | 113 | + return index <= starVal ? 'rated' : null; |
108 | }); | 114 | }); |
109 | }, | 115 | }, |
110 | 116 | ||
@@ -118,24 +124,26 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -118,24 +124,26 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
118 | }; | 124 | }; |
119 | 125 | ||
120 | Object.assign(params, data); | 126 | Object.assign(params, data); |
121 | - $.ajax({ | ||
122 | - type: 'POST', | ||
123 | - url: 'http://192.168.102.18:60101/api/evalute/saveEvalute', | ||
124 | - data: params, | ||
125 | - success: function(res) { | 127 | + |
128 | + api.saveEvalute(params) | ||
129 | + .done(res => { | ||
126 | if (res && res.code === 200) { | 130 | if (res && res.code === 200) { |
127 | elem.hide(); | 131 | elem.hide(); |
128 | elem.trigger('rating-success', [self.rankText]); | 132 | elem.trigger('rating-success', [self.rankText]); |
133 | + | ||
134 | + return; | ||
129 | } | 135 | } |
130 | - }, | ||
131 | - error: function() { | ||
132 | 136 | ||
133 | - } | ||
134 | - }); | 137 | + tip.show('评价失败'); |
138 | + }) | ||
139 | + .fail(()=> { | ||
140 | + tip.show('评价失败'); | ||
141 | + }); | ||
135 | }, | 142 | }, |
136 | 143 | ||
137 | toggle(willShow) { | 144 | toggle(willShow) { |
138 | this.elem.toggle(willShow); | 145 | this.elem.toggle(willShow); |
146 | + this.rating(3); | ||
139 | } | 147 | } |
140 | }); | 148 | }); |
141 | 149 |
-
Please register or login to post a comment