Data acquisition method, device, equipment and storage medium based on H5 page development

By introducing an interface layer and implementation layer in H5 page development and configuring the execution environment according to the pattern type, the problem that H5 page cannot be debugged independently on the computer is solved, improving development efficiency and simplifying code maintenance.

CN112083925BActive Publication Date: 2024-12-03CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202010927073.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-07
Publication Date
2024-12-03
Estimated Expiration
2040-09-07

AI Technical Summary

Technical Problem

In hybrid mobile applications, due to the lack of real App environment during development of H5 pages, it is impossible to independently debug and develop on the computer, which affects development efficiency.

Method used

By introducing preset interface layer and implementation layer in H5 page development, the execution environment is configured according to the page mode type (local development mode or debug mode), and the corresponding implementation layer is called to obtain target data, so as to achieve decoupling and efficiency improvement.

Benefits of technology

In the development of H5 pages, data acquisition in different modes is realized, development efficiency is improved, and code maintenance and reconstruction are simplified through the design of unified interface layer and implementation layer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112083925B_ABST
    Figure CN112083925B_ABST
Patent Text Reader

Abstract

The present invention relates to data processing technology, and provides a data acquisition method, device, equipment and storage medium based on H5 page development. When receiving a request for obtaining data sent by an H5 page, the mode type to which the H5 page belongs is judged based on a preset interface layer, and based on the mode type to which the H5 page belongs, an execution environment corresponding to the mode type is configured for the H5 page, and a preset implementation layer is called based on the configured execution environment to obtain target data corresponding to the request, and the target data is fed back to the H5 page. The present invention can enable the H5 page to call different implementation layers under different execution environments to obtain corresponding target data, avoid the situation where many functions of the H5 page cannot be independently developed and debugged on the computer side, and improve the development efficiency of the H5 page. The present invention also relates to blockchain technology, and data related to the interface layer and target data corresponding to the request can be stored in a blockchain node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data acquisition method, device, equipment and storage medium based on H5 page development. Background Art

[0002] At present, in the hybrid mobile application (Hybrid App) mode, the App has a built-in webview to load the H5 page. H5 can perform some basic functions of the page and call the native functions of the App. When developing H5 pages in this mode, some data interactions with the native App will be encountered. When H5 tries to obtain some data from the native App, the developer must debug it on the real App. Since most of the development work is done on the computer side, and there is no real App environment on the computer side, this greatly affects the development efficiency, resulting in many functions of the H5 page not being able to be independently developed and debugged on the computer side. Summary of the invention

[0003] In view of the above, the present invention provides a data acquisition method, device, equipment and storage medium based on H5 page development, which aims to solve the technical problem that many functions of H5 pages in the prior art cannot be independently developed and debugged on the computer side.

[0004] To achieve the above object, the present invention provides a data acquisition method based on H5 page development, the method comprising:

[0005] When receiving a request for obtaining data sent by the H5 page, determining the mode type to which the H5 page belongs based on a preset interface layer;

[0006] Based on the mode type to which the H5 page belongs, configuring an execution environment corresponding to the mode type for the H5 page;

[0007] Based on the configured execution environment, the preset implementation layer is called to obtain the target data corresponding to the request, and the target data is fed back to the H5 page.

[0008] Preferably, the mode type includes a local development mode and a debugging mode, and the mode type to which the H5 page belongs, configuring the execution environment corresponding to the mode type for the H5 page includes:

[0009] When it is determined that the mode type to which the H5 page belongs is the local development mode, configuring the execution environment of the H5 page to be the first preset execution environment;

[0010] When it is determined that the mode type to which the H5 page belongs is the debugging mode, the execution environment of the H5 page is configured as a second preset execution environment.

[0011] Preferably, the calling of a preset implementation layer based on the configured execution environment to obtain target data corresponding to the request, and feeding back the target data to the H5 page comprises:

[0012] Based on the first preset execution environment, the interface layer is used to call the first preset implementation layer to obtain simulation data corresponding to the request, and the simulation data is fed back to the H5 page;

