InitializeThe.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view>
  3. </view>
  4. </template>
  5. <script>
  6. var wv = [];
  7. export default {
  8. data() {
  9. return {
  10. userList: [],
  11. userListshow: [],
  12. list: [],
  13. lastUserName: '',
  14. userid: '',
  15. identify: '',
  16. bool: '',
  17. }
  18. },
  19. created() {
  20. this.getUserList();
  21. },
  22. computed: {
  23. sisStageIp: function() {
  24. return this.$store.state.wholeSituationBackStageIp;
  25. },
  26. sisStagePort: function() {
  27. return this.$store.state.wholeSituationBackStagePort;
  28. },
  29. backStageIp: function() {
  30. return this.$store.state.GlobalLocalIp;
  31. },
  32. backStagePort: function() {
  33. return this.$store.state.GlobalLocalPort;
  34. },
  35. windpowerstationNameToId: function() {
  36. return this.$store.state.windpowerstationNameToId;
  37. },
  38. },
  39. methods: {
  40. getUserList() {
  41. this.lastUserName = uni.getStorageSync('gyeeusername');
  42. this.userid = uni.getStorageSync('userid');
  43. let _this = this;
  44. uni.request({
  45. url: 'http://' + this.sisStageIp + ':' + this.sisStagePort + '/GyeeuserController/selectUserList',
  46. data: {},
  47. method: 'GET',
  48. success: function(res) {
  49. _this.userList = [];
  50. for (var i = 0; i < res.data.length; i++) {
  51. if (res.data[i].id != _this.userid) {
  52. var pages = getCurrentPages();
  53. var page = pages[pages.length - 1];
  54. let webView = plus.webview.create("", "webview"+res.data[i].id, {
  55. plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
  56. 'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
  57. top: uni.getSystemInfoSync().statusBarHeight + 44 //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
  58. })
  59. let url = '';
  60. if (_this.identify == res.data[i].id && _this.bool == 0) {
  61. url = "https://" + _this.backStageIp + ":" + _this.backStagePort +
  62. "/websocket/usercontroller/viewoffline?send=" + _this
  63. .userid + "&receive=" + res.data[i].id + "&sendname=" + _this.lastUserName + "&receivename=" + res.data[i].nickName;
  64. } else {
  65. url = "https://" + _this.backStageIp + ":" + _this.backStagePort + "/websocket/usercontroller/view?send=" +
  66. _this.userid + "&receive=" + res.data[i].id + "&sendname=" + _this.lastUserName + "&receivename=" + res.data[i].nickname;
  67. }
  68. webView.loadURL(url)
  69. var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
  70. currentWebview.append(webView); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
  71. //wv.setStyle({top:70,height:height});
  72. webView.hide();
  73. wv.push(webView)
  74. }
  75. };
  76. },
  77. fail: () => {
  78. _this.tips = '网络错误,小程序端请检查合法域名';
  79. },
  80. });
  81. },
  82. childMethod(id, bool,state) {
  83. console.log(id);
  84. this.identify = id;
  85. this.bool = bool;
  86. //this.getUserList();
  87. let webview;
  88. for (var i = 0; i < wv.length; i++) {
  89. if(wv[i].id=="webview"+id)
  90. {
  91. webview=wv[i];
  92. let url=webview.getURL();
  93. if(bool!=null)
  94. {
  95. if(bool==1)
  96. {
  97. if(url.indexOf("/view?")<0)
  98. {
  99. url=url.replace("/viewoffline?","/view?");
  100. webview.loadURL(url);
  101. }
  102. }else
  103. {
  104. if(url.indexOf("/viewoffline?")<0)
  105. {
  106. url=url.replace("/view?","/viewoffline?");
  107. webview.loadURL(url);
  108. }
  109. }
  110. }
  111. if(state==1)
  112. {
  113. webview.show()
  114. }else
  115. {
  116. webview.hide();
  117. }
  118. break;
  119. }
  120. }
  121. }
  122. }
  123. }
  124. </script>
  125. <style>
  126. </style>