优化app通知栏提醒
parent
c2bfc1c66a
commit
15df45c89d
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -417,21 +417,23 @@
|
|||
console.log("会员上线",msg);
|
||||
});
|
||||
// 接收消息
|
||||
if(uni.getStorageSync('ifMessage')){
|
||||
socket.on('new_msg',(msg)=> {
|
||||
console.log(msg,121212)
|
||||
// this.offMusic();
|
||||
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')){
|
||||
console.log('进入接收消息');
|
||||
this.createMessage();
|
||||
// uni.showToast({
|
||||
// title:'您有新消息!'
|
||||
// })
|
||||
// this.bofang(msg);
|
||||
this.openSettings();
|
||||
this.bofang(msg);
|
||||
}
|
||||
// #endif
|
||||
});
|
||||
}
|
||||
},
|
||||
// uniapp设置消息提醒(调用手机系统静音或铃声)
|
||||
openSettings() {
|
||||
|
@ -451,13 +453,37 @@
|
|||
// #endif
|
||||
},
|
||||
// 创建本地通知栏消息
|
||||
createMessage(){
|
||||
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({
|
||||
title:'你好Y',
|
||||
content:'这是测试内容',
|
||||
icon:'/static/public/icon-plan-fire.png',
|
||||
cover:true // 是否覆盖上一次提示的消息
|
||||
content:msg,
|
||||
sound:uni.getStorageSync('ifVoice')?'system':'none',// 默认没有声音none,系统声音system
|
||||
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',// 默认没有声音none,系统声音system
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue