logwire-wms-pda-ui
Version:
运匠科技wms-PDA基础组件库
184 lines (156 loc) • 3.58 kB
JavaScript
/*
* app壳子提供的能力
* @author 蔡礼标
* @date 2022-01-19
* */
export const AppPower = {
/**
* app 蓝牙打印
* @param template string 模板
* @param data 打印数据--"[{},{}]"
* @returns true|false
*/
bluePrint: (template, data) => {
let app = window.App_bluePrint
if (app && typeof (app.bluePrint) == "function") {
return true == app.bluePrint(JSON.stringify({"template": template, "data": data}))
} else {
return false
}
},
/**
* 预先连接蓝牙打印 提升打印连接速度
* 可多次调用
* @returns {boolean}
*/
bluePrintOpen: () => {
let app = window.App_bluePrint
if (app && typeof (app.bluePrintOpen) == "function") {
return true == app.bluePrintOpen()
} else {
return false
}
},
/**
* 关闭蓝牙打印连接
* 可多次调用
* @returns {boolean}
*/
bluePrintClose: () => {
let app = window.App_bluePrint
if (app && typeof (app.bluePrintClose) == "function") {
return true == app.bluePrintClose()
} else {
return false
}
},
/**
* 一次震动
* @param time
* @returns {boolean}
*/
shortVibrate: (time) => {
let app = window.App_vibrate
if (app && typeof (app.shortVibrate) == "function") {
return true == app.shortVibrate(time)
} else {
return false
}
},
/**
* 获取UUID
* 示例 shortVibrate(500)
* @returns uuid
*/
appUUID: () => {
let app = window.App_uuid
if (app && typeof (app.getUUID) == "function") {
return app.getUUID()
} else {
return false
}
},
/**
* 波动震动
* list:0+n*2=停止时间,1+n*2=震动时间
* 示例 longVibrate([50,150,100,150,100,1000])
* @param list
* @returns {boolean}
*/
longVibrate: (list) => {
let app = window.App_vibrate
if (app && typeof (app.waveVibrate) == "function") {
return true == app.waveVibrate(JSON.stringify({"list": list, "repeat": -1}))
} else {
return false
}
},
/**
* 语音提示
* 示例 speak("1234567")
*/
speak: (data) => {
let app = window.App_tts
if (app && typeof (app.speak) == "function") {
// 大于15个字符就不朗读
if (data.length > 15) return false
return true == app.speak(data)
} else {
return false
}
},
// 扫描
scan: () => {
let app = window.App_scan
if (app && typeof (app.scan) == "function") {
return app.scan()
} else {
return null
}
},
// 获取图片 多张 默认最多9
getImages: (maxNum) => {
let app = window.App_gallery
if (app && typeof (app.images) == "function") {
let images = app.images(maxNum);
if (images) return JSON.parse(images)
}
return null
},
/**
* 获取配置信息:环境名
* @returns {string}
*/
appHostName:() => {
let app = window.App_config
if(app && typeof (app.getHostName) == "function"){
return app.getHostName()
}else{
return "-"
}
},
/**
* 获取配置信息:调试模式
* @returns {boolean}
*/
appIsDebug:() => {
let app = window.App_config
if(app && typeof (app.isDebug) == "function"){
return true == app.isDebug()
}else{
return false
}
},
/**
* 获取配置信息:发布类型
* @returns {string}
*/
appChannel:() => {
let app = window.App_config
if(app && typeof (app.getChannel) == "function"){
return app.getChannel()
}else{
return ""
}
}
}