[0013] Based on the second preset execution environment, the interface layer is used to call the second preset implementation layer to obtain the real data corresponding to the request, and the real data is fed back to the H5 page.

[0014] Preferably, the determining the mode type of the H5 page based on a preset interface layer includes:

[0015] Obtain the identifier carried by the request, determine whether the identifier contains characters corresponding to the local development mode, and if so, determine that the mode type of the H5 page is the local development mode;

[0016] If there is no character corresponding to the local development, it is determined that the mode type to which the H5 page belongs is the debugging mode.

[0017] Preferably, configuring the execution environment of the H5 page as the first preset execution environment includes:

[0018] The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the first preset execution environment.

[0019] Preferably, configuring the execution environment of the H5 page as the second preset execution environment includes:

[0020] The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the second preset execution environment.

[0021] Preferably, the interface layer is developed based on the development code of the interface layer, and the specific development steps of the interface layer include:

[0022] Extract the common parts of the development code of the interface layer, and use the extracted codes to form multiple interface development base classes;

[0023] Constructing an interface development framework according to the association relationship between each interface development base class, wherein the association relationship includes a logical relationship or an execution sequence;

[0024] Receiving a logical interface configuration instruction, and configuring a logical relationship between components corresponding to the logical interface in the interface development framework;

[0025] A general interface configuration instruction is received, components and backend interfaces corresponding to the general interface are configured in the interface development framework, and the configured interface development framework is used as a developed interface layer.

[0026] To achieve the above object, the present invention further provides a data acquisition device based on H5 page development, the data acquisition device based on H5 page development comprises:

[0027] A judgment module: when receiving a request for obtaining data sent by an H5 page, judging the mode type to which the H5 page belongs based on a preset interface layer;

[0028] Configuration module: used for configuring the execution environment corresponding to the mode type for the H5 page based on the mode type to which the H5 page belongs;

[0029] Acquisition module: used to call the preset implementation layer based on the configured execution environment to obtain the target data corresponding to the request, and feed back the target data to the H5 page.

[0030] To achieve the above object, the present invention further provides an electronic device, the electronic device comprising:

[0031] at least one processor; and,

[0032] a memory communicatively connected to the at least one processor; wherein,

[0033] The memory stores a program executable by the at least one processor, and the program is executed by the at least one processor so that the at least one processor can execute any step of the data acquisition method developed based on the H5 page as described above.

[0034] To achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, which includes a data storage area and a program storage area. The data storage area stores data created according to the use of the blockchain node, and the program storage area stores a data acquisition program developed based on the H5 page. When the data acquisition program developed based on the H5 page is executed by the processor, any step of the data acquisition method developed based on the H5 page as described above is implemented.

[0035] The data acquisition method, device, equipment and storage medium based on H5 page development proposed in the present invention call an interface layer uniformly during H5 development, and the interface layer is respectively connected to the implementation layer in the local development mode and the implementation layer in the debugging mode. Different execution environments are configured according to the mode type of the H5 page, so that the H5 page calls different implementation layers in different execution environments to obtain corresponding target data, which can realize decoupling in the development of H5 and greatly improve the development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of a preferred embodiment of the electronic device of the present invention;

[0037] Figure 2 for Figure 1 A schematic diagram of a module of a preferred embodiment of a data acquisition device developed based on an H5 page;

[0038] Figure 3 A flowchart of a preferred embodiment of the data acquisition method developed based on H5 pages of the present invention;

[0039] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0041] Reference Figure 1 FIG. 1 is a schematic diagram of a preferred embodiment of an electronic device 1 of the present invention.

[0042] The electronic device 1 includes but is not limited to: a memory 11, a processor 12, a display 13 and a network interface 14. The electronic device 1 is connected to a network through the network interface 14 to obtain raw data. The network may be a wireless or wired network such as an intranet, the Internet, a global system of mobile communications (GSM), a wideband code division multiple access (WCDMA), a 4G network, a 5G network, Bluetooth, Wi-Fi, a call network, etc.

