123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <view>
- </view>
- </template>
- <script>
- var wv = [];
- export default {
- name: "initial",
- props: {
- showModal: {
- type: String,
- default: '0'
- }
- },
- data() {
- return {
- userList: [],
- userListshow: [],
- list: [],
- lastUserName: '',
- userid: '',
- identify: '',
- bool: '',
- }
- },
- created() {
- this.getUserList();
- },
- computed: {
- sisStageIp: function() {
- return this.$store.state.wholeSituationBackStageIp;
- },
- sisStagePort: function() {
- return this.$store.state.wholeSituationBackStagePort;
- },
- backStageIp: function() {
- return this.$store.state.GlobalLocalIp;
- },
- backStagePort: function() {
- return this.$store.state.GlobalLocalPort;
- },
- windpowerstationNameToId: function() {
- return this.$store.state.windpowerstationNameToId;
- },
- },
- methods: {
-
- getUserList() {
- let im_show =uni.getStorageSync('im_show');
- if (im_show == "1") {
- this.lastUserName = uni.getStorageSync('gyeeusername');
- this.userid = uni.getStorageSync('userid');
- let _this = this;
- uni.request({
- url: 'http://' + this.sisStageIp + ':' + this.sisStagePort + '/GyeeuserController/selectUserList',
- data: {},
- method: 'GET',
- success: function(res) {
- _this.userList = [];
- for (var i = 0; i < res.data.length; i++) {
- if (res.data[i].id != _this.userid) {
- var pages = getCurrentPages();
- var page = pages[pages.length - 1];
- let webView = plus.webview.create("", "webview" + res.data[i].id, {
- plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
- 'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
- top: uni.getSystemInfoSync().statusBarHeight + 44 //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
- })
- let url = '';
- if (_this.identify == res.data[i].id && _this.bool == 0) {
- url = "https://" + _this.backStageIp + ":" + _this.backStagePort +
- "/websocket/usercontroller/viewoffline?send=" + _this
- .userid + "&receive=" + res.data[i].id + "&sendname=" + _this.lastUserName + "&receivename=" + res.data[i]
- .nickName;
- } else {
- url = "https://" + _this.backStageIp + ":" + _this.backStagePort + "/websocket/usercontroller/view?send=" +
- _this.userid + "&receive=" + res.data[i].id + "&sendname=" + _this.lastUserName + "&receivename=" + res.data[
- i].nickname;
- }
- webView.loadURL(url)
- var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
- currentWebview.append(webView); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
- //wv.setStyle({top:70,height:height});
- webView.hide();
- wv.push(webView)
- }
- };
- },
- fail: () => {
- _this.tips = '网络错误,小程序端请检查合法域名';
- },
- });
-
- uni.setStorageSync('im_show','0');
-
- }
- },
- childMethod(id, bool, state) {
- console.log(id);
- this.identify = id;
- this.bool = bool;
- //this.getUserList();
- let webview;
- for (var i = 0; i < wv.length; i++) {
- if (wv[i].id == "webview" + id) {
- webview = wv[i];
- let url = webview.getURL();
- if (bool != null) {
- if (bool == 1) {
- if (url.indexOf("/view?") < 0) {
- url = url.replace("/viewoffline?", "/view?");
- webview.loadURL(url);
- }
- } else {
- if (url.indexOf("/viewoffline?") < 0) {
- url = url.replace("/view?", "/viewoffline?");
- webview.loadURL(url);
- }
- }
- }
- if (state == 1) {
- webview.show()
- } else {
- webview.hide();
- }
- break;
- }
- }
- }
- }
- }
- </script>
- <style>
- </style>
|