This commit is contained in:
Iruka 2025-01-17 12:56:38 +08:00
parent 417583afca
commit 598eb3bb32
6 changed files with 94 additions and 62 deletions

View File

@ -8,12 +8,6 @@
import mqttUtil from "@/utils/mqttUtil.js"
const mqttUrl = import.meta.env.VITE_BASE_MQTT;
//
import {
requestPermissions,
goSetting
} from "@/js_sdk/yu-app-permission/yu-app-permission.js"
export default {
data() {
return {

View File

@ -44,9 +44,13 @@ import {
createSSRApp
} from 'vue'
import uviewPlus from "@/uni_modules/uview-plus"
import directive from "@/directive"
import directive from "@/directive"
import * as commonUtils from "@/utils/common.js"
import constant from "@/utils/constant.js"
import {
VerifyPermissions
} from "@/utils/requestPermissions.js"
export function createApp() {
const app = createSSRApp(App)
app.use(uviewPlus)
@ -54,7 +58,8 @@ export function createApp() {
app.config.globalProperties.$toast = commonUtils.toast;
app.config.globalProperties.$showConfirm = commonUtils.showConfirm;
app.config.globalProperties.$constant = constant;
app.config.globalProperties.$VerifyPermissions = VerifyPermissions;
// #ifndef MP
// 处理 wx.connectSocket promisify 兼容问题,强制返回 SocketTask
uni.connectSocket = (function(connectSocket) {

View File

@ -633,37 +633,27 @@
},
//
async toQRCode() {
// // { isSuc : true} ,
// const {
// isSuc
// } = await requestPermissions({
// title: "/", //
// content: "便使,", //
// permissionID: "CAMERA" // ID
// })
// if (!isSuc) {
// return false
// }
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// qrCodebarCode
'scanType': ['qrCode', 'barCode'],
// false
'hideAlbum': false,
//ios zh-Hansen
'language': 'en',
//(ios)
'failedMsg': '未识别到二维码,请重试',
//Android
'screenType': 'full'
}, (ret) => {
console.error("ret:", ret);
if (ret.resp_code == 1000) {
const deviceCode = ret.resp_result;
// showModal.value = true
this.$toast(JSON.stringify(deviceCode))
}
this.$VerifyPermissions("CAMERA", "扫描设备二维码,查看设备信息").then(res => {
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// qrCodebarCode
'scanType': ['qrCode', 'barCode'],
// false
'hideAlbum': false,
//ios zh-Hansen
'language': 'en',
//(ios)
'failedMsg': '未识别到二维码,请重试',
//Android
'screenType': 'full'
}, (ret) => {
console.error("ret:", ret);
if (ret.resp_code == 1000) {
const deviceCode = ret.resp_result;
// showModal.value = true
this.$toast(JSON.stringify(deviceCode))
}
})
})
},
// adc

View File

@ -179,10 +179,7 @@
//
function forgotPassword() {
uni.showToast({
title: "忘记密码,请联系管理员",
icon: "none"
})
this.$toast("忘记密码,请联系管理员");
}
const codeBtnText = ref('获取验证码');
@ -195,21 +192,18 @@
}
//
if (!checkTelephone(loginForm.value.phone)) {
uni.showToast({
title: "请输入正确手机号!",
icon: "none"
})
this.$toast("请输入正确手机号!");
return
}
codeBtnDisabled.value = true;
uni.showLoading({
title: "正在获取验证码...",
title: "获取验证码...",
mask: true
})
getCodePhone(loginForm.value.phone).then(res => {
plugin.modal.closeLoading()
uni.hideLoading()
if (res.smsResponse) {
plugin.modal.showToast("短信已发送")
this.$toast("短信已发送");
loginForm.value.uuid = res.uuid
codeBtnTimer.value = 60
setCodeTimer();
@ -294,10 +288,7 @@
loginSuccess()
})
.catch(error => {
uni.showToast({
title: error,
icon: "error"
})
this.$toast(error);
})
.finally(() => {})
}
@ -312,10 +303,7 @@
if (result.code == 200) {
toIndex(result.user.userId);
} else {
uni.showToast({
title: result.msg,
icon: "none"
})
this.$toast(result.msg);
}
})
//
@ -323,10 +311,7 @@
.dispatch("getUserRoles")
.then(res => {})
.catch(error => {
uni.showToast({
title: "获取用户权限失败",
icon: "none"
})
this.$toast("获取用户权限失败");
})
.finally(() => {})
}

View File

@ -137,6 +137,14 @@
},
async getImage() {
var _this = this
const _CAMERA = await _this.$VerifyPermissions("CAMERA", "个性化设置头像")
if (!_CAMERA) {
return false;
}
const _READ_EXTERNAL_STORAGE = await _this.$VerifyPermissions("READ_EXTERNAL_STORAGE", "个性化设置头像")
if (!_READ_EXTERNAL_STORAGE) {
return false;
}
uni.chooseImage({
success: function(res) {
_this.setData({

View File

@ -0,0 +1,50 @@
// 引入插件包
import {
requestPermissions,
goSetting
} from "@/js_sdk/yu-app-permission/yu-app-permission.js"
const permission = {
CAMERA: {
value: "CAMERA",
title: "相机/摄像头",
},
CALL_PHONE: {
value: "CALL_PHONE",
title: "拨打电话",
},
READ_EXTERNAL_STORAGE: {
value: "READ_EXTERNAL_STORAGE",
title: "访问相册",
},
}
/**
* @param {Object} key permissionKey 类型 参考上方
* @param {Object} content 功能描述
*/
export function VerifyPermissions(key, content) {
return new Promise((resolve, reject) => {
// 权限检测成功则返回 { isSuc : true} ,未授权则弹出权限询问弹窗以及权限说明窗口
// const {
// isSuc
// } = await requestPermissions({
// title: title, // 申请权限时弹出框标题
// content: content, // 申请权限时弹出框内容
// permissionID: permissionID // 权限ID
// })
// if (!isSuc) {
// return false
// }
requestPermissions({
title: permission[key].title, // 申请权限时弹出框标题
content: content, // 申请权限时弹出框内容
permissionID: permission[key].value // 权限ID
}).then(res => {
if (res.isSuc) {
resolve(true)
}
})
})
}