From 0c6cbb7be982b4f8ff5b553b1c49f3e9e1f8a25d Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Sat, 9 Nov 2024 11:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/staffTabBer/tabBar.vue | 51 ++++++++++++++++++++++++++++--- main.js | 25 +++++++++++++++ pages/Login/login.vue | 3 +- pages/index/selectProject.vue | 24 ++++++++++----- pages/staff/staff.vue | 37 ++++++++++++++++++---- 5 files changed, 120 insertions(+), 20 deletions(-) diff --git a/components/staffTabBer/tabBar.vue b/components/staffTabBer/tabBar.vue index 227ca13..839f21f 100644 --- a/components/staffTabBer/tabBar.vue +++ b/components/staffTabBer/tabBar.vue @@ -23,10 +23,12 @@ </template> <script> + const innerAudioContext = uni.createInnerAudioContext(); import request from '../../utils/request'; export default{ data(){ return{ + msgSocket: this.$msgSocket, aindex:1, arr:[ {text:'首页'}, @@ -42,16 +44,56 @@ onLoad() { this.aindex = this.msg }, - // onShow() { - // this.aindex = this.msg - // }, mounted() { console.log(this.aindex); this.aindex = this.msg }, + watch: { + msgSocket(newVal, oldVal) { + console.log('msgSocket值发生变化', newVal, oldVal) + this.msgInfo() + }, + deep: true, + }, methods:{ + dianyidain() { + console.log('执行了,dianyidain'); + innerAudioContext.src = 'https://www.nuoyunr.com/lananRsc/rescue/msgV.mp3'; + // 设置播放次数和计数器 + const playCount = 3; + let currentCount = 0; + + // 监听音频播放结束事件 + innerAudioContext.onEnded(() => { + // 播放计数加一 + currentCount++; + + // 判断是否达到播放次数上限 + if (currentCount < playCount) { + // 继续播放 + innerAudioContext.play(); + } else { + // 播放完成,可以在这里添加额外的逻辑 + console.log('播放完成'); + } + }); + + // 初次播放 + innerAudioContext.play(); + }, + msgInfo() { + console.log(this.msgSocket, 'msgSocket') + if (this.msgSocket) { + console.log('消息回调启动成功') + this.msgSocket.onMessage(res => { + console.log("发出提示音"); + + this.dianyidain() + }) + } + + }, getgogo(index){ - if(index == 1){ this.aindex = index uni.reLaunch({ @@ -59,7 +101,6 @@ }); } - if(index == 3){ this.aindex = index uni.reLaunch({ diff --git a/main.js b/main.js index 908e974..c7d898e 100644 --- a/main.js +++ b/main.js @@ -5,8 +5,33 @@ const baseUrl = config.baseUrl Vue.prototype.$baseUrl = baseUrl; const baseImageUrl = config.baseImageUrl Vue.prototype.$baseImageUrl = baseImageUrl; +const wsUrl = config.wsUrl +Vue.prototype.$wsUrl = wsUrl; Vue.use(uView) +import { + connect, + sendSocketMessage, + closeSocket +} from './utils/orderSocket.js' +let SocketTask; +let timerId; +export function startSocketConnect(userId) { + SocketTask = null + SocketTask = connect(userId); + if (!timerId && uni.getStorageSync('userId')) { + timerId = setInterval(() => { + sendSocketMessage(SocketTask) + }, 10000); + } +} +export function closeSocketMain(userId) { + clearInterval(timerId) + closeSocket(SocketTask); +} +Vue.prototype.$startSocketConnect = startSocketConnect +Vue.prototype.$closeSocketMain = closeSocketMain +Vue.prototype.$msgSocket = SocketTask Vue.prototype.$imgeUrl = 'http://www.nuoyunr.com/lananRsc'; // #ifndef VUE3 diff --git a/pages/Login/login.vue b/pages/Login/login.vue index 8f235e5..46f65a8 100644 --- a/pages/Login/login.vue +++ b/pages/Login/login.vue @@ -216,12 +216,13 @@ method: 'get', }).then((res)=>{ - console.log(res,219219); if(res.code == 200){ uni.setStorageSync('staffinfo',res.data.user) uni.setStorageSync('partnerId',res.data.partnerId) uni.setStorageSync('roleSelect','worker') + uni.setStorageSync('userId',res.data.user.id) uni.hideLoading(); + this.$startSocketConnect() uni.redirectTo({ url:'/pages/staff/staff' }) diff --git a/pages/index/selectProject.vue b/pages/index/selectProject.vue index c13d405..2bd6e3a 100644 --- a/pages/index/selectProject.vue +++ b/pages/index/selectProject.vue @@ -102,6 +102,14 @@ export default { </script> <style scoped> + ::v-deep .step-style{ + .u-steps-item__content{ + .u-text__value { + font-size:80rpx !important; + line-height: 90rpx !important; + } + } + } .cont_box { box-sizing: border-box; padding: 10px; @@ -124,11 +132,11 @@ export default { display: flex; align-items: center; justify-content: center; - font-size: 14px; + font-size: 18px; box-sizing: border-box; - padding: 5px 10px; - margin-right: 5px; - margin-bottom: 5px; + padding: 10px 15px; + margin-right: 15px; + margin-bottom: 15px; background: #0D2E8D; color: #fff; } @@ -139,11 +147,11 @@ export default { display: flex; align-items: center; justify-content: center; - font-size: 14px; + font-size: 18px; box-sizing: border-box; - padding: 5px 10px; - margin-right: 5px; - margin-bottom: 5px; + padding: 10px 15px; + margin-right: 15px; + margin-bottom: 15px; } .dlanniu { diff --git a/pages/staff/staff.vue b/pages/staff/staff.vue index c78010e..353bcd3 100644 --- a/pages/staff/staff.vue +++ b/pages/staff/staff.vue @@ -94,6 +94,7 @@ import tabBar from '../../components/staffTabBer/tabBar.vue' export default { data() { return { + msgSocket: this.$msgSocket, imgurl: this.$imgeUrl, baseUrl: this.$baseUrl, infoDatas: {}, @@ -123,11 +124,17 @@ export default { } }, onLoad() { - // this.getList() }, onShow() { this.getList() }, + watch: { + msgSocket(newVal, oldVal) { + console.log('msgSocket值发生变化', newVal, oldVal) + this.msgInfo() + }, + deep: true, + }, onReachBottom() { console.log(111) if (this.pageNum >= this.totalPages) { @@ -146,6 +153,19 @@ export default { tabBar, }, methods: { + msgInfo() { + console.log(this.msgSocket, 'msgSocket') + if (this.msgSocket) { + console.log('消息回调启动成功') + this.msgSocket.onMessage(res => { + console.log("刷新订单列表"); + this.pageNum = 1 + this.totalPages =0 + this.getList() + }) + } + + }, callUser(phone) { console.log(phone) uni.makePhoneCall({ @@ -385,7 +405,7 @@ export default { display: flex; justify-content: center; align-items: center; - padding: 20px; + } .button-container { @@ -395,10 +415,15 @@ export default { } .button { - flex: 0.5; /* 减小按钮的占比 */ - margin: 0 5px; /* 缩小两侧间距 */ - padding: 5px 10px; /* 缩小按钮内边距 */ - font-size: 0.9rem; /* 缩小字体 */ + width: 80%; + height: 45px; + background: linear-gradient(180deg, #3F61C0 0%, #0D2E8D 100%); + border-radius: 50px; + display: flex; + align-items: center; + justify-content: center; + + color: white; }