上商机信息

This commit is contained in:
THK3121 2023-10-07 18:56:59 +08:00
parent f3305df1ca
commit 2e6ea98e21
4 changed files with 98 additions and 123 deletions

View File

@ -5,8 +5,10 @@ import oahttp from "@/utils/aa.js";
*/
export const bindScoket = (data) => oahttp.post('/common/im/doBindUid', data)
// 发送消息
export const sendMsgApi = (data) => oahttp.post('/common/im/sendMessage', data)
export const sendMsgApi = (data) => oahttp.post('/common/im/sendTextMsg', data)
// 发送文件
export const sendFileApi = (data) => oahttp.post('/common/im/sendFileMsg', data)
// 消息列表
export const getMsgListApi = (data) => oahttp.post('/common/im/msgList', data)
// 片区经理id
export const getAreaManagerApi = (data) => oahttp.post('/common/im/getAreaManager', data)

View File

@ -22,7 +22,7 @@ switch (env) {
httpApi = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiThree = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiTwo = 'https://ceshi-logistics.lihaink.cn' //测试环境
httpApiTest = 'http://192.168.1.16:8081' //测试环境
httpApiTest = 'http://192.168.1.9:8081' //测试环境
}

View File

@ -29,7 +29,6 @@
"path": "pages/business/business",
"style": {
"navigationBarTitleText": "商机信息",
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#0122C7",
"navigationBarTextStyle": "white"
}

View File

