From f4a4c7709e09bb7c31f802ea8187d1e117efda2b Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Thu, 12 Aug 2021 09:48:16 +0800
Subject: [PATCH] 视频
---
App.vue | 84 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 81 insertions(+), 3 deletions(-)
diff --git a/App.vue b/App.vue
index 7a4e426..79c0309 100644
--- a/App.vue
+++ b/App.vue
@@ -4,6 +4,14 @@
data() {
return {
login: '',
+
+ show: true,
+ name: 'a',
+ list: [{
+ "name": 'tip',
+ "msg": 'The first content!'
+ }],
+ content: '123456'
}
},
methods: {
@@ -25,14 +33,84 @@
url: 'pages/loging/loging?id=1',
})
}
- }
+ },
+ //发送消息
+ send: function() {
+ if (this.content) {
+ this.list.push({
+ "name": this.name,
+ "msg": this.content
+ })
+ console.log(this.list)
+ this.socket.emit('sendMessage', {
+ "name": this.name,
+ "msg": this.content
+ });
+ this.content = ''
+ uni.pageScrollTo({
+ duration: 0,
+ scrollTop: this.list.length * 100
+ })
+ } else {
+ uni.showToast({
+ title: '请输入内容',
+ icon: 'none'
+ })
+ }
+ },
+ //提交姓名
+ onSubmitName: function() {
+ console.log(this.name)
+ if (this.name) {
+ this.show = false
+ this.socket.emit('newPeople', this.name);
+ }
+ },
},
watch: {},
- mounted() {},
+ mounted() {
+ // 加载长连接服务器
+ // this.socket.on('connect', () => {
+ // console.log('connection created.');
+ // // that.onSubmitName();
+ // });
+
+
+
+ },
onLaunch: function() { //初始化完成时触发(全局只触发一次)
+ var that = this;
if (WxStorage.get("init") == '') {
WxStorage.set("init", 'false');
- console.log('第一次进入')
+ console.log('第一次进入');
+
+ // uni.connectSocket({
+ // url: 'ws://192.168.0.111:9034/websocket'
+ // });
+
+ // uni.onSocketOpen(function(res) {
+ // socketOpen = true;
+ // sendSocketMessage();
+ // });
+
+ // function sendSocketMessage() {
+ // var data = {
+ // type: that.$store.state.puserName,
+ // id: that.$store.state.puserID
+ // }
+ // if (socketOpen) {
+ // uni.sendSocketMessage({
+ // data: JSON.stringify(data)
+ // });
+ // }
+ // }
+
+ // 加载长连接服务器
+ // this.socket.on('connect', () => {
+ // console.log('connection created.');
+ // that.onSubmitName();
+ // });
+
}
// this.judgeAdmin();
},
--
Gitblit v1.9.3