From e8f7eac1787e96934e2779401b78a46952c70067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89?= <814457906@qq.com> Date: Mon, 13 Nov 2023 14:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 9 - pages/homepage/homepage.vue | 334 ++++++++++++++---------------------- 2 files changed, 130 insertions(+), 213 deletions(-) diff --git a/pages.json b/pages.json index 7d44ebc..4ff551c 100644 --- a/pages.json +++ b/pages.json @@ -53,15 +53,6 @@ "enablePullDownRefresh": true //设置参数为true } }, - { - "path": "pages/quanyi/quanyi", - "style": { - // "navigationBarTitleText": "消息列表", - // "navigationStyle": "custom", - "onReachBottomDistance": 40, //距离底部多远时触发 单位为px - "enablePullDownRefresh": true //设置参数为true - } - }, { "path": "pages/taskDetails/taskDetails", "style": { diff --git a/pages/homepage/homepage.vue b/pages/homepage/homepage.vue index 247ca71..b764665 100644 --- a/pages/homepage/homepage.vue +++ b/pages/homepage/homepage.vue @@ -1,116 +1,32 @@ @@ -127,7 +43,8 @@ import { getSex } from '@/utils/conversion.js' - import protocol from '../quanyi/quanyi.vue' + import protocol from '@/pages/workorder/workorder.vue' + import socketurl from '@/api/socketurl.js' export default { components: { protocol, @@ -135,46 +52,26 @@ data() { return { Refresh: 1, - down: 2, + down: 1, tabslist: [{ - name: '全部工单', + name: '全部', value: '', }, { - name: '我的工单', - value: 'RECEIVED_GOODS', + name: '已解决', + value: '2', }, { - name: '已完成工单', - value: 'COMPLETED', + name: '未解决', + value: '1', }], tabscurrent: 0, optionindex: 0, optionname: '全部', - options: [{ - label: '全部', - value: '', - }, { - label: '待接单', - value: 'WAIT_RECEIVED_GOODS', - }, { - label: '待服务', - value: 'RECEIVED_GOODS', - }, { - label: '已完成', - value: 'COMPLETED', - }], - query: { - hospitalPersonId: uni.getStorageSync("id"), - orderStatus: '', - orderType: '', - pageNum: 1, - pageSize: 10, - }, missionlist: [], missiontotal: 0, remark: '', formdata: { pageNum: 1, - pageSize: 10, + pageSize: 1000, doctorId: uni.getStorageSync("id"), consultationType: 'IMAGE_TEXT_CONSULTATION', status: '', @@ -182,6 +79,11 @@ listinfo: [], listtotal: 0, status: '', + SOCKETURL: '', + socketOpen: false, + timeoutObj: null, + status: '', + title: '', } }, onReady() { //更改导航栏文字 @@ -189,20 +91,94 @@ title: this.title, }); }, - onShow() { + onLoad() { this.status = uni.getStorageSync("status") if (this.status == 2) { this.title = '工单' - this.info(); } else { this.title = '消息列表' + this.SOCKETURL = socketurl + uni.getStorageSync("id") + this.connectSocket(); + } + }, + onShow() { + this.down = 1 + this.Refresh = 1 + if (this.status == 1) { + this.info() + this.socket(); } }, methods: { + connectSocket() { + let that = this + console.log(that.SOCKETURL) + try { + uni.connectSocket({ + url: that.SOCKETURL + }) + uni.onSocketOpen(res => { + console.log('webScoket连接已打开', res); + that.socketOpen = true + that.reset() + }) + uni.onSocketError(err => { + console.log('webScoket连接打开失败', err); + if (err && err.code != 1000) { + setTimeout(() => { + that.socketOpen = true + uni.connectSocket({ + url: that.SOCKETURL + }) + }, 3 * 1000) + } + }) + uni.onSocketClose(err => { + console.log('webScoket连接关闭', err); + if (err && err.code !== 1000) { + setTimeout(() => { + that.socketOpen = true + uni.connectSocket({ + url: that.SOCKETURL + }) + }, 3 * 1000) + } + }) + } catch (e) { + console.log(e); + } + }, + socket() { + let that = this + uni.onSocketMessage(res => { + console.log("webScoket监听收到的信息", res); + that.info(); + }) + }, + reset() { + let that = this + clearInterval(that.timeoutObj); + that.timeoutObj = setInterval(() => { + uni.sendSocketMessage({ + data: 'ping', + success(res) { + console.log('正在发送心跳'); + }, + fail(err) { + console.log('心跳发送失败,重新连接...'); + that.socketOpen = true + uni.connectSocket({ + url: that.SOCKETURL + }) + } + }) + }, 180000) + }, //前往聊天 goseekadvicefrom(item) { uni.navigateTo({ url: `/pages/seekadvicefrom/seekadvicefrom?item=${JSON.stringify(item)}` + // url: '/pages/seekadvicefrom/seekadvicefrom' }) }, //详情 @@ -253,83 +229,55 @@ }, // 视频通话 govideo(item) { - getUserSig(item.doctorId).then(res => { - // 获取roomId - consultation(item.goodsOrderId).then(resp => { - if (resp.code == 200) { - uni.navigateTo({ - url: `/pages/Industrialbutler/video?roomId=${resp.msg}&userId=${item.doctorId}&userName=${item.doctorName}&userSig=${res.data}&remoteUserId=${item.patientId}` - }) - // var urlStr = encodeURI( - // `https://msg.xinyilu.cn​​​​​?userId=${item.doctorId}&userName=${item.doctorName}&userSig=${res.data}&roomId=${resp.msg}` - // ) - // console.log(urlStr) - // plus.runtime.openURL(urlStr, function(res) { - // console.log(res); - // }); - // this.src = - // `https://msg.xinyilu.cn​​​​​?userId=${this.userId}&userName=${this.userName}&userSig=${res.data}&roomId=${resp.msg}` - } else if (resp.code == 500) { - this.$refs.uToast.show({ - title: resp.msg, - type: 'error', - duration: '1500' - }) - } - }) + uni.navigateTo({ + url: `/pages/Industrialbutler/Industrialbutler?item=${JSON.stringify(item)}` }) }, info() { - this.query.pageNum = 1 - getList(this.query).then(res => { - res.rows.forEach(e => { - e.sex = getSex(e.cardNo) - }) - this.missionlist = res.rows - this.missiontotal = res.total + this.formdata.pageNum = 1 + consultationInfolist(this.formdata).then(res => { + this.listinfo = res.rows + this.listtotal = res.total }) - // consultationInfolist(this.formdata).then(res => { - // this.listinfo = res.rows - // this.listtotal = res.rows - // }) }, tabschange(index) { this.tabscurrent = index; - this.query.orderStatus = this.tabslist[index].value - this.optionname = '全部' + this.formdata.status = this.tabslist[index].value + // this.optionname = '全部' this.optionindex = 0 this.info(); }, - dropitemchange(e) { - this.optionname = this.options.find(m => m.value === e).label - this.query.orderStatus = this.options.find(m => m.value === e).value - this.info(); - }, + // dropitemchange(e) { + // this.optionname = this.options.find(m => m.value === e).label + // this.query.orderStatus = this.options.find(m => m.value === e).value + // this.info(); + // }, }, onReachBottom() { //下滑加载 - // if(this.status==2){ - if (this.missionlist.length >= this.missiontotal) {} else { - // this.down++ - this.query.pageNum++ - getList(this.query).then( - res => { + if (this.status == 1) { + if (this.listinfo.length >= this.listtotal) {} else { + this.formdata.pageNum++ + consultationInfolist(this.formdata).then(res => { res.rows.forEach(e => { - e.sex = getSex(e.cardNo) - this.missionlist.push(e) + this.listinfo.push(e) }) }) + } + } else { + this.down++ } - // } }, onPullDownRefresh() { //下拉刷新 - if (this.status == 2) { + if (this.status == 1) { this.info(); } else { this.Refresh++ + this.down = 1 } setTimeout(function() { uni.stopPullDownRefresh(); }, 1000); + }, } @@ -346,28 +294,6 @@ background-color: #fff; font-size: 24rpx; - .titlelist { - font-size: 20px; - text-align: center; - height: 80rpx; - border-bottom: 1rpx solid #f6f6f6; - padding-top: 100rpx; - position: fixed; - width: 100%; - background: #18CBB3; - z-index: 10; - color: #fff; - - image { - width: 20rpx; - height: 30rpx; - transform: rotate(180deg); - position: absolute; - left: 40rpx; - bottom: 38rpx; - } - } - .lists { width: 96%; margin: 0 auto;