im完成
This commit is contained in:
parent
c10460b9b6
commit
be0045b4b0
16
App.vue
16
App.vue
@ -64,13 +64,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
const audioContext = uni.createInnerAudioContext()
|
jpushModule.initJPushService()
|
||||||
// 设置音频文件地址
|
// const audioContext = uni.createInnerAudioContext()
|
||||||
audioContext.src = '/static/mp3/order.mp3'
|
// // 设置音频文件地址
|
||||||
|
// audioContext.src = '/static/mp3/order.mp3'
|
||||||
// 播放音频
|
// 播放音频
|
||||||
//#ifdef APP-PLUS
|
//#ifdef APP-PLUS
|
||||||
jpushModule.addNotificationListener(res => {
|
jpushModule.addNotificationListener(res => {
|
||||||
|
const audioContext = uni.createInnerAudioContext()
|
||||||
|
if(res.content.includes(':')){
|
||||||
|
audioContext.src = '/static/mp3/im.wav'
|
||||||
|
audioContext.play()
|
||||||
|
uni.vibrateLong();
|
||||||
|
console.log("im")
|
||||||
|
return
|
||||||
|
}
|
||||||
if (res.notificationEventType == 'notificationOpened') return
|
if (res.notificationEventType == 'notificationOpened') return
|
||||||
|
audioContext.src = '/static/mp3/order.mp3'
|
||||||
audioContext.play()
|
audioContext.play()
|
||||||
uni.vibrateLong();
|
uni.vibrateLong();
|
||||||
console.log("app的监听")
|
console.log("app的监听")
|
||||||
|
@ -3,8 +3,8 @@ let httpApi; // 总域名
|
|||||||
let httpApiTwo; // 物流系统域名
|
let httpApiTwo; // 物流系统域名
|
||||||
let httpApiTest
|
let httpApiTest
|
||||||
|
|
||||||
const env = 'dev'; // 开发
|
// const env = 'dev'; // 开发
|
||||||
// const env = 'prod'; // 生产
|
const env = 'prod'; // 生产
|
||||||
// const env = 'prew'; // 预上线
|
// const env = 'prew'; // 预上线
|
||||||
|
|
||||||
switch (env) {
|
switch (env) {
|
||||||
@ -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.9:8081' //测试环境
|
httpApiTest = 'http://192.168.1.13:8081' //测试环境
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
25
pages.json
25
pages.json
@ -31,10 +31,8 @@
|
|||||||
"navigationBarTitleText": "商机信息",
|
"navigationBarTitleText": "商机信息",
|
||||||
"navigationBarBackgroundColor": "#0122C7",
|
"navigationBarBackgroundColor": "#0122C7",
|
||||||
"navigationBarTextStyle": "white",
|
"navigationBarTextStyle": "white",
|
||||||
"app-plus": {
|
"enablePullDownRefresh": true
|
||||||
//手机软键盘升起不让其将页面头部上推
|
|
||||||
"softinputMode": "adjustResize"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -277,6 +275,16 @@
|
|||||||
"navigationBarTextStyle": "white"
|
"navigationBarTextStyle": "white"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},{
|
||||||
|
"path": "chatMang/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "聊天",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"navigationBarBackgroundColor": "#0122C7",
|
||||||
|
"navigationBarTextStyle": "white",
|
||||||
|
"enablePullDownRefresh": true
|
||||||
|
}
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
"path": "topUp/topUp",
|
"path": "topUp/topUp",
|
||||||
"style": {
|
"style": {
|
||||||
@ -593,6 +601,15 @@
|
|||||||
"navigationBarTextStyle": "white"
|
"navigationBarTextStyle": "white"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}, {
|
||||||
|
"path": "property/buyCar",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "车辆购买",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"navigationBarBackgroundColor": "#0122C7",
|
||||||
|
"navigationBarTextStyle": "white"
|
||||||
|
}
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
"path": "property/success",
|
"path": "property/success",
|
||||||
"style": {
|
"style": {
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<view style="background-color: #F6F7FD;">
|
<view style="background-color: #F6F7FD;">
|
||||||
|
<u-loading-page :loading="showLoading" v-if="showLoading"></u-loading-page>
|
||||||
<!-- 消息 -->
|
<!-- 消息 -->
|
||||||
<view class="content" @click="showPlus=false" id="content">
|
<view class="content" @click="showPlus=false" id="content" v-show='!showLoading'>
|
||||||
<view class="">
|
<view class="">
|
||||||
<u-loadmore :status="status"
|
<u-loadmore :status="status"
|
||||||
:loadmore-text="`你正在与${'wo'}聊天`"
|
:loadmore-text="`你正在与${manager_nmae}聊天`" />
|
||||||
/>
|
|
||||||
</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 class="" v-if="index %5 ==0" style="text-align: center;">
|
||||||
|
{{timeFn(item.create_time)}}
|
||||||
|
</view>
|
||||||
<!-- 对方消息 -->
|
<!-- 对方消息 -->
|
||||||
<view v-if="item.from_user_id!=fromId">
|
<view v-if="item.from_user_id!=fromId">
|
||||||
<view class="task-li-r">
|
<view class="task-li-r">
|
||||||
@ -21,7 +23,7 @@
|
|||||||
</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;"
|
||||||
@tap="showOverLayFn(item.content,item.type)">
|
@tap="previewImage(item.content)">
|
||||||
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
||||||
</view>
|
</view>
|
||||||
<!-- 视频 -->
|
<!-- 视频 -->
|
||||||
@ -32,9 +34,7 @@
|
|||||||
<view class="yl-text">
|
<view class="yl-text">
|
||||||
<u-icon name="play-circle" color='white' size='30'></u-icon>
|
<u-icon name="play-circle" color='white' size='30'></u-icon>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="send-time">
|
<view class="send-time">
|
||||||
{{item.sendTime}}
|
{{item.sendTime}}
|
||||||
@ -42,7 +42,6 @@
|
|||||||
</view>
|
</view>
|
||||||
<!-- 我的消息 -->
|
<!-- 我的消息 -->
|
||||||
<view class="task-li-l" v-else>
|
<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;">
|
||||||
@ -50,7 +49,7 @@
|
|||||||
</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;"
|
||||||
@tap="showOverLayFn(item.content,item.type)">
|
@tap="previewImage(item.content)">
|
||||||
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
||||||
</view>
|
</view>
|
||||||
<!-- 视频 -->
|
<!-- 视频 -->
|
||||||
@ -59,7 +58,6 @@
|
|||||||
<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>
|
<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>
|
<u-icon name="play-circle" color='white' size='30'></u-icon>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="">
|
||||||
@ -68,36 +66,32 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 本地 -->
|
<!-- 本地 -->
|
||||||
<view v-if="local">
|
<view v-show="item.status" v-for="(item,index) in local">
|
||||||
<view class="localTask" v-if="localType=='video'">
|
<view class="localTask" v-if="item.localType=='video'">
|
||||||
<view class="task-li-content" style="margin-right: 10rpx;">
|
<view class="task-li-content" style="margin-right: 10rpx;">
|
||||||
<video :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
|
<video :src="item.localSrc" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
|
||||||
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
|
<!-- <image :src="" style="width:200rpx" mode="widthFix"></image> -->
|
||||||
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
|
<u-loadmore status="loading" loading-text="努力上传中" />
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-right: 10rpx;">
|
<view class="" style="margin-right: 10rpx;">
|
||||||
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="localTask" v-if="item.localType=='image'">
|
||||||
<view class="localTask" v-if="localType=='image'">
|
|
||||||
<view class="task-li-content" style="margin-right: 10rpx;">
|
<view class="task-li-content" style="margin-right: 10rpx;">
|
||||||
<!-- <image :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></image> -->
|
<image :src="item.localSrc" style="width:200rpx" mode="widthFix"></image>
|
||||||
<image :src="local" style="width:200rpx" mode="widthFix"></image>
|
<u-loadmore status="loading" loading-text="努力上传中" />
|
||||||
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-right: 10rpx;">
|
<view class="" style="margin-right: 10rpx;">
|
||||||
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view style="height: 300rpx;background-color: #F6F7FD;" v-if="showPlus">
|
<view style="height: 300rpx;background-color: #F6F7FD;" v-if="showPlus">
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view style="height: 150rpx;background-color: #F6F7FD;" v-else>
|
<view style="height: 150rpx;background-color: #F6F7FD;" v-else>
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
@ -123,29 +117,20 @@
|
|||||||
<view class="plus_li">
|
<view class="plus_li">
|
||||||
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
|
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
|
||||||
@click="choseVideoFn"></u--image>
|
@click="choseVideoFn"></u--image>
|
||||||
|
|
||||||
<text>视频</text>
|
<text>视频</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</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'">
|
|
||||||
|
|
||||||
<image :showLoading="true" style="width: 80vw;" mode="widthFix" :src="overLaySrc"></image>
|
|
||||||
</view>
|
|
||||||
<view class="rect" @tap.stop v-if="overLayType=='video'">
|
<view class="rect" @tap.stop v-if="overLayType=='video'">
|
||||||
<video :src="overLaySrc"></video>
|
<video :src="overLaySrc" controls :autoplay="true"></video>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</u-overlay>
|
</u-overlay>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
sendMsgApi,getMsgListApi,bindScoket,sendFileApi,getAreaManagerApi
|
sendMsgApi,getMsgListApi,bindScoket,sendFileApi,getAreaManagerApi
|
||||||
@ -153,33 +138,81 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
showLoading:true,
|
||||||
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,
|
||||||
num: 0,
|
scollNum: 50000,
|
||||||
flags: true,
|
|
||||||
scollNum: 0,
|
|
||||||
client_id: "",
|
client_id: "",
|
||||||
fromId: "",
|
fromId: "",
|
||||||
toId:"",
|
toId:"",
|
||||||
name: "",
|
name: "",
|
||||||
status: "loadmore",
|
status: "loadmore",
|
||||||
page: 1,
|
page_no: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
formUser: "",
|
|
||||||
show: false,
|
show: false,
|
||||||
overLaySrc: "",
|
overLaySrc: "",
|
||||||
overLayType: "",
|
overLayType: "",
|
||||||
local: "",
|
local: [],
|
||||||
localType: "",
|
localType: "",
|
||||||
progress: "",
|
imageList:[],
|
||||||
sendData:{}
|
sendData:{},
|
||||||
|
manager_nmae:"",
|
||||||
|
msg_id:"",
|
||||||
|
aaa:false,
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
previewImage(src) {
|
||||||
|
this.imageList[0]=src
|
||||||
|
uni.previewImage({
|
||||||
|
urls: this.imageList,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
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;
|
||||||
|
this.msg_id=uuid
|
||||||
|
console.log("改变id")
|
||||||
|
},
|
||||||
|
timeFn(time) {
|
||||||
|
time=time*1000
|
||||||
|
const currentDate = new Date(); // 当前日期对象
|
||||||
|
const targetDate = new Date(time);
|
||||||
|
if (this.isSameDay(currentDate, targetDate)) {
|
||||||
|
const hours = targetDate.getHours(); // 小时
|
||||||
|
const minutes = targetDate.getMinutes(); // 分钟
|
||||||
|
return hours + ':' + (minutes>=10?minutes:'0'+minutes);
|
||||||
|
|
||||||
|
} else if (this.isYesterday(currentDate, targetDate)) {
|
||||||
|
return '昨天';
|
||||||
|
}
|
||||||
|
const month = targetDate.getMonth() + 1; // 月份(注意月份从0开始,需要加1)
|
||||||
|
const day = targetDate.getDate(); // 日期
|
||||||
|
return month + '月' + day + '日';
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
isSameDay(date1, date2) {
|
||||||
|
return (
|
||||||
|
date1.getFullYear() === date2.getFullYear() &&
|
||||||
|
date1.getMonth() === date2.getMonth() &&
|
||||||
|
date1.getDate() === date2.getDate()
|
||||||
|
);
|
||||||
|
|
||||||
|
},
|
||||||
|
isYesterday(currentDate, targetDate) {
|
||||||
|
const yesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 1);
|
||||||
|
return this.isSameDay(yesterday, targetDate);
|
||||||
|
},
|
||||||
toast(msg){
|
toast(msg){
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: msg,
|
title: msg,
|
||||||
@ -196,7 +229,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail() {
|
fail() {
|
||||||
toast('保存失败')
|
this.toast('保存失败')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -218,60 +251,61 @@
|
|||||||
this.overLayType = type
|
this.overLayType = type
|
||||||
},
|
},
|
||||||
getListFn() {
|
getListFn() {
|
||||||
return
|
getMsgListApi({
|
||||||
|
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){
|
||||||
|
uni.stopPullDownRefresh();
|
||||||
|
this.status="nomore"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.list=res.data.reverse().concat(this.list )
|
||||||
|
uni.stopPullDownRefresh();
|
||||||
|
})
|
||||||
},
|
},
|
||||||
scrollFn() {
|
scrollFn() {
|
||||||
return
|
|
||||||
this.scollNum += 1000
|
|
||||||
let that=this
|
let that=this
|
||||||
|
this.scollNum+=100
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop:that.scollNum,
|
|
||||||
});
|
|
||||||
console.log("滚动1",that.scollNum)
|
|
||||||
}, 200)
|
|
||||||
|
|
||||||
},
|
|
||||||
sendFn() {
|
|
||||||
this.list.push({
|
|
||||||
content:this.value,
|
|
||||||
from_user_id:10,
|
|
||||||
type:"text",
|
|
||||||
from_user_avatar:"https://ts1.cn.mm.bing.net/th/id/R-C.2079d983dc3db1b0282e9d6044588021?rik=rO6pzNsFk%2f5Wlg&riu=http%3a%2f%2fwww.d2ziran.com%2fpublic%2fupload%2fimage%2f20190918%2f1568820586479461.jpg&ehk=4poVBmEdgXhqVLgf%2bjIlFtR6oUrNtHg3%2fu2qWk8b6aw%3d&risl=&pid=ImgRaw&r=0"
|
|
||||||
})
|
|
||||||
let that=this
|
|
||||||
this.scollNum += 1000
|
|
||||||
this.value = ""
|
|
||||||
// this.scrollFn()
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.pageScrollTo({
|
|
||||||
duration: 0,// 过渡时间
|
|
||||||
|
|
||||||
scrollTop: that.scollNum,// 滚动的实际距离
|
scrollTop: that.scollNum,// 滚动的实际距离
|
||||||
success:function(){
|
success:function(){
|
||||||
console.log('成功了', that.scollNum)
|
console.log('滚动')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
return
|
|
||||||
if (!this.value) return
|
},
|
||||||
this.num++
|
sendFn() {
|
||||||
this.flags = !this.flags
|
let that=this
|
||||||
|
if (!this.value) {
|
||||||
|
this.toast("消息不能为空")
|
||||||
|
return
|
||||||
|
}
|
||||||
let data = {
|
let data = {
|
||||||
from_user_id: this.fromId,
|
from_user_id: this.fromId,
|
||||||
to_user_id:this.toId,
|
to_user_id:this.toId,
|
||||||
type: "text",
|
type: "text",
|
||||||
content: this.value,
|
content: this.value,
|
||||||
scene:0,
|
scene:0,
|
||||||
|
create_time:(Date.now()/1000),
|
||||||
|
msg_id:this.msg_id
|
||||||
}
|
}
|
||||||
sendMsgApi({
|
sendMsgApi({
|
||||||
...data
|
...data
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
console.log(data)
|
||||||
this.list.push(data)
|
this.list.push(data)
|
||||||
this.scrollFn(100)
|
this.scrollFn(100)
|
||||||
this.value = ""
|
this.value = ""
|
||||||
|
this.generateRandId()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
toast('发送失败')
|
this.toast('发送失败')
|
||||||
|
this.generateRandId()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
showPlusFn() {
|
showPlusFn() {
|
||||||
@ -279,45 +313,58 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
choseImgFn() {
|
choseImgFn() {
|
||||||
|
this.generateRandId()
|
||||||
let time = Date.now()
|
let time = Date.now()
|
||||||
let that = this
|
let that = this
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1, // 最多可以选择的图片张数
|
count: 1, // 最多可以选择的图片张数
|
||||||
success: res => {
|
success: res => {
|
||||||
const tempFilePath = res.tempFilePaths[0];
|
const tempFilePath = res.tempFilePaths[0];
|
||||||
that.local = tempFilePath
|
that.local.push({
|
||||||
that.localType = 'image'
|
localType:'image',
|
||||||
|
localSrc:tempFilePath,
|
||||||
|
status:true,
|
||||||
|
msg_id:that.msg_id
|
||||||
|
})
|
||||||
that.showPlus = false
|
that.showPlus = false
|
||||||
|
that.scrollFn()
|
||||||
const uploadTask = uni.uploadFile({
|
console.log(that.local)
|
||||||
url: "http://192.168.1.9:8081/common/im/sendFileMsg",
|
uni.uploadFile({
|
||||||
|
url: "https://worker-task.lihaink.cn/common/im/sendFileMsg",
|
||||||
filePath: tempFilePath, // 选择的图片文件路径
|
filePath: tempFilePath, // 选择的图片文件路径
|
||||||
name: 'file',
|
name: 'file',
|
||||||
header: {
|
header: {
|
||||||
"Authorization": uni.getStorageSync("TOKEN")
|
"Authorization": uni.getStorageSync("TOKEN")
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
...this.sendData,
|
from_user_id:that.fromId,
|
||||||
|
to_user_id:that.toId,
|
||||||
|
scene:0,
|
||||||
|
msg_id:that.msg_id,
|
||||||
type:'image'
|
type:'image'
|
||||||
},
|
},
|
||||||
success: function(uploadRes) {
|
success: function(uploadRes) {
|
||||||
that.local = ""
|
let data=JSON.parse(uploadRes.data).data
|
||||||
that.list.push(JSON.parse(uploadRes.data).data)
|
|
||||||
|
var localIndex =that.local.findIndex(function (element) {
|
||||||
|
return element.msg_id === data.msg_id;
|
||||||
|
});
|
||||||
|
that.local[localIndex].status=false
|
||||||
|
that.list.push(data)
|
||||||
},
|
},
|
||||||
fail: function(error) {
|
fail: function(error) {
|
||||||
toast('上传失败')
|
this.toast('上传失败')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uploadTask.onProgressUpdate((res) => {
|
|
||||||
this.progress = res.progress
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
toast('操作取消')
|
this.toast('操作取消')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
choseVideoFn() {
|
choseVideoFn() {
|
||||||
|
this.generateRandId()
|
||||||
let that = this
|
let that = this
|
||||||
uni.chooseVideo({
|
uni.chooseVideo({
|
||||||
sourceType: ['album', 'camera'], // 视频选择的来源,可以是相册或摄像头
|
sourceType: ['album', 'camera'], // 视频选择的来源,可以是相册或摄像头
|
||||||
@ -325,90 +372,99 @@
|
|||||||
camera: 'back', // 摄像头类型,可以是前置或后置
|
camera: 'back', // 摄像头类型,可以是前置或后置
|
||||||
success: res => {
|
success: res => {
|
||||||
const tempFilePath = res.tempFilePath;
|
const tempFilePath = res.tempFilePath;
|
||||||
that.local = res.tempFilePath
|
that.local.push({
|
||||||
that.localType = 'video'
|
localType:'video',
|
||||||
|
localSrc:tempFilePath,
|
||||||
|
status:true,
|
||||||
|
msg_id:that.msg_id
|
||||||
|
})
|
||||||
|
|
||||||
that.showPlus = false
|
that.showPlus = false
|
||||||
|
that.scrollFn()
|
||||||
const uploadTask = uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: "http://192.168.1.9:8081/common/im/sendFileMsg",
|
url: "https://worker-task.lihaink.cn/common/im/sendFileMsg",
|
||||||
filePath: tempFilePath, // 选择的图片文件路径
|
filePath: tempFilePath, // 选择的图片文件路径
|
||||||
name: 'file',
|
name: 'file',
|
||||||
header: {
|
header: {
|
||||||
"Authorization": uni.getStorageSync("token")
|
"Authorization": uni.getStorageSync("token")
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
...this.sendData,
|
from_user_id:that.fromId,
|
||||||
|
to_user_id:that.toId,
|
||||||
|
scene:0,
|
||||||
|
msg_id:that.msg_id,
|
||||||
type:'video'
|
type:'video'
|
||||||
}, // 服务端接收文件的字段名
|
}, // 服务端接收文件的字段名
|
||||||
|
|
||||||
success: function(uploadRes) {
|
success: function(uploadRes) {
|
||||||
that.local = ""
|
|
||||||
that.list.push(JSON.parse(uploadRes.data).data)
|
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
|
||||||
|
that.list.push(data)
|
||||||
// 处理上传成功的逻辑
|
// 处理上传成功的逻辑
|
||||||
},
|
},
|
||||||
fail: function(error) {
|
fail: function(error) {
|
||||||
|
console.log(error)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '视频不能超过60s',
|
title: '视频不能超过60s',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
that.local = false
|
// that.local = false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadTask.onProgressUpdate((res) => {
|
|
||||||
this.progress = res.progress
|
|
||||||
console.log('上传进度', res.progress);
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: '视频不能超过60s',
|
// title: '视频不能超过60s',
|
||||||
duration: 2000,
|
// duration: 2000,
|
||||||
icon: 'none'
|
// icon: 'none'
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
this.page_no=1
|
||||||
return
|
this.generateRandId()
|
||||||
|
|
||||||
this.fromId= JSON.parse( uni.getStorageSync("USER_INFO")).id
|
this.fromId= JSON.parse( uni.getStorageSync("USER_INFO")).id
|
||||||
|
|
||||||
getAreaManagerApi({user_id:this.fromId}).then(res=>{
|
getAreaManagerApi({user_id:this.fromId}).then(res=>{
|
||||||
this.toId=res.data.to_user_id
|
this.toId=res.data.to_user_id
|
||||||
this.sendData={
|
this.manager_nmae=res.data.manager_name
|
||||||
|
getMsgListApi({
|
||||||
from_user_id:this.fromId,
|
from_user_id:this.fromId,
|
||||||
to_user_id:this.toId,
|
to_user_id:this.toId,
|
||||||
scene:0,
|
scene:0,
|
||||||
}
|
|
||||||
getMsgListApi({
|
|
||||||
...this.sendData,
|
|
||||||
page_no:1,
|
page_no:1,
|
||||||
page_size:10
|
page_size:10
|
||||||
}).then(res=>{
|
}).then(res=>{
|
||||||
|
this.showLoading=false
|
||||||
this.list=res.data.reverse()
|
this.list=res.data.reverse()
|
||||||
this.scrollFn()
|
this.scrollFn()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// async onPullDownRefresh() {
|
async onPullDownRefresh() {
|
||||||
// this.status = "loading"
|
let that=this
|
||||||
// this.page++
|
this.status = "loading"
|
||||||
// await this.getListFn()
|
this.page_no++
|
||||||
// // console.log("刷新")
|
await this.getListFn()
|
||||||
// uni.stopPullDownRefresh();
|
this.status = "loadmore"
|
||||||
|
|
||||||
// },
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
return
|
let user=JSON.parse(uni.getStorageSync('USER_INFO'))
|
||||||
|
this.a=user.avatar
|
||||||
|
console.log(user.avatar)
|
||||||
uni.connectSocket({
|
uni.connectSocket({
|
||||||
url: 'ws://192.168.1.9:8282'
|
url: 'wss://worker-task.lihaink.cn/wss'
|
||||||
});
|
});
|
||||||
uni.onSocketOpen(function (res) {
|
uni.onSocketOpen(function (res) {
|
||||||
console.log('WebSocket连接已打开!');
|
console.log('WebSocket连接已打开!');
|
||||||
@ -435,12 +491,13 @@
|
|||||||
else if(data.type!='ping') {
|
else if(data.type!='ping') {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
that.list.push(data)
|
that.list.push(data)
|
||||||
|
that.scrollFn()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.generateRandId()
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -465,12 +522,9 @@
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
// min-height: 100vh;
|
|
||||||
min-height: 95vh;
|
min-height: 95vh;
|
||||||
background-color: #F6F7FD;
|
background-color: #F6F7FD;
|
||||||
padding-top: 10rpx;
|
padding-top: 10rpx;
|
||||||
// padding-bottom: 50px;
|
|
||||||
|
|
||||||
.task-li {
|
.task-li {
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
@ -498,8 +552,6 @@
|
|||||||
|
|
||||||
.bottom {
|
.bottom {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
// height: 8vh;
|
|
||||||
// padding: 20rpx;
|
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -1,224 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="box">
|
|
||||||
<button @click="scrollFn(li4)">按钮</button>
|
|
||||||
<scroller style="padding-bottom: 200rpx;" :scrollable="true">
|
|
||||||
<view v-for="(item, index) in dataList" :key="item.id" ref="li">
|
|
||||||
<view class="sendtime" v-if="index %2 == 0||index==0" ref="sj">
|
|
||||||
<text class="font-size-cls" ref="sjt">10:25</text>
|
|
||||||
</view>
|
|
||||||
<!-- 对方消息 -->
|
|
||||||
<view class="talk-content">
|
|
||||||
<u--image shape="circle" :showLoading="true" :src="a" width="91.12rpx" height="91.12rpx"></u--image>
|
|
||||||
<!-- 文字 -->
|
|
||||||
<view class="talk-value">
|
|
||||||
<text class="font-size-cls">是独立建国路口附近过来的疯狂进攻打法了适当放宽是独立访客</text>
|
|
||||||
</view>
|
|
||||||
<!-- 图片 -->
|
|
||||||
<!-- 视频 -->
|
|
||||||
|
|
||||||
</view>
|
|
||||||
<!-- 我的消息 -->
|
|
||||||
<view class="talk-content" style="justify-content: flex-end;">
|
|
||||||
<view class="talk-value" style="margin-left: 0;margin-right: 30rpx;">
|
|
||||||
<text class="font-size-cls">是独立建国路口附近过来的疯狂进攻打法了适当放宽是独立访客</text>
|
|
||||||
</view>
|
|
||||||
<u--image shape="circle" :showLoading="true" :src="a" width="91.12rpx" height="91.12rpx"></u--image>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroller>
|
|
||||||
<!-- 底部 -->
|
|
||||||
|
|
||||||
<view class="bottom">
|
|
||||||
<!-- -->
|
|
||||||
<view class="send-col">
|
|
||||||
<view class="" style="width: 500rpx;">
|
|
||||||
<u--input class="send-ipt" placeholder="请输入内容" border="surround" v-model="value"></u--input>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" @tap="showPlusFn" width="49.07rpx"
|
|
||||||
height="49.07rpx"></u--image>
|
|
||||||
|
|
||||||
<view class="send"><text class="send-text" @click="scrollFn">发送</text></view>
|
|
||||||
</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"></u--image>
|
|
||||||
<text>图片</text>
|
|
||||||
</view>
|
|
||||||
<view class="plus_li">
|
|
||||||
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx"
|
|
||||||
height="120rpx"></u--image>
|
|
||||||
|
|
||||||
<text>视频</text>
|
|
||||||
</view>
|
|
||||||
<!-- asdas -->
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 遮罩图 -->
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const dom = uni.requireNativePlugin('dom')
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
scollNum: 99999999999999999999,
|
|
||||||
value: "",
|
|
||||||
showPlus: false,
|
|
||||||
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",
|
|
||||||
dataList: [{
|
|
||||||
id: "1",
|
|
||||||
name: 'A'
|
|
||||||
}, {
|
|
||||||
id: "2",
|
|
||||||
name: 'B'
|
|
||||||
}, {
|
|
||||||
id: "3",
|
|
||||||
name: 'C'
|
|
||||||
}, {
|
|
||||||
id: "4",
|
|
||||||
name: "5"
|
|
||||||
}, {
|
|
||||||
id: "6",
|
|
||||||
name: "7"
|
|
||||||
}, {
|
|
||||||
id: "7",
|
|
||||||
name: "7"
|
|
||||||
}, {
|
|
||||||
id: "8",
|
|
||||||
name: "7"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showPlusFn() {
|
|
||||||
this.showPlus = !this.showPlus
|
|
||||||
},
|
|
||||||
scrollFn(el1) {
|
|
||||||
const el = this.$refs.li[0]
|
|
||||||
|
|
||||||
console.log(el)
|
|
||||||
dom.scrollToElement(el, {})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
,
|
|
||||||
onShow() {
|
|
||||||
this.scrollFn(500)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.box {
|
|
||||||
background-color: #F6F8FD;
|
|
||||||
padding: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.font-size-cls {
|
|
||||||
font-size: 29rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sendtime {
|
|
||||||
width: 750rpx;
|
|
||||||
/* background-color: red; */
|
|
||||||
/* text-align: center; */
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-around;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.talk-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.talk-value {
|
|
||||||
background-color: #fff;
|
|
||||||
width: 550rpx;
|
|
||||||
margin-left: 30rpx;
|
|
||||||
border-radius: 5.26rpx 21.03rpx 21.03rpx 21.03rpx;
|
|
||||||
padding: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bottom {
|
|
||||||
background-color: white;
|
|
||||||
// height: 8vh;
|
|
||||||
padding: 0 20rpx;
|
|
||||||
position: fixed;
|
|
||||||
box-sizing: border-box;
|
|
||||||
bottom: 0px;
|
|
||||||
// padding-bottom: 10px;
|
|
||||||
padding: 20rpx 0 40rpx 0;
|
|
||||||
width: 750rpx;
|
|
||||||
|
|
||||||
.send-col {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-around;
|
|
||||||
flex-direction: row;
|
|
||||||
// width: 700;
|
|
||||||
|
|
||||||
.send-ipt {
|
|
||||||
|
|
||||||
height: 63.08rpx;
|
|
||||||
background-color: #F5F5F5;
|
|
||||||
height: 60rpx;
|
|
||||||
|
|
||||||
padding-left: 20rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.send {
|
|
||||||
background-color: #2573fb;
|
|
||||||
height: 50.82rpx;
|
|
||||||
border: none;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
padding: 0;
|
|
||||||
width: 94.63rpx;
|
|
||||||
line-height: 62rpx;
|
|
||||||
// text-align: center;
|
|
||||||
// lighting-color: 50rpx;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: #1573fb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.send-text {
|
|
||||||
color: white;
|
|
||||||
font-size: 26.29rpx;
|
|
||||||
line-height: 50rpx;
|
|
||||||
// margin: 0 50rpx;
|
|
||||||
margin-left: 20rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.plus {
|
|
||||||
display: flex;
|
|
||||||
background-color: white;
|
|
||||||
padding: 20rpx;
|
|
||||||
flex-direction: row;
|
|
||||||
|
|
||||||
.plus_li {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
margin-right: 20rpx;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -110,6 +110,25 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 片区经理聊天 -->
|
||||||
|
<view class="chat" @click="navTo('/subpkg/chatMang/index')" style="margin-top: 130rpx;">
|
||||||
|
<view class="chat-l">
|
||||||
|
<u--image shape="circle" :showLoading="true" :src="managerInfo.manager_avatar" width="91rpx" height="91rpx"></u--image>
|
||||||
|
<view class="" style="margin-left: 40rpx;">
|
||||||
|
{{managerInfo.manager_name}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="" style="display: flex;">
|
||||||
|
<view class="brange">
|
||||||
|
99
|
||||||
|
</view>
|
||||||
|
<view class="iconfont icon-you">
|
||||||
|
<uni-icons type="forward"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="my_task">
|
<view class="my_task">
|
||||||
<view class="task_title flex_a_c_j_sb">
|
<view class="task_title flex_a_c_j_sb">
|
||||||
<view class="title">工作管理</view>
|
<view class="title">工作管理</view>
|
||||||
@ -215,6 +234,9 @@ import {
|
|||||||
import {
|
import {
|
||||||
noticeList
|
noticeList
|
||||||
} from "@/api/notice.js";
|
} from "@/api/notice.js";
|
||||||
|
import {
|
||||||
|
getAreaManagerApi
|
||||||
|
} from "@/api/bussness.js"
|
||||||
// import tabbar from '../components/tabbar'
|
// import tabbar from '../components/tabbar'
|
||||||
import {
|
import {
|
||||||
getIndexListAPI,
|
getIndexListAPI,
|
||||||
@ -241,6 +263,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
brange:0,
|
||||||
options: {
|
options: {
|
||||||
data: '',
|
data: '',
|
||||||
},
|
},
|
||||||
@ -248,6 +271,7 @@ export default {
|
|||||||
page_num: 1,
|
page_num: 1,
|
||||||
flag: false,
|
flag: false,
|
||||||
uniMP: false,
|
uniMP: false,
|
||||||
|
managerInfo:{},
|
||||||
id: "",
|
id: "",
|
||||||
is_captain: 0,
|
is_captain: 0,
|
||||||
notArr: [],
|
notArr: [],
|
||||||
@ -292,11 +316,16 @@ export default {
|
|||||||
await this.$onLaunched;
|
await this.$onLaunched;
|
||||||
this.is_captain = JSON.parse(uni.getStorageSync("USER_INFO")||'{}')?.is_captain
|
this.is_captain = JSON.parse(uni.getStorageSync("USER_INFO")||'{}')?.is_captain
|
||||||
this.options.data = bj;
|
this.options.data = bj;
|
||||||
|
let user_id= JSON.parse( uni.getStorageSync("USER_INFO")).id
|
||||||
|
getAreaManagerApi({user_id}).then(res=>{
|
||||||
|
console.log(res.data)
|
||||||
|
this.managerInfo=res.data
|
||||||
|
})
|
||||||
//#ifdef APP-PLUS
|
//#ifdef APP-PLUS
|
||||||
let that = this;
|
let that = this;
|
||||||
jpushModule.addNotificationListener(function (result) {
|
jpushModule.addNotificationListener(function (result) {
|
||||||
if (!that.notArr.includes(result.messageID)) {
|
if (!that.notArr.includes(result.messageID)) {
|
||||||
that.$refs.globalPopup.showPopu();
|
// that.$refs.globalPopup.showPopu();
|
||||||
that.getOrderList();
|
that.getOrderList();
|
||||||
console.log("idnex的");
|
console.log("idnex的");
|
||||||
that.notArr.push(result.messageID);
|
that.notArr.push(result.messageID);
|
||||||
@ -408,14 +437,21 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 通知
|
// 通知
|
||||||
noticeFn () {
|
noticeFn () {
|
||||||
const audioContext = uni.createInnerAudioContext()
|
jpushModule.addNotificationListener(res => {
|
||||||
audioContext.src = '/static/mp3/order.mp3'
|
const audioContext = uni.createInnerAudioContext()
|
||||||
jpushModule.addNotificationListener(res => {
|
if(res.content.includes(':')){
|
||||||
|
audioContext.src = '/static/mp3/im.wav'
|
||||||
|
audioContext.play()
|
||||||
|
uni.vibrateLong();
|
||||||
|
console.log("im")
|
||||||
|
return
|
||||||
|
}
|
||||||
if (res.notificationEventType == 'notificationOpened') return
|
if (res.notificationEventType == 'notificationOpened') return
|
||||||
|
audioContext.src = '/static/mp3/order.mp3'
|
||||||
audioContext.play()
|
audioContext.play()
|
||||||
uni.vibrateLong();
|
uni.vibrateLong();
|
||||||
this.getOrderList()
|
this.getOrderList()
|
||||||
this.$refs.globalPopup.showPopu();
|
// this.$refs.globalPopup.showPopu();
|
||||||
console.log("index的监听")
|
console.log("index的监听")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -958,4 +994,32 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.chat{
|
||||||
|
margin-top: 1000px;
|
||||||
|
// margin-top: 2000rpx;
|
||||||
|
width: 694.74rpx;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding:20rpx;
|
||||||
|
// padding-top: 10rpx;
|
||||||
|
padding-right: 24rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
.chat-l{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.brange{
|
||||||
|
color: white;
|
||||||
|
background-color: red;
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
lighting-color: 40rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
BIN
static/mp3/im.mp3
Normal file
BIN
static/mp3/im.mp3
Normal file
Binary file not shown.
BIN
static/mp3/im.wav
Normal file
BIN
static/mp3/im.wav
Normal file
Binary file not shown.
@ -1,29 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<view style="background-color: #F6F7FD;">
|
<view style="background-color: #F6F7FD;">
|
||||||
|
<u-loading-page :loading="showLoading" v-if="showLoading"></u-loading-page>
|
||||||
<!-- <view class="storeName" style="padding-top:var(--status-bar-height) ;">
|
|
||||||
<u--image src="/static/right.png" width="50rpx" height="50rpx" @click='backFn'></u--image>
|
|
||||||
<view class="" @click="timeFn">
|
|
||||||
{{timeFn()}}
|
|
||||||
</view>
|
|
||||||
<view class="">
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<!-- 消息 -->
|
<!-- 消息 -->
|
||||||
<view class="content" @click="showPlus=false" id="content">
|
<view class="content" @click="showPlus=false" id="content" v-show='!showLoading'>
|
||||||
<view class="">
|
<view class="">
|
||||||
<u-loadmore :status="status" />
|
<u-loadmore :status="status"
|
||||||
|
:loadmore-text="`你正在与${manager_nmae}聊天`" />
|
||||||
</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 class="" v-if="index %5 ==0" style="text-align: center;">
|
||||||
|
{{timeFn(item.create_time)}}
|
||||||
|
</view>
|
||||||
<!-- 对方消息 -->
|
<!-- 对方消息 -->
|
||||||
<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;">
|
||||||
@ -31,86 +23,75 @@
|
|||||||
</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;"
|
||||||
@tap="showOverLayFn(item.content,item.type)">
|
@tap="previewImage(item.content)">
|
||||||
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
||||||
</view>
|
</view>
|
||||||
<!-- 视频 -->
|
<!-- 视频 -->
|
||||||
<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"
|
|
||||||
style="width: 400rpx; height: 100px;"></video> -->
|
|
||||||
<!-- <image src="item.content" style="width:200rpx" mode="widthFix"></image> -->
|
|
||||||
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="send-time">
|
<view class="send-time">
|
||||||
{{item.sendTime}}
|
{{item.sendTime}}
|
||||||
</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;"
|
||||||
@tap="showOverLayFn(item.content,item.type)">
|
@tap="previewImage(item.content)">
|
||||||
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
|
||||||
</view>
|
</view>
|
||||||
<!-- 视频 -->
|
<!-- 视频 -->
|
||||||
<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="">
|
||||||
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
|
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<!-- 本地 -->
|
<!-- 本地 -->
|
||||||
<view v-if="local">
|
<view v-show="item.status" v-for="(item,index) in local">
|
||||||
<view class="localTask" v-if="localType=='video'">
|
<view class="localTask" v-if="item.localType=='video'">
|
||||||
<view class="task-li-content" style="margin-right: 10rpx;">
|
<view class="task-li-content" style="margin-right: 10rpx;">
|
||||||
<video :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
|
<video :src="item.localSrc" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
|
||||||
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
|
<!-- <image :src="" style="width:200rpx" mode="widthFix"></image> -->
|
||||||
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
|
<u-loadmore status="loading" loading-text="努力上传中" />
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-right: 10rpx;">
|
<view class="" style="margin-right: 10rpx;">
|
||||||
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="localTask" v-if="item.localType=='image'">
|
||||||
<view class="localTask" v-if="localType=='image'">
|
|
||||||
<view class="task-li-content" style="margin-right: 10rpx;">
|
<view class="task-li-content" style="margin-right: 10rpx;">
|
||||||
<!-- <image :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></image> -->
|
<image :src="item.localSrc" style="width:200rpx" mode="widthFix"></image>
|
||||||
<image :src="local" style="width:200rpx" mode="widthFix"></image>
|
<u-loadmore status="loading" loading-text="努力上传中" />
|
||||||
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-right: 10rpx;">
|
<view class="" style="margin-right: 10rpx;">
|
||||||
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view style="height: 300rpx;background-color: #F6F7FD;" v-if="showPlus">
|
||||||
<view style="height: 50px;background-color: #F6F7FD;">
|
</view>
|
||||||
|
<view style="height: 150rpx;background-color: #F6F7FD;" v-else>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
@ -118,7 +99,7 @@
|
|||||||
<view class="bottom">
|
<view class="bottom">
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<view class="send-col">
|
<view class="send-col">
|
||||||
<input type="text" class="send-ipt" @click="scrollFn(300)" v-model="value" placeholder="请输入聊天内容"
|
<input type="text" class="send-ipt" @focus="scrollFn" v-model="value" placeholder="请输入聊天内容"
|
||||||
placeholder-style="color:#DDD;" :cursor-spacing="6">
|
placeholder-style="color:#DDD;" :cursor-spacing="6">
|
||||||
|
|
||||||
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" width="32px" height="32px"
|
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" width="32px" height="32px"
|
||||||
@ -136,83 +117,89 @@
|
|||||||
<view class="plus_li">
|
<view class="plus_li">
|
||||||
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
|
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
|
||||||
@click="choseVideoFn"></u--image>
|
@click="choseVideoFn"></u--image>
|
||||||
|
|
||||||
<text>视频</text>
|
<text>视频</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- asdas -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</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'">
|
|
||||||
|
|
||||||
<image :showLoading="true" style="width: 80vw;" mode="widthFix" :src="overLaySrc"></image>
|
|
||||||
</view>
|
|
||||||
<view class="rect" @tap.stop v-if="overLayType=='video'">
|
<view class="rect" @tap.stop v-if="overLayType=='video'">
|
||||||
<video :src="overLaySrc"></video>
|
<video :src="overLaySrc" controls :autoplay="true"></video>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</u-overlay>
|
</u-overlay>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
sendMsgApi
|
sendMsgApi,getMsgListApi,bindScoket,sendFileApi,getAreaManagerApi
|
||||||
} from "@/api/bussness.js"
|
} from "@/api/bussness.js"
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
showLoading:true,
|
||||||
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,
|
||||||
value: "",
|
value: "",
|
||||||
showPlus: false,
|
showPlus: false,
|
||||||
num: 0,
|
scollNum: 500000000000,
|
||||||
flags: true,
|
|
||||||
scollNum: 999999999999,
|
|
||||||
client_id: "",
|
client_id: "",
|
||||||
formId: "",
|
fromId: "",
|
||||||
|
toId:"",
|
||||||
name: "",
|
name: "",
|
||||||
status: "lodemore",
|
status: "loadmore",
|
||||||
page: 1,
|
page_no: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
formUser: "",
|
|
||||||
show: false,
|
show: false,
|
||||||
overLaySrc: "",
|
overLaySrc: "",
|
||||||
overLayType: "",
|
overLayType: "",
|
||||||
canvasContext: null,
|
local: [],
|
||||||
timer: "",
|
|
||||||
local: "",
|
|
||||||
localType: "",
|
localType: "",
|
||||||
progress: "",
|
imageList:[],
|
||||||
showNotice: false
|
sendData:{},
|
||||||
|
manager_nmae:"",
|
||||||
|
msg_id:"",
|
||||||
|
aaa:false,
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
previewImage(src) {
|
||||||
|
this.imageList[0]=src
|
||||||
|
uni.previewImage({
|
||||||
|
urls: this.imageList,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
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;
|
||||||
|
this.msg_id=uuid
|
||||||
|
console.log("改变id")
|
||||||
|
},
|
||||||
timeFn(time) {
|
timeFn(time) {
|
||||||
// 1695722299000
|
time=time*1000
|
||||||
const currentDate = new Date(); // 当前日期对象
|
const currentDate = new Date(); // 当前日期对象
|
||||||
const targetDate = new Date(1695722299000);
|
const targetDate = new Date(time);
|
||||||
if (this.isSameDay(currentDate, targetDate)) {
|
if (this.isSameDay(currentDate, targetDate)) {
|
||||||
const hours = targetDate.getHours(); // 小时
|
const hours = targetDate.getHours(); // 小时
|
||||||
const minutes = targetDate.getMinutes(); // 分钟
|
const minutes = targetDate.getMinutes(); // 分钟
|
||||||
return hours + ':' + minutes;
|
return hours + ':' + (minutes>=10?minutes:'0'+minutes);
|
||||||
|
|
||||||
} else if (this.isYesterday(currentDate, targetDate)) {
|
} else if (this.isYesterday(currentDate, targetDate)) {
|
||||||
return '昨天';
|
return '昨天';
|
||||||
}
|
}
|
||||||
const month = targetDate.getMonth() + 1; // 月份(注意月份从0开始,需要加1)
|
const month = targetDate.getMonth() + 1; // 月份(注意月份从0开始,需要加1)
|
||||||
const day = targetDate.getDate(); // 日期
|
const day = targetDate.getDate(); // 日期
|
||||||
return month + '月' + day + '日';
|
return month + '月' + day + '日';
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
isSameDay(date1, date2) {
|
isSameDay(date1, date2) {
|
||||||
return (
|
return (
|
||||||
@ -220,11 +207,18 @@
|
|||||||
date1.getMonth() === date2.getMonth() &&
|
date1.getMonth() === date2.getMonth() &&
|
||||||
date1.getDate() === date2.getDate()
|
date1.getDate() === date2.getDate()
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
isYesterday(currentDate, targetDate) {
|
isYesterday(currentDate, targetDate) {
|
||||||
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);
|
||||||
},
|
},
|
||||||
|
toast(msg){
|
||||||
|
uni.showToast({
|
||||||
|
title: msg,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
},
|
||||||
saveImage(src) {
|
saveImage(src) {
|
||||||
uni.saveImageToPhotosAlbum({
|
uni.saveImageToPhotosAlbum({
|
||||||
filePath: src,
|
filePath: src,
|
||||||
@ -235,10 +229,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail() {
|
fail() {
|
||||||
uni.showToast({
|
this.toast('保存失败')
|
||||||
title: '保存失败',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -254,192 +245,127 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
backFn() {
|
|
||||||
uni.navigateBack()
|
|
||||||
},
|
|
||||||
|
|
||||||
showOverLayFn(src, type) {
|
showOverLayFn(src, type) {
|
||||||
this.show = true
|
this.show = true
|
||||||
this.overLaySrc = src
|
this.overLaySrc = src
|
||||||
this.overLayType = type
|
this.overLayType = type
|
||||||
},
|
},
|
||||||
getListFn() {
|
getListFn() {
|
||||||
return
|
getMsgListApi({
|
||||||
request("POST", "enterprise/im/getMessageList", {
|
from_user_id:this.fromId,
|
||||||
limit: this.limit,
|
to_user_id:this.toId,
|
||||||
page: this.page,
|
scene:0,
|
||||||
toContactId: this.formId,
|
page_no:this.page_no,
|
||||||
}).then(res => {
|
page_size:10
|
||||||
if (res.data.data.length == 0) {
|
}).then(res=>{
|
||||||
this.status = "nomore"
|
if(res.data.length<=0){
|
||||||
|
uni.stopPullDownRefresh();
|
||||||
|
this.status="nomore"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.list.unshift(...res.data.data)
|
this.list=res.data.reverse().concat(this.list )
|
||||||
this.status = "loadmore"
|
uni.stopPullDownRefresh();
|
||||||
}).catch(err => {
|
|
||||||
console.log(err, "获取消息列表失败")
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
scrollFn(time) {
|
scrollFn() {
|
||||||
this.scollNum += 500
|
let that=this
|
||||||
|
this.scollNum+=100
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: this.scollNum,
|
scrollTop: that.scollNum,// 滚动的实际距离
|
||||||
});
|
success:function(){
|
||||||
}, time ? time : 100)
|
console.log('滚动')
|
||||||
|
}
|
||||||
},
|
})
|
||||||
generateRandId() {
|
}, 100)
|
||||||
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;
|
|
||||||
},
|
},
|
||||||
sendFn() {
|
sendFn() {
|
||||||
if (!this.value) return
|
let that=this
|
||||||
this.num++
|
if (!this.value) {
|
||||||
this.flags = !this.flags
|
this.toast("消息不能为空")
|
||||||
|
return
|
||||||
|
}
|
||||||
let data = {
|
let data = {
|
||||||
to_user_id: "2",
|
from_user_id: this.fromId,
|
||||||
|
to_user_id:this.toId,
|
||||||
type: "text",
|
type: "text",
|
||||||
content: this.value,
|
content: this.value,
|
||||||
msg_id: this.generateRandId(),
|
scene:0,
|
||||||
to_user_name: "sdas",
|
create_time:(Date.now()/1000),
|
||||||
to_user_avatar: "https://ceshi-worker-task.lihaink.cn/uploads/images/20230926/20230926185925e41de3046.png",
|
msg_id:this.msg_id
|
||||||
}
|
}
|
||||||
sendMsgApi({
|
sendMsgApi({
|
||||||
...data
|
...data
|
||||||
|
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
|
||||||
this.list.push(data)
|
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
this.list.push(data)
|
||||||
|
this.scrollFn(100)
|
||||||
|
this.value = ""
|
||||||
|
this.generateRandId()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err, "发送消息失败")
|
this.toast('发送失败')
|
||||||
|
this.generateRandId()
|
||||||
})
|
})
|
||||||
this.value = ""
|
|
||||||
// this.scrollFn(100)
|
|
||||||
return
|
|
||||||
request("POST", "enterprise/im/sendMessage", {
|
|
||||||
content: this.value,
|
|
||||||
extends: null,
|
|
||||||
fileName: "",
|
|
||||||
fileSize: 0,
|
|
||||||
file_cate: 0,
|
|
||||||
file_id: 0,
|
|
||||||
fromUser: {
|
|
||||||
...this.fromUser
|
|
||||||
},
|
|
||||||
from_user: this.fromUser.id,
|
|
||||||
id: this.generateRandId(),
|
|
||||||
is_group: 0,
|
|
||||||
is_read: 0,
|
|
||||||
sendTime: Date.now(),
|
|
||||||
status: "going",
|
|
||||||
toContactId: this.formId,
|
|
||||||
type: "text",
|
|
||||||
}).then(res => {
|
|
||||||
console.log("发送消息成功")
|
|
||||||
// this.list.push(res.data.data)
|
|
||||||
})
|
|
||||||
|
|
||||||
this.value = ""
|
|
||||||
this.scrollFn(100)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
login() {
|
|
||||||
return
|
|
||||||
// request("POST", "common/Pub/login", {
|
|
||||||
// account: 13800000006,
|
|
||||||
// password: "123456",
|
|
||||||
// rememberMe: false,
|
|
||||||
// }).then(res => {
|
|
||||||
// uni.setStorageSync("token", (res.data.data.authToken))
|
|
||||||
// uni.setStorageSync("userinfo", JSON.stringify(res.data.data.userInfo))
|
|
||||||
|
|
||||||
// })
|
|
||||||
},
|
},
|
||||||
showPlusFn() {
|
showPlusFn() {
|
||||||
this.showPlus = !this.showPlus
|
this.showPlus = !this.showPlus
|
||||||
this.scrollFn(200)
|
this.scrollFn()
|
||||||
|
|
||||||
},
|
},
|
||||||
choseImgFn() {
|
choseImgFn() {
|
||||||
this.login()
|
this.generateRandId()
|
||||||
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]
|
that.local.push({
|
||||||
console.log(file)
|
localType:'image',
|
||||||
that.local = tempFilePath
|
localSrc:tempFilePath,
|
||||||
that.localType = 'image'
|
status:true,
|
||||||
|
msg_id:that.msg_id
|
||||||
|
})
|
||||||
that.showPlus = false
|
that.showPlus = false
|
||||||
that.scrollFn(200)
|
that.scrollFn()
|
||||||
const uploadTask = uni.uploadFile({
|
console.log(that.local)
|
||||||
url: "http://192.168.112:8081/apiim/upload",
|
uni.uploadFile({
|
||||||
|
url: "https://worker-task.lihaink.cn/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({
|
from_user_id:that.fromId,
|
||||||
// "id": this.generateRandId(),
|
to_user_id:that.toId,
|
||||||
// "sendTime": Date.now(),
|
scene:0,
|
||||||
// "status": "going",
|
msg_id:that.msg_id,
|
||||||
// "type": "image",
|
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 = ""
|
let data=JSON.parse(uploadRes.data).data
|
||||||
that.list.push(JSON.parse(uploadRes.data).data)
|
|
||||||
|
var localIndex =that.local.findIndex(function (element) {
|
||||||
// 处理上传成功的逻辑
|
return element.msg_id === data.msg_id;
|
||||||
|
});
|
||||||
|
that.local[localIndex].status=false
|
||||||
|
that.list.push(data)
|
||||||
},
|
},
|
||||||
fail: function(error) {
|
fail: function(error) {
|
||||||
console.log('上传失败', error);
|
this.toast('上传失败')
|
||||||
// 处理上传失败的逻辑
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadTask.onProgressUpdate((res) => {
|
|
||||||
this.progress = res.progress
|
|
||||||
console.log('上传进度', res.progress);
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
console.log(err, "没有选择图片");
|
this.toast('操作取消')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
choseVideoFn() {
|
choseVideoFn() {
|
||||||
|
this.generateRandId()
|
||||||
let that = this
|
let that = this
|
||||||
uni.chooseVideo({
|
uni.chooseVideo({
|
||||||
sourceType: ['album', 'camera'], // 视频选择的来源,可以是相册或摄像头
|
sourceType: ['album', 'camera'], // 视频选择的来源,可以是相册或摄像头
|
||||||
@ -447,144 +373,149 @@
|
|||||||
camera: 'back', // 摄像头类型,可以是前置或后置
|
camera: 'back', // 摄像头类型,可以是前置或后置
|
||||||
success: res => {
|
success: res => {
|
||||||
const tempFilePath = res.tempFilePath;
|
const tempFilePath = res.tempFilePath;
|
||||||
that.local = res.tempFilePath
|
that.local.push({
|
||||||
that.localType = 'video'
|
localType:'video',
|
||||||
|
localSrc:tempFilePath,
|
||||||
|
status:true,
|
||||||
|
msg_id:that.msg_id
|
||||||
|
})
|
||||||
|
|
||||||
that.showPlus = false
|
that.showPlus = false
|
||||||
that.scrollFn(200)
|
that.scrollFn()
|
||||||
const uploadTask = uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: "https://ceshi-im.lihaink.cn/common/upload/uploadFile",
|
url: "https://worker-task.lihaink.cn/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({
|
from_user_id:that.fromId,
|
||||||
"id": this.generateRandId(),
|
to_user_id:that.toId,
|
||||||
"sendTime": Date.now(),
|
scene:0,
|
||||||
"status": "going",
|
msg_id:that.msg_id,
|
||||||
"type": "image",
|
type:'video'
|
||||||
// "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.list.push(JSON.parse(uploadRes.data).data)
|
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
|
||||||
|
that.list.push(data)
|
||||||
// 处理上传成功的逻辑
|
// 处理上传成功的逻辑
|
||||||
},
|
},
|
||||||
fail: function(error) {
|
fail: function(error) {
|
||||||
|
console.log(error)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '视频不能超过60s',
|
title: '视频不能超过60s',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
that.local = false
|
// that.local = false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadTask.onProgressUpdate((res) => {
|
|
||||||
this.progress = res.progress
|
|
||||||
console.log('上传进度', res.progress);
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: '视频不能超过60s',
|
// title: '视频不能超过60s',
|
||||||
duration: 2000,
|
// duration: 2000,
|
||||||
icon: 'none'
|
// icon: 'none'
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
return
|
this.page_no=1
|
||||||
let that = this
|
this.generateRandId()
|
||||||
this.scrollFn(500)
|
this.fromId= JSON.parse( uni.getStorageSync("USER_INFO")).id
|
||||||
this.timer = setInterval(() => {
|
|
||||||
request("POST", "enterprise/im/getMessageList", {
|
getAreaManagerApi({user_id:this.fromId}).then(res=>{
|
||||||
limit: 1,
|
this.toId=res.data.to_user_id
|
||||||
page: 1,
|
this.manager_nmae=res.data.manager_name
|
||||||
toContactId: this.formId,
|
getMsgListApi({
|
||||||
}).then(res => {
|
from_user_id:this.fromId,
|
||||||
|
to_user_id:this.toId,
|
||||||
if (res.data.data[0]?.id != this.list[this.list.length - 1]?.id) {
|
scene:0,
|
||||||
this.list.push(res.data.data[0])
|
page_no:1,
|
||||||
if (res.data.data[0].type == 'video' || res.data.data[0].type == 'image') {
|
page_size:10
|
||||||
this.local = ""
|
}).then(res=>{
|
||||||
}
|
this.showLoading=false
|
||||||
// console.log(res.data.data)
|
this.list=res.data.reverse()
|
||||||
}
|
this.scrollFn()
|
||||||
// this.list.unshift(...res.data.data)
|
|
||||||
// this.status = "loadmore"
|
|
||||||
})
|
})
|
||||||
}, 3000)
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
async onPullDownRefresh() {
|
async onPullDownRefresh() {
|
||||||
|
let that=this
|
||||||
this.status = "loading"
|
this.status = "loading"
|
||||||
this.page++
|
this.page_no++
|
||||||
await this.getListFn()
|
await this.getListFn()
|
||||||
// console.log("刷新")
|
this.status = "loadmore"
|
||||||
uni.stopPullDownRefresh();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
let user=JSON.parse(uni.getStorageSync('USER_INFO'))
|
||||||
|
this.a=user.avatar
|
||||||
|
console.log(user.avatar)
|
||||||
|
uni.connectSocket({
|
||||||
|
url: 'wss://worker-task.lihaink.cn/wss'
|
||||||
|
});
|
||||||
|
uni.onSocketOpen(function (res) {
|
||||||
|
console.log('WebSocket连接已打开!');
|
||||||
|
});
|
||||||
|
uni.onSocketError(function (res) {
|
||||||
|
console.log('WebSocket连接打开失败,请检查!');
|
||||||
|
});
|
||||||
|
let that=this
|
||||||
uni.onSocketMessage(function(res) {
|
uni.onSocketMessage(function(res) {
|
||||||
console.log('收到服务器内容6565:' + res.data);
|
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)
|
||||||
|
that.scrollFn()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getListFn()
|
|
||||||
|
|
||||||
|
this.generateRandId()
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
onUnload() {
|
|
||||||
clearInterval(this.timer)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// .storeName {
|
|
||||||
// position: fixed;
|
|
||||||
// text-align: center;
|
|
||||||
// background-color: white;
|
|
||||||
// font-weight: bold;
|
|
||||||
// height: 80rpx;
|
|
||||||
// width: 100vw;
|
|
||||||
// z-index: 9;
|
|
||||||
// display: flex;
|
|
||||||
// align-items: center;
|
|
||||||
// justify-content: space-between;
|
|
||||||
// }
|
|
||||||
|
|
||||||
.topflag {
|
.topflag {
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
background-color: #F6F7FD;
|
background-color: #F6F7FD;
|
||||||
@ -592,13 +523,9 @@
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
// min-height: 100vh;
|
min-height: 95vh;
|
||||||
height: 89vh;
|
|
||||||
background-color: #F6F7FD;
|
background-color: #F6F7FD;
|
||||||
overflow: auto;
|
|
||||||
padding-top: 10rpx;
|
padding-top: 10rpx;
|
||||||
// padding-bottom: 50px;
|
|
||||||
|
|
||||||
.task-li {
|
.task-li {
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
@ -616,7 +543,7 @@
|
|||||||
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;
|
||||||
|
|
||||||
@ -626,13 +553,14 @@
|
|||||||
|
|
||||||
.bottom {
|
.bottom {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
// height: 8vh;
|
|
||||||
// padding: 20rpx;
|
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
|
/* #ifndef APP-PLUS */
|
||||||
|
// bottom: 40px;
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
.send-col {
|
.send-col {
|
||||||
display: flex;
|
display: flex;
|
64
subpkg/property/buyCar.vue
Normal file
64
subpkg/property/buyCar.vue
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<template>
|
||||||
|
<view class="">
|
||||||
|
<view class="car-list" v-for="item,index in carList" :key="index">
|
||||||
|
<view class="car-info">
|
||||||
|
<view class="car-info-l">
|
||||||
|
<view class="">
|
||||||
|
<u--image :src="a" width="150rpx" height="150rpx"
|
||||||
|
style="margin-right:20rpx"></u--image>
|
||||||
|
</view>
|
||||||
|
<view class="car-info-c">
|
||||||
|
<view class="lincense">
|
||||||
|
车牌号: 12121545454
|
||||||
|
</view>
|
||||||
|
<view class="lincense">
|
||||||
|
行驶里程: 1212KM
|
||||||
|
</view>
|
||||||
|
<view class="lincense">
|
||||||
|
当前状态: 平台公司闲置中
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="car-info-r">
|
||||||
|
选择该车辆为监管车辆
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script scoped>
|
||||||
|
export default{
|
||||||
|
data(){
|
||||||
|
return{
|
||||||
|
a:"https://tse3-mm.cn.bing.net/th/id/OIP-C.0xzWZj1_A-nzJiUBxrk8XQHaEo?w=298&h=186&c=7&r=0&o=5&pid=1.7"
|
||||||
|
,carList:[1,1,1,1,1,1,,1,1,]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.car-list{
|
||||||
|
padding: 20rpx;
|
||||||
|
|
||||||
|
.car-info{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
.car-info-l{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.car-info-c{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.car-info-r{
|
||||||
|
max-width: 20vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
201
utils/aa.js
201
utils/aa.js
@ -1,118 +1,127 @@
|
|||||||
import {
|
import {
|
||||||
httpApiTest,
|
HTTP_REQUEST_URL_THREE,
|
||||||
HEADER,
|
HEADER,
|
||||||
TOKENNAME,
|
TOKENNAME,
|
||||||
} from '@/config/app';
|
} from '@/config/app';
|
||||||
import {
|
import {
|
||||||
Toast
|
Toast
|
||||||
} from '../libs/uniApi';
|
} from '../libs/uniApi';
|
||||||
// import { checkLogin } from '../libs/login';
|
// import { checkLogin } from '../libs/login';
|
||||||
import store from '../store';
|
import store from '../store';
|
||||||
|
|
||||||
function toLogin() {
|
function toLogin() {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请先登录',
|
title: '请先登录',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 1000
|
duration: 1000
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function baseRequestTwo(url, method, data, {
|
function baseRequestTwo(url, method, data, {
|
||||||
noAuth = false,
|
noAuth = false,
|
||||||
noVerify = false
|
noVerify = false,
|
||||||
|
onReLogin = false
|
||||||
}) {
|
}) {
|
||||||
let Url = httpApiTest,
|
let Url = HTTP_REQUEST_URL_THREE,
|
||||||
header = HEADER;
|
header = HEADER;
|
||||||
if (!noAuth) {
|
if (!noAuth) {
|
||||||
// 已经未登录了,禁止请求
|
// 已经未登录了,禁止请求
|
||||||
if (!store.state.config.request) return Promise.reject({
|
if (!store.state.config.request) return Promise.reject({
|
||||||
msg: '未登录'
|
msg: '未登录'
|
||||||
});
|
});
|
||||||
//登录过期自动登录
|
//登录过期自动登录
|
||||||
if (!store.state.app.token) {
|
if (!store.state.app.token) {
|
||||||
toLogin();
|
toLogin();
|
||||||
store.commit("SET_REQUEST", false);
|
store.commit("SET_REQUEST", false);
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
msg: '未登录'
|
msg: '未登录'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
|
// if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
|
||||||
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
|
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
|
||||||
|
|
||||||
// header[TOKENNAME] = 'Bearer sdjflidshjgfkbdasgjmasbgvhauuiavhkesvndkaesbvkjsdbv';
|
// header[TOKENNAME] = 'Bearer sdjflidshjgfkbdasgjmasbgvhauuiavhkesvndkaesbvkjsdbv';
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
// uni.showLoading({
|
// uni.showLoading({
|
||||||
// title: '加载中'
|
// title: '加载中'
|
||||||
// })
|
// })
|
||||||
uni.request({
|
uni.request({
|
||||||
// url: Url + '/api/v1' + url,
|
// url: Url + '/api/v1' + url,
|
||||||
url: Url + url,
|
url: Url + url,
|
||||||
method: method || 'GET',
|
method: method || 'GET',
|
||||||
header: {
|
header: {
|
||||||
...header
|
...header
|
||||||
|
},
|
||||||
},
|
data: method != 'GET' ? data || {} : {},
|
||||||
data: method != 'GET' ? data || {} : {},
|
params: method == 'GET' ? data : {},
|
||||||
params: method == 'GET' ? data : {},
|
success: (res) => {
|
||||||
success: (res) => {
|
if (noVerify)
|
||||||
// uni.hideLoading()
|
reslove(res.data);
|
||||||
if (noVerify)
|
else if (res.data.code == -1) {
|
||||||
// reslove(res.data, res);
|
if(onReLogin) {
|
||||||
reslove(res.data);
|
store.commit('LOGOUT');
|
||||||
else if (res.data.code == -1) {
|
return reject();
|
||||||
store.commit("LOGOUT");
|
}
|
||||||
store.commit("SET_REQUEST", false);
|
// 如果登录超时,自动重新登录并且继续发送请求
|
||||||
reject(res.data);
|
store.dispatch("RE_LOGIN", {
|
||||||
} else if (res.data.code == 0) {
|
url: url,
|
||||||
// uni.hideLoading();
|
method: method,
|
||||||
if (res.data.show != 1 && res.data.msg != '无登录信息') {
|
data: data,
|
||||||
uni.showToast({
|
opt: {
|
||||||
title: res.data.msg || '请检查网络',
|
noAuth,
|
||||||
icon: 'none',
|
noVerify
|
||||||
})
|
}
|
||||||
}
|
}).then((e)=>{
|
||||||
reject(res.data);
|
reslove(e);
|
||||||
} else if (res.data.code == 1) {
|
}).catch((err)=>{
|
||||||
store.commit("SET_REQUEST");
|
reject(res.data);
|
||||||
reslove(res.data);
|
})
|
||||||
} else if (res.data.code == 200) {
|
// store.commit("SET_REQUEST", false);
|
||||||
store.commit("SET_REQUEST");
|
} else if (res.data.code == 0) {
|
||||||
reslove(res.data.data);
|
if (res.data.msg != '无登录信息') {
|
||||||
} else if ([410000, 410001, 410002, 40000].indexOf(res.data.code) !== -1) {
|
uni.showToast({
|
||||||
toLogin();
|
title: res.data.msg || '请检查网络',
|
||||||
reject(res.data);
|
icon: 'none',
|
||||||
} else if (res.data.code == 501) {
|
})
|
||||||
// uni.reLaunch({
|
}
|
||||||
// url: '/pages/error/index'
|
reject(res.data);
|
||||||
// })
|
} else if (res.data.code == 1) {
|
||||||
reject(res.data);
|
store.commit("SET_REQUEST");
|
||||||
} else {
|
reslove(res.data);
|
||||||
// uni.hideLoading();
|
} else if (res.data.code == 200) {
|
||||||
uni.showToast({
|
store.commit("SET_REQUEST");
|
||||||
title: res.data.msg || '请检查网络',
|
reslove(res.data.data);
|
||||||
icon: 'none'
|
} else if ([410000, 410001, 410002, 40000].indexOf(res.data.code) !== -1) {
|
||||||
})
|
toLogin();
|
||||||
reject(res.data.msg || '请检查网络');
|
reject(res.data);
|
||||||
}
|
} else if (res.data.code == 501) {
|
||||||
},
|
reject(res.data);
|
||||||
fail: (message) => {
|
} else {
|
||||||
// uni.hideLoading()
|
uni.showToast({
|
||||||
uni.showToast({
|
title: res.data.msg || '请检查网络',
|
||||||
title: '网络错误',
|
icon: 'none'
|
||||||
icon: 'none'
|
})
|
||||||
})
|
reject(res.data.msg || '请检查网络');
|
||||||
reject('请求失败');
|
}
|
||||||
}
|
},
|
||||||
})
|
fail: (message) => {
|
||||||
});
|
// uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
reject('请求失败');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const oahttp = {};
|
const oahttp = {};
|
||||||
|
|
||||||
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
|
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
|
||||||
oahttp[method] = (api, data, opt) => baseRequestTwo(api, method, data, opt || {})
|
oahttp[method] = (api, data, opt) => baseRequestTwo(api, method, data, opt || {})
|
||||||
});
|
});
|
||||||
|
|
||||||
export default oahttp;
|
export default oahttp;
|
Loading…
x
Reference in New Issue
Block a user