[0043] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 1, such as a hard disk or memory of the electronic device 1. In other embodiments, the memory 11 can also be an external storage device of the electronic device 1, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped with the electronic device 1. Of course, the memory 11 can also include both the internal storage unit of the electronic device 1 and its external storage device. In this embodiment, the memory 11 is generally used to store the operating system and various application software installed on the electronic device 1, such as the program code of the data acquisition program 10 developed based on the H5 page, etc. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.

[0044] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication. In this embodiment, the processor 12 is used to run the program code stored in the memory 11 or process data, such as running the program code of the data acquisition program 10 developed based on the H5 page.

[0045] The display 13 may be referred to as a display screen or a display unit. In some embodiments, the display 13 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an organic light-emitting diode (OLED) touch device. The display 13 is used to display information processed in the electronic device 1 and to display a visual working interface, such as displaying the results of data statistics.

[0046] The network interface 14 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), and the network interface 14 is generally used to establish a communication connection between the electronic device 1 and other electronic devices.

[0047] Figure 1Only an electronic device 1 having components 11 - 14 and a data acquisition program 10 developed based on an H5 page is shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0048] Optionally, the electronic device 1 may further include a user interface, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an organic light-emitting diode (Organic Light-Emitting Diode, OLED) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.

[0049] The electronic device 1 may further include a radio frequency (RF) circuit, a sensor, an audio circuit, etc., which will not be described in detail here.

[0050] In the above embodiment, the processor 12 can implement the following steps when executing the data acquisition program 10 based on H5 page development and stored in the memory 11:

[0051] When receiving a request for obtaining data sent by the H5 page, determining the mode type to which the H5 page belongs based on a preset interface layer;

[0052] Based on the mode type to which the H5 page belongs, configuring an execution environment corresponding to the mode type for the H5 page;

[0053] Based on the configured execution environment, the preset implementation layer is called to obtain the target data corresponding to the request, and the target data is fed back to the H5 page.

[0054] The storage device may be the memory 11 of the electronic device 1 , or may be another storage device that is communicatively connected to the electronic device 1 .

[0055] For a detailed description of the above steps, please refer to the following Figure 2 Functional module diagram of an embodiment of a data acquisition device 100 developed based on H5 pages and Figure 3 Description of the flowchart of an implementation of a data acquisition method based on H5 page development.

[0056] Reference Figure 2 As shown, it is a functional module diagram of the data acquisition device 100 developed based on the H5 page of the present invention.

[0057] The data acquisition device 100 based on H5 page development of the present invention can be installed in an electronic device. According to the functions to be implemented, the data acquisition device 100 based on H5 page development can include a judgment module 110, a configuration module 120 and an acquisition module 130. The module described in the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.

[0058] In this embodiment, the functions of each module / unit are as follows:

[0059] The judgment module 110 is used to judge the mode type to which the H5 page belongs based on a preset interface layer when receiving a request for obtaining data sent by the H5 page.

[0060] In this embodiment, in the Hybrid App mode, the H5 page can use WebViewJavascriptBridg to call the native functions of the App. Since Native does not exist when the H5 page calls the native Native in the computer development environment, the H5 page cannot complete the call to the native Native in the computer environment.

[0061] When developing H5 for hybrid mobile applications, there will be situations where data interaction with native apps is required. When the H5 page needs to obtain some data from the native app, development must be done on the real app. This greatly affects development efficiency and makes it impossible to develop and debug many H5 functions independently. Therefore, an interface layer and two implementation layers can be developed in advance to ensure that there is always a corresponding implementation layer in the operating environment of the H5 page during the development process.

[0062] When a request for obtaining data sent by an H5 page is received, the mode type of the H5 page is determined based on a pre-developed interface layer, that is, the mode type of the H5 page that needs to obtain data is determined. Furthermore, the mode types include local development mode and debugging mode, that is, it is determined whether the H5 page that needs to obtain data is in local development mode or debugging mode. In actual applications, the data that the H5 page needs to obtain may be obtaining GPS location, OCR recognition of bank card information, obtaining a bank data list, and the like.

