Interaction Method, Device, and Computer Equipment between Application and Web Page
By obtaining call requests and saving transmission information in the WeChat applet, combining cache and page fallback mechanisms, real-time communication between the applet and H5 is realized, solving the problem of the official API restrictions of WeChat applets, and improving the real-timeness of online medical services.
Patent Information
- Application Number
- CN202310859831.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-12
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2043-07-12
AI Technical Summary
In the prior art, the communication between WeChat applet and H5 cannot be achieved due to the limitation of WeChat official API, resulting in insufficient real-time communication of online medical services.
By obtaining the call request initiated by the web page to the application, the transmission information is saved to the cache based on the preset message queue rules, and immediately jump to the current page after falling back to the previous page at a specific time, combining encryption processing to realize real-time communication between the applet and H5.
Real-time communication between mini programs and H5 is realized, real-time performance of online medical services is improved, and visually unaware, breaking through the limitations of WeChat mini programs' official API.
Smart Images

Figure CN116881602B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of digital medical technologies, and particularly to an interaction method, apparatus, and computer device between an application program and a web page. Background Art
[0002] The interaction between an application program and a web page refers to the interaction between a native mini-program and a mobile front-end page (H5) nested in the form of a WebView in the WeChat mini-program environment, that is, realizing mutual page jumps and mutual information transmission between the two pages. For example: real-time mutual communication between page A of mini-program A and page B of H5, or page A of the mini-program jumps to page B of H5, and then returns from page B of H5 to page A of the mini-program or jumps to page C of the mini-program, etc.
[0003] Currently, in the medical field, many medical services are gradually digitized, and WeChat is the most frequently used digital tool in people's daily lives. Therefore, many medical services have rushed to develop WeChat mini-programs to follow the trend of digitalization of medical services.
[0004] In some WeChat mini-programs for medical services, these mini-programs use the postMessage method to receive messages sent by H5 to the mini-program. According to the description of the official application program interface (API) of WeChat mini-programs, this API is not real-time. It is a queue. Although H5 will send the message at that time, the mini-program does not receive it in real-time. The mini-program will only trigger the receiving function when the mini-program goes back, the component is destroyed, or shared. For some medical services, for medical information that needs to be obtained in real-time, the mini-program using the postMessage method will have a lag in information acquisition, which obviously cannot meet the requirements of real-time communication. Summary of the Invention
[0005] The purpose of this application is to solve at least to a certain extent the problems in the prior art, and provide an interaction method, apparatus, and computer device between an application program and a web page, which can break through the limitations of the official API documentation of WeChat mini-programs, realize real-time communication between the mini-program and H5, and improve the real-time performance of online medical services.
[0006] The technical solution of the embodiment of this application is as follows:
[0007] In a first aspect, this application provides an interaction method between an application program and a web page, and the method includes:
[0008] Obtain a call request initiated by the web page to the application program, where the call request carries transmission information;
[0009] According to the call request, save the transmission information to the cache based on a preset message queue rule, and set the current page address and page marker corresponding to the current web page;
[0010] In response to the execution result of the message queue rule, roll back the current web page to the previous page corresponding to the current web page based on a preset page rollback rule;
[0011] In response to the operation of rolling back to the previous page, when it is detected that the page marker exists in the cache, immediately jump to the current web page corresponding to the current page address and delete the page marker;
[0012] Obtain the feedback information returned by the application according to the call request, where the feedback information carries link parameters;
[0013] Modify the attribute parameters in a preset call component based on the link parameters to transfer data.
[0014] According to some embodiments of the present application, after immediately jumping to the current web page corresponding to the current page address, the method further includes:
[0015] Obtain the transmission information from the cache;
[0016] Obtain the feedback information based on the transmission information to transmit the feedback information to the current web page.
[0017] According to some embodiments of the present application, the obtaining the feedback information based on the transmission information to transmit the feedback information to the current web page includes:
[0018] Execute the response operation corresponding to the transmission information to obtain an execution result;
[0019] Obtain the identification field of the execution result;
[0020] Perform encryption processing on the identification field to obtain ciphertext information;
[0021] Use the ciphertext information to replace the identification field in the execution result to obtain the feedback information to transmit the feedback information to the current web page.
[0022] According to some embodiments of the present application, the modifying the attribute parameters in a preset call component based on the link parameters to transfer data includes:
[0023] Obtain the ciphertext information in the link parameters;
[0024] Perform decryption processing on the ciphertext information to obtain the identification field;
[0025] Replace the ciphertext information in the feedback information with the identification field to obtain a first plaintext parameter;
[0026] Modify the attribute parameters in a preset call component based on the first plaintext parameter to transfer data.
[0027] According to some embodiments of the present application, after encrypting the identification field to obtain ciphertext information, the method further includes:
[0028] Perform an encryption verification process on the ciphertext information to obtain encryption verification information;
[0029] Replace the identification field in the execution result with the encryption verification information to obtain the feedback information, so as to transmit the feedback information to the current web page.
[0030] According to some embodiments of the present application, the modifying the attribute parameters in a preset call component based on the link parameter to transfer data further includes:
[0031] Obtain the encryption verification information in the link parameter;
[0032] Verify the encryption verification information. If the verification is passed, obtain the ciphertext information, perform a decryption process on the ciphertext information to obtain the identification field;
[0033] Replace the ciphertext information in the feedback information with the identification field to obtain a second plaintext parameter;
[0034] Modify the attribute parameters in a preset call component based on the second plaintext parameter to transfer data.
[0035] According to some embodiments of the present application, the method further includes: when the encryption process and the decryption process exceed a preset processing time, transmit exception information to a background program;
[0036] Receive a status code returned by the background program, and send the status code to a client, and the client displays a login page for re-login.
[0037] In a second aspect, the present application provides an interaction device between an application program and a web page, and the device includes:
[0038] An information acquisition module, configured to acquire a call request initiated by a web page to an application program, where the call request carries transmission information;
[0039] An information storage module, configured to store the transmission information into a cache based on a preset message queue rule according to the call request, and set a current page address and a page flag corresponding to the current web page;
[0040] A page rollback module, configured to roll back the current web page to the previous page corresponding to the current web page based on a preset page rollback rule in response to an execution result of the message queue rule;
[0041] A jump module, configured to, in response to an operation of rolling back to the previous page, immediately jump to the current web page corresponding to the current page address and delete the page flag when detecting that the page flag exists in the cache;
[0042] An information feedback module, configured to obtain feedback information returned by the application program according to the call request, where the feedback information carries link parameters;
[0043] A data processing module, configured to modify attribute parameters in a preset call component based on the link parameters to transmit data.
[0044] In a third aspect, the present application provides a computer device, where the computer device includes a memory and a processor, and computer-readable instructions are stored in the memory. When the computer-readable instructions are executed by one or more of the processors, one or more of the processors are caused to execute the steps of any one of the methods described in the first aspect above.
[0045] In a fourth aspect, the present application further provides a computer-readable storage medium, where the storage medium can be read and written by a processor, and computer-readable instructions are stored in the storage medium. When the computer-readable instructions are executed by one or more processors, one or more of the processors are caused to execute the steps of any one of the methods described in the first aspect above.
[0046] The technical solution provided by the embodiments of the present application has the following beneficial effects:
[0047] An embodiment of the present application provides a method, device, and computer device for interaction between an application and a web page. The method for interaction between the application and the web page first obtains a call request initiated by the web page to the application, where the call request carries transmission information; according to the call request, the transmission information is saved to a cache based on a preset message queue rule for subsequent calls, and the current page address and page marker corresponding to the current web page are set; in response to the execution result of the message queue rule, the current web page is reverted to the previous page corresponding to the current web page based on a preset page back rule, and a specific timing is triggered by reverting to the previous page; then, in response to the operation of reverting to the previous page, when it is detected that there is a page marker in the cache, the current web page corresponding to the current page address is immediately jumped to, and the page marker is deleted to achieve real-time communication between the web page and the applet; the return information returned by the application according to the call request is obtained, and the return information carries link parameters; the attribute parameters in a preset call component are modified based on the link parameters to transfer data, thereby achieving real-time communication between the applet and the web page. Compared with the prior art where an applet and H5 can only communicate at specific timings, after the applet reverts to the previous page to trigger a specific timing in an embodiment of the present application and then immediately jumps to the current web page, it can not only achieve real-time communication between the web page and the applet, but also make the user unaware visually, breaking through the limitations of the official API documentation of WeChat applets, achieving mutual real-time communication between the applet and H5, and improving the real-time performance of online medical services. Description of the Drawings
[0048] Figure 1 is a schematic flowchart of a method for interaction between an application and a web page provided by an embodiment of the present application;
[0049] Figure 2 is a schematic flowchart of a method for interaction between an application and a web page provided by another embodiment of the present application;
[0050] Figure 3 is Figure 2 a sub-step flowchart of step S220 in
[0051] Figure 4 is Figure 1 a sub-step flowchart of step S160 in
[0052] Figure 5 is Figure 2 another sub-step flowchart of step S220 in
[0053] Figure 6 is Figure 1 another sub-step flowchart of step S160 in
[0054] Figure 7It is a schematic flowchart of an interaction method between an application program and a web page provided by another embodiment of the present application;
[0055] Figure 8 It is a schematic structural diagram of an interaction device between an application program and a web page provided by an embodiment of the present application;
[0056] Figure 9 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0058] It should be noted that unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0059] First, several terms involved in the present application are analyzed:
[0060] The postMessage() method: The postMessage() method allows scripts from different origins to communicate asynchronously in a limited way and can achieve cross-document, multi-window, and cross-domain message passing. The postMessage(data, origin) method accepts two parameters: (1) data: the data to be transmitted. The html5 specification mentions that this parameter can be any basic type of JavaScript or a copyable object. However, not all browsers have achieved this. Some browsers can only handle string parameters. Therefore, when transmitting parameters, the JSON.stringify() method needs to be used to serialize object parameters. Referencing json2.js in lower version IE can achieve a similar effect; (2) origin: a string parameter indicating the origin of the target window, protocol + host + port number [+ URL]. The uniform resource locator (URL) will be ignored, so it can be not written. This parameter is for security considerations. The postMessage() method will only transmit the message to the specified window. The parameter can also be set to "*", so that it can be transmitted to any window. If it is necessary to specify the same origin as the current window, it is set to " / ".
[0061] In the related art, when H5 communicates with a mini-program, the postMessage method can be used. The mini-program will trigger the receiving function only when the mini-program goes back, a component is destroyed, or shared. However, in actual development scenarios, what should be done if the interaction requirement is to transfer data in real time? That is to say, how can the current page be retained so that the mini-program can immediately receive information?
[0062] Based on this, an embodiment of the present application proposes an interaction method, device, and computer device between an application and a web page. The interaction method between the application and the web page first obtains a call request initiated by the web page to the application, and the call request carries transmission information; according to the call request, the transmission information is saved to a cache based on a preset message queue rule for subsequent calls, and the current page address and page mark corresponding to the current web page are set; in response to the execution result of the message queue rule, the current web page is rolled back to the previous page corresponding to the current web page based on a preset page rollback rule, and a specific timing is triggered by rolling back to the previous page; then, in response to the operation of rolling back to the previous page, when it is detected that there is a page mark in the cache, it immediately jumps to the current web page corresponding to the current page address, deletes the page mark, and realizes real-time communication from the web page to the mini-program; obtains the feedback information returned by the application according to the call request, and the feedback information carries link parameters; modifies the attribute parameters in the preset call component based on the link parameters to transfer data, thereby realizing real-time communication from the mini-program to the web page. Compared with the prior art where the mini-program and H5 can only communicate at specific times, after triggering a specific timing by rolling back the mini-program to the previous page in the embodiment of the present application, and then immediately jumping to the current web page, it can not only realize real-time communication between the web page and the mini-program, but also make the user unaware visually, break through the limitations of the official API documentation of WeChat mini-programs, realize mutual real-time communication between the mini-program and H5, and improve the real-time performance of online medical services.
[0063] It should be noted that the interaction method between the application and the web page is implemented through the uni-app framework. Real-time communication between a WeChat mini-program and a web page can be achieved in the uni-app framework, and it can also be applied to real-time communication between a mini-program of a QQ application software and a web page, realizing real-time communication between a QQ mini-program and a web page. It can also be real-time communication between a mini-program and a web page in other application software. As the development of application software progresses, it is applicable to similar problems, which will not be elaborated here. Among them, the application mentioned in the embodiment of the present application is a mini-program embedded in an application software.
[0064] It should be noted that in each specific embodiment of the present application, when it comes to performing relevant processing based on data related to the user's identity or characteristics, such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first. Moreover, the collection, use, and processing of such data will comply with relevant laws, regulations, and standards. In addition, when the embodiments of the present application need to obtain the user's sensitive personal information, the user's separate permission or separate consent will be obtained through methods such as pop-up windows or redirecting to a confirmation page. After clearly obtaining the user's separate permission or separate consent, the necessary user-related data for the normal operation of the embodiments of the present application will be obtained.
[0065] The embodiments of the present application can be used in numerous general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and so on. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0066] The following will describe the interaction method, device, and computer device between an application program and a web page provided by the embodiments of the present application with reference to the accompanying drawings.
[0067] See Figure 1 , Figure 1 FIG. shows a schematic flowchart of the interaction method between an application program and a web page provided by the embodiments of the present application. The interaction method between the application program and the web page includes but is not limited to steps S110, S120, S130, S140, S150, and S160.
[0068] Step S110: Obtain a call request initiated by the web page to the application program, where the call request carries transmission information.
[0069] In one embodiment, on the H5 page of the web-view, when the H5 needs to communicate with a mini-program, a call request initiated by the web page to the application is obtained. The call request carries transmission information. Here, the application is a mini-program, and the web page can be a mobile front-end page written in the fifth-generation HyperText Markup Language, abbreviated as H5, or a front-end page written in other version languages, which will not be elaborated here. That is to say, the H5 sends the transmission information to the mini-program, and by sending the transmission information, subsequent operations of backtracking and storing information are triggered.
[0070] Step S120: According to the call request, save the transmission information to the cache based on a preset message queue rule, and set the current page address and page mark corresponding to the current web page.
[0071] In one embodiment, according to the call request of the H5 to the mini-program, the transmission information is saved to the local cache through a preset message queue rule. The current page of the H5 is also set with the corresponding current page address and page mark. The page mark is denoted as flag, and the current page address and page mark are also saved to the cache, which is beneficial for subsequent obtaining of corresponding information through the cache to achieve information communication. Among them, the preset message queue rule is the postMessage() method; the cache can also be the cache of cloud services, and it is only necessary to be able to quickly read the content in the cache, which will not be elaborated here; the current page address can be the Uniform Resource Locator (URL) of the current page.
[0072] Step S130: In response to the execution result of the message queue rule, backtrack the current web page to the previous page corresponding to the current web page based on a preset page backtracking rule.
[0073] In one embodiment, after saving the transmission information, the current page address, and the page mark to the local cache through a preset message queue rule, the current web page is backtracked to the previous page corresponding to the current web page by using a preset page backtracking rule, thereby triggering a specific timing so that the mini-program can receive the transmission information. Among them, the preset page backtracking rule can be the navigateBack function; the previous page corresponding to the current web page refers to the previous page accessed when accessing the current web page.
[0074] Step S140: In response to the operation of backtracking to the previous page, when it is detected that there is a page mark in the cache, immediately jump to the current web page corresponding to the current page address and delete the page mark.
[0075] In one embodiment, in order to ensure that the current web page is still on the current web page during real-time communication, after returning to the previous page through the preset page fallback rule, if the cache is detected to have a page mark, it will immediately jump to the current web page corresponding to the current page address and delete the page mark. Since the above fallback operation and jump operation are completed in a very short time, the user is visually unaware, thereby achieving information transmission with the mini program when the user is on the current web page in terms of visual perception.
[0076] For example, a user needs to go to the hospital for medical treatment, but the hospital is an appointment system and needs to make an appointment. The user then inquires about the hospital's appointment quota through the WeChat applet. Here, the user initiates a request to obtain medical information from the hospital's H5 page for appointment booking through the WeChat applet. At this time, after the H5 page responds to this request, it will call the relevant function and return relevant medical information such as the available appointment quota and the available appointment time period. In the process of returning these medical messages, these medical messages will generate a call request in the corresponding call function as transmission information. After generating the call request, H5 will first initiate a call request carrying the transmission information to the WeChat applet. After receiving this call request, the applet will save the transmission information carried in the call request in the user's local cache based on the preset message queue rules, and mark the H5 page for appointment booking as a flag, and then save the flag mark and the page address of this H5 page together with the transmission information to the user's local cache. After the save is completed, the preset page rollback rule is triggered, and the H5 is rolled back to the corresponding previous H5 page. At this time, the rollback action triggers the postMessage() method in the WeChat applet, thereby triggering the receiving function of the WeChat applet, so as to obtain relevant appointment medical messages in real time, thereby improving the real-time performance of online medical services. In addition to triggering the postMessage() method, the rollback action will also trigger the detection program to detect whether the flag tag is cached in the local cache. If so, it will jump back to this page according to the page address of the H5 page for appointment to see a doctor in the local cache, and delete the page tag to reduce the cache consumption of local users.
[0077] In another embodiment, when no page mark is detected in the cache, indicating that the H5 web page executes a jump operation from the web page to the mini program, the jump operation is directly executed to jump to the mini program page.
[0078] like Figure 2 As shown, after immediately jumping to the current web page corresponding to the current page address, the interaction method between the application and the web page also includes but is not limited to the following steps:
[0079] Step S210, obtaining transmission information from the cache.
[0080] In one embodiment, according to the transmission information, current page address, and page marker saved in the local cache, the transmission information is read from the local cache so that the subsequent applet can perform an operation corresponding to the transmission information according to the transmission information, thereby feeding back the transmission information.
[0081] Step S220, obtain the feedback information based on the transmission information to transmit the feedback information to the current web page.
[0082] As Figure 3 shown, obtaining the feedback information based on the transmission information to transmit the feedback information to the current web page includes, but is not limited to, the following steps:
[0083] Step S221, perform the response operation corresponding to the transmission information to obtain the execution result.
[0084] In one embodiment, the applet performs the response operation corresponding to the transmission information according to the indication of the transmission information to obtain the execution result, which is beneficial to subsequent identification and extraction processing of the execution result. Exemplarily, the transmission information is a parameter for obtaining the login information of the applet page, and the execution result returned by the applet is the URL of the applet, and the login information parameter is carried in the URL.
[0085] Step S222, obtain the identification field of the execution result.
[0086] In one embodiment, according to the execution result obtained in step S221, obtaining the identification field in the execution result is beneficial to subsequent encryption processing of the identification field to ensure information security. Exemplarily, a preset character matching algorithm can be used to obtain the identification field in the execution result, obtain the login information parameter in the URL, and the URL can be expressed in the following form: website + token=&age=0&city=M, and the token character is identified through the preset character matching algorithm, and the information after the token character is obtained as the identification field.
[0087] Step S223, perform encryption processing on the identification field to obtain ciphertext information.
[0088] In one embodiment, the identification field is encrypted using a symmetric encryption algorithm to obtain ciphertext information, and the ciphertext information is the secret key generated by symmetric encryption. Encryption processing can ensure the security of data transmission. Among them, the symmetric encryption algorithm can be the AED encryption algorithm or other symmetric encryption algorithms, which will not be elaborated here.
[0089] Step S224, use the ciphertext information to replace the identification field in the execution result to obtain the feedback information, and transmit the feedback information to the current web page.
[0090] In one embodiment, since the identification field is extracted from the execution result by recognizing token characters in step S222, and the ciphertext information obtained in step S223 is used to replace the identification field in the execution result to obtain the feedback information, it can be seen that the identification field in the feedback information is encrypted data. In the case of a network attack or packet capture operation when transmitting the feedback information to the current web page, the security of the information can be guaranteed.
[0091] As Figure 5 shown, after encrypting the identification field to obtain ciphertext information, the interaction method between the application and the web page further includes but is not limited to the following steps:
[0092] Step S225, perform an encryption verification process on the ciphertext information to obtain encryption verification information.
[0093] In one embodiment, the security of the transmitted feedback information can be guaranteed through steps S221 to S224. However, during the transmission process, if the ciphertext information, that is, the secret key, is intercepted by a packet capture tool, it may also lead to information insecurity. Therefore, an information digest algorithm is used to perform an encryption verification process on the ciphertext information to obtain encryption verification information, and by performing encryption again, the security of the transmitted information is further guaranteed. Among them, the information digest algorithm can be the MD5 algorithm, and different-digit MD5 algorithms can be selected and set according to actual needs, which will not be elaborated here.
[0094] Step S226, use the encryption verification information to replace the identification field in the execution result to obtain the feedback information, so as to transmit the feedback information to the current web page.
[0095] In one embodiment, the encryption verification information obtained in step S225 is used to replace the identification field in the execution result to obtain the feedback information. It can be seen that the identification field in the feedback information is data encrypted again. Transmitting the feedback information to the current web page further guarantees the security of the information.
[0096] Step S150, obtain the feedback information returned by the application according to the call request, and the feedback information carries link parameters.
[0097] In one embodiment, when the applet obtains the feedback information based on the transmission information according to the call request and transmits the feedback information to the H5 page, obtain the feedback information returned by the applet. The feedback information carries link parameters, which is beneficial to modifying the parameters of the web page according to the carried link parameters later to realize the communication between the applet and the H5 page.
[0098] Step S160, modify the attribute parameters in the preset call component based on the link parameters to transfer data.
[0099] As Figure 4As shown, modifying the attribute parameters in the preset call component based on the link parameters to transfer data includes but is not limited to the following steps:
[0100] Step S161, obtain the ciphertext information in the link parameters.
[0101] In one embodiment, according to the link parameters obtained in step S150, obtaining the ciphertext information in the link parameters is beneficial for subsequent decryption processing of the ciphertext information to obtain the plaintext data. Exemplarily, obtain the login information parameter in the link parameters, identify the token character through a preset character matching algorithm, and obtain the ciphertext information after the token character.
[0102] Step S162, perform decryption processing on the ciphertext information to obtain an identification field.
[0103] In one embodiment, use the decryption algorithm of the symmetric encryption algorithm to perform decryption processing on the ciphertext information to obtain an identification field. By performing decryption processing, the transmitted information can be obtained. Among them, the decryption algorithm of the symmetric encryption algorithm can be the AED decryption algorithm or other symmetric decryption algorithms. Corresponding to the encryption operation of the above symmetric encryption algorithm, as long as symmetric encryption and decryption can be performed, it will not be elaborated here.
[0104] Step S163, use the identification field to replace the ciphertext information in the feedback information to obtain the first plaintext parameter.
[0105] In one embodiment, step S161 extracts the ciphertext information from the link parameters, uses the identification field obtained in step S162 to replace the ciphertext information in the feedback information to obtain the first plaintext parameter. It can be seen that the identification field in the feedback information is the decrypted data, and the obtained first plaintext parameter is beneficial for subsequent modification of the web page parameters. Among them, the first plaintext parameter is the link parameter obtained by performing symmetric decryption only once.
[0106] Step S164, modify the attribute parameters in the preset call component based on the first plaintext parameter to transfer data.
[0107] In one embodiment, the preset call component can be a web-view component, which is a container of the carrier. Modify the attribute parameters in the web-view component according to the first plaintext parameter to transfer data, so that the web page can receive the feedback information of the applet. Exemplarily, the attribute parameter is the link parameter in the src attribute of the web-view component, which corresponds to the link parameter in the first plaintext parameter, so as to obtain the feedback information.
[0108] As Figure 6 shown, modifying the attribute parameters in the preset call component based on the link parameters to transfer data further includes but is not limited to the following steps:
[0109] Step S165: Obtain the encrypted verification information in the link parameter.
[0110] In one embodiment, obtaining the encrypted verification information in the link parameter is beneficial for subsequent verification processing of the encrypted verification information to obtain the ciphertext information. Exemplarily, obtain the login information parameter in the link parameter, identify the token character through a preset character matching algorithm, and obtain the encrypted verification information after the token character.
[0111] Step S166: Verify the encrypted verification information. When the verification passes, obtain the ciphertext information, and perform decryption processing on the ciphertext information to obtain the identification field.
[0112] In one embodiment, since the MD5 algorithm is used to perform encrypted verification processing on the ciphertext information, when the encrypted verification information is obtained, the encrypted verification information is verified. When the verification passes, the ciphertext information is obtained, and then the decryption algorithm of the symmetric encryption algorithm is used to perform decryption processing on the ciphertext information to obtain the identification field. By performing decryption processing, the transmitted information can be obtained. Among them, the decryption algorithm of the symmetric encryption algorithm can be the AED decryption algorithm or other symmetric decryption algorithms. Corresponding to the encryption operation of the above symmetric encryption algorithm, as long as symmetric encryption and decryption can be performed, it will not be elaborated here; the process of verifying the encrypted verification information is specifically as follows: use MD5 to perform encrypted verification processing on the ciphertext information, and compare whether the obtained encrypted verification information is consistent. If it is consistent, the verification passes; if it is inconsistent, the verification fails. Since MD5 encryption is an irreversible encryption algorithm, the characteristic of the irreversible encryption algorithm is that no key is required during the encryption process. After the plaintext is input, it is directly processed into ciphertext through the encryption algorithm, and this encrypted data cannot be decrypted, thus ensuring the security of the data.
[0113] In another embodiment, when the verification fails, it proves that the transmitted ciphertext information has been tampered with and the transmitted feedback information is untrustworthy. The terminal page can display abnormal information to play a warning role. By verifying the encrypted verification information, it is ensured that the obtained information is trustworthy and secure.
[0114] Step S167: Use the identification field to replace the ciphertext information in the feedback information to obtain the second plaintext parameter.
[0115] In one embodiment, after the encrypted verification information is verified in step S166, the ciphertext information is obtained, and the identification field obtained by decrypting the ciphertext information is used to replace the ciphertext information in the feedback information to obtain the second plaintext parameter. It can be seen that the identification field in the feedback information is the decrypted data, and the obtained second plaintext parameter is beneficial for subsequent modification of the web page parameters. Among them, the second plaintext parameter is the link parameter obtained by performing secondary decryption.
[0116] Step S168: Modify the property parameters in the preset call component based on the second plaintext parameter to transfer data.
[0117] In one embodiment, the preset call component can be a web-view component, which is a container of the carrier. Modify the property parameters in the web-view component according to the second plaintext parameter to transfer data, so that the web page can receive the callback information of the applet. Exemplarily, the property parameter is the link parameter in the src attribute of the web-view component, which corresponds to the link parameter in the second plaintext parameter, so as to obtain the callback information.
[0118] Exemplarily, the obtained execution result URL representation is website + token=&age=0&city=M. Obtain the identification field of the execution result, encrypt the values of age and city parameters after the token character using AES encryption to obtain the secret key aeskey. The secret key can be 8, 16, or 32 bits. In this embodiment, it is set to 8 bits, and aesKey represents 1kikw78q. Then use the MD5 algorithm to perform encryption verification processing on aeskey to obtain the encryption verification information, and the encryption verification information is expressed as:
[0119] encryptValue1 = 6pmSr5ceJEL3SLmynh / gJ55t4IosAibRcz0Lc5t0 / cg=
[0120] Replace the identification field in the execution result with the encrypted verification information to obtain the feedback information, which can be expressed in the form of a website + token. The representation forms of the token character and the identification field are as follows: token=&encryptValue1=6pmSr5ceJEL3SLmynh / gJ55t4IosAibRcz0Lc5t0 / cg=. The feedback information is obtained through secondary encryption, making the data transmission more secure and further ensuring the security of the transmitted information. After transmitting the obtained feedback information to the web page, the web page obtains the link parameters, extracts the encrypted verification information in the link parameters, and the encrypted verification information corresponds to encryptValue1=6pmSr5ceJEL3SLmynh / gJ55t4IosAibRcz0Lc5t0 / cg=. Verify the encrypted information. In the case of successful verification, obtain the ciphertext information, that is, the symmetric encryption key aeskey, and then decrypt the encrypted verification information to obtain the identification field, expressed as token=&age=0&city=M. Subsequently, use the identification field to replace the ciphertext information in the feedback information to obtain the second plaintext parameter, and the second plaintext parameter is expressed in the form of a URL. Exemplarily, the website + token=&age=0&city=M. Through the above encryption and decryption process, the real-time communication between pages is secure and reliable, avoiding the leakage of user information and achieving privacy protection.
[0121] In one embodiment, when obtaining the call request initiated by the web page to the application, the call request carries the transmission information. Transmit the transmission information to the applet. The web page encrypts the transmission information using symmetric encryption to avoid the leakage of private data during the process of transmitting the information to the applet. Receive the transmitted encrypted parameters through the preset loading method set on the applet page, and use the decryption function corresponding to the symmetric encryption to decrypt to obtain the transmission information. Encrypt some parameters carrying user information or sensitive data to ensure the security of the entire interaction process. It is also possible to perform MD5 encryption on the key obtained after the web page is symmetrically encrypted. The applet first performs MD5 verification and then decrypts to further ensure the security of the interaction process.
[0122] As Figure 7 shown, the interaction method between the application and the web page further includes but is not limited to the following steps:
[0123] Step S310, in the case where the encryption process and the decryption process exceed the preset processing time, transmit the exception information to the background program.
[0124] In one embodiment, the preset processing time can be 4 seconds or 5 seconds, which will not be elaborated here. In the case where the encryption process and the decryption process exceed the preset processing time, abnormal information is transmitted to the background program, and the abnormal information can be that the symmetric encryption key is cracked or leaked. By setting the processing time limit, the security of the mini-program and H5 interactive communication can be ensured from multiple dimensions. Exemplarily, under normal circumstances and when the network is not too poor, the entire communication process can be completed within 2 seconds. The user starts encrypting the data to be communicated at 10:10:10, and if the decryption function has not been executed by 10:10:15, then even if the decryption is performed later, when it is determined that the time difference has exceeded 5 seconds, no response processing will be done on the decrypted information, and abnormal information will be transmitted to the background program. The symmetric encryption key is encrypted and verified to ensure that the key for each person after each login is different. At the same time, it is also stipulated that the time difference between the encryption process and the decryption process cannot exceed 5 seconds, so as to ensure the security of the mini-program and H5 interactive communication from multiple dimensions.
[0125] Step S320: Receive the status code returned by the background program, and send the status code to the client. The client displays the login page for re-login.
[0126] In one embodiment, by transmitting abnormal information to the background program, after receiving the abnormal information, the background program makes the identification field in an invalid state and returns the status code. The status code is sent to the client, and the client immediately responds after receiving the status code: clears the current local cache, login information, and user information, displays the login page for re-login. When the user logs in, the page information of the mini-program will also be updated. By re-logging in, information leakage can be avoided.
[0127] See Figure 8, an embodiment of the present application provides an interaction device 100 between an application and a web page. The interaction device 100 between the application and the web page uses an information acquisition module 110 to acquire a call request initiated by the web page to the application, and the call request carries transmission information; then uses an information storage module 120 to save the transmission information to a cache based on a preset message queue rule according to the call request for subsequent calls, and sets the current page address and page mark corresponding to the current web page; subsequently, a page back module 130 responds to the execution result of the message queue rule and backs the current web page back to the previous page corresponding to the current web page based on a preset page back rule, triggering a specific timing by backing to the previous page; then, in response to the operation of backing to the previous page, a jump module 140 immediately jumps to the current web page corresponding to the current page address and deletes the page mark when detecting that there is a page mark in the cache, realizing real-time communication between the web page and the applet; uses an information feedback module 150 to acquire feedback information returned by the application according to the call request, and the feedback information carries link parameters; then a data processing module 160 modifies the attribute parameters in a preset call component based on the link parameters to transfer data, thereby realizing real-time communication between the applet and the web page and improving the real-time performance of online medical services.
[0128] It should be noted that the information acquisition module 110 is connected to the information storage module 120, the information storage module 120 is connected to the page back module 130, the page back module 130 is connected to the jump module 140, the jump module 140 is connected to the information feedback module 150, and the information feedback module 150 is connected to the data processing module 160. The above interaction method between the application and the web page acts on the interaction device 100 between the application and the web page. After the interaction device 100 between the application and the web page triggers a specific timing by backing the applet to the previous page, it immediately jumps to the current web page, which can not only realize real-time communication between the web page and the applet, but also make the user unaware visually, break through the limitations of the official API document of WeChat applet, realize mutual real-time communication between the applet and H5, and improve the real-time performance of online medical services.
[0129] The embodiments described in the embodiments of the present application are for more clearly explaining the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art know that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0130] Figure 9 Fig. shows a computer device 500 provided by an embodiment of the present application. The computer device 500 can be a server or a terminal, and the internal structure of the computer device 500 includes but is not limited to:
[0131] A memory 510 for storing programs;
[0132] A processor 520 for executing the programs stored in the memory 510. When the processor 520 executes the programs stored in the memory 510, the processor 520 is used to execute the above-mentioned interaction method between the application program and the web page.
[0133] The processor 520 and the memory 510 can be connected via a bus or other means.
[0134] The memory 510, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs, such as the interaction method between the application program and the web page described in any embodiment of the present application. The processor 520 realizes the above-mentioned interaction method between the application program and the web page by running the non-transitory software programs and instructions stored in the memory 510.
[0135] The memory 510 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store the execution of the above-mentioned interaction method between the application program and the web page. In addition, the memory 510 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory 510 may optionally include a memory remotely set relative to the processor 520, and these remote memories can be connected to the processor 520 through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0136] The non-transitory software programs and instructions required to implement the above-mentioned interaction method between the application program and the web page are stored in the memory 510. When executed by one or more processors 520, they execute the interaction method between the application program and the web page provided in any embodiment of the present application.
[0137] An embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions for executing the above-mentioned interaction method between the application program and the web page.
[0138] In one embodiment, the storage medium stores computer-executable instructions, which are executed by one or more control processors 520, for example, by a processor 520 in the above-mentioned computer device 500, so that the one or more processors 520 execute the interaction method between the application program and the web page provided in any embodiment of the present application.
[0139] The embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In the specification of this application and the above-mentioned drawings, terms such as "first", "second", "third", etc. (if any) are used to distinguish similar objects and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that comprises a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0141] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally means that the associated objects before and after are in an "or" relationship. "At least one (one) of the following" or its similar expression means any combination of these items, including any combination of single item (one) or plural items (ones). For example, at least one (one) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0142] Those of ordinary skill in the art will understand that all or some of the steps and systems disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, communication media typically includes computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery media.
[0143] The above is a specific description of the preferred embodiment of the present application, but the present application is not limited to the above embodiments. Those skilled in the art can make various equivalent deformations or substitutions without departing from the spirit of the present application. These equivalent deformations or substitutions are all included within the scope defined by the claims of the present application.
Claims
1. A method for interaction between an application program and a web page, characterized in that The method includes: Obtain a call request initiated by a web page for an application, where the call request carries transmission information; According to the call request, save the transmission information to a cache based on a preset message queue rule, and set the current page address and page mark corresponding to the current web page; In response to the execution result of the message queue rule, based on a preset page rollback rule, roll back the current web page to the previous page corresponding to the current web page; In response to the operation of rolling back to the previous page, when it is detected that the page mark exists in the cache, immediately jump to the current web page corresponding to the current page address, and delete the page mark; Obtain the transmission information from the cache; Execute the response operation corresponding to the transmission information to obtain an execution result; Perform encryption processing on the execution result to obtain a return message, so as to transmit the return message to the current web page, and the return message carries link parameters; Perform decryption processing on the link parameters to obtain a first plaintext parameter; Modify the parameter attributes in a preset call component based on the first plaintext parameter to transfer data.
2. The method according to claim 1, characterized in that, The performing encryption processing on the execution result to obtain a return message, so as to transmit the return message to the current web page, includes: Obtain the identification field of the execution result; Perform encryption processing on the identification field to obtain ciphertext information; Use the ciphertext information to replace the identification field in the execution result to obtain the return message, so as to transmit the return message to the current web page.
3. The method according to claim 2, wherein The performing decryption processing on the link parameters to obtain a first plaintext parameter includes: Obtain the ciphertext information in the link parameters; Perform decryption processing on the ciphertext information to obtain the identification field; Use the identification field to replace the ciphertext information in the return message to obtain a first plaintext parameter.
4. The method according to claim 2, characterized in that, After performing encryption processing on the identification field to obtain ciphertext information, the method further includes: Perform encryption verification processing on the ciphertext information to obtain encryption verification information; Use the encryption verification information to replace the identification field in the execution result to obtain the return message, so as to transmit the return message to the current web page.
5. The method according to claim 4, wherein The modifying the attribute parameters in a preset call component based on the link parameters to transfer data further includes: Obtain the encryption verification information in the link parameters; Verify the encryption verification information, and when the verification passes, obtain the ciphertext information, perform decryption processing on the ciphertext information pair to obtain the identification field; Use the identification field to replace the ciphertext information in the return message to obtain a second plaintext parameter; Modify the attribute parameters in a preset call component based on the second plaintext parameter to transfer data.
6. The method according to claim 3, wherein The method further includes: when the encryption processing and decryption processing exceed a preset processing time, transmit exception information to a background program; Receive the status code returned by the background program, and send the status code to a client, and the client displays a login page for re-login.
7. An interaction device between an application and a web page, characterized in that, Includes: An information acquisition module, configured to acquire a call request initiated by a web page for an application, where the call request carries transmission information; An information storage module, configured to save the transmission information to a cache based on a preset message queue rule according to the call request, and set a current page address and a page marker corresponding to the current web page; A page rollback module, configured to roll back the current web page to the previous page corresponding to the current web page based on a preset page rollback rule in response to an execution result of the message queue rule; A jump module, configured to immediately jump to the current web page corresponding to the current page address and delete the page marker when it is detected that the page marker exists in the cache in response to an operation of rolling back to the previous page; An information feedback module, configured to obtain the transmission information from the cache; Execute a response operation corresponding to the transmission information to obtain an execution result; Perform an encryption process on the execution result to obtain feedback information, so as to transmit the feedback information to the current web page, where the feedback information carries link parameters; A data processing module, configured to perform a decryption process on the link parameters to obtain a first plaintext parameter; Modify parameter attributes in a preset call component based on the first plaintext parameter to transmit data.
8. A computer device, characterized in that, The computer device includes a memory and a processor. When computer-readable instructions stored in the memory are executed by one or more of the processors, the one or more processors are caused to execute the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The storage medium is readable and writable by a processor. When computer-readable instructions stored in the storage medium are executed by one or more processors, the one or more processors are caused to execute the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Small program page skipping method, device and equipment and computer readable storage medium
CN112052064A
Applet and webview data exchange method and device and storage medium
CN112162871A