@ -18,12 +18,11 @@
</view>
<!-- -->
<view class="task-li" v-for="item,index in list" :key="index">
<!-- 对方消息 -->
<view v-if="false">
<view v-if="item.from_user_id!=fromId">
<view class="task-li-r">
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
<u--image :showLoading="true" :src="item.from_user_avatar" shape="circle" width="40px" height="40px"></u--image>
</view>
<view @longpress="copyText(item.content)" class="task-li-content" v-if="item.type=='text'"
style="margin-right: 10rpx;">
@ -38,9 +37,9 @@
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;"
@tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true" :src="a" width="100px" height="80px"></u--image>
<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>
<view class="yl-text">
点击预览
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
<!-- <video :src="item.content" @loadedmetadata="onVideoLoaded" controls id="vi1"
style="width: 400rpx; height: 100px;"></video> -->
@ -54,12 +53,12 @@
</view>
</view>
<!-- 我的消息 -->
<view class="task-li-l" v-else="true">
<view class="task-li-l" v-else>
<!-- 文字 -->
<view class="task-li-content" @longpress="copyText(item.content)" v-if="item.type=='text'"
style="margin-right: 10rpx;">
{{item.content}}
{{item.content}}
</view>
<!-- 图片 -->
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
@ -69,9 +68,10 @@
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;" @tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true" src="/static/YL1.png" width="100px" height="80px"></u--image>
<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>
<view class="yl-text">
点击预览
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
</view>
<view class="">
@ -144,8 +144,6 @@
</view>
<!-- 遮罩图 -->
<u-overlay :show="show" @click="show = false">
<view class="warp">
<view class="rect" @tap.stop @longpress="saveImage(overLaySrc)" v-if="overLayType=='image'">
@ -163,14 +161,13 @@
<script>
import {
sendMsgApi,getMsgListApi,bindScoket,sendFileApi
sendMsgApi,getMsgListApi,bindScoket,sendFileApi,getAreaManagerApi
} from "@/api/bussness.js"
export default {
data() {
return {
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",
list: [
],
list: [],
bind:false,
value: "",
showPlus: false,
@ -178,7 +175,8 @@
flags: true,
scollNum: 999999999999,
client_id: "",
formId: "",
fromId: "",
toId:"",
name: "",
status: "lodemore",
page: 1,
@ -192,13 +190,13 @@
local: "",
localType: "",
progress: "",
showNotice: false
showNotice: false,
sendData:{}
}
},
methods: {
timeFn(time) {
// 1695722299000
const currentDate = new Date(); //
const targetDate = new Date(1695722299000);
if (this.isSameDay(currentDate, targetDate)) {
@ -226,6 +224,7 @@
const yesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 1);
return this.isSameDay(yesterday, targetDate);
},
saveImage(src) {
uni.saveImageToPhotosAlbum({
filePath: src,
@ -255,10 +254,6 @@
}
});
},
backFn() {
uni.navigateBack()
},
showOverLayFn(src, type) {
this.show = true
this.overLaySrc = src
@ -283,48 +278,47 @@
// })
},
scrollFn(time) {
this.scollNum += 500
this.scollNum += 100000
let that=this
setTimeout(() => {
uni.pageScrollTo({
scrollTop: this.scollNum,
scrollTop: that.scollNum,
});
}, time ? time : 100)
console.log("滚动")
}, 100)
},
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;
},
// 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;
// },
// wn
sendFn() {
if (!this.value) return
this.num++
this.flags = !this.flags
let data = {
from_user_id: "2",
to_user_id:"",
from_user_id: this.fromId,
to_user_id:this.toId,
type: "text",
content: this.value,
msg_id: this.generateRandId(),
to_user_id: "sdas",
// to_user_avatar: "https://ceshi-worker-task.lihaink.cn/uploads/images/20230926/20230926185925e41de3046.png",
scene:0,
}
sendMsgApi({
...data
}).then(res => {
this.list.push(data)
console.log(data)
this.scrollFn(100)
}).catch(err => {
console.log(err, "发送消息失败")
})
this.value = ""
// this.scrollFn(100)
return
request("POST", "enterprise/im/sendMessage", {
content: this.value,
@ -342,7 +336,7 @@
is_read: 0,
sendTime: Date.now(),
status: "going",
toContactId: this.formId,
toContactId: this.fromId,
type: "text",
}).then(res => {
console.log("发送消息成功")
@ -375,48 +369,24 @@
this.login()
let time = Date.now()
let that = this
// https://im.raingad.com/common/upload/uploadFile
uni.chooseImage({
count: 1, //
success: res => {
const tempFilePath = res.tempFilePaths[0];
const file = res.tempFiles[0]
console.log(file)
that.local = tempFilePath
that.localType = 'image'
that.showPlus = false
that.scrollFn(200)
const uploadTask = uni.uploadFile({
url: "http://192.168.112:8081/apiim/upload",
url: "http://192.168.1.9:8081/common/im/sendFileMsg",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("TOKEN")
},
formData: {
// message: JSON.stringify({
// "id": this.generateRandId(),
// "sendTime": Date.now(),
// "status": "going",
// "type": "image",
// // "content": "blob:https://im.raingad.com/e2ffd725-a9e7-4a01-b7da-83fd64af97a4",
// "content": `blob:${tempFilePath}`,
// "is_read": 0,
// "is_group": 0,
// "file_id": 0,
// "file_cate": 0,
// "fileName": file.name,
// "fileSize": file.size,
// "extends": null,
// "fromUser": {
// ...this.fromUser
// },
// from_user: this.fromUser.id,
// toContactId: this.formId,
// })
to_user_id: "2",
type: "image",
msg_id: this.generateRandId(),
...this.sendData,
type:'image'
}, //
success: function(uploadRes) {
that.local = ""
@ -429,11 +399,8 @@
//
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
console.log('上传进度', res.progress);
});
},
fail: err => {
@ -454,33 +421,15 @@
that.showPlus = false
that.scrollFn(200)
const uploadTask = uni.uploadFile({
url: "https://ceshi-im.lihaink.cn/common/upload/uploadFile",
url: "http://192.168.1.9:8081/common/im/sendFileMsg",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("token")
},
formData: {
message: JSON.stringify({
"id": this.generateRandId(),
"sendTime": Date.now(),
"status": "going",
"type": "image",
// "content": "blob:https://im.raingad.com/e2ffd725-a9e7-4a01-b7da-83fd64af97a4",
"content": `blob:${tempFilePath}`,
"is_read": 0,
"is_group": 0,
"file_id": 0,
"file_cate": 0,
"fileName": "20210719150601_4401e.jpg",
"fileSize": 72046,
"extends": null,
"fromUser": {
...this.fromUser
},
from_user: this.fromUser.id,
toContactId: this.formId,
})
...this.sendData,
type:'video'
}, //
success: function(uploadRes) {
that.local = ""
@ -515,6 +464,25 @@
},
},
onShow() {
this.fromId= JSON.parse( uni.getStorageSync("USER_INFO")).id
getAreaManagerApi({user_id:this.fromId}).then(res=>{
this.toId=res.data.to_user_id
this.sendData={
from_user_id:this.fromId,
to_user_id:this.toId,
scene:0,
}
getMsgListApi({
...this.sendData,
page_no:1,
page_size:10
}).then(res=>{
this.list=res.data.reverse()
this.scrollFn()
})
})
// 08302669767
return
let that = this
this.scrollFn(500)
@ -522,7 +490,7 @@
request("POST", "enterprise/im/getMessageList", {
limit: 1,
page: 1,
toContactId: this.formId,
toContactId: this.fromId,
}).then(res => {
if (res.data.data[0]?.id != this.list[this.list.length - 1]?.id) {
@ -538,17 +506,17 @@
}, 3000)
},
async onPullDownRefresh() {
this.status = "loading"
this.page++
await this.getListFn()
// console.log("")
uni.stopPullDownRefresh();
// async onPullDownRefresh() {
// this.status = "loading"
// this.page++
// await this.getListFn()
// // console.log("")
// uni.stopPullDownRefresh();
},
// },
onLoad() {
uni.connectSocket({
url: 'ws://192.168.1.16:8282'
url: 'ws://192.168.1.9:8282'
});
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开');
@ -556,20 +524,26 @@
uni.onSocketError(function (res) {
console.log('WebSocket连接打开失败请检查');
});
let that=this
let that=this
uni.onSocketMessage(function(res) {
if(!that.bind){
let id= JSON.parse( uni.getStorageSync("USER_INFO")).id
bindScoket({
client_id:JSON.parse(res.data).client_id,
user_id:id,
scene:0,
}).then(res=>{
that.bind=true
})
let data=JSON.parse(res.data)
if(data.client_id){
let client_id= data.client_id
if(!that.bind){
bindScoket({
client_id:client_id,
user_id:that.fromId,
scene:0,
}).then(res=>{
that.bind=true
})
}
}
//
else if(data.type!='ping') {
console.log(data)
that.list.push(data)
}
});
@ -591,10 +565,10 @@ let that=this
<style lang="scss">
.yl-text {
position: absolute;
color: black;
top: 60%;
color: white;
top: 50%;
left: 50%;
transform: translateX(-50%);
transform: translate(-50%,-50%);
font-size: 24rpx;
}
@ -645,7 +619,7 @@ let that=this
background-color: white;
padding: 20rpx;
border-radius: 20rpx;
color: white;
// color: white;
word-break: break-all;
max-width: 60vw;