handle.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import {FlatListReload} from "$components/flat-list/const";
  2. import followEntrust, {EntrustType} from "$utils/request/entrust";
  3. import socket from "$utils/socket";
  4. import personalDetail from "$utils/control/personal-detail";
  5. import {NoticeType} from "$utils/socket/const";
  6. export default <LibMixins>{
  7. inject:['openUserContent'],
  8. methods:{
  9. fetch(obj){
  10. let key = 'get_'+this.type;
  11. if (this[key]) {
  12. return this[key](obj).then(function (data){
  13. return obj.success(data.data);
  14. }).catch(obj.fail);
  15. } else {
  16. setTimeout(()=> obj.fail(),0);
  17. }
  18. },
  19. // 获取关注列表
  20. get_follow(obj){
  21. return this.$request({
  22. url:'user/get_user_follow_list',
  23. page:obj.data,
  24. token:true,
  25. entrust: followEntrust.getEntrust(EntrustType.follow),
  26. })
  27. },
  28. // 获取粉丝列表
  29. get_fans(obj){
  30. return this.$request({
  31. url:'user/hx_get_user_fans_list',
  32. page:obj.data,
  33. entrust: followEntrust.getEntrust(EntrustType.fans),
  34. token:true
  35. })
  36. },
  37. triggerOpenUserContent(item){
  38. if (item.uid !== this.uid) {
  39. // 获取
  40. let conversation = socket.getConversation(item.uid);
  41. // 清楚标记
  42. conversation.read();
  43. return this.openUserContent(item.uid,item.pid || 0,item);
  44. }
  45. }
  46. },
  47. created() {
  48. if (this.type === 'follow') {
  49. socket.on('popup-chat-list',(params)=>{
  50. if (params.uid) {
  51. if (params.status) {
  52. this.$refs.flat && this.$refs.flat.flat_unshift(params.uid,params.followUserInfo);
  53. } else {
  54. this.$refs.flat && this.$refs.flat.flat_delete(params.uid);
  55. }
  56. }
  57. personalDetail.updateCache(params);
  58. },NoticeType.follow);
  59. }
  60. },
  61. beforeUnmount() {
  62. if (this.type === 'follow') {
  63. socket.off('popup-chat-list',NoticeType.follow);
  64. }
  65. }
  66. }