This invention discloses a
barcode scanning fault-tolerant identification method and
system based on a phased notification mechanism, applied to the WeChat Mini Program runtime environment. The
barcode string obtained by scanning undergoes a progressive multi-layer format
verification (pure number
verification → length
verification → country code matching → verification bit calculation), terminating if the previous layer fails. When verification fails, the module-level closure variable retry counter increments: if the maximum threshold is not reached, a progress indicator is displayed via `wx.showToast`, and after a preset
delay, `wx.scanCode` is called again to initiate a new scanning operation; if the threshold is reached, a three-step phase switch driven by the UI layer alternation rules of the WeChat Mini Program API is executed: ① resetting the counter, ② `wx.hideToast()` actively closes any potentially still-displayed toasts to avoid rendering conflicts with `wx.showModal`, ③ a confirmation
dialog box pops up for the user to choose between using the current result or rescanning. When verification passes or the user selects "use this result," a local product
database query is executed, and the result is passed to the calling page via a
callback function. This invention also discloses an independent implementation of dual-mode
barcode scanning on the cashier page—manual scanning and continuous camera scanning
modes employ differentiated "pause → resume" retry strategies. This invention resolves the UI-level conflict between the two
system notification APIs in WeChat Mini Programs by mandating the sequential operation of `wx.hideToast()` → `wx.showModal()`, and ensures the
correctness of the recursive retry state and the continuity of the retry state across short-lifecycle pages through a module-level closure counter.