|
@@ -3,8 +3,9 @@
|
|
|
<view class="main">
|
|
|
<view class="one">
|
|
|
<!-- 聊天内容 -->
|
|
|
- <scroll-view class="chat" scroll-y="true" scroll-with-animation="true" :scroll-into-view="scrollToView">
|
|
|
- <view class="chat-main" :style="{paddingBottom:inputh+'px'}">
|
|
|
+ <scroll-view class="scroll-view" scroll-y="true" scroll-with-animation="true"
|
|
|
+ :scroll-into-view="scrollToView">
|
|
|
+ <view class="list-scroll-view">
|
|
|
<view class="chat-ls" v-for="(item,index) in unshiftmsg" :key="index" :id="'msg'+ index">
|
|
|
<view class="chat-time" v-if="item.time != ''">
|
|
|
{{item.time}}
|
|
@@ -38,6 +39,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
+ </view>
|
|
|
+ <view class="two">
|
|
|
<submit_1 @inputs="inputs" @heights="heights"></submit_1>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -54,6 +57,7 @@
|
|
|
data() {
|
|
|
return {
|
|
|
friendName: "zs",
|
|
|
+ user: {},
|
|
|
info: {},
|
|
|
id: '',
|
|
|
name: '',
|
|
@@ -129,31 +133,63 @@
|
|
|
const that = this;
|
|
|
that.$set(that, `id`, e.id);
|
|
|
that.$set(that, `name`, e.name);
|
|
|
- // await that.searchOther();
|
|
|
if (e.name) {
|
|
|
uni.setNavigationBarTitle({
|
|
|
title: e.name
|
|
|
});
|
|
|
}
|
|
|
- if (e.id) await that.search()
|
|
|
+ await that.watchlogin();
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 监听用户是否登录
|
|
|
+ watchlogin() {
|
|
|
+ const that = this;
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'token',
|
|
|
+ success: function(res) {
|
|
|
+ let user = that.$jwt(res.data);
|
|
|
+ if (user) {
|
|
|
+ that.$set(that, `user`, user)
|
|
|
+ // if (that.id)
|
|
|
+ that.search()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
async search() {
|
|
|
const that = this;
|
|
|
let res;
|
|
|
- res = await that.$api(`/chatRecord`, `GET`, {
|
|
|
- room: that.id
|
|
|
- }, 'chat');
|
|
|
- if (res.errcode == '0') {
|
|
|
- console.log(res);
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: res.errmsg,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- }
|
|
|
+ let config = that.$config;
|
|
|
+ let url = `wss://${config.stompUrl}/ws/exchange/t_m_dev_local/635f82e62df39d4755a25a4a`;
|
|
|
+ console.log(url);
|
|
|
+ uni.closeSocket()
|
|
|
+ uni.connectSocket({
|
|
|
+ url,
|
|
|
+ // header: {
|
|
|
+ // login: 'tehqDev',
|
|
|
+ // passcode: 'tehqDev'
|
|
|
+ // },
|
|
|
+ success: async function(res) {
|
|
|
+ console.log(res, 's');
|
|
|
+ // res = await that.$api(`/chatRecord`, `GET`, {
|
|
|
+ // room: that.id
|
|
|
+ // }, 'chat');
|
|
|
+ // if (res.errcode == '0') {
|
|
|
+ // console.log(res);
|
|
|
+ // } else {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: res.errmsg,
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ console.log(err, 'e');
|
|
|
+ }
|
|
|
+ });
|
|
|
// 跳转到最后一条数据 与前面的:id进行对照
|
|
|
that.$nextTick(function() {
|
|
|
+ console.log(that.unshiftmsg);
|
|
|
that.scrollToView = 'msg' + (that.unshiftmsg.length - 1)
|
|
|
})
|
|
|
},
|
|
@@ -224,18 +260,13 @@
|
|
|
flex-direction: column;
|
|
|
width: 100vw;
|
|
|
height: 100vh;
|
|
|
+ overflow: hidden;
|
|
|
|
|
|
.one {
|
|
|
- .chat {
|
|
|
- height: 100%;
|
|
|
+ position: relative;
|
|
|
+ flex-grow: 1;
|
|
|
|
|
|
- .chat-main {
|
|
|
- padding-left: 32rpx;
|
|
|
- padding-right: 32rpx;
|
|
|
- padding-top: 20rpx;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- }
|
|
|
+ .scroll-view {
|
|
|
|
|
|
.chat-ls {
|
|
|
.chat-time {
|
|
@@ -311,6 +342,11 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .two {
|
|
|
+ background-color: #f0f0f0;
|
|
|
+ border-top: 1px solid rgba(39, 40, 50, 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.scroll-view {
|