上商机信息

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 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 sendFileApi = (data) => oahttp.post('/common/im/sendFileMsg', data)
// 消息列表 // 消息列表
export const getMsgListApi = (data) => oahttp.post('/common/im/msgList', 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' //测试 httpApi = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiThree = 'https://ceshi-worker-task.lihaink.cn' //测试 httpApiThree = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiTwo = 'https://ceshi-logistics.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", "path": "pages/business/business",
"style": { "style": {
"navigationBarTitleText": "商机信息", "navigationBarTitleText": "商机信息",
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#0122C7", "navigationBarBackgroundColor": "#0122C7",
"navigationBarTextStyle": "white" "navigationBarTextStyle": "white"
} }

View File

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