You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.3 KiB
116 lines
3.3 KiB
<script>
|
|
import { go2 } from '@/utils/hook.js'
|
|
import { isString } from '@/utils/is.js'
|
|
import store from '@/store/index.js'
|
|
import handlePushMsg from '@/utils/handlePushMsg.js'
|
|
import { checkUpdate } from '@/apis/commonApi.js'
|
|
export default {
|
|
onLaunch: function () {
|
|
const token = store.state.qnToken
|
|
let flag = uni.getStorageSync('hasLaunch')
|
|
if (flag && !token) {
|
|
go2('login')
|
|
}
|
|
if (flag && token) {
|
|
go2('client')
|
|
}
|
|
// #ifdef APP-PLUS
|
|
let client = uni.getSystemInfoSync().platform
|
|
setTimeout(() => {
|
|
plus.push.addEventListener(
|
|
'click',
|
|
function (msg) {
|
|
console.log('click msg',msg)
|
|
handlePushMsg(msg)
|
|
},
|
|
false
|
|
)
|
|
// 监听在线消息事件
|
|
plus.push.addEventListener(
|
|
'receive',
|
|
function (msg) {
|
|
if (isString(msg.payload)) {
|
|
msg.payload = JSON.parse(msg.payload)
|
|
}
|
|
if (client === 'ios') {
|
|
if (msg.aps == null && msg.type == 'receive') {
|
|
let content = msg.payload.content
|
|
let title = msg.payload.title
|
|
let payload = JSON.stringify(msg.payload)
|
|
console.log('ios receive:', title, payload, content)
|
|
plus.push.createMessage(content, payload, {
|
|
title: title
|
|
})
|
|
if (msg.payload.messageType == 4) {
|
|
enquiryVoice()
|
|
}
|
|
}
|
|
}
|
|
if (client === 'android') {
|
|
console.log('receive msg',msg)
|
|
let title = msg.title
|
|
let content = msg.content
|
|
plus.push.createMessage(content, JSON.stringify(msg.payload), {
|
|
title: title
|
|
})
|
|
if (msg.payload.messageType == 4) {
|
|
enquiryVoice()
|
|
}
|
|
}
|
|
// 在线语音播放
|
|
},
|
|
false
|
|
)
|
|
}, 1000)
|
|
// #endif
|
|
let timer = null
|
|
function enquiryVoice() {
|
|
if (timer) {
|
|
clearTimeout(timer)
|
|
timer = null
|
|
}
|
|
timer = setTimeout(() => {
|
|
const innerAudioContext = uni.createInnerAudioContext()
|
|
innerAudioContext.autoplay = true
|
|
innerAudioContext.src = 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/BasePaperInquiryVoice.mp3'
|
|
innerAudioContext.onPlay(() => {
|
|
console.log('开始播放')
|
|
})
|
|
innerAudioContext.onError((res) => {
|
|
console.log(res.errMsg)
|
|
console.log(res.errCode)
|
|
})
|
|
}, 3000)
|
|
}
|
|
// app更新
|
|
//#ifdef APP-PLUS
|
|
checkUpdate().then((version) => {
|
|
let curVersion = plus.runtime.version
|
|
if(version != curVersion) {
|
|
plus.runtime.openURL(`https://www.pgyer.com/ST8i`)
|
|
}
|
|
})
|
|
//#endif
|
|
},
|
|
onShow: function () {
|
|
// 先默认进入应用就清除所有消息
|
|
plus.runtime.setBadgeNumber(0)
|
|
},
|
|
onHide: function () {}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
/*每个页面公共css */
|
|
@import url('./common/css/reset.scss');
|
|
@import '@/static/icon/iconfont.css';
|
|
page {
|
|
height: 100%;
|
|
}
|
|
/* uni-dialog标题样式 */
|
|
.uni-dialog-title-text {
|
|
font-size: 32rpx !important;
|
|
color: #323233 !important;
|
|
font-weight: 500 !important;
|
|
}
|
|
</style>
|