_get.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import _mixins from './_mixins';
  2. import _action from './action';
  3. import _data from './_data';
  4. export default {
  5. /** 获得会话列表数据 */
  6. getChatList(){
  7. _mixins.methods.$httpSend({
  8. path: '/im/get/chatList',
  9. success(data) {
  10. _data.localData('chat_list',data);
  11. uni.$emit('data_chat_list',data);
  12. _action.setStatusTips();
  13. }
  14. });
  15. },
  16. /**
  17. * 获得对话数据
  18. * @param {
  19. 发送的数据
  20. send_data: {
  21. list_id: list_id,
  22. time: 0,
  23. 是否更新未读消息数
  24. is_up: 1,
  25. },
  26. 回调函数
  27. calllback(data){
  28. },
  29. 是否需要操作本地缓存数据
  30. is_action_data: 1,
  31. }
  32. */
  33. getChatData(config){
  34. _mixins.methods.$httpSend({
  35. path: '/im/get/chatData',
  36. data: config.send_data,
  37. success(data) {
  38. if(config.is_action_data){
  39. uni.$emit('data_chat_data',data);
  40. _data.localData(data.list_id,data);
  41. }
  42. else{
  43. uni.$emit('data_chat_data_unshift',data.list);
  44. }
  45. if('callback' in config){
  46. config.callback(data);
  47. }
  48. }
  49. });
  50. },
  51. /** 获得通讯录数据 */
  52. getFriendList(send_data,callback){
  53. if(!send_data){
  54. send_data = {};
  55. }
  56. _mixins.methods.$httpSend({
  57. path: '/im/get/friendList',
  58. data: send_data,
  59. success(data) {
  60. if(data.data.length || 'up' in send_data){
  61. _data.localData('friend_list',data.data);
  62. uni.$emit('data_friend_list',data.data);
  63. }
  64. if(callback){
  65. callback(data);
  66. }
  67. }
  68. });
  69. },
  70. /** 获得朋友圈数据 data要发送的数据 type 0加载最新数据 1加载历史数据 */
  71. getCircleList(send_data,callback){
  72. _mixins.methods.$httpSend({
  73. path: '/im/get/circleData',
  74. data: send_data,
  75. success(data) {
  76. let circle_data = _data.localData('circle_data');
  77. if(!circle_data){
  78. circle_data = [];
  79. }
  80. if(send_data.type){
  81. circle_data.push(...data.data);
  82. } else {
  83. circle_data.unshift(...data.data);
  84. }
  85. _data.localData('circle_data',circle_data);
  86. uni.$emit('data_circle_data',circle_data);
  87. if(callback) {
  88. callback(data);
  89. }
  90. }
  91. });
  92. },
  93. /** 获得基础数据 */
  94. base(){
  95. _mixins.methods.$httpSend({
  96. path: '/im/get/base',
  97. success(data) {
  98. data.user_info.photo += '?_=' + Math.random();
  99. data.user_info.circle_img += '?_=' + Math.random();
  100. _data.data('user_info',data.user_info);
  101. uni.$emit('data_user_info',data.user_info);
  102. _data.data('new_friend_tips_num',data.new_friend_tips_num);
  103. _data.data('no_reader_chat_num',data.no_reader_chat_num);
  104. _data.data('no_reader_circle',data.no_reader_circle);
  105. _data.data('no_reader_circle_chat_num',data.no_reader_circle_chat_num);
  106. _data.data('new_group_tips_num',data.new_group_tips_num);
  107. _action.setStatusTips();
  108. _action.downloadPhoto();
  109. }
  110. });
  111. },
  112. /** 获得好友申请列表数据 */
  113. getFriendApplyList(callback){
  114. _mixins.methods.$httpSend({
  115. path: '/im/get/applyFriend',
  116. success(data) {
  117. _data.localData('friend_apply_list',data);
  118. uni.$emit('data_friend_apply_list',data);
  119. if(callback){
  120. callback(data);
  121. }
  122. }
  123. });
  124. },
  125. /** 获得群认证列表数据 */
  126. getGroupApplyList(callback){
  127. _mixins.methods.$httpSend({
  128. path: '/im/get/applyGroup',
  129. success(data) {
  130. _data.localData('group_apply_list',data);
  131. uni.$emit('data_group_apply_data',data);
  132. if(callback){
  133. callback(data);
  134. }
  135. }
  136. });
  137. },
  138. }