Showing
5 changed files
with
114 additions
and
19 deletions
@@ -24,6 +24,11 @@ exports.appAdapter = (req, res, next) => { | @@ -24,6 +24,11 @@ exports.appAdapter = (req, res, next) => { | ||
24 | exports.page = (req, res, next) => { | 24 | exports.page = (req, res, next) => { |
25 | let uid = req.user.uid; | 25 | let uid = req.user.uid; |
26 | 26 | ||
27 | + if (!uid) { | ||
28 | + uid = req.query.uid; | ||
29 | + } | ||
30 | + | ||
31 | + | ||
27 | userApi.profile(req.user.uid) | 32 | userApi.profile(req.user.uid) |
28 | .then(userinfo => { | 33 | .then(userinfo => { |
29 | userinfo = userinfo.data; | 34 | userinfo = userinfo.data; |
@@ -49,12 +54,18 @@ exports.page = (req, res, next) => { | @@ -49,12 +54,18 @@ exports.page = (req, res, next) => { | ||
49 | }; | 54 | }; |
50 | 55 | ||
51 | exports.getOrders = (req, res, next) => { | 56 | exports.getOrders = (req, res, next) => { |
57 | + let uid = req.user.uid; | ||
58 | + | ||
59 | + if (!uid) { | ||
60 | + uid = req.query.uid; | ||
61 | + } | ||
62 | + | ||
52 | orderModel.getOrders({ | 63 | orderModel.getOrders({ |
53 | type: req.query.type || 1, | 64 | type: req.query.type || 1, |
54 | page: req.query.page || 1, | 65 | page: req.query.page || 1, |
55 | gender: req.query.gender || '1,3', | 66 | gender: req.query.gender || '1,3', |
56 | yh_channel: req.query.channel || 1, | 67 | yh_channel: req.query.channel || 1, |
57 | - uid: req.user.uid | 68 | + uid |
58 | }).then(result => { | 69 | }).then(result => { |
59 | res.render('chat/chat-order', { | 70 | res.render('chat/chat-order', { |
60 | layout: false, | 71 | layout: false, |
@@ -69,7 +80,12 @@ exports.getOrders = (req, res, next) => { | @@ -69,7 +80,12 @@ exports.getOrders = (req, res, next) => { | ||
69 | * | 80 | * |
70 | */ | 81 | */ |
71 | exports.fetchHistory = (req, res) => { | 82 | exports.fetchHistory = (req, res) => { |
72 | - const uid = req.user.uid; | 83 | + let uid = req.user.uid; |
84 | + | ||
85 | + if (!uid) { | ||
86 | + uid = req.query.uid; | ||
87 | + } | ||
88 | + | ||
73 | const endTime = req.query.endTime; | 89 | const endTime = req.query.endTime; |
74 | 90 | ||
75 | imApi.fetchImHistory(uid, endTime).then(result => { | 91 | imApi.fetchImHistory(uid, endTime).then(result => { |
@@ -79,7 +95,12 @@ exports.fetchHistory = (req, res) => { | @@ -79,7 +95,12 @@ exports.fetchHistory = (req, res) => { | ||
79 | 95 | ||
80 | 96 | ||
81 | exports.msghistory = (req, res) => { | 97 | exports.msghistory = (req, res) => { |
82 | - const uid = req.user.uid; | 98 | + let uid = req.user.uid; |
99 | + | ||
100 | + if (!uid) { | ||
101 | + uid = req.query.uid; | ||
102 | + } | ||
103 | + | ||
83 | 104 | ||
84 | imApi.fetchImHistory(uid).then(result => { | 105 | imApi.fetchImHistory(uid).then(result => { |
85 | res.json(result); | 106 | res.json(result); |
@@ -94,7 +115,12 @@ exports.msghistory = (req, res) => { | @@ -94,7 +115,12 @@ exports.msghistory = (req, res) => { | ||
94 | * content 留言内容 | 115 | * content 留言内容 |
95 | */ | 116 | */ |
96 | exports.saveMSG = (req, res) => { | 117 | exports.saveMSG = (req, res) => { |
97 | - const uid = req.user.uid; | 118 | + let uid = req.user.uid; |
119 | + | ||
120 | + if (!uid) { | ||
121 | + uid = req.body.uid; | ||
122 | + } | ||
123 | + | ||
98 | const conversationId = req.body.conversationId; | 124 | const conversationId = req.body.conversationId; |
99 | const content = req.body.content; | 125 | const content = req.body.content; |
100 | 126 | ||
@@ -113,7 +139,12 @@ exports.saveMSG = (req, res) => { | @@ -113,7 +139,12 @@ exports.saveMSG = (req, res) => { | ||
113 | * 2. 失败情况 | 139 | * 2. 失败情况 |
114 | */ | 140 | */ |
115 | exports.fetchOrders = (req, res) => { | 141 | exports.fetchOrders = (req, res) => { |
116 | - const uid = req.user.uid; | 142 | + let uid = req.user.uid; |
143 | + | ||
144 | + if (!uid) { | ||
145 | + uid = req.query.uid; | ||
146 | + } | ||
147 | + | ||
117 | 148 | ||
118 | imApi.fetchOrderList(uid) | 149 | imApi.fetchOrderList(uid) |
119 | .then(result => { | 150 | .then(result => { |
@@ -128,7 +159,12 @@ exports.fetchOrders = (req, res) => { | @@ -128,7 +159,12 @@ exports.fetchOrders = (req, res) => { | ||
128 | }; | 159 | }; |
129 | 160 | ||
130 | exports.saveEvalute = (req, res) => { | 161 | exports.saveEvalute = (req, res) => { |
131 | - const uid = req.user.uid; | 162 | + let uid = req.user.uid; |
163 | + | ||
164 | + if (!uid) { | ||
165 | + uid = req.body.uid; | ||
166 | + } | ||
167 | + | ||
132 | 168 | ||
133 | const conversationId = req.body.conversationId; | 169 | const conversationId = req.body.conversationId; |
134 | const promoter = req.body.promoter; | 170 | const promoter = req.body.promoter; |
@@ -148,7 +184,12 @@ exports.saveEvalute = (req, res) => { | @@ -148,7 +184,12 @@ exports.saveEvalute = (req, res) => { | ||
148 | 184 | ||
149 | 185 | ||
150 | exports.queryGlobalOrder = (req, res) => { | 186 | exports.queryGlobalOrder = (req, res) => { |
151 | - const uid = req.user.uid; | 187 | + let uid = req.user.uid; |
188 | + | ||
189 | + if (!uid) { | ||
190 | + uid = req.query.uid; | ||
191 | + } | ||
192 | + | ||
152 | 193 | ||
153 | let emptyOrder = { | 194 | let emptyOrder = { |
154 | code: 200, | 195 | code: 200, |
@@ -19,13 +19,6 @@ module.exports = () => { | @@ -19,13 +19,6 @@ module.exports = () => { | ||
19 | req.user.uid = cookie.getUid(req); | 19 | req.user.uid = cookie.getUid(req); |
20 | } | 20 | } |
21 | 21 | ||
22 | - // app 特殊读法 | ||
23 | - let userAgent = _.get(req.headers, 'user-agent', ''); | ||
24 | - | ||
25 | - if (!req.user.uid && userAgent.indexOf('YohoBuy') >= 0) { | ||
26 | - req.user.uid = req.cookies._YOHOUID || 0; | ||
27 | - } | ||
28 | - | ||
29 | next(); | 22 | next(); |
30 | }; | 23 | }; |
31 | }; | 24 | }; |
@@ -851,23 +851,58 @@ $('#chat-window').on('click', '.chat-image', function() { | @@ -851,23 +851,58 @@ $('#chat-window').on('click', '.chat-image', function() { | ||
851 | }); | 851 | }); |
852 | 852 | ||
853 | 853 | ||
854 | +function tellAppSuccess() { | ||
855 | + window.setTimeout(() => { | ||
856 | + appBridge.invokeMethod('im.page_success', {url: location.href}); | ||
857 | + }, 1000); | ||
858 | + | ||
859 | + window.addEventListener('pageshow', tellAppSuccess); | ||
860 | +} | ||
861 | + | ||
862 | + | ||
863 | +function setChannelColor(channel) { | ||
864 | + var dict = { | ||
865 | + 1: 'boys', | ||
866 | + 2: 'girls', | ||
867 | + 3: 'kids', | ||
868 | + 4: 'lifestyle' | ||
869 | + }; | ||
870 | + | ||
871 | + $(document.body) | ||
872 | + .removeClass('boys girls kids lifestyle') | ||
873 | + .addClass(dict[channel]); | ||
874 | +} | ||
875 | + | ||
854 | if (appBridge.isApp && /YohoBuy-iOS/i.test(navigator.userAgent)) { | 876 | if (appBridge.isApp && /YohoBuy-iOS/i.test(navigator.userAgent)) { |
855 | document.body.classList.add('app-ios'); | 877 | document.body.classList.add('app-ios'); |
856 | } | 878 | } |
857 | 879 | ||
858 | if (/YohoBuy-android/i.test(navigator.userAgent)) { | 880 | if (/YohoBuy-android/i.test(navigator.userAgent)) { |
881 | + | ||
859 | $('#js-back').removeAttr('href').on('click', function(e) { | 882 | $('#js-back').removeAttr('href').on('click', function(e) { |
860 | e.preventDefault(); | 883 | e.preventDefault(); |
861 | window.im.goBack(); | 884 | window.im.goBack(); |
862 | }); | 885 | }); |
886 | + | ||
887 | + setChannelColor(qs.yh_channel); | ||
863 | } else if (appBridge.isApp) { | 888 | } else if (appBridge.isApp) { |
864 | $('#js-back').removeAttr('href').on('click', function(e) { | 889 | $('#js-back').removeAttr('href').on('click', function(e) { |
865 | e.preventDefault(); | 890 | e.preventDefault(); |
866 | appBridge.invokeMethod('go.back', {}); | 891 | appBridge.invokeMethod('go.back', {}); |
867 | }); | 892 | }); |
893 | + | ||
894 | + tellAppSuccess(); | ||
895 | + setChannelColor(qs.yh_channel); | ||
868 | } | 896 | } |
869 | 897 | ||
870 | 898 | ||
899 | + | ||
900 | + | ||
901 | +window.channelChanged = function(channel) { | ||
902 | + setChannelColor(channel); | ||
903 | +}; | ||
904 | + | ||
905 | + | ||
871 | window.$ = $; | 906 | window.$ = $; |
872 | window.chat = chat; | 907 | window.chat = chat; |
873 | window.cmEntity = cmEntity; | 908 | window.cmEntity = cmEntity; |
@@ -5,6 +5,8 @@ const socketConf = require('./socket-config'); | @@ -5,6 +5,8 @@ const socketConf = require('./socket-config'); | ||
5 | const conversation = socketConf.conversationMessage; | 5 | const conversation = socketConf.conversationMessage; |
6 | const slice = Array.prototype.slice; | 6 | const slice = Array.prototype.slice; |
7 | 7 | ||
8 | +let uid = $('#js-uid').val(); | ||
9 | + | ||
8 | // EventEmitter | 10 | // EventEmitter |
9 | //-------------------------------------------------------- | 11 | //-------------------------------------------------------- |
10 | const EventEmitter = function() {}; | 12 | const EventEmitter = function() {}; |
@@ -53,6 +55,7 @@ let api = { | @@ -53,6 +55,7 @@ let api = { | ||
53 | return $.post('/service/leavemsg/save.json', { | 55 | return $.post('/service/leavemsg/save.json', { |
54 | conversationId: conversation.conversationId, | 56 | conversationId: conversation.conversationId, |
55 | content, | 57 | content, |
58 | + uid | ||
56 | }); | 59 | }); |
57 | }, | 60 | }, |
58 | 61 | ||
@@ -64,7 +67,7 @@ let api = { | @@ -64,7 +67,7 @@ let api = { | ||
64 | fetchOrders: function(type) { | 67 | fetchOrders: function(type) { |
65 | let url = `/service/im/${type}-list`; | 68 | let url = `/service/im/${type}-list`; |
66 | 69 | ||
67 | - return $.get(url); | 70 | + return $.get(url, {uid}); |
68 | }, | 71 | }, |
69 | 72 | ||
70 | // 获取10条历史记录 | 73 | // 获取10条历史记录 |
@@ -81,6 +84,7 @@ let api = { | @@ -81,6 +84,7 @@ let api = { | ||
81 | }, | 84 | }, |
82 | 85 | ||
83 | saveEvalute: function(data) { | 86 | saveEvalute: function(data) { |
87 | + data.uid = uid; | ||
84 | return $.post('/service/im/saveEvalute', data); | 88 | return $.post('/service/im/saveEvalute', data); |
85 | } | 89 | } |
86 | }; | 90 | }; |
@@ -149,11 +149,33 @@ | @@ -149,11 +149,33 @@ | ||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | - | ||
153 | body.app-ios { | 152 | body.app-ios { |
154 | - margin-top: 20PX; | 153 | + margin-top: 6PX; |
155 | 154 | ||
156 | - #chat-window { | ||
157 | - margin-top: 20PX; | 155 | + #chat-window, |
156 | + .connection-failed, | ||
157 | + .chat-page { | ||
158 | + margin-top: 6PX; | ||
158 | } | 159 | } |
160 | +} | ||
161 | + | ||
162 | + | ||
163 | +body.boys, .boys .chat-header { | ||
164 | + background-color: #414141 !important; | ||
165 | + background-image: none; | ||
166 | +} | ||
167 | + | ||
168 | +body.girls, .girls .chat-header { | ||
169 | + background-color: #ff88ae !important; | ||
170 | + background-image: none; | ||
171 | +} | ||
172 | + | ||
173 | +body.kids, .kids .chat-header { | ||
174 | + background-color: #7ad9f9 !important; | ||
175 | + background-image: none; | ||
176 | +} | ||
177 | + | ||
178 | +body.lifestyle, .lifestyle .chat-header { | ||
179 | + background-color: #4f4138 !important; | ||
180 | + background-image: none; | ||
159 | } | 181 | } |
-
Please register or login to post a comment