This commit is contained in:
THK3121 2023-10-09 20:22:16 +08:00
parent c10460b9b6
commit be0045b4b0
11 changed files with 703 additions and 783 deletions

16
App.vue
View File

@ -64,13 +64,23 @@
}
},
onShow: function() {
const audioContext = uni.createInnerAudioContext()
//
audioContext.src = '/static/mp3/order.mp3'
jpushModule.initJPushService()
// const audioContext = uni.createInnerAudioContext()
// //
// audioContext.src = '/static/mp3/order.mp3'
//
//#ifdef APP-PLUS
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
audioContext.src = '/static/mp3/order.mp3'
audioContext.play()
uni.vibrateLong();
console.log("app的监听")

View File

@ -3,8 +3,8 @@ let httpApi; // 总域名
let httpApiTwo; // 物流系统域名
let httpApiTest
const env = 'dev'; // 开发
// const env = 'prod'; // 生产
// const env = 'dev'; // 开发
const env = 'prod'; // 生产
// const env = 'prew'; // 预上线
switch (env) {
@ -22,7 +22,7 @@ switch (env) {
httpApi = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiThree = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiTwo = 'https://ceshi-logistics.lihaink.cn' //测试环境
httpApiTest = 'http://192.168.1.9:8081' //测试环境
httpApiTest = 'http://192.168.1.13:8081' //测试环境
}

View File

@ -31,10 +31,8 @@
"navigationBarTitleText": "商机信息",
"navigationBarBackgroundColor": "#0122C7",
"navigationBarTextStyle": "white",
"app-plus": {
//
"softinputMode": "adjustResize"
}
"enablePullDownRefresh": true
}
},
@ -277,6 +275,16 @@
"navigationBarTextStyle": "white"
}
},{
"path": "chatMang/index",
"style": {
"navigationBarTitleText": "聊天",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#0122C7",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": true
}
}, {
"path": "topUp/topUp",
"style": {
@ -593,6 +601,15 @@
"navigationBarTextStyle": "white"
}
}, {
"path": "property/buyCar",
"style": {
"navigationBarTitleText": "车辆购买",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#0122C7",
"navigationBarTextStyle": "white"
}
}, {
"path": "property/success",
"style": {

View File

@ -1,14 +1,16 @@
<template>
<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="">
<u-loadmore :status="status"
:loadmore-text="`你正在与${'wo'}聊天`"
/>
:loadmore-text="`你正在与${manager_nmae}聊天`" />
</view>
<!-- -->
<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 class="task-li-r">
@ -21,7 +23,7 @@
</view>
<!-- 图片 -->
<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>
</view>
<!-- 视频 -->
@ -32,9 +34,7 @@
<view class="yl-text">
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
</view>
</view>
<view class="send-time">
{{item.sendTime}}
@ -42,7 +42,6 @@
</view>
<!-- 我的消息 -->
<view class="task-li-l" v-else>
<!-- 文字 -->
<view class="task-li-content" @longpress="copyText(item.content)" v-if="item.type=='text'"
style="margin-right: 10rpx;">
@ -50,7 +49,7 @@
</view>
<!-- 图片 -->
<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>
</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>
<view class="yl-text">
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
</view>
<view class="">
@ -68,36 +66,32 @@
</view>
</view>
<!-- 本地 -->
<view v-if="local">
<view class="localTask" v-if="localType=='video'">
<view v-show="item.status" v-for="(item,index) in local">
<view class="localTask" v-if="item.localType=='video'">
<view class="task-li-content" style="margin-right: 10rpx;">
<video :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
<video :src="item.localSrc" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
<!-- <image :src="" style="width:200rpx" mode="widthFix"></image> -->
<u-loadmore status="loading" loading-text="努力上传中" />
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
<view class="localTask" v-if="localType=='image'">
<view class="localTask" v-if="item.localType=='image'">
<view class="task-li-content" style="margin-right: 10rpx;">
<!-- <image :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></image> -->
<image :src="local" style="width:200rpx" mode="widthFix"></image>
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
<image :src="item.localSrc" style="width:200rpx" mode="widthFix"></image>
<u-loadmore status="loading" loading-text="努力上传中" />
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</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 style="height: 150rpx;background-color: #F6F7FD;" v-else>
</view>
</view>
<!-- 底部 -->
@ -123,29 +117,20 @@
<view class="plus_li">
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
@click="choseVideoFn"></u--image>
<text>视频</text>
</view>
</view>
</view>
<!-- 遮罩图 -->
<u-overlay :show="show" @click="show = false">
<view class="warp">
<view class="rect" @tap.stop @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'">
<video :src="overLaySrc"></video>
<video :src="overLaySrc" controls :autoplay="true"></video>
</view>
</view>
</u-overlay>
</view>
</template>
<script>
import {
sendMsgApi,getMsgListApi,bindScoket,sendFileApi,getAreaManagerApi
@ -153,33 +138,81 @@
export default {
data() {
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",
list: [],
bind:false,
value: "",
showPlus: false,
num: 0,
flags: true,
scollNum: 0,
scollNum: 50000,
client_id: "",
fromId: "",
toId:"",
name: "",
status: "loadmore",
page: 1,
page_no: 1,
limit: 10,
formUser: "",
show: false,
overLaySrc: "",
overLayType: "",
local: "",
local: [],
localType: "",
progress: "",
sendData:{}
imageList:[],
sendData:{},
manager_nmae:"",
msg_id:"",
aaa:false,
}
},
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; // 01
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){
uni.showToast({
title: msg,
@ -196,7 +229,7 @@
});
},
fail() {
toast('保存失败')
this.toast('保存失败')
}
});
},
@ -218,60 +251,61 @@
this.overLayType = type
},
getListFn() {
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() {
return
this.scollNum += 1000
let that=this
this.scollNum+=100
setTimeout(() => {
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,//
   
uni.pageScrollTo({  
 scrollTop: that.scollNum,//
success:function(){
console.log('成功了', that.scollNum)
console.log('滚动')
}
  })
}, 100)
},
sendFn() {
let that=this
if (!this.value) {
this.toast("消息不能为空")
return
if (!this.value) return
this.num++
this.flags = !this.flags
}
let data = {
from_user_id: this.fromId,
to_user_id:this.toId,
type: "text",
content: this.value,
scene:0,
create_time:(Date.now()/1000),
msg_id:this.msg_id
}
sendMsgApi({
...data
}).then(res => {
console.log(data)
this.list.push(data)
this.scrollFn(100)
this.value = ""
this.generateRandId()
}).catch(err => {
toast('发送失败')
this.toast('发送失败')
this.generateRandId()
})
},
showPlusFn() {
@ -279,45 +313,58 @@
},
choseImgFn() {
this.generateRandId()
let time = Date.now()
let that = this
uni.chooseImage({
count: 1, //
success: res => {
const tempFilePath = res.tempFilePaths[0];
that.local = tempFilePath
that.localType = 'image'
that.local.push({
localType:'image',
localSrc:tempFilePath,
status:true,
msg_id:that.msg_id
})
that.showPlus = false
const uploadTask = uni.uploadFile({
url: "http://192.168.1.9:8081/common/im/sendFileMsg",
that.scrollFn()
console.log(that.local)
uni.uploadFile({
url: "https://worker-task.lihaink.cn/common/im/sendFileMsg",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("TOKEN")
},
formData: {
...this.sendData,
from_user_id:that.fromId,
to_user_id:that.toId,
scene:0,
msg_id:that.msg_id,
type:'image'
},
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) {
toast('上传失败')
this.toast('上传失败')
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
});
},
fail: err => {
toast('操作取消')
this.toast('操作取消')
}
});
},
choseVideoFn() {
this.generateRandId()
let that = this
uni.chooseVideo({
sourceType: ['album', 'camera'], //
@ -325,90 +372,99 @@
camera: 'back', //
success: res => {
const tempFilePath = res.tempFilePath;
that.local = res.tempFilePath
that.localType = 'video'
that.showPlus = false
that.local.push({
localType:'video',
localSrc:tempFilePath,
status:true,
msg_id:that.msg_id
})
const uploadTask = uni.uploadFile({
url: "http://192.168.1.9:8081/common/im/sendFileMsg",
that.showPlus = false
that.scrollFn()
uni.uploadFile({
url: "https://worker-task.lihaink.cn/common/im/sendFileMsg",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("token")
},
formData: {
...this.sendData,
from_user_id:that.fromId,
to_user_id:that.toId,
scene:0,
msg_id:that.msg_id,
type:'video'
}, //
success: function(uploadRes) {
that.local = ""
that.list.push(JSON.parse(uploadRes.data).data)
success: function(uploadRes) {
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) {
console.log(error)
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
that.local = false
// that.local = false
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
console.log('上传进度', res.progress);
});
},
fail: err => {
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
// uni.showToast({
// title: '60s',
// duration: 2000,
// icon: 'none'
// });
}
});
},
},
onShow() {
return
this.page_no=1
this.generateRandId()
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={
this.manager_nmae=res.data.manager_name
getMsgListApi({
from_user_id:this.fromId,
to_user_id:this.toId,
scene:0,
}
getMsgListApi({
...this.sendData,
page_no:1,
page_size:10
}).then(res=>{
this.showLoading=false
this.list=res.data.reverse()
this.scrollFn()
})
})
},
// async onPullDownRefresh() {
// this.status = "loading"
// this.page++
// await this.getListFn()
// // console.log("")
// uni.stopPullDownRefresh();
async onPullDownRefresh() {
let that=this
this.status = "loading"
this.page_no++
await this.getListFn()
this.status = "loadmore"
// },
},
onLoad() {
return
let user=JSON.parse(uni.getStorageSync('USER_INFO'))
this.a=user.avatar
console.log(user.avatar)
uni.connectSocket({
url: 'ws://192.168.1.9:8282'
url: 'wss://worker-task.lihaink.cn/wss'
});
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开');
@ -435,12 +491,13 @@
else if(data.type!='ping') {
console.log(data)
that.list.push(data)
that.scrollFn()
}
});
this.generateRandId()
},
@ -465,12 +522,9 @@
.content {
padding: 0 20rpx;
// min-height: 100vh;
min-height: 95vh;
background-color: #F6F7FD;
padding-top: 10rpx;
// padding-bottom: 50px;
.task-li {
margin-bottom: 20rpx;
}
@ -498,8 +552,6 @@
.bottom {
background-color: white;
// height: 8vh;
// padding: 20rpx;
padding: 20rpx 0;
position: fixed;
box-sizing: border-box;

View File

@ -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>

View File

@ -110,6 +110,25 @@
</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="task_title flex_a_c_j_sb">
<view class="title">工作管理</view>
@ -215,6 +234,9 @@ import {
import {
noticeList
} from "@/api/notice.js";
import {
getAreaManagerApi
} from "@/api/bussness.js"
// import tabbar from '../components/tabbar'
import {
getIndexListAPI,
@ -241,6 +263,7 @@ export default {
},
data () {
return {
brange:0,
options: {
data: '',
},
@ -248,6 +271,7 @@ export default {
page_num: 1,
flag: false,
uniMP: false,
managerInfo:{},
id: "",
is_captain: 0,
notArr: [],
@ -292,11 +316,16 @@ export default {
await this.$onLaunched;
this.is_captain = JSON.parse(uni.getStorageSync("USER_INFO")||'{}')?.is_captain
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
let that = this;
jpushModule.addNotificationListener(function (result) {
if (!that.notArr.includes(result.messageID)) {
that.$refs.globalPopup.showPopu();
// that.$refs.globalPopup.showPopu();
that.getOrderList();
console.log("idnex的");
that.notArr.push(result.messageID);
@ -408,14 +437,21 @@ export default {
methods: {
//
noticeFn () {
const audioContext = uni.createInnerAudioContext()
audioContext.src = '/static/mp3/order.mp3'
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
audioContext.src = '/static/mp3/order.mp3'
audioContext.play()
uni.vibrateLong();
this.getOrderList()
this.$refs.globalPopup.showPopu();
// this.$refs.globalPopup.showPopu();
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>

BIN
static/mp3/im.mp3 Normal file

Binary file not shown.

BIN
static/mp3/im.wav Normal file

Binary file not shown.

View File

@ -1,29 +1,21 @@
<template>
<view style="background-color: #F6F7FD;">
<!-- <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> -->
<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="">
<u-loadmore :status="status" />
<u-loadmore :status="status"
:loadmore-text="`你正在与${manager_nmae}聊天`" />
</view>
<!-- -->
<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="" style="margin-right: 10rpx;">
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
<u--image :showLoading="true" :src="item.from_user_avatar" shape="circle" width="40px" height="40px"></u--image>
</view>
<view @longpress="copyText(item.content)" class="task-li-content" v-if="item.type=='text'"
style="margin-right: 10rpx;">
@ -31,31 +23,25 @@
</view>
<!-- 图片 -->
<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>
</view>
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;"
@tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true" :src="a" width="100px" height="80px"></u--image>
<u--image :showLoading="true" :src=" item.content+'?x-oss-process=video\/snapshot,t_1000,m_fast,w_800,f_png' " width="100px" height="80px"></u--image>
<view class="yl-text">
点击预览
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
<!-- <video :src="item.content" @loadedmetadata="onVideoLoaded" controls id="vi1"
style="width: 400rpx; height: 100px;"></video> -->
<!-- <image src="item.content" style="width:200rpx" mode="widthFix"></image> -->
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
</view>
</view>
<view class="send-time">
{{item.sendTime}}
</view>
</view>
<!-- 我的消息 -->
<view class="task-li-l" v-else="true">
<view class="task-li-l" v-else>
<!-- 文字 -->
<view class="task-li-content" @longpress="copyText(item.content)" v-if="item.type=='text'"
style="margin-right: 10rpx;">
@ -63,54 +49,49 @@
</view>
<!-- 图片 -->
<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>
</view>
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;" @tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true" src="/static/YL1.png" width="100px" height="80px"></u--image>
<u--image :showLoading="true" :src=" item.content+'?x-oss-process=video\/snapshot,t_1000,m_fast,w_800,f_png' " width="100px" height="80px"></u--image>
<view class="yl-text">
点击预览
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
</view>
<view class="">
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
</view>
</view>
</view>
<!-- 本地 -->
<view v-if="local">
<view class="localTask" v-if="localType=='video'">
<view v-show="item.status" v-for="(item,index) in local">
<view class="localTask" v-if="item.localType=='video'">
<view class="task-li-content" style="margin-right: 10rpx;">
<video :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
<video :src="item.localSrc" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
<!-- <image :src="" style="width:200rpx" mode="widthFix"></image> -->
<u-loadmore status="loading" loading-text="努力上传中" />
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
<view class="localTask" v-if="localType=='image'">
<view class="localTask" v-if="item.localType=='image'">
<view class="task-li-content" style="margin-right: 10rpx;">
<!-- <image :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></image> -->
<image :src="local" style="width:200rpx" mode="widthFix"></image>
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
<image :src="item.localSrc" style="width:200rpx" mode="widthFix"></image>
<u-loadmore status="loading" loading-text="努力上传中" />
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
</view>
<view style="height: 50px;background-color: #F6F7FD;">
<view style="height: 300rpx;background-color: #F6F7FD;" v-if="showPlus">
</view>
<view style="height: 150rpx;background-color: #F6F7FD;" v-else>
</view>
</view>
<!-- 底部 -->
@ -118,7 +99,7 @@
<view class="bottom">
<!-- -->
<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">
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" width="32px" height="32px"
@ -136,74 +117,80 @@
<view class="plus_li">
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
@click="choseVideoFn"></u--image>
<text>视频</text>
</view>
<!-- asdas -->
</view>
</view>
<!-- 遮罩图 -->
<u-overlay :show="show" @click="show = false">
<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'">
<video :src="overLaySrc"></video>
<video :src="overLaySrc" controls :autoplay="true"></video>
</view>
</view>
</u-overlay>
</view>
</template>
<script>
import {
sendMsgApi
sendMsgApi,getMsgListApi,bindScoket,sendFileApi,getAreaManagerApi
} from "@/api/bussness.js"
export default {
data() {
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",
list: [
],
list: [],
bind:false,
value: "",
showPlus: false,
num: 0,
flags: true,
scollNum: 999999999999,
scollNum: 500000000000,
client_id: "",
formId: "",
fromId: "",
toId:"",
name: "",
status: "lodemore",
page: 1,
status: "loadmore",
page_no: 1,
limit: 10,
formUser: "",
show: false,
overLaySrc: "",
overLayType: "",
canvasContext: null,
timer: "",
local: "",
local: [],
localType: "",
progress: "",
showNotice: false
imageList:[],
sendData:{},
manager_nmae:"",
msg_id:"",
aaa:false,
}
},
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) {
// 1695722299000
time=time*1000
const currentDate = new Date(); //
const targetDate = new Date(1695722299000);
const targetDate = new Date(time);
if (this.isSameDay(currentDate, targetDate)) {
const hours = targetDate.getHours(); //
const minutes = targetDate.getMinutes(); //
return hours + ':' + minutes;
return hours + ':' + (minutes>=10?minutes:'0'+minutes);
} else if (this.isYesterday(currentDate, targetDate)) {
return '昨天';
@ -220,11 +207,18 @@
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){
uni.showToast({
title: msg,
icon: 'none'
});
},
saveImage(src) {
uni.saveImageToPhotosAlbum({
filePath: src,
@ -235,10 +229,7 @@
});
},
fail() {
uni.showToast({
title: '保存失败',
icon: 'none'
});
this.toast('保存失败')
}
});
},
@ -254,192 +245,127 @@
}
});
},
backFn() {
uni.navigateBack()
},
showOverLayFn(src, type) {
this.show = true
this.overLaySrc = src
this.overLayType = type
},
getListFn() {
return
request("POST", "enterprise/im/getMessageList", {
limit: this.limit,
page: this.page,
toContactId: this.formId,
}).then(res => {
if (res.data.data.length == 0) {
this.status = "nomore"
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.unshift(...res.data.data)
this.status = "loadmore"
}).catch(err => {
console.log(err, "获取消息列表失败")
this.list=res.data.reverse().concat(this.list )
uni.stopPullDownRefresh();
})
},
scrollFn(time) {
this.scollNum += 500
scrollFn() {
let that=this
this.scollNum+=100
setTimeout(() => {
uni.pageScrollTo({
scrollTop: this.scollNum,
});
}, time ? time : 100)
uni.pageScrollTo({  
 scrollTop: that.scollNum,//
success:function(){
console.log('滚动')
}
  })
}, 100)
},
generateRandId() {
var d = new Date().getTime();
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == "x" ? r : r & 0x3 | 0x8).toString(16);
});
return uuid;
},
sendFn() {
if (!this.value) return
this.num++
this.flags = !this.flags
let that=this
if (!this.value) {
this.toast("消息不能为空")
return
}
let data = {
to_user_id: "2",
from_user_id: this.fromId,
to_user_id:this.toId,
type: "text",
content: this.value,
msg_id: this.generateRandId(),
to_user_name: "sdas",
to_user_avatar: "https://ceshi-worker-task.lihaink.cn/uploads/images/20230926/20230926185925e41de3046.png",
scene:0,
create_time:(Date.now()/1000),
msg_id:this.msg_id
}
sendMsgApi({
...data
}).then(res => {
this.list.push(data)
console.log(data)
}).catch(err => {
console.log(err, "发送消息失败")
})
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.list.push(data)
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))
// })
this.value = ""
this.generateRandId()
}).catch(err => {
this.toast('发送失败')
this.generateRandId()
})
},
showPlusFn() {
this.showPlus = !this.showPlus
this.scrollFn(200)
this.scrollFn()
},
choseImgFn() {
this.login()
this.generateRandId()
let time = Date.now()
let that = this
// https://im.raingad.com/common/upload/uploadFile
uni.chooseImage({
count: 1, //
success: res => {
const tempFilePath = res.tempFilePaths[0];
const file = res.tempFiles[0]
console.log(file)
that.local = tempFilePath
that.localType = 'image'
that.local.push({
localType:'image',
localSrc:tempFilePath,
status:true,
msg_id:that.msg_id
})
that.showPlus = false
that.scrollFn(200)
const uploadTask = uni.uploadFile({
url: "http://192.168.112:8081/apiim/upload",
that.scrollFn()
console.log(that.local)
uni.uploadFile({
url: "https://worker-task.lihaink.cn/common/im/sendFileMsg",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("TOKEN")
},
formData: {
// message: JSON.stringify({
// "id": this.generateRandId(),
// "sendTime": Date.now(),
// "status": "going",
// "type": "image",
// // "content": "blob:https://im.raingad.com/e2ffd725-a9e7-4a01-b7da-83fd64af97a4",
// "content": `blob:${tempFilePath}`,
// "is_read": 0,
// "is_group": 0,
// "file_id": 0,
// "file_cate": 0,
// "fileName": file.name,
// "fileSize": file.size,
// "extends": null,
// "fromUser": {
// ...this.fromUser
// },
// from_user: this.fromUser.id,
// toContactId: this.formId,
// })
to_user_id: "2",
type: "image",
msg_id: this.generateRandId(),
}, //
from_user_id:that.fromId,
to_user_id:that.toId,
scene:0,
msg_id:that.msg_id,
type:'image'
},
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) {
console.log('上传失败', error);
//
this.toast('上传失败')
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
console.log('上传进度', res.progress);
});
},
fail: err => {
console.log(err, "没有选择图片");
this.toast('操作取消')
}
});
},
choseVideoFn() {
this.generateRandId()
let that = this
uni.chooseVideo({
sourceType: ['album', 'camera'], //
@ -447,144 +373,149 @@
camera: 'back', //
success: res => {
const tempFilePath = res.tempFilePath;
that.local = res.tempFilePath
that.localType = 'video'
that.local.push({
localType:'video',
localSrc:tempFilePath,
status:true,
msg_id:that.msg_id
})
that.showPlus = false
that.scrollFn(200)
const uploadTask = uni.uploadFile({
url: "https://ceshi-im.lihaink.cn/common/upload/uploadFile",
that.scrollFn()
uni.uploadFile({
url: "https://worker-task.lihaink.cn/common/im/sendFileMsg",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("token")
},
formData: {
message: JSON.stringify({
"id": this.generateRandId(),
"sendTime": Date.now(),
"status": "going",
"type": "image",
// "content": "blob:https://im.raingad.com/e2ffd725-a9e7-4a01-b7da-83fd64af97a4",
"content": `blob:${tempFilePath}`,
"is_read": 0,
"is_group": 0,
"file_id": 0,
"file_cate": 0,
"fileName": "20210719150601_4401e.jpg",
"fileSize": 72046,
"extends": null,
"fromUser": {
...this.fromUser
},
from_user: this.fromUser.id,
toContactId: this.formId,
})
from_user_id:that.fromId,
to_user_id:that.toId,
scene:0,
msg_id:that.msg_id,
type:'video'
}, //
success: function(uploadRes) {
that.local = ""
that.list.push(JSON.parse(uploadRes.data).data)
success: function(uploadRes) {
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) {
console.log(error)
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
that.local = false
// that.local = false
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
console.log('上传进度', res.progress);
});
},
fail: err => {
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
// uni.showToast({
// title: '60s',
// duration: 2000,
// icon: 'none'
// });
}
});
},
},
onShow() {
return
let that = this
this.scrollFn(500)
this.timer = setInterval(() => {
request("POST", "enterprise/im/getMessageList", {
limit: 1,
page: 1,
toContactId: this.formId,
}).then(res => {
this.page_no=1
this.generateRandId()
this.fromId= JSON.parse( uni.getStorageSync("USER_INFO")).id
if (res.data.data[0]?.id != this.list[this.list.length - 1]?.id) {
this.list.push(res.data.data[0])
if (res.data.data[0].type == 'video' || res.data.data[0].type == 'image') {
this.local = ""
}
// console.log(res.data.data)
}
// this.list.unshift(...res.data.data)
// this.status = "loadmore"
getAreaManagerApi({user_id:this.fromId}).then(res=>{
this.toId=res.data.to_user_id
this.manager_nmae=res.data.manager_name
getMsgListApi({
from_user_id:this.fromId,
to_user_id:this.toId,
scene:0,
page_no:1,
page_size:10
}).then(res=>{
this.showLoading=false
this.list=res.data.reverse()
this.scrollFn()
})
})
}, 3000)
},
async onPullDownRefresh() {
let that=this
this.status = "loading"
this.page++
this.page_no++
await this.getListFn()
// console.log("")
uni.stopPullDownRefresh();
this.status = "loadmore"
},
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) {
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>
<style lang="scss">
.yl-text {
position: absolute;
color: black;
top: 60%;
color: white;
top: 50%;
left: 50%;
transform: translateX(-50%);
transform: translate(-50%,-50%);
font-size: 24rpx;
}
// .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 {
height: 80rpx;
background-color: #F6F7FD;
@ -592,13 +523,9 @@
.content {
padding: 0 20rpx;
// min-height: 100vh;
height: 89vh;
min-height: 95vh;
background-color: #F6F7FD;
overflow: auto;
padding-top: 10rpx;
// padding-bottom: 50px;
.task-li {
margin-bottom: 20rpx;
}
@ -616,7 +543,7 @@
background-color: white;
padding: 20rpx;
border-radius: 20rpx;
color: white;
// color: white;
word-break: break-all;
max-width: 60vw;
@ -626,13 +553,14 @@
.bottom {
background-color: white;
// height: 8vh;
// padding: 20rpx;
padding: 20rpx 0;
position: fixed;
box-sizing: border-box;
bottom: 0px;
padding-bottom: 10px;
/* #ifndef APP-PLUS */
// bottom: 40px;
/* #endif */
.send-col {
display: flex;

View 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>

View File

@ -1,5 +1,5 @@
import {
httpApiTest,
HTTP_REQUEST_URL_THREE,
HEADER,
TOKENNAME,
} from '@/config/app';
@ -19,9 +19,10 @@ function toLogin() {
function baseRequestTwo(url, method, data, {
noAuth = false,
noVerify = false
noVerify = false,
onReLogin = false
}) {
let Url = httpApiTest,
let Url = HTTP_REQUEST_URL_THREE,
header = HEADER;
if (!noAuth) {
// 已经未登录了,禁止请求
@ -52,22 +53,34 @@ function baseRequestTwo(url, method, data, {
method: method || 'GET',
header: {
...header
},
data: method != 'GET' ? data || {} : {},
params: method == 'GET' ? data : {},
success: (res) => {
// uni.hideLoading()
if (noVerify)
// reslove(res.data, res);
reslove(res.data);
else if (res.data.code == -1) {
store.commit("LOGOUT");
store.commit("SET_REQUEST", false);
if(onReLogin) {
store.commit('LOGOUT');
return reject();
}
// 如果登录超时,自动重新登录并且继续发送请求
store.dispatch("RE_LOGIN", {
url: url,
method: method,
data: data,
opt: {
noAuth,
noVerify
}
}).then((e)=>{
reslove(e);
}).catch((err)=>{
reject(res.data);
})
// store.commit("SET_REQUEST", false);
} else if (res.data.code == 0) {
// uni.hideLoading();
if (res.data.show != 1 && res.data.msg != '无登录信息') {
if (res.data.msg != '无登录信息') {
uni.showToast({
title: res.data.msg || '请检查网络',
icon: 'none',
@ -84,12 +97,8 @@ function baseRequestTwo(url, method, data, {
toLogin();
reject(res.data);
} else if (res.data.code == 501) {
// uni.reLaunch({
// url: '/pages/error/index'
// })
reject(res.data);
} else {
// uni.hideLoading();
uni.showToast({
title: res.data.msg || '请检查网络',
icon: 'none'