|
@@ -1,6 +1,9 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
- <!-- <web-view :webview-styles="" :src=""></web-view> -->
|
|
|
+ <view v-for="item in userList" v-if="judge(item.id)" >
|
|
|
+
|
|
|
+ <web-view :src="go(item.id,item.nickname)" v-bind:id="item.id" >{{item.id}}</web-view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -16,46 +19,71 @@
|
|
|
username:'',
|
|
|
remak2:'', */
|
|
|
},
|
|
|
- userid:'',
|
|
|
list:[],
|
|
|
+ lastUserName:'',
|
|
|
+ userid:'',
|
|
|
+ identify:'',
|
|
|
+ bool:'',
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
this.getUserList();
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ backStageIp: function() {
|
|
|
+ return this.$store.state.GlobalLocalIp;
|
|
|
+ },
|
|
|
+ backStagePort: function() {
|
|
|
+ return this.$store.state.GlobalLocalPort;
|
|
|
+ },
|
|
|
+ windpowerstationNameToId: function() {
|
|
|
+ return this.$store.state.windpowerstationNameToId;
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
- async getUserList() {
|
|
|
+ judge(id){
|
|
|
+ if(id==this.identify){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ go(id,nickname){
|
|
|
+ let _this=this;
|
|
|
+ if(_this.bool == 1){
|
|
|
+ return "https://"+_this.backStageIp+":"+_this.backStagePort+"/websocket/usercontroller/view?send="+_this.userid+"&receive="+id+"&sendname="+_this.lastUserName+"&receivename="+nickname;
|
|
|
+ }else{
|
|
|
+ return "https://"+ _this.backStageIp+":"+_this.backStagePort+"/websocket/usercontroller/viewoffline?send="+_this.userid+"&receive="+id+"&sendname="+_this.lastUserName+"&receivename="+nickname;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getUserList() {
|
|
|
+ this.lastUserName = uni.getStorageSync('gyeeusername');
|
|
|
+ this.userid = uni.getStorageSync('userid');
|
|
|
+
|
|
|
let _this = this;
|
|
|
- // 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
|
|
|
- this.socketTask_getUserList = uni.connectSocket({
|
|
|
- // 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
|
|
|
- url: 'ws://117.78.18.24:9988/websocket/pageNumber_4/functionNumber_3/all',
|
|
|
- success(data) {
|
|
|
- console.log(data);
|
|
|
- }
|
|
|
- });
|
|
|
- /* let windpowerstationid = uni.getStorageSync('windpowerstationName'); */
|
|
|
- // 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
|
|
|
- this.socketTask_getUserList.onOpen(res => {
|
|
|
- console.log('WebSocket连接正常打开中...!');
|
|
|
- this.is_open_socket = true;
|
|
|
+ uni.request({
|
|
|
+ url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeuserController/selectUserList',
|
|
|
+ data: {},
|
|
|
+ method: 'GET',
|
|
|
+ success: function(res) {
|
|
|
+ _this.userList =res.data;
|
|
|
+
|
|
|
|
|
|
- // 注:只有连接正常打开中 ,才能正常收到消息
|
|
|
- this.socketTask_getUserList.onMessage(res => {/*
|
|
|
- console.log("收到服务器内容:" + res.data); */
|
|
|
- /* _this.windpowerstationdetail.getUserList = JSON.parse(res.data); */
|
|
|
- _this.userList = JSON.parse(res.data);
|
|
|
- _this.userid = uni.getStorageSync('userid');
|
|
|
- let list = [{}];
|
|
|
- for(let i =0;i<_this.userList.length;i++){
|
|
|
- list[i] = {};
|
|
|
- list[i].id =_this.userList[i].id+'-'+_this.userid;
|
|
|
- }
|
|
|
- _this.list = list;
|
|
|
- console.log(list);
|
|
|
- });
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ _this.tips = '网络错误,小程序端请检查合法域名';
|
|
|
+ },
|
|
|
});
|
|
|
+
|
|
|
},
|
|
|
+ childMethod(id,bool){
|
|
|
+ console.log(id);
|
|
|
+ this.identify=id;
|
|
|
+ this.bool = bool;
|
|
|
+ this.getUserList();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|