[0063] In one embodiment, the interface layer is developed based on the development code of the interface layer, and the specific development steps of the interface layer include:

[0064] Extract the common parts of the development code of the interface layer, and use the extracted codes to form multiple interface development base classes;

[0065] Constructing an interface development framework according to the association relationship between each interface development base class, wherein the association relationship includes a logical relationship or an execution sequence;

[0066] Receiving a logical interface configuration instruction, and configuring a logical relationship between components corresponding to the logical interface in the interface development framework;

[0067] A general interface configuration instruction is received, components and backend interfaces corresponding to the general interface are configured in the interface development framework, and the configured interface development framework is used as a developed interface layer.

[0068] The common parts of the interface code are uniformly constructed into an interface development framework, which is called during development, and only the logical interface and common interface parts are configured, which can improve the development efficiency of the interface layer.

[0069] A module 120 is established, which is used to configure an execution environment corresponding to the mode type for the H5 page based on the mode type to which the H5 page belongs.

[0070] In this embodiment, since the mode types of the H5 pages that need to obtain data are different and their operating environments are also different, the execution environment corresponding to the mode type can be configured for the H5 page based on the mode type to which the H5 page belongs, so that H5 pages of different mode types can obtain data in the corresponding execution environment, wherein the mode types to which the H5 page belongs include local development mode and debugging mode.

[0071] In one embodiment, when it is determined that the mode type to which the H5 page belongs is the local development mode, the execution environment of the H5 page is configured as a first preset execution environment;

[0072] When it is determined that the mode type to which the H5 page belongs is the debugging mode, the execution environment of the H5 page is configured as a second preset execution environment.

[0073] When the H5 page is judged to be in local development mode, since there is no real App environment in computer-side development, the execution environment of the H5 page needs to be switched to the first preset execution environment, where the first preset execution environment can be a mock execution environment. At this time, the implementation layer JavascriptImpl of H5 can be called, that is, the implementation of H5 itself can be called. Since H5 also has its own implementation of the interface, development data can also be obtained at this time. For example: the page needs GPS coordinates, but there is no App environment at this time, so the H5 page directly obtains data from JavascriptImpl. At this time, JavascriptImpl can also return a simulated GPS data to meet the data needs of development.

[0074] When the H5 page is judged to be in debug mode, the execution environment of the H5 page is configured as the second preset execution environment, where the second preset execution environment is the real App environment, and the implementation layer NativeImpl of the App is called. At this time, the native App function is called. The native App returns its method to achieve normal calling. For example: if the page needs GPS coordinates, you can get the GPS coordinates from the App. At this time, the App can get the GPS coordinates through the mobile device's own functions.

[0075] Further, configuring the execution environment of the H5 page as the first preset execution environment includes:

[0076] The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the first preset execution environment. For example, the field value of the Bridge Mock field in the configuration file is configured as mock.

[0077] Further, configuring the execution environment of the H5 page as the second preset execution environment includes:

[0078] The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the second preset execution environment. The field value of the Bridge Mock field in the configuration file is configured as App.

[0079] In one embodiment, the determining the mode type of the H5 page based on a preset interface layer includes:

[0080] Obtain the identifier carried by the request, determine whether the identifier contains characters corresponding to the local development mode, and if so, determine that the mode type of the H5 page is the local development mode;

[0081] If there is no character corresponding to the local development, it is determined that the mode type to which the H5 page belongs is the debugging mode.

[0082] Specifically, window.navigator.userAgent can be used to determine whether the environment to which the H5 page belongs is Android or iOS device (i.e., App environment). In the App environment, window.navigator.userAgent contains the characters "Android", "Adr" or "Mac OS". If the characters "Android", "Adr" or "Mac OS" exist, the H5 page is judged to be in local development mode, otherwise the H5 page is judged to be in debugging mode. Window.navigator.userAgent declares the value of the user agent header used by the browser for HTTP requests, and generally sends a string that can represent the client type, such as browser type operating system and other information.

