This commit is contained in:
Vinjor 2024-11-13 10:34:57 +08:00
parent 1f1c515f4f
commit 84e8529386
5 changed files with 173 additions and 21 deletions

View File

@ -44,16 +44,6 @@
identity: 'user', identity: 'user',
nowPageInterval: null, nowPageInterval: null,
userInfo:{}, userInfo:{},
arr: [{
text: '首页'
},
{
text: '消息'
},
{
text: '运力'
}
]
} }
}, },
props: { props: {

View File

@ -229,8 +229,6 @@ export default {
selectedProj: [], selectedProj: [],
// //
tellCusText:"", tellCusText:"",
//
ifFirstLogin:true,
} }
}, },
onLoad(){ onLoad(){
@ -674,12 +672,6 @@ export default {
if(res.code==200){ if(res.code==200){
this.noReadNum = res.data>99?99:res.data this.noReadNum = res.data>99?99:res.data
} }
console.log("开始播放")
if(this.ifFirstLogin && this.noReadNum>0){
console.log("播放")
this.$refs.tarBar.dianyidain()
this.ifFirstLogin=false
}
}) })
}, },
/** /**

View File

@ -925,10 +925,13 @@ export default {
resultObj.projects = resultObj.projects.map((item)=>{ resultObj.projects = resultObj.projects.map((item)=>{
if(projectMap.has(item.id)){ if(projectMap.has(item.id)){
console.log(projectMap.get(item.id)) console.log(projectMap.get(item.id))
return projectMap.get(item.id) let localObj = projectMap.get(item.id)
}else{ item.itemPrice = localObj.itemPrice
return item item.itemCount = localObj.itemCount
item.itemDiscount = localObj.itemDiscount
item.itemMoney = localObj.itemMoney
} }
return item
}) })
} }
this.$nextTick(()=>{ this.$nextTick(()=>{

View File

@ -6,10 +6,14 @@
<script> <script>
import {getToken,getUserInfo} from "@/utils/auth"; import {getToken,getUserInfo} from "@/utils/auth";
import request from '@/utils/request';
let innerAudioContext ='';
const keepAlivePlugin = uni.requireNativePlugin('Ba-KeepAlive') const keepAlivePlugin = uni.requireNativePlugin('Ba-KeepAlive')
export default { export default {
data() { data() {
return { return {
//
ifPlay:false,
keepLive: { keepLive: {
channelId: 'Ba-KeepAlive', channelId: 'Ba-KeepAlive',
channelName: "Ba-KeepAlive", channelName: "Ba-KeepAlive",
@ -26,6 +30,7 @@
this.register() this.register()
// #endif // #endif
if(getToken()){ if(getToken()){
this.getNoReadNum()
// //
// //
let userInfo = getUserInfo() let userInfo = getUserInfo()
@ -58,6 +63,85 @@
console.log('保活注册', res); console.log('保活注册', res);
}); });
}, },
/**
* 获取未读消息数量
* @returns {Promise<void>}
*/
async getNoReadNum(){
await request({
url: "/admin-api/system/notify-message/get-unread-count",
method: "GET"
}).then((res) => {
if(res.code==200 && res.data>0){
this.dianyidain()
}
})
},
dianyidain() {
if(!this.ifPlay){
console.log('执行了dianyidain');
if(innerAudioContext!=""){
try {
console.log('调用前先销毁');
innerAudioContext.stop();
innerAudioContext.destroy();
innerAudioContext="";
}catch (e){
console.log('销毁出错');
}
}
innerAudioContext = uni.createInnerAudioContext();
this.ifPlay=true
// #ifdef APP-PLUS
innerAudioContext.src = '../../static/msgV.mp3';
// #endif
// #ifndef APP-PLUS
innerAudioContext.src = 'https://www.nuoyunr.com/lananRsc/rescue/msgV.mp3';
// #endif
//
const playCount = 4;
let currentCount = 0;
//
innerAudioContext.play();
//
uni.vibrateLong({
success: function () {
console.log('success');
}
});
innerAudioContext.onError((err) => {
console.error('播放错误', err);
this.ifPlay=false
innerAudioContext.stop();
innerAudioContext.destroy(); //
});
//
innerAudioContext.onEnded(() => {
//
currentCount++;
//
if (currentCount < playCount) {
//
innerAudioContext.play();
//
uni.vibrateLong({
success: function () {
console.log('success');
}
});
} else {
//
console.log('播放完成');
this.ifPlay=false
//
innerAudioContext.stop();
innerAudioContext.destroy();
}
});
}else{
console.log('正在播放音频,拒绝播放请求');
}
},
} }
} }
</script> </script>

View File

@ -60,9 +60,12 @@
getInfo, getInfo,
getTenantIdByPhone getTenantIdByPhone
} from '@/api/login' } from '@/api/login'
let innerAudioContext ='';
export default { export default {
data() { data() {
return { return {
//
ifPlay:false,
// //
sysCode:"weixiu", sysCode:"weixiu",
phoneNumber: "", phoneNumber: "",
@ -160,6 +163,7 @@
setToken(res.data.loginResult.accessToken) setToken(res.data.loginResult.accessToken)
setUserInfo(res.data.userinfo) setUserInfo(res.data.userinfo)
setStrData("userId",res.data.userinfo.id) setStrData("userId",res.data.userinfo.id)
this.getNoReadNum()
if(res.data.userinfo.roleCodes.includes("repair_staff")){ if(res.data.userinfo.roleCodes.includes("repair_staff")){
// //
this.getIdLeader() this.getIdLeader()
@ -302,6 +306,85 @@
} }
}, 1000); }, 1000);
}, },
/**
* 获取未读消息数量
* @returns {Promise<void>}
*/
async getNoReadNum(){
await request({
url: "/admin-api/system/notify-message/get-unread-count",
method: "GET"
}).then((res) => {
if(res.code==200 && res.data>0){
this.dianyidain()
}
})
},
dianyidain() {
if(!this.ifPlay){
console.log('执行了dianyidain');
if(innerAudioContext!=""){
try {
console.log('调用前先销毁');
innerAudioContext.stop();
innerAudioContext.destroy();
innerAudioContext="";
}catch (e){
console.log('销毁出错');
}
}
innerAudioContext = uni.createInnerAudioContext();
this.ifPlay=true
// #ifdef APP-PLUS
innerAudioContext.src = '../../static/msgV.mp3';
// #endif
// #ifndef APP-PLUS
innerAudioContext.src = 'https://www.nuoyunr.com/lananRsc/rescue/msgV.mp3';
// #endif
//
const playCount = 4;
let currentCount = 0;
//
innerAudioContext.play();
//
uni.vibrateLong({
success: function () {
console.log('success');
}
});
innerAudioContext.onError((err) => {
console.error('播放错误', err);
this.ifPlay=false
innerAudioContext.stop();
innerAudioContext.destroy(); //
});
//
innerAudioContext.onEnded(() => {
//
currentCount++;
//
if (currentCount < playCount) {
//
innerAudioContext.play();
//
uni.vibrateLong({
success: function () {
console.log('success');
}
});
} else {
//
console.log('播放完成');
this.ifPlay=false
//
innerAudioContext.stop();
innerAudioContext.destroy();
}
});
}else{
console.log('正在播放音频,拒绝播放请求');
}
},
} }
} }
</script> </script>