androidPiece.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /**
  2. * 重复扫描语音
  3. */
  4. export function scanRepeat(){
  5. try {
  6. // @ts-ignore
  7. window.android.scanRepeatVib()
  8. }catch (e){
  9. }
  10. }
  11. /**
  12. * 扫码失败
  13. */
  14. export function scanErr(){
  15. try {
  16. // @ts-ignore
  17. window.android.scanError()
  18. }catch (e){
  19. }
  20. }
  21. /**
  22. * 重新登录
  23. */
  24. export function reLoginTip(){
  25. try {
  26. // @ts-ignore
  27. window.android.reLoginTip()
  28. }catch (e){
  29. }
  30. }
  31. /**
  32. * 获取版本号 - piece
  33. */
  34. export function getVersionName() : string {
  35. try {
  36. // @ts-ignore
  37. return window.android.getVersionName()
  38. }catch (e){
  39. return '版本号获取失败!'
  40. }
  41. }
  42. /**
  43. * 检查版本更新 - piece
  44. */
  45. export function checkUpdate() : void {
  46. try {
  47. // @ts-ignore
  48. return window.android.checkUpdate()
  49. }catch (e){
  50. }
  51. }
  52. /**
  53. * 保存userId - piece
  54. */
  55. export function saveUserId(userId : string) : boolean {
  56. try {
  57. // @ts-ignore
  58. return window.android.saveUserId(userId)
  59. }catch (e){
  60. return false
  61. }
  62. }
  63. /**
  64. * 保存userId - piece
  65. */
  66. export function removeUserId() {
  67. try {
  68. // @ts-ignore
  69. return window.android.removeUserId()
  70. }catch (e){
  71. }
  72. }
  73. /**
  74. * 读取userId - piece
  75. */
  76. export function getUserId(): string {
  77. try {
  78. // @ts-ignore
  79. return window.android.getUserId()
  80. }catch (e){
  81. return ''
  82. }
  83. }
  84. /**
  85. * 获取异常的数量 - piece
  86. */
  87. export function getErrRecordsCount(): number {
  88. try {
  89. // @ts-ignore
  90. return window.android.getErrRecordsCount()
  91. }catch (e){
  92. return 0
  93. }
  94. }
  95. /**
  96. * 获取异常的数据 - piece
  97. */
  98. export function listErrRecords(): string {
  99. try {
  100. // @ts-ignore
  101. return window.android.listErrRecords()
  102. }catch (e){
  103. return ''
  104. }
  105. }
  106. /**
  107. * 更新状态为失败 - piece
  108. */
  109. export function updateDeliveryPushFail(code : string): number {
  110. try {
  111. // @ts-ignore
  112. return window.android.updateDeliveryPushFail(code)
  113. }catch (e){
  114. return -1
  115. }
  116. }
  117. /**
  118. * 更新状态为成功 - piece
  119. */
  120. export function markAsPushed(code : string): number {
  121. try {
  122. // @ts-ignore
  123. return window.android.markAsPushed(code)
  124. }catch (e){
  125. return -1
  126. }
  127. }
  128. /**
  129. * 校验是否存在
  130. */
  131. export function isDeliveryNoExists(deliveryNo : string) : boolean {
  132. try {
  133. // @ts-ignore
  134. return window.android.isDeliveryNoExists(deliveryNo)
  135. }catch (e){
  136. return false
  137. }
  138. }
  139. /**
  140. * 保存mac地址 - piece
  141. */
  142. export function saveMacAddress(mac : string) : boolean {
  143. try {
  144. // @ts-ignore
  145. return window.android.saveMacAddress(mac)
  146. }catch (e){
  147. return false
  148. }
  149. }
  150. /**
  151. * 读取mac地址 - piece
  152. */
  153. export function readMacAddress(): string {
  154. try {
  155. // @ts-ignore
  156. return window.android.readMacAddress()
  157. }catch (e){
  158. return ''
  159. }
  160. }
  161. /**
  162. * 分页查询 - piece
  163. */
  164. export function pageDelivery(page : number, size : number): any {
  165. try {
  166. // @ts-ignore
  167. const result = window.android.pageDelivery(page, size);
  168. return JSON.parse(result)
  169. }catch (e){
  170. return ''
  171. }
  172. }
  173. /**
  174. * 插入数据 - piece
  175. *
  176. * @param macAddress mac地址
  177. * @param deliveryNo 快递单号
  178. * @param userId 用户id
  179. */
  180. export function addDelivery(macAddress : string, deliveryNo : string, userId : string, userName : string): number {
  181. try {
  182. // @ts-ignore
  183. return window.android.addDelivery(macAddress, deliveryNo, userId, userName)
  184. }catch (e){
  185. return -2
  186. }
  187. }