[0083] The extraction module 130 is used to call the preset implementation layer based on the configured execution environment to obtain the target data corresponding to the request, and feed the target data back to the H5 page.

[0084] In this embodiment, since different execution environments need to call different implementation layers, the preset implementation layer can be called according to the configured execution environment to obtain the target data corresponding to the request, and the target data is fed back to the H5 page. Among them, the preset implementation layer includes a first preset implementation layer and a second preset implementation layer, and the target data includes simulated data and real data.

[0085] In one embodiment, the calling of a preset implementation layer based on the configured execution environment to obtain target data corresponding to the request, and feeding back the target data to the H5 page includes:

[0086] Based on the first preset execution environment, the interface layer is used to call the first preset implementation layer to obtain simulation data corresponding to the request, and the simulation data is fed back to the H5 page;

[0087] Based on the second preset execution environment, the interface layer is used to call the second preset implementation layer to obtain the real data corresponding to the request, and the real data is fed back to the H5 page.

[0088] The first preset implementation layer is a set of methods defined in the interface layer, and all methods are implemented with JS. The H5 implementation layer is also an implementation of the interface layer requirements, and it also needs to provide the functions of obtaining GPS data and obtaining bank data. However, the difference is that the Mock layer is simulated data, which is only used as a substitute data when the real App does not exist.

[0089] The second preset implementation layer is to implement all methods in Android or iOS according to the method set defined in the interface layer, and make them available through unit testing. The App implementation layer is the implementation of the interface layer requirements. The interface layer requires GPS data and bank data, so the App implementation layer needs to provide the actual usable functions of obtaining GPS data and bank data.

[0090] During H5 development, an interface layer is called uniformly. The interface layer is connected to the implementation layer in local development mode and the implementation layer in debug mode respectively. Different execution environments are configured according to the mode type of the H5 page, so that the H5 page calls different implementation layers in different execution environments to obtain the corresponding target data. This can achieve decoupling in H5 development and greatly improve development efficiency. At the same time, the use of interface maintenance can also formulate unified standards to facilitate reading and code reconstruction.

[0091] In addition, the present invention also provides a data acquisition method based on H5 page development. Figure 3 , which is a method flow diagram of an embodiment of the data acquisition method based on H5 page development of the present invention. When the processor 12 of the electronic device 1 executes the data acquisition program 10 based on H5 page development stored in the memory 11, the following steps of the data acquisition method based on H5 page development are implemented:

[0092] Step S10: When a request for obtaining data sent by the H5 page is received, the mode type to which the H5 page belongs is determined based on a preset interface layer.

[0093] In this embodiment, in the Hybrid App mode, the H5 page can use WebViewJavascriptBridg to call the native functions of the App. Since Native does not exist when the H5 page calls the native Native in the computer development environment, the H5 page cannot complete the call to the native Native in the computer environment.

[0094] When developing H5 for hybrid mobile applications, there will be situations where data interaction with native apps is required. When the H5 page needs to obtain some data from the native app, development must be done on the real app. This greatly affects development efficiency and makes it impossible to develop and debug many H5 functions independently. Therefore, an interface layer and two implementation layers can be developed in advance to ensure that there is always a corresponding implementation layer in the operating environment of the H5 page during the development process.

[0095] When a request for obtaining data sent by an H5 page is received, the mode type of the H5 page is determined based on a pre-developed interface layer, that is, the mode type of the H5 page that needs to obtain data is determined. Furthermore, the mode types include local development mode and debugging mode, that is, it is determined whether the H5 page that needs to obtain data is in local development mode or debugging mode. In actual applications, the data that the H5 page needs to obtain may be obtaining GPS location, OCR recognition of bank card information, obtaining a bank data list, and the like.

[0096] In one embodiment, the interface layer is developed based on the development code of the interface layer, and the specific development steps of the interface layer include:

[0097] Extract the common parts of the development code of the interface layer, and use the extracted codes to form multiple interface development base classes;

