|
|
|
<template>
|
|
|
|
<view class="chat">
|
|
|
|
<view class="chat-navbar">
|
|
|
|
<u-navbar :title="title">
|
|
|
|
<view class="slot-wrap" slot="right" @click="toSheet()">
|
|
|
|
<u-icon name="more-dot-fill" color="#000000" size="30"></u-icon>
|
|
|
|
</view>
|
|
|
|
</u-navbar>
|
|
|
|
</view>
|
|
|
|
<view class="chat-hd" v-if="list.length>0">
|
|
|
|
<u-notice-bar :volume-icon="false" mode="horizontal" :list="list"></u-notice-bar>
|
|
|
|
</view>
|
|
|
|
<scroll-view class="chat-bd" scroll-y :class="list.length==0?(isOpen?'chat-bd-active1':'chat-bd-active'):(isOpen?'chat-bd-on':'')">
|
|
|
|
<view class="item">
|
|
|
|
<view class="fl"><image src="@/static/nv.png"></image></view>
|
|
|
|
<view class="fr">
|
|
|
|
<view class="name">李大花<text>陪玩师</text></view>
|
|
|
|
<view class="desc">世间无敌,舍我其谁。霸气长存,风云变色</view>
|
|
|
|
<view class="gift">送出礼物<image mode="widthFix" src="/static/logo.png"></image>棒棒糖<text>X3</text></view>
|
|
|
|
<view class="yinping">
|
|
|
|
<image src="@/static/chat-03.png"></image> 8”
|
|
|
|
</view>
|
|
|
|
<view class="video">
|
|
|
|
<video src=""></video>
|
|
|
|
</view>
|
|
|
|
<view class="img">
|
|
|
|
<image src="/static/pic.jpg"></image>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="item item-on">
|
|
|
|
<view class="fr">
|
|
|
|
<view class="desc">天天忙的要死,好久没联系了哈,你最近咋样啊?</view>
|
|
|
|
</view>
|
|
|
|
<view class="fl"><image src="@/static/nv.png"></image></view>
|
|
|
|
</view>
|
|
|
|
</scroll-view>
|
|
|
|
<view class="chat-fd">
|
|
|
|
<view class="a">
|
|
|
|
<view class="luyin">
|
|
|
|
<image src="/static/chat-01.png"></image>
|
|
|
|
</view>
|
|
|
|
<view class="input">
|
|
|
|
<!-- <editor placeholder="单行输入" @input="inputValue"></editor> -->
|
|
|
|
<input type="text" v-model="keyword" placeholder="单行输入" />
|
|
|
|
<view class="more" @click="isOpen = !isOpen">
|
|
|
|
<u-icon name="more-dot-fill" color="#000000" size="30"></u-icon>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="btn">
|
|
|
|
发送
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="b" v-if="isOpen">
|
|
|
|
<image src="@/static/chat-zhaopian.png"></image>
|
|
|
|
<image src="@/static/chat-xiangji.png"></image>
|
|
|
|
<image src="@/static/chat-yinshipin.png"></image>
|
|
|
|
<image src="@/static/chat-liwu.png"></image>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ZIM from '@/js_sdk/zego-ZIMUniplugin-JS/lib/index.js';
|
|
|
|
ZIM.create({ appID: 267111980, appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e' });
|
|
|
|
const zim = ZIM.getInstance();
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
id: "",
|
|
|
|
isOpen: false,
|
|
|
|
title: "",
|
|
|
|
keyword: "",
|
|
|
|
userInfo: {},
|
|
|
|
list: [],
|
|
|
|
itemList: [],
|
|
|
|
chatList: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
onLoad(o) {
|
|
|
|
this.id = o.id;
|
|
|
|
this.getUserInfo();
|
|
|
|
this.getChatList();
|
|
|
|
},
|
|
|
|
onReady() {
|
|
|
|
this.toImLogin()
|
|
|
|
|
|
|
|
|
|
|
|
// 注册监听“收到单聊消息”的回调
|
|
|
|
zim.on('receivePeerMessage', function (zim, { messageList, fromConversationID }) {
|
|
|
|
console.log('receivePeerMessage', messageList, fromConversationID);
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toImLogin() {
|
|
|
|
zim.login(uni.getStorageSync("userInfo").id, {
|
|
|
|
userName: uni.getStorageSync("userInfo").nickname,
|
|
|
|
token: uni.getStorageSync("chatToken"),
|
|
|
|
})
|
|
|
|
.then(function (res) {
|
|
|
|
// 登录成功
|
|
|
|
console.log(res,"登录成功")
|
|
|
|
})
|
|
|
|
.catch(function (err) {
|
|
|
|
// 登录失败
|
|
|
|
console.log(err)
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async getChatList(){
|
|
|
|
const { code, data , msg } = await this.$api.findChatList({formUserId: uni.getStorageSync("userInfo").id,toUserId: this.id});
|
|
|
|
if(code == 200){
|
|
|
|
this.chatList= data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async getUserInfo() {
|
|
|
|
const { code, data , msg } = await this.$api.findOtherUserInfo({userId: uni.getStorageSync("userInfo").id,sellerId: this.id,});
|
|
|
|
if(code == 200){
|
|
|
|
this.userInfo = data;
|
|
|
|
this.itemList = ["查看TA的主页", (data.isCare == 0?"关注":"取消关注"), "举报", (data.isBlack == 0?"加入黑名单":"移除黑名单")];
|
|
|
|
this.title = data.nickname;
|
|
|
|
this.getConfigData();
|
|
|
|
}else{
|
|
|
|
uni.showToast({
|
|
|
|
title: mgs,
|
|
|
|
position: "bottom",
|
|
|
|
icon: "none",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//字典查询
|
|
|
|
async getConfigData() {
|
|
|
|
const that = this;
|
|
|
|
let res1 = await that.$api.getConfigData({dictType: 'CONFIG_MESSAGE_NOTICE'});
|
|
|
|
if(res1.data && res1.data.length > 0){
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//加入黑名单
|
|
|
|
async toYichu(type) {
|
|
|
|
const { code, data } = await this.$api.addOrRemoveBlacklist({
|
|
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
|
|
sellerId: this.id,
|
|
|
|
type
|
|
|
|
})
|
|
|
|
if(code == 200){
|
|
|
|
uni.showToast({
|
|
|
|
title: type == 2?"移除成功":"加入成功"
|
|
|
|
})
|
|
|
|
setTimeout(()=>{
|
|
|
|
this.getInfo();
|
|
|
|
},2000)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
toSheet() {
|
|
|
|
uni.showActionSheet({
|
|
|
|
itemList: this.itemList,
|
|
|
|
success(res){
|
|
|
|
console.log(res.tapIndex)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
inputValue(e) {
|
|
|
|
console.log(e)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onUnload() {
|
|
|
|
zim.logout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.chat{
|
|
|
|
&-navbar{
|
|
|
|
.slot-wrap{
|
|
|
|
margin-right: 30rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&-hd{
|
|
|
|
width: 100%;
|
|
|
|
height: 70rpx;
|
|
|
|
background: #FFEBEB;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 24rpx;
|
|
|
|
color: #222222;
|
|
|
|
line-height: 70rpx;
|
|
|
|
padding: 0 10rpx;
|
|
|
|
box-sizing: border-box;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
&-bd{
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100vh - 190rpx - 88rpx);
|
|
|
|
padding: 0 25rpx;
|
|
|
|
box-sizing: border-box;
|
|
|
|
&-on{
|
|
|
|
height: calc(100vh - 190rpx - 88rpx - 160rpx);
|
|
|
|
}
|
|
|
|
&-active{
|
|
|
|
height: calc(100vh - 120rpx - 88rpx);
|
|
|
|
}
|
|
|
|
&-active1{
|
|
|
|
height: calc(100vh - 120rpx - 88rpx - 160rpx);
|
|
|
|
}
|
|
|
|
.item{
|
|
|
|
padding: 20rpx 0;
|
|
|
|
width: 100%;
|
|
|
|
align-items: flex-start;
|
|
|
|
display: flex;
|
|
|
|
overflow: hidden;
|
|
|
|
justify-content: flex-start;
|
|
|
|
.fl{
|
|
|
|
width: 80rpx;
|
|
|
|
height: 80rpx;
|
|
|
|
border-radius: 50%;
|
|
|
|
margin-right: 20rpx;
|
|
|
|
image{
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.fr{
|
|
|
|
flex: 1;
|
|
|
|
overflow: hidden;
|
|
|
|
.name{
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 28rpx;
|
|
|
|
color: #222222;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
text{
|
|
|
|
width: 100rpx;
|
|
|
|
line-height: 40rpx;
|
|
|
|
background: linear-gradient(0deg, #000000, #3D3B38);
|
|
|
|
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
|
|
|
|
border-radius: 40rpx;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 22rpx;
|
|
|
|
color: #FFFFFF;
|
|
|
|
display: block;
|
|
|
|
margin-left: 30rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.video{
|
|
|
|
width: 400rpx;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
margin-top: 20rpx;
|
|
|
|
padding: 20rpx;
|
|
|
|
video{
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.img{
|
|
|
|
width: 400rpx;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
margin-top: 20rpx;
|
|
|
|
padding: 20rpx;
|
|
|
|
image{
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.yinping{
|
|
|
|
width: 200rpx;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 10rpx;
|
|
|
|
margin-top: 20rpx;
|
|
|
|
padding: 20rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
color: #000;
|
|
|
|
font-size: 30rpx;
|
|
|
|
image{
|
|
|
|
width: 50rpx;
|
|
|
|
height: 50rpx;
|
|
|
|
margin-right: 20rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.gift{
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 24rpx;
|
|
|
|
color: #999999;
|
|
|
|
line-height: 44px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 20rpx;
|
|
|
|
image{
|
|
|
|
width: 60rpx;
|
|
|
|
margin: 0 10rpx;
|
|
|
|
}
|
|
|
|
text{
|
|
|
|
margin-left: 10rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.desc{
|
|
|
|
max-width: 400rpx;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 30rpx 0px 30rpx 30rpx;
|
|
|
|
margin-top: 20rpx;
|
|
|
|
padding: 30rpx;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 30rpx;
|
|
|
|
color: #222222;
|
|
|
|
line-height: 48rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&-on{
|
|
|
|
.fl{
|
|
|
|
margin-left: 20rpx;
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
.fr{
|
|
|
|
.desc{
|
|
|
|
float: right;
|
|
|
|
background: #EAEBEB;
|
|
|
|
border-radius: 0px 30rpx 30rpx 30rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&-fd{
|
|
|
|
width: 100%;
|
|
|
|
min-height: 120rpx;
|
|
|
|
background: #F6F6F6;
|
|
|
|
.a{
|
|
|
|
width: 100%;
|
|
|
|
height: 120rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
padding: 0 20rpx;
|
|
|
|
box-sizing: border-box;
|
|
|
|
.luyin{
|
|
|
|
width: 50rpx;
|
|
|
|
height: 50rpx;
|
|
|
|
image{
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.input{
|
|
|
|
flex: 1;
|
|
|
|
height: 80rpx;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 10rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
margin-left: 20rpx;
|
|
|
|
margin-right: 20rpx;
|
|
|
|
editor,input{
|
|
|
|
flex: 1;
|
|
|
|
height: 50rpx;
|
|
|
|
line-height: 50rpx;
|
|
|
|
min-height: 50rpx;
|
|
|
|
font-style: normal !important;
|
|
|
|
margin-left: 20rpx;
|
|
|
|
}
|
|
|
|
.more{
|
|
|
|
margin: 0 20rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.btn{
|
|
|
|
width: 120rpx;
|
|
|
|
line-height: 70rpx;
|
|
|
|
background: linear-gradient(0deg, #000000, #3D3B38);
|
|
|
|
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
|
|
|
|
border-radius: 50rpx;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 28rpx;
|
|
|
|
color: #FFFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.b{
|
|
|
|
width: 100%;
|
|
|
|
height: 160rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
border-top: 1px solid #E2E2E2;
|
|
|
|
padding: 0 45rpx;
|
|
|
|
box-sizing: border-box;
|
|
|
|
image{
|
|
|
|
width: 100rpx;
|
|
|
|
height: 100rpx;
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|