Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. $rootScope.getUserInfo = (conversation) => {
  2. setTimeout(() => {
  3. this.userinfoService.getUserInfo(conversation.profile_id, conversation.chat_id, conversation.fanpage_id, (res) => {
  4. let name_default = 'Khách hàng';
  5. let user_info = {
  6. name: name_default,
  7. tag: [],
  8. avatar: '/boxchat/assets/images/default-profile-picture.jpg'
  9. };
  10. $.each(res.data, function (index, value) {
  11. user_info[index] = value;
  12. });
  13. if (user_info.name === name_default && $rootScope.activeConversation.fullname !== name_default) {
  14. user_info.name = $rootScope.activeConversation.fullname;
  15. }
  16. else {
  17. if (user_info.name.length > 0) {
  18. $rootScope.activeConversation.fullname = user_info.name;
  19. }
  20. }
  21. if (!this.$rootScope.user.tag) {
  22. this.$rootScope.user.tag = [];
  23. }
  24. this.$rootScope.user.avatar = $rootScope.activeConversation.avatar;
  25. if ($rootScope.activeConversation.tag) {
  26. $rootScope.activeConversation.tag.forEach((item) => {
  27. user_info.tag.push(item);
  28. });
  29. }
  30. this.$rootScope.user = user_info;
  31. $rootScope.getAnswerofQuicktag();
  32.  
  33. console.log(this.$rootScope.user);
  34. if (conversation.unread_message > 0) {
  35. let text = '';
  36. for (let i = 0; i < Conversation.unread_message; i++) {
  37. text += this.$rootScope.chatHistory[i].bodyMsg.msg + ' ';
  38. }
  39. $rootScope.checkEmailOrPhone(text);
  40. }
  41. });
  42. }, 100)
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement