|
|
|
@ -13,20 +13,22 @@ |
|
|
|
|
<scroll-view id="wrapper" class="chat-bd" |
|
|
|
|
:class="list.length==0?(isOpen?'chat-bd-active1':'chat-bd-active'):(isOpen?'chat-bd-on':'')" |
|
|
|
|
:scroll-y="true" |
|
|
|
|
@scrolltoupper="scrolltoupper" |
|
|
|
|
:scroll-with-animation="true" |
|
|
|
|
:scroll-top="wrapperScrollHeight" |
|
|
|
|
> |
|
|
|
|
<view id="wrapper"> |
|
|
|
|
<view class="item" :class="userId != a.rightUserId?'item-on':''" v-for="(a,index) in chatList" :key="index"> |
|
|
|
|
<template v-if="userId != a.rightUserId"> |
|
|
|
|
<view id="wrapper1"> |
|
|
|
|
<view class="item" :class="a.sendType == 1?'item-on':''" v-for="(a,index) in chatList" :key="index"> |
|
|
|
|
<!-- 增加字段:sendType 1我发给你 2你发给我 --> |
|
|
|
|
<template v-if="a.sendType == 1"> |
|
|
|
|
<view class="fr"> |
|
|
|
|
<view class="desc" v-if="a.type == 6 || a.type==3">{{a.message}}</view> |
|
|
|
|
<view class="gift" v-if="a.type == 5">送出礼物<image mode="widthFix" :src="a.message"></image>棒棒糖<text>X{{a.num}}</text></view> |
|
|
|
|
<view class="yinping" v-if="a.type == 1"> |
|
|
|
|
<image :src="a.message"></image> {{a.num}}” |
|
|
|
|
<view class="yinping" v-if="a.type == 1" @click="toAudio(a.message)"> |
|
|
|
|
<image src="@/static/chat-03.png"></image> {{a.num}}” |
|
|
|
|
</view> |
|
|
|
|
<view class="video" v-if="a.type == 2"> |
|
|
|
|
<video :src="a.message"></video> |
|
|
|
|
<image @click="toPlay(a.message)" src="@/static/video_bg.png"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="img" v-if="a.type == 4"> |
|
|
|
|
<image :src="a.message"></image> |
|
|
|
@ -37,14 +39,14 @@ |
|
|
|
|
<template v-else> |
|
|
|
|
<view class="fl"><image :src="a.rightFaceImage"></image></view> |
|
|
|
|
<view class="fr"> |
|
|
|
|
<view class="name">{{a.rightNickname}}<text v-if="a.rightRole == 2">陪玩师</text></view> |
|
|
|
|
<view class="name">{{a.leftNickname}}<text v-if="a.leftRole == 2">陪玩师</text></view> |
|
|
|
|
<view class="desc" v-if="a.type == 6 || a.type==3">{{a.message}}</view> |
|
|
|
|
<view class="gift" v-if="a.type == 5">送出礼物<image mode="widthFix" :src="a.message"></image>棒棒糖<text>X{{a.num}}</text></view> |
|
|
|
|
<view class="yinping" v-if="a.type == 1"> |
|
|
|
|
<image :src="a.message"></image> {{a.num}}” |
|
|
|
|
<view class="yinping" v-if="a.type == 1" @click="toAudio(a.message)"> |
|
|
|
|
<image src="@/static/chat-03.png"></image> {{a.num}}” |
|
|
|
|
</view> |
|
|
|
|
<view class="video" v-if="a.type == 2"> |
|
|
|
|
<video :src="a.message"></video> |
|
|
|
|
<image @click="toPlay(a.message)" src="@/static/video_bg.png"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="img" v-if="a.type == 4"> |
|
|
|
|
<image :src="a.message"></image> |
|
|
|
@ -77,7 +79,7 @@ |
|
|
|
|
<view class="b" v-if="isOpen"> |
|
|
|
|
<image @click="uploadImg()" src="@/static/chat-zhaopian.png"></image> |
|
|
|
|
<image @click="uploadVideo()" src="@/static/chat-xiangji.png"></image> |
|
|
|
|
<image src="@/static/chat-yinshipin.png"></image> |
|
|
|
|
<image @click="openShiping()" src="@/static/chat-yinshipin.png"></image> |
|
|
|
|
<image @click="openGift()" src="@/static/chat-liwu.png"></image> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -116,26 +118,29 @@ |
|
|
|
|
</view> |
|
|
|
|
</u-popup> |
|
|
|
|
<insufficient :isCoins="isCoins" /> |
|
|
|
|
<u-popup v-model="show2" mode="center"> |
|
|
|
|
<video style="width: 680rpx;" v-if="videoUrl" :src="videoUrl" object-fit="contain" controls></video> |
|
|
|
|
</u-popup> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
const systemInfoSync = uni.getSystemInfoSync(); |
|
|
|
|
import permision from "@/js_sdk/wa-permission/permission.js" |
|
|
|
|
const recorderManager = uni.getRecorderManager(); |
|
|
|
|
const innerAudioContext = uni.createInnerAudioContext(); |
|
|
|
|
innerAudioContext.autoplay = true; |
|
|
|
|
let timer = 0; |
|
|
|
|
// 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 { |
|
|
|
|
videoUrl: "", |
|
|
|
|
wrapperScrollHeight: 0, |
|
|
|
|
tabIndex: 0, |
|
|
|
|
id: "", |
|
|
|
|
current: 1, |
|
|
|
|
show1: false, |
|
|
|
|
show2: false, |
|
|
|
|
isCoins: false, |
|
|
|
|
isToggle: true, |
|
|
|
|
isOpen: false, |
|
|
|
@ -153,10 +158,15 @@ |
|
|
|
|
balanceInfo: {}, |
|
|
|
|
num: 1, |
|
|
|
|
giftList: [], |
|
|
|
|
giftListNum: 1 |
|
|
|
|
giftListNum: 1, |
|
|
|
|
statusBarHeight: 0, |
|
|
|
|
wrapperHeight: 0, |
|
|
|
|
total: 0, |
|
|
|
|
page: 1 |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
onLoad(o) { |
|
|
|
|
this.statusBarHeight = systemInfoSync.statusBarHeight; |
|
|
|
|
this.userId = uni.getStorageSync("userInfo").id; |
|
|
|
|
this.id = o.id; |
|
|
|
|
this.getUserInfo(); |
|
|
|
@ -165,7 +175,6 @@ |
|
|
|
|
}, |
|
|
|
|
onReady() { |
|
|
|
|
const that = this; |
|
|
|
|
this.toImLogin() |
|
|
|
|
recorderManager.onStop(function (res) { |
|
|
|
|
that.uploadAudio(res.tempFilePath); |
|
|
|
|
clearInterval(timer); |
|
|
|
@ -175,12 +184,26 @@ |
|
|
|
|
innerAudioContext.onEnded(res=>{ |
|
|
|
|
that.isPlay = false |
|
|
|
|
}) |
|
|
|
|
// //注册监听“收到单聊消息”的回调 |
|
|
|
|
// zim.on('receivePeerMessage', function (zim, { messageList, fromConversationID }) { |
|
|
|
|
// console.log('receivePeerMessage', messageList, fromConversationID); |
|
|
|
|
// }); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
scrolltoupper(e) { |
|
|
|
|
if(this.chatList.length <=this.total){ |
|
|
|
|
this.page ++; |
|
|
|
|
this.getChatList(1); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
toAudio(url) { |
|
|
|
|
innerAudioContext.src = url; |
|
|
|
|
innerAudioContext.play(); |
|
|
|
|
}, |
|
|
|
|
toPlay(url){ |
|
|
|
|
this.show2 = true; |
|
|
|
|
this.videoUrl = url |
|
|
|
|
}, |
|
|
|
|
// 将px转换为rpx |
|
|
|
|
pxToRpx(px) { |
|
|
|
|
return px * 750 / systemInfoSync.windowWidth; |
|
|
|
|
}, |
|
|
|
|
//发送得内容,type:1.语音 2.视频 3.文字 4图片 5礼物6搭讪 |
|
|
|
|
async giftGiving() { |
|
|
|
|
await this.$api.giftGiving({ |
|
|
|
@ -246,8 +269,10 @@ |
|
|
|
|
recorderManager.stop(); |
|
|
|
|
}, |
|
|
|
|
toToggle() { |
|
|
|
|
const that = this; |
|
|
|
|
this.isToggle = !this.isToggle |
|
|
|
|
this.isOpen = false; |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
//检查次数 |
|
|
|
|
async userBalance() { |
|
|
|
@ -276,11 +301,12 @@ |
|
|
|
|
}, |
|
|
|
|
toOpen(){ |
|
|
|
|
const that = this; |
|
|
|
|
// {"userId":"123","sellerId":"4575676878","type":3} 发送得内容,type:1.语音 2.视频 3.文字 4图片 5礼物6搭讪 |
|
|
|
|
//{"userId":"123","sellerId":"4575676878","type":3} 发送得内容,type:1.语音 2.视频 3.文字 4图片 5礼物6搭讪 |
|
|
|
|
// console.log(111) |
|
|
|
|
// console.log(JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"})) |
|
|
|
|
// uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"})}); |
|
|
|
|
// return ; |
|
|
|
|
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"})}); |
|
|
|
|
|
|
|
|
|
return ; |
|
|
|
|
// APP检查权限 |
|
|
|
|
if(uni.getSystemInfoSync().platform == 'android') { |
|
|
|
|
plus.android.checkPermission( |
|
|
|
@ -387,7 +413,6 @@ |
|
|
|
|
success: (res1) => { |
|
|
|
|
console.log(res1) |
|
|
|
|
that.count = res1.duration; |
|
|
|
|
return ; |
|
|
|
|
if(that.userInfo.isBlack == 1){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: "当前用户是黑名单,已限制", |
|
|
|
@ -489,7 +514,7 @@ |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
if(uni.getStorageSync("userInfo").sex == 1){ |
|
|
|
|
if(that.balanceInfo.wordCoins >= 1){ |
|
|
|
|
if(that.balanceInfo.wordCoins <= 1){ |
|
|
|
|
that.isCoins=true; |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
@ -519,35 +544,39 @@ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//登录房间 |
|
|
|
|
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) |
|
|
|
|
// }); |
|
|
|
|
//数组对象去重 |
|
|
|
|
arrayUnique (arr, name) { |
|
|
|
|
var hash = {}; |
|
|
|
|
return arr.reduce(function (item, next) { |
|
|
|
|
hash[next[name]] |
|
|
|
|
? "" |
|
|
|
|
: (hash[next[name]] = true && item.push(next)); |
|
|
|
|
return item; |
|
|
|
|
}, []); |
|
|
|
|
}, |
|
|
|
|
async getChatList(){ |
|
|
|
|
async getChatList(type){ |
|
|
|
|
const that = this; |
|
|
|
|
const { code, data , msg } = await this.$api.findChatList({formUserId: uni.getStorageSync("userInfo").id,toUserId: this.id}); |
|
|
|
|
const { code, data , msg } = await this.$api.findChatList({ |
|
|
|
|
limit: 10, |
|
|
|
|
page: this.page, |
|
|
|
|
formUserId: uni.getStorageSync("userInfo").id, |
|
|
|
|
toUserId: this.id}); |
|
|
|
|
if(code == 200){ |
|
|
|
|
this.chatList= data; |
|
|
|
|
this.total= data.total; |
|
|
|
|
this.chatList= that.arrayUnique([...this.chatList,...data.list],'msgId'); |
|
|
|
|
if(type == 1){ |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
setTimeout(()=>{ |
|
|
|
|
let wrapper = uni.createSelectorQuery().in(this).select('#wrapper'); |
|
|
|
|
wrapper.fields({ |
|
|
|
|
size: true, |
|
|
|
|
scrollOffset: true |
|
|
|
|
}, data => { |
|
|
|
|
console.log("得到节点信息" + JSON.stringify(data)); |
|
|
|
|
that.wrapperScrollHeight = data.scrollHeight |
|
|
|
|
console.log("wrapper",data) |
|
|
|
|
that.wrapperScrollHeight = data.scrollHeight*5 |
|
|
|
|
}).exec() |
|
|
|
|
// ; |
|
|
|
|
},100) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -566,6 +595,7 @@ |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//字典查询 |
|
|
|
|
async getConfigData() { |
|
|
|
|
const that = this; |
|
|
|
@ -610,6 +640,63 @@ |
|
|
|
|
},2000) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//视频语音说明 |
|
|
|
|
async openShiping() { |
|
|
|
|
const that = this; |
|
|
|
|
const {code, data } = await that.$api.costDescription({}); |
|
|
|
|
if(code == 200){ |
|
|
|
|
uni.showActionSheet({ |
|
|
|
|
title: "语音/视频通话", |
|
|
|
|
itemList: ["语音通话("+data.voiceCoins+"金币/分钟)","视频通话("+data.videoCoins+"金币/分钟)"], |
|
|
|
|
success(res){ |
|
|
|
|
if(res.tapIndex == 0){ |
|
|
|
|
if(that.userInfo.isBlack == 1){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: "当前用户是黑名单,已限制", |
|
|
|
|
position: "bottom", |
|
|
|
|
icon: "none", |
|
|
|
|
}) |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
if(uni.getStorageSync("userInfo").sex == 1){ |
|
|
|
|
if(that.balanceInfo.userBalance <= 0){ |
|
|
|
|
that.isCoins=true; |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: "/pages/pipwei/yuyin?id="+that.id |
|
|
|
|
}) |
|
|
|
|
}else if(res.tapIndex == 1){ |
|
|
|
|
if(that.userInfo.isBlack == 1){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: "当前用户是黑名单,已限制", |
|
|
|
|
position: "bottom", |
|
|
|
|
icon: "none", |
|
|
|
|
}) |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
if(uni.getStorageSync("userInfo").sex == 1){ |
|
|
|
|
if(that.balanceInfo.userBalance <= 0){ |
|
|
|
|
that.isCoins=true; |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: "/pages/pipei/shipin/?id="+that.id |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
toSheet1() { |
|
|
|
|
const that = this; |
|
|
|
|
that.getcostDescription(); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
toSheet() { |
|
|
|
|
const that = this; |
|
|
|
|
uni.showActionSheet({ |
|
|
|
@ -635,9 +722,6 @@ |
|
|
|
|
console.log(e) |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
onBackPress() { |
|
|
|
|
zim.logout(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
@ -797,17 +881,17 @@ |
|
|
|
|
} |
|
|
|
|
&-bd{ |
|
|
|
|
width: 100%; |
|
|
|
|
height: calc(100vh - 190rpx - 88rpx); |
|
|
|
|
height: calc(100vh - 190rpx - 88rpx - 50rpx); |
|
|
|
|
padding: 0 25rpx; |
|
|
|
|
box-sizing: border-box; |
|
|
|
|
&-on{ |
|
|
|
|
height: calc(100vh - 190rpx - 88rpx - 160rpx); |
|
|
|
|
height: calc(100vh - 190rpx - 88rpx - 50rpx - 160rpx); |
|
|
|
|
} |
|
|
|
|
&-active{ |
|
|
|
|
height: calc(100vh - 120rpx - 88rpx); |
|
|
|
|
height: calc(100vh - 120rpx - 88rpx - 50rpx); |
|
|
|
|
} |
|
|
|
|
&-active1{ |
|
|
|
|
height: calc(100vh - 120rpx - 88rpx - 160rpx); |
|
|
|
|
height: calc(100vh - 120rpx - 88rpx - 50rpx - 160rpx); |
|
|
|
|
} |
|
|
|
|
.item{ |
|
|
|
|
padding: 20rpx 0; |
|
|
|
@ -856,7 +940,7 @@ |
|
|
|
|
border-radius: 20rpx; |
|
|
|
|
margin-top: 20rpx; |
|
|
|
|
padding: 20rpx; |
|
|
|
|
video{ |
|
|
|
|
image{ |
|
|
|
|
width: 100%; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|