123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- var alog = uni.requireNativePlugin("AndroidLog")
- let speaker = uni.requireNativePlugin("SpeechPlug");
- const _handlePush = function(message) {
-
- try {
- alog.info({msg: '接收到消息:' + message});
- const value = uni.getStorageSync('pushreg_switch');
- if (value) {
- return;
- }
- const roadinfoCache = uni.getStorageSync('payee_roadinfo');
- alog.info({msg: '本地路段信息:' + roadinfoCache});
- if (!roadinfoCache){
- return;
- }
- let content = JSON.parse(message.content);
- const roadinfo = JSON.parse(roadinfoCache) ;
- if(content.roadNo && roadinfo.roadNo && content.roadNo == roadinfo.roadNo){
- if (content.type === 1){
- deviceParkIn(content)
- }else if (content.type === 2){
- deviceParkOut(content)
- }
- }
- } catch(e){
-
- }
-
- };
- function deviceParkIn(content){
- let speakDeviceParkIn='';
-
- uni.getStorage({
- key:'speakData',
- success: (res) => {
- speakDeviceParkIn = res.data.switchVal1;
- },
- fail: (err) => {
- }
- })
- if(content.speakMsg&&(speakDeviceParkIn==true||speakDeviceParkIn=='')){
- speaker.speakAction(content.speakMsg)
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- function deviceParkOut(content){
- let speakDeviceParkOut='';
-
- uni.getStorage({
- key:'speakData',
- success: (res) => {
- speakDeviceParkOut = res.data.switchVal2;
- },
- fail: (err) => {
- }
- })
- if(content.speakMsg&&(speakDeviceParkOut==true||speakDeviceParkOut=='')){
- speaker.speakAction(content.speakMsg)
- }
- }
- function pushreg(vue){
-
-
- uni.setStorageSync('pushreg_switch', '1');
-
- plus.push.addEventListener('click', _handlePush, false);
-
- plus.push.addEventListener('receive', _handlePush, false);
- }
- export default pushreg
|