InitializeThe.vue 4.1 KB

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