[0098] Constructing an interface development framework according to the association relationship between each interface development base class, wherein the association relationship includes a logical relationship or an execution sequence;

[0099] Receiving a logical interface configuration instruction, and configuring a logical relationship between components corresponding to the logical interface in the interface development framework;

[0100] A general interface configuration instruction is received, components and backend interfaces corresponding to the general interface are configured in the interface development framework, and the configured interface development framework is used as a developed interface layer.

[0101] The common parts of the interface code are uniformly constructed into an interface development framework, which is called during development, and only the logical interface and common interface parts are configured, which can improve the development efficiency of the interface layer.

[0102] Step S20: Based on the mode type to which the H5 page belongs, configure an execution environment corresponding to the mode type for the H5 page.

[0103] In this embodiment, since the mode types of the H5 pages that need to obtain data are different and their operating environments are also different, the execution environment corresponding to the mode type can be configured for the H5 page based on the mode type to which the H5 page belongs, so that H5 pages of different mode types can obtain data in the corresponding execution environment, wherein the mode types to which the H5 page belongs include local development mode and debugging mode.

[0104] In one embodiment, when it is determined that the mode type to which the H5 page belongs is the local development mode, the execution environment of the H5 page is configured as a first preset execution environment;

[0105] When it is determined that the mode type to which the H5 page belongs is the debugging mode, the execution environment of the H5 page is configured as a second preset execution environment.

[0106] When the H5 page is judged to be in local development mode, since there is no real App environment in computer-side development, the execution environment of the H5 page needs to be switched to the first preset execution environment, where the first preset execution environment can be a mock execution environment. At this time, the implementation layer JavascriptImpl of H5 can be called, that is, the implementation of H5 itself can be called. Since H5 also has its own implementation of the interface, development data can also be obtained at this time. For example: the page needs GPS coordinates, but there is no App environment at this time, so the H5 page directly obtains data from JavascriptImpl. At this time, JavascriptImpl can also return a simulated GPS data to meet the data needs of development.

[0107] When the H5 page is judged to be in debug mode, the execution environment of the H5 page is configured as the second preset execution environment, where the second preset execution environment is the real App environment, and the implementation layer NativeImpl of the App is called. At this time, the native App function is called. The native App returns its method to achieve normal calling. For example: if the page needs GPS coordinates, you can get the GPS coordinates from the App. At this time, the App can get the GPS coordinates through the mobile device's own functions.

[0108] Further, configuring the execution environment of the H5 page as the first preset execution environment includes:

[0109] The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the first preset execution environment. For example, the field value of the Bridge Mock field in the configuration file is configured as mock.

[0110] Further, configuring the execution environment of the H5 page as the second preset execution environment includes:

[0111] The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the second preset execution environment. The field value of the Bridge Mock field in the configuration file is configured as App.

[0112] In one embodiment, the determining the mode type of the H5 page based on a preset interface layer includes:

[0113] Obtain the identifier carried by the request, determine whether the identifier contains characters corresponding to the local development mode, and if so, determine that the mode type of the H5 page is the local development mode;

[0114] If there is no character corresponding to the local development, it is determined that the mode type to which the H5 page belongs is the debugging mode.

[0115] Specifically, window.navigator.userAgent can be used to determine whether the environment to which the H5 page belongs is Android or iOS device (i.e., App environment). In the App environment, window.navigator.userAgent contains the characters "Android", "Adr" or "Mac OS". If the characters "Android", "Adr" or "Mac OS" exist, the H5 page is judged to be in local development mode, otherwise the H5 page is judged to be in debugging mode. Window.navigator.userAgent declares the value of the user agent header used by the browser for HTTP requests, and generally sends a string that can represent the client type, such as browser type operating system and other information.

[0116] Step S30: Based on the configured execution environment, the preset implementation layer is called to obtain the target data corresponding to the request, and the target data is fed back to the H5 page.

