2023-09-27 19:06:47 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view style="background-color: #F6F7FD;">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<u-loading-page :loading="showLoading" v-if="showLoading"></u-loading-page>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<!-- 消息 -->
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view class="content" @click="showPlus=false" id="content" v-show='!showLoading'>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<view class="">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<u-loadmore :status="status" :loadmore-text="`你正在与${manager_nmae}聊天`" />
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="task-li" v-for="item,index in list" :key="index">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view class="" v-if="index %5 ==0" style="text-align: center;">
|
|
|
|
|
{{timeFn(item.create_time)}}
|
|
|
|
|
</view>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<!-- 对方消息 -->
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view v-if="item.from_user_id!=fromId">
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<view class="task-li-r">
|
|
|
|
|
<view class="" style="margin-right: 10rpx;">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<u--image :showLoading="true" :src="item.from_user_avatar" shape="circle" width="40px"
|
|
|
|
|
height="40px"></u--image>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view @longpress="copyText(item.content)" class="task-li-content" v-if="item.type=='text'"
|
|
|
|
|
style="margin-right: 10rpx;">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<view style="color: #576B95;" @click="href(item.content)" v-if="isLink(item.content)">
|
|
|
|
|
{{item.content}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="" v-else>
|
|
|
|
|
{{item.content}}
|
|
|
|
|
</view>
|
2023-10-10 18:44:37 +08:00
|
|
|
|
</view>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<!-- 图片 -->
|
|
|
|
|
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
|
2023-10-09 20:22:16 +08:00
|
|
|
|
@tap="previewImage(item.content)">
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 视频 -->
|
|
|
|
|
<view class="task-li-content" v-if="item.type=='video'"
|
|
|
|
|
style="margin-right: 10rpx;position: relative;"
|
|
|
|
|
@tap="showOverLayFn(item.content,item.type)">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<u--image :showLoading="true"
|
|
|
|
|
:src=" item.content+'?x-oss-process=video\/snapshot,t_1000,m_fast,w_800,f_png' "
|
|
|
|
|
width="100px" height="80px"></u--image>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<view class="yl-text">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<u-icon name="play-circle" color='white' size='30'></u-icon>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="send-time">
|
|
|
|
|
{{item.sendTime}}
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 我的消息 -->
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view class="task-li-l" v-else>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<!-- 文字 -->
|
|
|
|
|
<view class="task-li-content" @longpress="copyText(item.content)" v-if="item.type=='text'"
|
|
|
|
|
style="margin-right: 10rpx;">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<!-- {{item.content}} -->
|
|
|
|
|
|
|
|
|
|
<view style="color: #576B95;" @click="href(item.content)" v-if="isLink(item.content)">
|
|
|
|
|
{{item.content}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="" v-else>
|
|
|
|
|
{{item.content}}
|
|
|
|
|
</view>
|
|
|
|
|
<!-- <a href="item.content" target="_blank"> {{item.content}}</a> -->
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
<!-- 图片 -->
|
|
|
|
|
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
|
2023-10-09 20:22:16 +08:00
|
|
|
|
@tap="previewImage(item.content)">
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 视频 -->
|
|
|
|
|
<view class="task-li-content" v-if="item.type=='video'"
|
|
|
|
|
style="margin-right: 10rpx;position: relative;" @tap="showOverLayFn(item.content,item.type)">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<u--image :showLoading="true"
|
|
|
|
|
:src=" item.content+'?x-oss-process=video\/snapshot,t_1000,m_fast,w_800,f_png' "
|
|
|
|
|
width="100px" height="80px"></u--image>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<view class="yl-text">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<u-icon name="play-circle" color='white' size='30'></u-icon>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="">
|
|
|
|
|
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 本地 -->
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view v-show="item.status" v-for="(item,index) in local">
|
|
|
|
|
<view class="localTask" v-if="item.localType=='video'">
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<view class="task-li-content" style="margin-right: 10rpx;">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<video :src="item.localSrc" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
|
|
|
|
|
<!-- <image :src="" style="width:200rpx" mode="widthFix"></image> -->
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<u-loadmore status="loading" loading-text="努力上传中" />
|
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="" style="margin-right: 10rpx;">
|
|
|
|
|
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view class="localTask" v-if="item.localType=='image'">
|
2023-09-27 19:06:47 +08:00
|
|
|
|
<view class="task-li-content" style="margin-right: 10rpx;">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<image :src="item.localSrc" style="width:200rpx" mode="widthFix"></image>
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<u-loadmore status="loading" loading-text="努力上传中" />
|
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="" style="margin-right: 10rpx;">
|
|
|
|
|
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<view style="height: 300rpx;background-color: #F6F7FD;" v-if="showPlus">
|
|
|
|
|
</view>
|
|
|
|
|
<view style="height: 150rpx;background-color: #F6F7FD;" v-else>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 底部 -->
|
|
|
|
|
|
|
|
|
|
<view class="bottom">
|
|
|
|
|
<!-- -->
|
|
|
|
|
<view class="send-col">
|
2023-10-11 15:54:26 +08:00
|
|
|
|
<input type="text" class="send-ipt" @focus="scrollFn" v-model="value" placeholder="请输入聊天内容"
|
2023-09-27 19:06:47 +08:00
|
|
|
|
placeholder-style="color:#DDD;" :cursor-spacing="6">
|
|
|
|
|
|
|
|
|
|
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" width="32px" height="32px"
|
|
|
|
|
@click="showPlusFn"></u--image>
|
|
|
|
|
|
|
|
|
|
<button class="send" @tap="sendFn">发送</button>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 发送照片 -->
|
|
|
|
|
<view class="plus" v-if="showPlus">
|
|
|
|
|
<view class="plus_li">
|
|
|
|
|
<u--image :showLoading="true" src="/static/img/bussness/XC.png" width="120rpx" height="120rpx"
|
|
|
|
|
@click="choseImgFn"></u--image>
|
|
|
|
|
<text>图片</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="plus_li">
|
|
|
|
|
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
|
|
|
|
|
@click="choseVideoFn"></u--image>
|
|
|
|
|
<text>视频</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 遮罩图 -->
|
|
|
|
|
<u-overlay :show="show" @click="show = false">
|
|
|
|
|
<view class="warp">
|
|
|
|
|
<view class="rect" @tap.stop v-if="overLayType=='video'">
|
2023-10-09 20:22:16 +08:00
|
|
|
|
<video :src="overLaySrc" controls :autoplay="true"></video>
|
2023-09-27 19:06:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</u-overlay>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
FILE_URL_IM
|
|
|
|
|
} from "@/api/file.js"
|
|
|
|
|
import {
|
|
|
|
|
sendMsgApi,
|
|
|
|
|
getMsgListApi,
|
|
|
|
|
bindScoket,
|
|
|
|
|
sendFileApi,
|
|
|
|
|
getAreaManagerApi
|
2023-09-27 19:06:47 +08:00
|
|
|
|
} from "@/api/bussness.js"
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
showLoading: true,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
a: "https://img1.baidu.com/it/u=716638254,3920932970&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1695920400&t=aeec3d0e86c23759d5f82b3757e9b442",
|
2023-10-09 20:22:16 +08:00
|
|
|
|
list: [],
|
2023-10-11 15:54:26 +08:00
|
|
|
|
bind: false,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
value: "",
|
|
|
|
|
showPlus: false,
|
2023-10-09 20:22:16 +08:00
|
|
|
|
scollNum: 500000000000,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
client_id: "",
|
2023-10-09 20:22:16 +08:00
|
|
|
|
fromId: "",
|
2023-10-11 15:54:26 +08:00
|
|
|
|
toId: "",
|
2023-09-27 19:06:47 +08:00
|
|
|
|
name: "",
|
2023-10-09 20:22:16 +08:00
|
|
|
|
status: "loadmore",
|
|
|
|
|
page_no: 1,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
limit: 10,
|
|
|
|
|
show: false,
|
|
|
|
|
overLaySrc: "",
|
|
|
|
|
overLayType: "",
|
2023-10-09 20:22:16 +08:00
|
|
|
|
local: [],
|
2023-09-27 19:06:47 +08:00
|
|
|
|
localType: "",
|
2023-10-11 15:54:26 +08:00
|
|
|
|
imageList: [],
|
|
|
|
|
sendData: {},
|
|
|
|
|
manager_nmae: "",
|
|
|
|
|
msg_id: "",
|
|
|
|
|
aaa: false,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
isLink(text) {
|
|
|
|
|
var pattern = /^(https?:\/\/|www\.|.*\.com).*$/i;
|
|
|
|
|
return pattern.test(text);
|
2023-10-10 18:44:37 +08:00
|
|
|
|
},
|
2023-10-11 15:54:26 +08:00
|
|
|
|
href(url) {
|
2023-10-10 18:44:37 +08:00
|
|
|
|
// uni.navigate
|
|
|
|
|
plus.runtime.openURL(url);
|
|
|
|
|
// plus.runtime.openUrl(url)
|
|
|
|
|
},
|
2023-10-11 15:54:26 +08:00
|
|
|
|
previewImage(src) {
|
|
|
|
|
this.imageList[0] = src
|
|
|
|
|
uni.previewImage({
|
|
|
|
|
urls: this.imageList,
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-10-09 20:22:16 +08:00
|
|
|
|
generateRandId() {
|
|
|
|
|
var d = new Date().getTime();
|
|
|
|
|
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
|
|
|
var r = (d + Math.random() * 16) % 16 | 0;
|
|
|
|
|
d = Math.floor(d / 16);
|
|
|
|
|
return (c == "x" ? r : r & 0x3 | 0x8).toString(16);
|
|
|
|
|
});
|
|
|
|
|
// return uuid;
|
2023-10-11 15:54:26 +08:00
|
|
|
|
this.msg_id = uuid
|
2023-10-09 20:22:16 +08:00
|
|
|
|
console.log("改变id")
|
|
|
|
|
},
|
2023-09-27 19:06:47 +08:00
|
|
|
|
timeFn(time) {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
time = time * 1000
|
2023-09-27 19:06:47 +08:00
|
|
|
|
const currentDate = new Date(); // 当前日期对象
|
2023-10-09 20:22:16 +08:00
|
|
|
|
const targetDate = new Date(time);
|
2023-09-27 19:06:47 +08:00
|
|
|
|
if (this.isSameDay(currentDate, targetDate)) {
|
|
|
|
|
const hours = targetDate.getHours(); // 小时
|
|
|
|
|
const minutes = targetDate.getMinutes(); // 分钟
|
2023-10-11 15:54:26 +08:00
|
|
|
|
return hours + ':' + (minutes >= 10 ? minutes : '0' + minutes);
|
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
} else if (this.isYesterday(currentDate, targetDate)) {
|
|
|
|
|
return '昨天';
|
|
|
|
|
}
|
|
|
|
|
const month = targetDate.getMonth() + 1; // 月份(注意月份从0开始,需要加1)
|
|
|
|
|
const day = targetDate.getDate(); // 日期
|
|
|
|
|
return month + '月' + day + '日';
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
isSameDay(date1, date2) {
|
|
|
|
|
return (
|
|
|
|
|
date1.getFullYear() === date2.getFullYear() &&
|
|
|
|
|
date1.getMonth() === date2.getMonth() &&
|
|
|
|
|
date1.getDate() === date2.getDate()
|
|
|
|
|
);
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
isYesterday(currentDate, targetDate) {
|
|
|
|
|
const yesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 1);
|
|
|
|
|
return this.isSameDay(yesterday, targetDate);
|
|
|
|
|
},
|
2023-10-11 15:54:26 +08:00
|
|
|
|
toast(msg) {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
title: msg,
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-09-27 19:06:47 +08:00
|
|
|
|
saveImage(src) {
|
|
|
|
|
uni.saveImageToPhotosAlbum({
|
|
|
|
|
filePath: src,
|
|
|
|
|
success() {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '保存成功',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
fail() {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.toast('保存失败')
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
copyText(value) {
|
|
|
|
|
const text = value;
|
|
|
|
|
uni.setClipboardData({
|
|
|
|
|
data: text,
|
|
|
|
|
success() {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '复制成功',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
showOverLayFn(src, type) {
|
|
|
|
|
this.show = true
|
|
|
|
|
this.overLaySrc = src
|
|
|
|
|
this.overLayType = type
|
|
|
|
|
},
|
|
|
|
|
getListFn() {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
getMsgListApi({
|
2023-10-11 15:54:26 +08:00
|
|
|
|
from_user_id: this.fromId,
|
|
|
|
|
to_user_id: this.toId,
|
|
|
|
|
scene: 0,
|
|
|
|
|
page_no: this.page_no,
|
|
|
|
|
page_size: 10
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.data.length <= 0) {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
uni.stopPullDownRefresh();
|
2023-10-11 15:54:26 +08:00
|
|
|
|
this.status = "nomore"
|
2023-09-27 19:06:47 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2023-10-11 15:54:26 +08:00
|
|
|
|
this.list = res.data.reverse().concat(this.list)
|
|
|
|
|
uni.stopPullDownRefresh();
|
2023-09-27 19:06:47 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2023-10-09 20:22:16 +08:00
|
|
|
|
scrollFn() {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let that = this
|
|
|
|
|
this.scollNum += 100
|
2023-09-27 19:06:47 +08:00
|
|
|
|
setTimeout(() => {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
uni.pageScrollTo({
|
|
|
|
|
scrollTop: that.scollNum, // 滚动的实际距离
|
|
|
|
|
success: function() {
|
|
|
|
|
console.log('滚动')
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-10-09 20:22:16 +08:00
|
|
|
|
}, 100)
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
sendFn() {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let that = this
|
2023-10-09 20:22:16 +08:00
|
|
|
|
if (!this.value) {
|
|
|
|
|
this.toast("消息不能为空")
|
|
|
|
|
return
|
2023-10-11 15:54:26 +08:00
|
|
|
|
}
|
2023-09-27 19:06:47 +08:00
|
|
|
|
let data = {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
from_user_id: this.fromId,
|
2023-10-11 15:54:26 +08:00
|
|
|
|
to_user_id: this.toId,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
type: "text",
|
|
|
|
|
content: this.value,
|
2023-10-11 15:54:26 +08:00
|
|
|
|
scene: 0,
|
|
|
|
|
create_time: (Date.now() / 1000),
|
|
|
|
|
msg_id: this.msg_id
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
sendMsgApi({
|
|
|
|
|
...data
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log(data)
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.list.push(data)
|
|
|
|
|
this.scrollFn(100)
|
|
|
|
|
this.value = ""
|
|
|
|
|
this.generateRandId()
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}).catch(err => {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.toast('发送失败')
|
|
|
|
|
this.generateRandId()
|
2023-09-27 19:06:47 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
showPlusFn() {
|
|
|
|
|
this.showPlus = !this.showPlus
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.scrollFn()
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
choseImgFn() {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.generateRandId()
|
2023-09-27 19:06:47 +08:00
|
|
|
|
let time = Date.now()
|
|
|
|
|
let that = this
|
|
|
|
|
uni.chooseImage({
|
|
|
|
|
count: 1, // 最多可以选择的图片张数
|
|
|
|
|
success: res => {
|
|
|
|
|
const tempFilePath = res.tempFilePaths[0];
|
2023-10-09 20:22:16 +08:00
|
|
|
|
that.local.push({
|
2023-10-11 15:54:26 +08:00
|
|
|
|
localType: 'image',
|
|
|
|
|
localSrc: tempFilePath,
|
|
|
|
|
status: true,
|
|
|
|
|
msg_id: that.msg_id
|
2023-10-09 20:22:16 +08:00
|
|
|
|
})
|
2023-09-27 19:06:47 +08:00
|
|
|
|
that.showPlus = false
|
2023-10-09 20:22:16 +08:00
|
|
|
|
that.scrollFn()
|
|
|
|
|
console.log(that.local)
|
2023-10-11 15:54:26 +08:00
|
|
|
|
uni.uploadFile({
|
|
|
|
|
url: FILE_URL_IM,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
filePath: tempFilePath, // 选择的图片文件路径
|
|
|
|
|
name: 'file',
|
|
|
|
|
header: {
|
|
|
|
|
"Authorization": uni.getStorageSync("TOKEN")
|
|
|
|
|
},
|
|
|
|
|
formData: {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
from_user_id: that.fromId,
|
|
|
|
|
to_user_id: that.toId,
|
|
|
|
|
scene: 0,
|
|
|
|
|
msg_id: that.msg_id,
|
|
|
|
|
type: 'image'
|
2023-10-09 20:22:16 +08:00
|
|
|
|
},
|
2023-09-27 19:06:47 +08:00
|
|
|
|
success: function(uploadRes) {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let data = JSON.parse(uploadRes.data).data
|
|
|
|
|
|
|
|
|
|
var localIndex = that.local.findIndex(function(element) {
|
|
|
|
|
return element.msg_id === data.msg_id;
|
|
|
|
|
});
|
|
|
|
|
that.local[localIndex].status = false
|
2023-10-09 20:22:16 +08:00
|
|
|
|
that.list.push(data)
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
fail: function(error) {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
this.toast('上传失败')
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.toast('操作取消')
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
choseVideoFn() {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.generateRandId()
|
2023-09-27 19:06:47 +08:00
|
|
|
|
let that = this
|
|
|
|
|
uni.chooseVideo({
|
|
|
|
|
sourceType: ['album', 'camera'], // 视频选择的来源,可以是相册或摄像头
|
|
|
|
|
maxDuration: 600, // 视频的最大时长(单位:秒)
|
|
|
|
|
camera: 'back', // 摄像头类型,可以是前置或后置
|
|
|
|
|
success: res => {
|
|
|
|
|
const tempFilePath = res.tempFilePath;
|
2023-10-09 20:22:16 +08:00
|
|
|
|
that.local.push({
|
2023-10-11 15:54:26 +08:00
|
|
|
|
localType: 'video',
|
|
|
|
|
localSrc: tempFilePath,
|
|
|
|
|
status: true,
|
|
|
|
|
msg_id: that.msg_id
|
2023-10-09 20:22:16 +08:00
|
|
|
|
})
|
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
that.showPlus = false
|
2023-10-09 20:22:16 +08:00
|
|
|
|
that.scrollFn()
|
|
|
|
|
uni.uploadFile({
|
2023-10-11 15:54:26 +08:00
|
|
|
|
url: FILE_URL_IM,
|
2023-09-27 19:06:47 +08:00
|
|
|
|
filePath: tempFilePath, // 选择的图片文件路径
|
|
|
|
|
name: 'file',
|
|
|
|
|
header: {
|
|
|
|
|
"Authorization": uni.getStorageSync("token")
|
|
|
|
|
},
|
|
|
|
|
formData: {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
from_user_id: that.fromId,
|
|
|
|
|
to_user_id: that.toId,
|
|
|
|
|
scene: 0,
|
|
|
|
|
msg_id: that.msg_id,
|
|
|
|
|
type: 'video'
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}, // 服务端接收文件的字段名
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
success: function(uploadRes) {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
|
|
|
|
let data = JSON.parse(uploadRes.data).data
|
|
|
|
|
var localIndex = that.local.findIndex(function(element) {
|
|
|
|
|
return element.msg_id === data.msg_id;
|
|
|
|
|
});
|
|
|
|
|
that.local[localIndex].status = false
|
2023-10-09 20:22:16 +08:00
|
|
|
|
that.list.push(data)
|
2023-09-27 19:06:47 +08:00
|
|
|
|
// 处理上传成功的逻辑
|
|
|
|
|
},
|
|
|
|
|
fail: function(error) {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
console.log(error)
|
2023-09-27 19:06:47 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '视频不能超过60s',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
2023-10-09 20:22:16 +08:00
|
|
|
|
// that.local = false
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
// uni.showToast({
|
|
|
|
|
// title: '视频不能超过60s',
|
|
|
|
|
// duration: 2000,
|
|
|
|
|
// icon: 'none'
|
|
|
|
|
// });
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
this.page_no = 1
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.generateRandId()
|
2023-10-11 15:54:26 +08:00
|
|
|
|
this.fromId = JSON.parse(uni.getStorageSync("USER_INFO")).id
|
|
|
|
|
|
|
|
|
|
getAreaManagerApi({
|
|
|
|
|
user_id: this.fromId
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.toId = res.data.to_user_id
|
|
|
|
|
this.manager_nmae = res.data.manager_name
|
2023-10-09 20:22:16 +08:00
|
|
|
|
getMsgListApi({
|
2023-10-11 15:54:26 +08:00
|
|
|
|
from_user_id: this.fromId,
|
|
|
|
|
to_user_id: this.toId,
|
|
|
|
|
scene: 0,
|
|
|
|
|
page_no: 1,
|
|
|
|
|
page_size: 10
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.showLoading = false
|
|
|
|
|
this.list = res.data.reverse()
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.scrollFn()
|
2023-09-27 19:06:47 +08:00
|
|
|
|
})
|
2023-10-09 20:22:16 +08:00
|
|
|
|
})
|
2023-09-27 19:06:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async onPullDownRefresh() {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let that = this
|
2023-09-27 19:06:47 +08:00
|
|
|
|
this.status = "loading"
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.page_no++
|
2023-09-27 19:06:47 +08:00
|
|
|
|
await this.getListFn()
|
2023-10-09 20:22:16 +08:00
|
|
|
|
this.status = "loadmore"
|
2023-09-27 19:06:47 +08:00
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
2023-10-21 09:39:29 +08:00
|
|
|
|
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let user = JSON.parse(uni.getStorageSync('USER_INFO'))
|
|
|
|
|
this.a = user.avatar
|
2023-10-09 20:22:16 +08:00
|
|
|
|
console.log(user.avatar)
|
|
|
|
|
uni.connectSocket({
|
2023-10-21 09:39:29 +08:00
|
|
|
|
url: 'wss://ceshi-worker-task.lihaink.cn/im'
|
2023-10-09 20:22:16 +08:00
|
|
|
|
});
|
2023-10-11 15:54:26 +08:00
|
|
|
|
uni.onSocketOpen(function(res) {
|
|
|
|
|
console.log('WebSocket连接已打开!');
|
2023-10-09 20:22:16 +08:00
|
|
|
|
});
|
2023-10-11 15:54:26 +08:00
|
|
|
|
uni.onSocketError(function(res) {
|
|
|
|
|
console.log('WebSocket连接打开失败,请检查!');
|
2023-10-09 20:22:16 +08:00
|
|
|
|
});
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let that = this
|
2023-09-27 19:06:47 +08:00
|
|
|
|
uni.onSocketMessage(function(res) {
|
2023-10-11 15:54:26 +08:00
|
|
|
|
let data = JSON.parse(res.data)
|
|
|
|
|
if (data.client_id) {
|
|
|
|
|
let client_id = data.client_id
|
|
|
|
|
if (!that.bind) {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
bindScoket({
|
2023-10-11 15:54:26 +08:00
|
|
|
|
client_id: client_id,
|
|
|
|
|
user_id: that.fromId,
|
|
|
|
|
scene: 0,
|
|
|
|
|
}).then(res => {
|
|
|
|
|
that.bind = true
|
2023-10-09 20:22:16 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 收到消息
|
2023-10-11 15:54:26 +08:00
|
|
|
|
else if (data.type != 'ping') {
|
|
|
|
|
console.log(data)
|
|
|
|
|
that.list.push(data)
|
|
|
|
|
that.scrollFn()
|
|
|
|
|
}
|
2023-09-27 19:06:47 +08:00
|
|
|
|
});
|
|
|
|
|
|
2023-10-09 20:22:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.generateRandId()
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
|
|
|
|
|
},
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.yl-text {
|
|
|
|
|
position: absolute;
|
2023-10-09 20:22:16 +08:00
|
|
|
|
color: white;
|
|
|
|
|
top: 50%;
|
2023-09-27 19:06:47 +08:00
|
|
|
|
left: 50%;
|
2023-10-11 15:54:26 +08:00
|
|
|
|
transform: translate(-50%, -50%);
|
2023-09-27 19:06:47 +08:00
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
.topflag {
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
background-color: #F6F7FD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content {
|
|
|
|
|
padding: 0 20rpx;
|
2023-10-09 20:22:16 +08:00
|
|
|
|
min-height: 95vh;
|
2023-09-27 19:06:47 +08:00
|
|
|
|
background-color: #F6F7FD;
|
|
|
|
|
padding-top: 10rpx;
|
2023-10-11 15:54:26 +08:00
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
.task-li {
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.task-li-l {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.task-li-r {
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.task-li-content {
|
|
|
|
|
background-color: white;
|
2023-10-11 15:54:26 +08:00
|
|
|
|
padding: 10rpx 20rpx;
|
|
|
|
|
line-height: 50rpx;
|
|
|
|
|
// line-height: 30rpx;
|
2023-09-27 19:06:47 +08:00
|
|
|
|
border-radius: 20rpx;
|
2023-10-09 20:22:16 +08:00
|
|
|
|
// color: white;
|
2023-09-27 19:06:47 +08:00
|
|
|
|
word-break: break-all;
|
2023-10-11 15:54:26 +08:00
|
|
|
|
max-width: 535rpx;
|
2023-10-10 18:44:37 +08:00
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
|
|
2023-09-27 19:06:47 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bottom {
|
|
|
|
|
background-color: white;
|
|
|
|
|
padding: 20rpx 0;
|
|
|
|
|
position: fixed;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
bottom: 0px;
|
|
|
|
|
padding-bottom: 10px;
|
2023-10-09 20:22:16 +08:00
|
|
|
|
/* #ifndef APP-PLUS */
|
|
|
|
|
// bottom: 40px;
|
|
|
|
|
/* #endif */
|
2023-09-27 19:06:47 +08:00
|
|
|
|
|
|
|
|
|
.send-col {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
|
|
|
|
|
.send-ipt {
|
|
|
|
|
width: 70vw;
|
|
|
|
|
background-color: #F5F5F5;
|
|
|
|
|
height: 60rpx;
|
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
padding-left: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.send {
|
|
|
|
|
background-color: #2573fb;
|
|
|
|
|
color: #fff;
|
|
|
|
|
height: 64rpx;
|
|
|
|
|
margin-left: 20rpx;
|
|
|
|
|
border-radius: 6rpx;
|
|
|
|
|
padding: 0;
|
|
|
|
|
width: 120rpx;
|
|
|
|
|
line-height: 62rpx;
|
|
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
|
background-color: #1573fb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.plus {
|
|
|
|
|
display: flex;
|
|
|
|
|
background-color: white;
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
|
|
|
|
|
.plus_li {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-right: 20rpx;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.warp {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.rect {}
|
|
|
|
|
|
|
|
|
|
.localTask {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
}
|
|
|
|
|
</style>
|