The seventh chapter is the penultimate article of the introductory article, and tomorrow the whole app will go to the finale.
This tutorial mainly teaches you to use QR code to scan and add the Do_webview component to the HTML page.
- Import Project
- Do_webview components
- Scan function
- Custom events
The demo that will be learned is shown below
1. Import the full project
This section of the sample demo is referenced and can be imported into the designer for learning.
The components to be used in this tutorial are Do_barcodeview the methods taught in the previous tutorials, add these two components ahead of time, and make the appropriate debug package for debugging.
2. Do_webview Components
Do_webview is a powerful component that can access both Web pages and local HTML, as well as nesting deviceone components in HTML pages that perfectly combine H5 pages and deviceone native components.
Analysis of the discovery page we are going to implement, click on the "Scan" button to call Do_barcodeview scan function, QR Code scan, and put a Do_webview component in the center of the page, load the local HTML file, in the file to customize the page style, and the button buttons in the HTML are drawn in response to the Deviceone functions of each component.
For more detailed documentation please see the use of WebView
3. Scanning function
Create a new Scanbarcode.ui page, put a do_barcodeview component in it, click on the "Click to Scan" button to open the page, and call Do_barcodeview scan function scanning QR code, Call Closepage in the successful callback to close the page, here for demonstration purposes only, the results of the normal scan will be returned in the callback function data, the user can get this data to do any action.
4. Custom Events
DeviceOne
Provides an event and message mechanism that developers can use very conveniently. Here's a simple example:
By using on to subscribe to the do_alayout_opt Touch event, fire is used to trigger the event in the right place, and it is important to note that the triggering of the event is required after the subscription.
For more detailed documentation see the event and message mechanism introduction
One app to get started (vii)-Completing the Discovery page