[0117] In this embodiment, since different execution environments need to call different implementation layers, the preset implementation layer can be called according to the configured execution environment to obtain the target data corresponding to the request, and the target data is fed back to the H5 page. Among them, the preset implementation layer includes a first preset implementation layer and a second preset implementation layer, and the target data includes simulated data and real data.

[0118] In one embodiment, the calling of a preset implementation layer based on the configured execution environment to obtain target data corresponding to the request, and feeding back the target data to the H5 page includes:

[0119] Based on the first preset execution environment, the interface layer is used to call the first preset implementation layer to obtain simulation data corresponding to the request, and the simulation data is fed back to the H5 page;

[0120] Based on the second preset execution environment, the interface layer is used to call the second preset implementation layer to obtain the real data corresponding to the request, and the real data is fed back to the H5 page.

[0121] The first preset implementation layer is a set of methods defined in the interface layer, and all methods are implemented with JS. The H5 implementation layer is also an implementation of the interface layer requirements, and it also needs to provide the functions of obtaining GPS data and obtaining bank data. However, the difference is that the Mock layer is simulated data, which is only used as a substitute data when the real App does not exist.

[0122] The second preset implementation layer is to implement all methods in Android or iOS according to the method set defined in the interface layer, and make them available through unit testing. The App implementation layer is the implementation of the interface layer requirements. The interface layer requires GPS data and bank data, so the App implementation layer needs to provide the actual usable functions of obtaining GPS data and bank data.

[0123] During H5 development, an interface layer is called uniformly. The interface layer is connected to the implementation layer in local development mode and the implementation layer in debug mode respectively. Different execution environments are configured according to the mode type of the H5 page, so that the H5 page calls different implementation layers in different execution environments to obtain the corresponding target data. This can achieve decoupling in H5 development and greatly improve development efficiency. At the same time, the use of interface maintenance can also formulate unified standards to facilitate reading and code reconstruction.

[0124] In addition, the embodiment of the present invention further proposes a computer-readable storage medium, which may be any one or any combination of a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a USB memory, etc. The computer-readable storage medium includes a data storage area and a program storage area, the data storage area stores data created according to the use of the blockchain node, and the program storage area stores a data acquisition program 10 developed based on the H5 page, and the data acquisition program 10 developed based on the H5 page is executed by the processor to implement the following operations:

[0125] When receiving a request for obtaining data sent by the H5 page, determining the mode type to which the H5 page belongs based on a preset interface layer;

[0126] Based on the mode type to which the H5 page belongs, configuring an execution environment corresponding to the mode type for the H5 page;

[0127] Based on the configured execution environment, the preset implementation layer is called to obtain the target data corresponding to the request, and the target data is fed back to the H5 page.

[0128] In another embodiment, the data acquisition method based on H5 page development provided by the present invention can further ensure the privacy and security of all the above data, and all the above data can also be stored in a blockchain node. For example, data related to the interface layer, target data corresponding to the request, etc., all of these data can be stored in the blockchain node.

[0129] It should be noted that the blockchain referred to in the present invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.

[0130] The specific implementation of the computer-readable storage medium of the present invention is roughly the same as the specific implementation of the data acquisition method based on H5 page development mentioned above, and will not be repeated here.

[0131] It should be noted that the serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising" or any other variants thereof in this article are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "including a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.

[0132] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, including a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, an electronic device, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0133] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A data acquisition method based on H5 page development, applied to electronic devices, characterized in that: The method comprises: A preset interface layer and two preset implementation layers are pre-established, a common part of the development code of the preset interface layer is extracted, the extracted code is used to form a plurality of interface development base classes, and an interface development framework is constructed according to the association relationship between the interface development base classes, wherein the association relationship includes a logical relationship or an execution sequence; Receiving a logical interface configuration instruction, and configuring a logical relationship between components corresponding to the logical interface in the interface development framework; Receiving a general interface configuration instruction, configuring components and backend interfaces corresponding to the general interface in the interface development framework, and using the configured interface development framework as a developed interface layer; When receiving a request for obtaining data sent by the H5 page, determining the mode type to which the H5 page belongs based on the preset interface layer; Based on the mode type to which the H5 page belongs, configuring an execution environment corresponding to the mode type for the H5 page; Based on the configured execution environment, the preset implementation layer is called to obtain the target data corresponding to the request, and the target data is fed back to the H5 page.

