This commit is contained in:
36
App.vue
36
App.vue
@@ -24,26 +24,26 @@
|
|||||||
|
|
||||||
// 监听登录成功
|
// 监听登录成功
|
||||||
uni.$on("loginSuccess", () => {
|
uni.$on("loginSuccess", () => {
|
||||||
// NotifyPermission.ensurePermission(() => {
|
this.initWebSocket()
|
||||||
// // 权限已开,执行你的逻辑
|
NotifyPermission.ensurePermission(() => {
|
||||||
// this.initWebSocket()
|
|
||||||
// })
|
})
|
||||||
// // 仅在 Android 13+ 才需要
|
// // 仅在 Android 13+ 才需要
|
||||||
if (plus.os.name === "Android" && parseInt(plus.os.version) >= 13) {
|
// if (plus.os.name === "Android" && parseInt(plus.os.version) >= 13) {
|
||||||
var permission = "android.permission.POST_NOTIFICATIONS";
|
// var permission = "android.permission.POST_NOTIFICATIONS";
|
||||||
// 请求权限
|
// // 请求权限
|
||||||
plus.android.requestPermissions(
|
// plus.android.requestPermissions(
|
||||||
[permission],
|
// [permission],
|
||||||
(resultObj) => {
|
// (resultObj) => {
|
||||||
this.initWebSocket()
|
// this.initWebSocket()
|
||||||
},
|
// },
|
||||||
(error) => {
|
// (error) => {
|
||||||
|
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
} else {
|
// } else {
|
||||||
this.initWebSocket()
|
// this.initWebSocket()
|
||||||
}
|
// }
|
||||||
})
|
})
|
||||||
//只有在基座运行的情况下才能打印看到
|
//只有在基座运行的情况下才能打印看到
|
||||||
const clientInfo = plus.push.getClientInfo()
|
const clientInfo = plus.push.getClientInfo()
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "数字南川",
|
"name" : "数字南川",
|
||||||
"appid" : "__UNI__7AF1078",
|
"appid" : "__UNI__DA9B8DE",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.8.4",
|
"versionName" : "1.8.4",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
|
@@ -10,12 +10,12 @@
|
|||||||
<view class="login-form">
|
<view class="login-form">
|
||||||
<view class="input-row">
|
<view class="input-row">
|
||||||
<image class="iconfont" src="/static/ic_login_phone.png" />
|
<image class="iconfont" src="/static/ic_login_phone.png" />
|
||||||
<input class="login-input" type="text" placeholder="输入手机号" v-model="username" />
|
<input class="login-input" type="text" placeholder="请输入账号" v-model="username" />
|
||||||
</view>
|
</view>
|
||||||
<view class="input-row">
|
<view class="input-row">
|
||||||
<image class="iconfont2" src="/static/ic_login_code.png" />
|
<image class="iconfont2" src="/static/ic_login_code.png" />
|
||||||
<input class="login-input" type="text" placeholder="请输入验证码" v-model="password" />
|
<input class="login-input" type="text" placeholder="请输入密码" v-model="password" />
|
||||||
<button class="code-btn">获取校验码</button>
|
<!-- <button class="code-btn">获取校验码</button> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="protocol-row">
|
<view class="protocol-row">
|
||||||
<label class="custom-checkbox-label">
|
<label class="custom-checkbox-label">
|
||||||
@@ -38,10 +38,12 @@
|
|||||||
import base64 from '@/common/base64.js';
|
import base64 from '@/common/base64.js';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
// username: 'admin',
|
||||||
|
// password: 'admin123',
|
||||||
phoneNo: '',
|
phoneNo: '',
|
||||||
username: 'admin',
|
username: '',
|
||||||
password: 'admin123',
|
password: '',
|
||||||
loginType: 'currentPhone',
|
loginType: 'currentPhone',
|
||||||
showPassword: false,
|
showPassword: false,
|
||||||
remember: true,
|
remember: true,
|
||||||
@@ -62,7 +64,11 @@
|
|||||||
this.getUserInfo()
|
this.getUserInfo()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async submit() {
|
async submit() {
|
||||||
|
if(!this.checked){
|
||||||
|
this.$u.toast('请先同意用户协议和隐私政策');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.username.length == 0) {
|
if (this.username.length == 0) {
|
||||||
this.$u.toast('请输入账号');
|
this.$u.toast('请输入账号');
|
||||||
return;
|
return;
|
||||||
@@ -184,8 +190,8 @@
|
|||||||
.iconfont {
|
.iconfont {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
margin-right: 16rpx;
|
margin-right: 16rpx;
|
||||||
width: 27rpx;
|
width: 35rpx;
|
||||||
height: 43rpx;
|
height: 35rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconfont2 {
|
.iconfont2 {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 6.2 KiB |
@@ -1,66 +1,73 @@
|
|||||||
// utils/notification-permission.js
|
|
||||||
export default {
|
export default {
|
||||||
// 检查通知权限
|
// 检查通知权限
|
||||||
checkPermission(callback) {
|
checkPermission(callback) {
|
||||||
if (plus.os.name !== "Android") {
|
if (plus.os.name !== "Android") {
|
||||||
callback(true) // iOS 默认返回 true,另外可以用 APNs 检查
|
callback(true) // iOS 这里直接返回 true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let NotificationManagerCompat = plus.android.importClass("androidx.core.app.NotificationManagerCompat")
|
let NotificationManagerCompat = plus.android.importClass("androidx.core.app.NotificationManagerCompat")
|
||||||
let context = plus.android.runtimeMainActivity()
|
let context = plus.android.runtimeMainActivity()
|
||||||
let manager = NotificationManagerCompat.from(context)
|
let manager = NotificationManagerCompat.from(context)
|
||||||
callback(manager.areNotificationsEnabled())
|
callback(manager.areNotificationsEnabled())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("检查通知权限出错:", e)
|
console.error("检查通知权限出错:", e)
|
||||||
callback(false)
|
callback(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 打开通知权限设置页面
|
// 打开通知权限设置页面
|
||||||
openPermissionSetting() {
|
openPermissionSetting() {
|
||||||
if (plus.os.name !== "Android") return
|
if (plus.os.name !== "Android") return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let main = plus.android.runtimeMainActivity()
|
const main = plus.android.runtimeMainActivity()
|
||||||
let Intent = plus.android.importClass("android.content.Intent")
|
const Intent = plus.android.importClass('android.content.Intent')
|
||||||
let Settings = plus.android.importClass("android.provider.Settings")
|
const Settings = plus.android.importClass('android.provider.Settings')
|
||||||
|
const Uri = plus.android.importClass('android.net.Uri')
|
||||||
|
const Build = plus.android.importClass('android.os.Build')
|
||||||
|
|
||||||
let intent = new Intent()
|
let intent
|
||||||
if (parseInt(plus.device.sdkVersion) >= 33) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
// Android 13 及以上
|
// Android 8.0 及以上
|
||||||
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, main.getPackageName())
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, main.getPackageName())
|
||||||
} else {
|
} else if (Build.VERSION.SDK_INT >= 21) {
|
||||||
// Android 8 ~ 12
|
// Android 5.0 - 7.1
|
||||||
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS")
|
intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
||||||
intent.putExtra("app_package", main.getPackageName())
|
intent.putExtra("app_package", main.getPackageName())
|
||||||
intent.putExtra("app_uid", main.getApplicationInfo().uid)
|
intent.putExtra("app_uid", main.getApplicationInfo().uid)
|
||||||
}
|
} else {
|
||||||
main.startActivity(intent)
|
// Android 4.4 及以下,跳转到应用详情页
|
||||||
} catch (e) {
|
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||||
console.error("跳转通知设置页失败:", e)
|
intent.setData(Uri.fromParts("package", main.getPackageName(), null))
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
// 统一方法:检查并申请
|
main.startActivity(intent)
|
||||||
ensurePermission(next) {
|
} catch (e) {
|
||||||
this.checkPermission((enabled) => {
|
console.error("跳转通知设置页失败:", e)
|
||||||
if (enabled) {
|
}
|
||||||
next && next() // 已有权限,继续逻辑
|
},
|
||||||
} else {
|
|
||||||
uni.showModal({
|
// 统一方法:检查并申请
|
||||||
title: "通知权限未开启",
|
ensurePermission(next) {
|
||||||
content: "请开启通知权限以接收消息提醒",
|
this.checkPermission((enabled) => {
|
||||||
confirmText: "去开启",
|
if (enabled) {
|
||||||
success: (res) => {
|
next && next() // 已有权限,继续逻辑
|
||||||
if (res.confirm) {
|
} else {
|
||||||
this.openPermissionSetting()
|
uni.showModal({
|
||||||
}
|
title: "通知权限未开启",
|
||||||
}
|
content: "请开启通知权限以接收消息提醒",
|
||||||
})
|
confirmText: "去开启",
|
||||||
}
|
success: (res) => {
|
||||||
})
|
if (res.confirm) {
|
||||||
}
|
console.log('t1', '11111111')
|
||||||
}
|
this.openPermissionSetting()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user