userInfo.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import $request, {InstructionsCacheType} from "$utils/request";
  2. import personalDetail from '$utils/control/personal-detail';
  3. export default {
  4. data(){
  5. return {
  6. number:1
  7. }
  8. },
  9. methods:{
  10. // 下单
  11. placeOrder(){
  12. if (this.userInfo && this.userInfo.is_player) {
  13. return personalDetail.placeOrder(this.number || 1,this.userInfo.gameList,this.userInfo);
  14. }
  15. },
  16. // 获取陪玩信息
  17. getPlayerList(){
  18. this.number = 1;
  19. return this.$request({
  20. url:'player/get_player_list',
  21. data:{
  22. uid: this.uid,
  23. },
  24. token:true,
  25. page:{
  26. page:1,
  27. pageSize:1
  28. },
  29. cache:{
  30. type: InstructionsCacheType.memory,
  31. id:'get_player_list_'+this.uid
  32. }
  33. });
  34. },
  35. // 获取用户信息
  36. getUserInfo(requestUnique){
  37. this.getPlayerList().then((data)=>{
  38. if (this.requestUnique === requestUnique) {
  39. let requestAjax = [personalDetail.getPlayInfo({
  40. uid:this.uid
  41. })];
  42. let pid = 0;
  43. if (data.data && data.data.length > 0) {
  44. pid = data.data[0].pid;
  45. requestAjax.push(personalDetail.getPlayList({
  46. pid
  47. }));
  48. }
  49. Promise.all(requestAjax).then(([user,gameList])=>{
  50. if (this.requestUnique === requestUnique) {
  51. user = user.data || {};
  52. if (gameList) {
  53. gameList = gameList.data.palyer_game_list || [];
  54. let unshiftData = undefined;
  55. gameList.map((item,index)=>{
  56. if (this.pid && item.pid === this.pid) {
  57. unshiftData = item;
  58. }
  59. });
  60. if (!unshiftData && gameList[0]) {
  61. unshiftData = gameList[0];
  62. }
  63. user.gameList = gameList;
  64. user.gameItem = unshiftData;
  65. user.pid = this.pid || pid;
  66. user.is_player = !!user.pid;
  67. // 游戏列表
  68. let gameCate = this.$store.state.cate.gameCate || [];
  69. gameCate = gameCate[0] && gameCate[0].children || [];
  70. for (let i=0,count=gameCate.length;i<count;i++){
  71. if (gameCate[i] && gameCate[i].game_name === user.gameItem.game_name) {
  72. user.gameItem.gameInfo = gameCate[i];
  73. break;
  74. }
  75. }
  76. }
  77. if (data.data[0]) {
  78. let playInfo = data.data[0];
  79. user.stay_roominfo = playInfo.stay_roominfo;
  80. user.guanming = playInfo.guanming;
  81. user.is_business = playInfo.is_business;
  82. user.is_player = true;
  83. }
  84. this.userInfo = user || {};
  85. this.setFollow(user);
  86. this.sendMessageScroll();
  87. this.loadingStatus = false;
  88. // obj.success([{}]);
  89. }
  90. })
  91. }
  92. });
  93. },
  94. }
  95. }