2. The data acquisition method based on H5 page development as claimed in claim 1, characterized in that: The mode types include local development mode and debugging mode. Based on the mode type to which the H5 page belongs, configuring the execution environment corresponding to the mode type for the H5 page includes: When it is determined that the mode type to which the H5 page belongs is the local development mode, configuring the execution environment of the H5 page to be the first preset execution environment; When it is determined that the mode type to which the H5 page belongs is the debugging mode, the execution environment of the H5 page is configured as a second preset execution environment.

3. The data acquisition method based on H5 page development as described in claim 2 is characterized in that: The calling of the preset implementation layer based on the configured execution environment to obtain the target data corresponding to the request, and feeding back the target data to the H5 page includes: Based on the first preset execution environment, the interface layer is used to call the first preset implementation layer to obtain simulation data corresponding to the request, and the simulation data is fed back to the H5 page; Based on the second preset execution environment, the interface layer is used to call the second preset implementation layer to obtain the real data corresponding to the request, and the real data is fed back to the H5 page.

4. The data acquisition method based on H5 page development as described in claim 2 or 3, characterized in that: The determining the mode type of the H5 page based on the preset interface layer includes: Obtain the identifier carried by the request, and determine whether the identifier contains characters corresponding to the local development mode. If there are characters corresponding to the local development, it is determined that the mode type of the H5 page is the local development mode; If there is no character corresponding to the local development, it is determined that the mode type to which the H5 page belongs is the debugging mode.

5. The data acquisition method based on H5 page development as described in claim 2 is characterized in that: The configuring the execution environment of the H5 page as the first preset execution environment includes: The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the first preset execution environment.

6. The data acquisition method based on H5 page development as claimed in claim 2, characterized in that: The configuring the execution environment of the H5 page as the second preset execution environment includes: The field value of the Bridge Mock field in the preset configuration file is configured as the field value corresponding to the second preset execution environment.

7. A data acquisition device developed based on H5 pages, characterized in that: The device comprises: Judgment module: used to pre-establish a preset interface layer and two preset implementation layers, extract the common parts in the development code of the preset interface layer, construct multiple interface development base classes with the extracted codes, and construct an interface development framework according to the association relationship between the interface development base classes, wherein the association relationship includes a logical relationship or an execution sequence; receive a logical interface configuration instruction, and configure the logical relationship between the components corresponding to the logical interface in the interface development framework; receive a general interface configuration instruction, and configure the components and back-end interfaces corresponding to the general interface in the interface development framework, and use the configured interface development framework as the interface layer that has been developed; when receiving a request for obtaining data sent by an H5 page, determine the mode type to which the H5 page belongs based on the preset interface layer; Configuration module: used for configuring the execution environment corresponding to the mode type for the H5 page based on the mode type to which the H5 page belongs; Acquisition module: used to call the preset implementation layer based on the configured execution environment to obtain the target data corresponding to the request, and feed back the target data to the H5 page.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a program executable by the at least one processor, and the program is executed by the at least one processor so that the at least one processor can execute the data acquisition method based on H5 page development as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a data storage area and a program storage area. The data storage area stores data created according to the use of the blockchain node, and the program storage area stores a data acquisition program developed based on the H5 page. When the data acquisition program developed based on the H5 page is executed by the processor, the steps of the data acquisition method developed based on the H5 page as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method and device for developing interface layers and realizing data interaction of interface layers

    CN104252339A

  • Front-end code testing method, device and system based on analog data and medium

    CN109726108A

  • Independent development method and device for front-end page, equipment and storage medium

    CN109783078A

  • Test data acquisition method and device, storage medium and computer equipment

    CN110727587A

  • Front-end development method and device, electronic equipment and storage medium

    CN111414154A