android.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // @ts-ignore
  2. import { useStore } from '@/store/modules/user'
  3. const store = useStore()
  4. /**
  5. * 获取请求参数
  6. */
  7. export function getHeader(){
  8. try {
  9. // @ts-ignore
  10. const header = window.android.getHeader();
  11. const user=JSON.parse(header)
  12. user.token=user.Authorization
  13. store.setToken(user);
  14. }catch (e){
  15. // router.push('/login')
  16. }
  17. }
  18. /**
  19. * 登出
  20. */
  21. export function logout(){
  22. try {
  23. // @ts-ignore
  24. window.android.logout()
  25. // store.removeToken()
  26. }catch (e){
  27. // showToast(JSON.stringify(e))
  28. }
  29. }
  30. /**
  31. * 关闭当前页面方法(回到首页)
  32. */
  33. export function goBack(){
  34. try {
  35. // @ts-ignore
  36. window.android.goBack()
  37. // store.removeToken()
  38. }catch (e){
  39. history.back();
  40. }
  41. }
  42. /**
  43. * 播报拣货数量
  44. * 播报:需要拣货number
  45. * @param number
  46. */
  47. export function playVoicePickNum(number: number) {
  48. try {
  49. // @ts-ignore
  50. window.android.playVoicePickNum(number)
  51. }catch (e){
  52. // showToast(JSON.stringify(e))
  53. }
  54. }
  55. /**
  56. * 播报格口
  57. * 播报:格口:number
  58. * @param number
  59. */
  60. export function playVoiceBin(number: number) {
  61. try {
  62. // @ts-ignore
  63. window.android.playVoiceBin(number)
  64. }catch (e){
  65. }
  66. }
  67. /**
  68. * 第一次进入页面获取焦点
  69. */
  70. export function androidFocus(){
  71. try {
  72. // @ts-ignore
  73. window.android.focus()
  74. }catch (e){
  75. }
  76. }
  77. /**
  78. * 扫描成功语音
  79. */
  80. export function scanSuccess(){
  81. try {
  82. // @ts-ignore
  83. window.android.scanSuccessVib()
  84. }catch (e){
  85. }
  86. }
  87. /**
  88. * 扫描失败语音
  89. */
  90. export function scanError(){
  91. try {
  92. // @ts-ignore
  93. window.android.scanErrorVib()
  94. }catch (e){
  95. }
  96. }
  97. /**
  98. * 保存mac地址 - piece
  99. */
  100. export function saveMacAddress(mac : string) : boolean {
  101. try {
  102. // @ts-ignore
  103. return window.android.saveMacAddress(mac)
  104. }catch (e){
  105. return false
  106. }
  107. }
  108. /**
  109. * 读取mac地址 - piece
  110. */
  111. export function readMacAddress(): string {
  112. try {
  113. // @ts-ignore
  114. return window.android.readMacAddress()
  115. }catch (e){
  116. return ''
  117. }
  118. }