优化app通知栏提醒

master
chen 2022-08-19 15:02:10 +08:00
parent c2bfc1c66a
commit 15df45c89d
4 changed files with 140 additions and 48 deletions

View File

@ -63,11 +63,38 @@
"appkey_android" : ""
}
},
"push" : {
"unipush" : {
"version" : "2",
"offline" : true
}
"push" : {}
},
"icons" : {
"ios" : {
"ipad" : {
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification" : "unpackage/res/icons/20x20.png",
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"notification@3x" : "unpackage/res/icons/60x60.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
},
"appstore" : "unpackage/res/icons/1024x1024.png"
},
"android" : {
"xxxhdpi" : "unpackage/res/icons/192x192.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"hdpi" : "unpackage/res/icons/72x72.png"
}
}
}

View File

@ -28,7 +28,7 @@
// #ifdef MP-WEIXIN
this.ifH5 = false;
// #endif
this.checkContext();
// this.checkContext();
if(uni.getStorageSync('guideImg')){
this.ad_img = uni.getStorageSync('guideImg');
//
@ -54,14 +54,14 @@
}
},1000)
this.timeNumTimer = setTimeout(()=>{
this.goPage();
this.checkContext();
},this.timeNum)
},
//
closeEv(){
clearInterval(this.countTimer);
clearTimeout(this.timeNumTimer);
this.goPage();
this.checkContext();
},
checkContext(){
if(uni.getStorageSync('password')) {
@ -79,13 +79,17 @@
this.$store.commit('setUid',res.data.uid);
// token
uni.setStorageSync('token',res.data.token);
this.omg = 1;
this.goPage();
} else {
this.$toolAll.tools.showToast(res.msg);
this.omg = 0;
this.goPage();
}
})
this.omg = 1;
} else {
this.omg = 0;
this.goPage();
}
},
//
@ -104,7 +108,9 @@
page{background-color: #FFFFFF;}
.count-box{
background-color: rgba(0, 0, 0, .3);
padding: 16rpx 30rpx;
/* padding: 16rpx 30rpx; */
width: 120rpx;
height: 60rpx;
}
.app-h5-count-box{
position: fixed;

View File

@ -417,21 +417,23 @@
console.log("会员上线",msg);
});
//
if(uni.getStorageSync('ifMessage')){
socket.on('new_msg', (msg)=> {
console.log(msg,121212)
// this.offMusic();
if(uni.getStorageSync('ifVoice')){
console.log('进入接收消息');
this.createMessage();
// uni.showToast({
// title:''
// })
// this.bofang(msg);
this.openSettings();
socket.on('new_msg',(msg)=> {
console.log(msg,'接收的消息');
// #ifdef APP-PLUS
if(uni.getStorageSync('ifMessage') || uni.getStorageSync('ifVoice')){
if(msg.includes('.mp3')){
this.bofang(msg);
} else {
this.createMessage(msg);
}
});
}
}
// #endif
// #ifdef H5 || MP-WEIXIN
if(uni.getStorageSync('ifVoice')){
this.bofang(msg);
}
// #endif
});
},
// uniapp
openSettings() {
@ -451,13 +453,37 @@
// #endif
},
//
createMessage(){
uni.createPushMessage({
title:'你好Y',
content:'这是测试内容',
icon:'/static/public/icon-plan-fire.png',
cover:true //
})
createMessage(msg){
let that = this;
// #ifdef APP-PLUS
uni.getSystemInfo({
success(res) {
if(res.platform == 'ios'){
if(uni.getStorageSync('ifVoice') || uni.getStorageSync('ifMessage')){
uni.createPushMessage({
content:msg,
sound:uni.getStorageSync('ifVoice')?'system':'none',// nonesystem
success: () => {},
complete: () => {}
})
}
} else if (res.platform == 'android'){
if(uni.getStorageSync('ifVoice') || uni.getStorageSync('ifMessage')){
uni.createPushMessage({
// title:'',//
content:msg,//
// icon:'/static/public/icon-plan-fire.png',//
cover:true ,//
when:that.timeago(new Date().getTime()), //
sound:uni.getStorageSync('ifVoice')?'system':'none',// nonesystem
success: () => {},
complete: () => {}
})
}
}
}
});
// #endif
},
//
bofang(msg){
@ -480,21 +506,6 @@
this.ifPlayIng = false;
}
},
// uniapp
openSettings() {
uni.getSystemInfo({
success(res) {
if(res.platform == 'ios'){
plus.runtime.openURL("app-settings://");
} else if (res.platform == 'android'){
var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass("android.content.Intent");
var mIntent = new Intent('android.settings.SOUND_SETTINGS');
main.startActivity(mIntent);
}
}
});
},
//
checkHome(){
this.$requst.get('/universal/api.home/home').then(res=>{
@ -693,6 +704,52 @@
callEv(){
// this.$toolAll.tools.countCustomer('15616330510');
this.$toolAll.tools.countCustomer(this.contactPhone);
},
//
timeago(dateTimeStamp){
let result = '';
var minute = 1000 * 60; //
var hour = minute * 60;
var day = hour * 24;
var week = day * 7;
var halfamonth = day * 15;
var month = day * 30;
var now = new Date().getTime(); //
console.log(now)
var diffValue = now - dateTimeStamp;//
if(diffValue < 0){
return;
}
var minC = diffValue/minute; //
var hourC = diffValue/hour;
var dayC = diffValue/day;
var weekC = diffValue/week;
var monthC = diffValue/month;
if(monthC >= 1 && monthC <= 3){
result = " " + parseInt(monthC) + "月前"
}else if(weekC >= 1 && weekC <= 3){
result = " " + parseInt(weekC) + "周前"
}else if(dayC >= 1 && dayC <= 6){
result = " " + parseInt(dayC) + "天前"
}else if(hourC >= 1 && hourC <= 23){
result = " " + parseInt(hourC) + "小时前"
}else if(minC >= 1 && minC <= 59){
result =" " + parseInt(minC) + "分钟前"
}else if(diffValue >= 0 && diffValue <= minute){
result = "刚刚"
}else {
var datetime = new Date();
datetime.setTime(dateTimeStamp);
var Nyear = datetime.getFullYear();
var Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
var Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
var Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
var Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
var Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
result = Nyear + "-" + Nmonth + "-" + Ndate
}
return result;
}
}
}

View File

@ -7,10 +7,12 @@
<view>开启语音提醒</view>
<view><evan-switch v-model="voiceStatus" @change="voiceNewsEv($event,1)" :size="18" inactive-color="#b3b3b3" active-color="#fd8956"></evan-switch></view>
</view>
<!-- #ifdef APP-PLUS -->
<view class="bacf pad30 disjbac mar-x20">
<view>接受新消息通知</view>
<view><evan-switch v-model="newsStatus" @change="voiceNewsEv" :size="18" inactive-color="#b3b3b3" active-color="#fd8956"></evan-switch></view>
</view>
<!-- #endif -->
<view @tap="updatePassword" class="bacf pad30 disjbac bbot">
<view>修改登录密码</view>
<i class="icon icon-next col9" style="font-size: 26rpx;"></i>