Method for applet to communicate with webpage, related device and system
By using a WebSocket server to establish a communication connection between the mini-program and the web client, the problem of mini-programs being unable to use web resources during web browsing is solved, thus improving the user experience.
Patent Information
- Application Number
- CN202111238503.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-25
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2041-10-25
AI Technical Summary
In existing technologies, mini-programs cannot directly use web page resources within the mini-program's Web-View component during web page browsing, resulting in a poor user experience.
The communication connection between the mini-program and the web client is established through a WebSocket server, allowing the mini-program to send messages to the web client and generate a page by calling the web client's native data resources through the WebSocket server, which is then displayed directly within the mini-program's Web-View component.
This improves the user experience, allowing users to directly use web resources within the Mini Program's Web-View component to implement some of the Mini Program's functions while browsing web pages.
Smart Images

Figure CN113934557B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer application, and in particular, to a method for communication between a small program and a webpage, related equipment and system. BACKGROUND
[0002] With the continuous development of mobile application technology, people have higher and higher requirements for the convenience of using mobile application functions. Small programs have emerged as the times require. Small programs do not need to be downloaded and installed to use mobile application programs. Users do not need to worry about the problem of too many application programs occupying too much local resource of mobile terminal. Small programs can usually use Web-View components as containers to carry webpages. When the webpages in the small program Web-View component communicate with the small program through the API (Application Programming Interface, application programming interface) provided by the official application program, the webpages in the small program Web-View component send messages to the small program. Only at a specific time (such as small program back, Web-View component destruction, small program sharing, etc.) can the small program Web-View component trigger the message event and obtain the content of the message. Therefore, this communication method cannot send messages from the small program to the webpages in the small program Web-View component. However, if it is desired to directly use the webpage resources in the small program Web-View component to realize part of the functions of the small program during webpage browsing, the above communication method obviously cannot meet this use requirement, thereby causing poor user experience. SUMMARY
[0003] In view of this, the purpose of the present application is to provide a method for communication between a small program and a webpage, related equipment and system, which can send messages from the small program to the webpages in the small program Web-View component, directly use the webpage resources in the small program Web-View component to realize part of the functions of the small program during webpage browsing, and thereby improve the user experience.
[0004] In a first aspect, embodiments of the present application provide a method for communication between a webpage and an applet, applied to a webpage client, wherein the webpage client and an applet client are connected through a WebSocket server, and the webpage client and the applet client are respectively configured with an identity; the method comprises: receiving a first message of the applet client forwarded by the WebSocket server; obtaining content of the first message; executing a processing instruction corresponding to the content of the first message; calling native data resources corresponding to the webpage client from the WebSocket server to generate a first page corresponding to an execution result of the processing instruction; sending the first page to a Web-View component of the applet client through the WebSocket server; wherein the Web-View component is configured to display the first page.
[0005] In combination with the first aspect, embodiments of the present application provide a first possible implementation manner of the first aspect, wherein the webpage client is pre-configured with a plurality of parameters for executing processing instructions; the step of executing the processing instruction corresponding to the content of the first message comprises: obtaining a first parameter for executing the processing instruction corresponding to the content of the first message from the plurality of parameters for executing processing instructions, and executing the processing instruction corresponding to the content of the first message according to the first parameter.
[0006] In combination with the first aspect, embodiments of the present application provide a second possible implementation manner of the first aspect, wherein the method further comprises: sending a connection request to the WebSocket server to create a connection through the WebSocket server; wherein the connection request carries the identity of the webpage client.
[0007] In combination with the first aspect, embodiments of the present application provide a third possible implementation manner of the first aspect, wherein the method further comprises: in response to a first trigger operation on the first page, canceling display of the first page.
[0008] In a second aspect, the embodiments of the present application further provide a method for communication between a small program and a webpage. The method is applied to a small program client, the small program client and a webpage client are connected through a WebSocket server, and the small program client and the webpage client are respectively configured with an identity. The method comprises the following steps: sending a first message to the webpage client through the WebSocket server; receiving a second page corresponding to an execution result of the first message returned by the webpage client through the WebSocket server; wherein the second page is generated by the webpage client according to a result of calling native data resources corresponding to the webpage client from the WebSocket server and executing processing instructions corresponding to the content of the first message; and displaying the second page through a Web-View component of the small program client.
[0009] With reference to the second aspect, the embodiments of the present application provide a first possible implementation manner of the second aspect, wherein the method further comprises the following steps: sending a connection request to the WebSocket server to create a connection through the WebSocket server; wherein the connection request carries the identity of the small program client.
[0010] With reference to the second aspect, the embodiments of the present application provide a second possible implementation manner of the second aspect, wherein the method further comprises the following step: in response to a second triggering operation on the second page, canceling the display of the second page.
[0011] In a third aspect, the embodiments of the present application further provide a webpage client. The webpage client and a small program client are connected through a WebSocket server, and the webpage client and the small program client are respectively configured with an identity. The webpage client comprises the following modules: a first receiving module, configured to receive a first message of a small program client forwarded by the WebSocket server; a first obtaining module, configured to obtain the content of the first message; a first executing module, configured to execute processing instructions corresponding to the content of the first message; a first page generating module, configured to call native data resources corresponding to the webpage client from the WebSocket server to generate a first page corresponding to the execution result of the processing instructions; and a first page sending module, configured to send the first page to a Web-View component of the small program client through the WebSocket server; wherein the Web-View component is configured to display the first page.
[0012] In a fourth aspect, the embodiments of the present application further provide a mini-program client, wherein the mini-program client and a web client are connected through a WebSocket server, and the mini-program client and the web client are respectively configured with an identity; the mini-program client comprises: a second sending module configured to send a first message to the web client through the WebSocket server; a second receiving module configured to receive a second page corresponding to an execution result of the first message returned by the web client through the WebSocket server; wherein the second page is generated by the web client according to a result of calling native data resources corresponding to the web client from the WebSocket server and executing processing instructions corresponding to the content of the first message; and a second page display module configured to display the second page through a Web-View component of the mini-program client.
[0013] In a fifth aspect, the embodiments of the present application further provide a system for communication between a mini-program and a web page, wherein the system comprises at least a web client, a WebSocket server and a mini-program client, the web client and the mini-program client are connected through the WebSocket server, and the web client and the mini-program client are respectively configured with an identity; the web client is configured to receive a first message of the mini-program client forwarded by the WebSocket server, obtain the content of the first message, execute processing instructions corresponding to the content of the first message, call native data resources corresponding to the web client from the WebSocket server, generate a first page corresponding to an execution result of the processing instructions, and send the first page to a Web-View component of the mini-program client through the WebSocket server; wherein the Web-View component is configured to display the first page; the mini-program client is configured to send a first message to the web client through the WebSocket server, and receive a second page corresponding to an execution result of the first message returned by the web client through the WebSocket server; wherein the second page is generated by the web client according to a result of calling native data resources corresponding to the web client from the WebSocket server and executing processing instructions corresponding to the content of the first message; and the second page is displayed through a Web-View component of the mini-program client.
[0014] The method, related device and system for communicating between the applet and the webpage provided by the embodiments of the present application, after the webpage client receives the first message of the applet client forwarded by the WebSocket server, the webpage client acquires the content of the first message and executes the processing instruction corresponding to the content of the first message, then calls the native data resource corresponding to the webpage client from the WebSocket server and generates the first page corresponding to the processing instruction execution result, and sends the first page to the Web-View component of the applet client through the WebSocket server to display the first page. By using the above technology, the applet can communicate with the webpage in the Web-View component of the applet through the forwarding of the WebSocket server, and the communication opportunity can be selected according to actual needs, and the webpage resource in the Web-View component of the applet can be directly used to realize part of the function of the applet in the webpage browsing process, thereby improving the user experience.
[0015] Other features and advantages of the present application will be set forth in the descriptions below, and in part will become apparent to those skilled in the art upon examination of the following or can be learned by practice of the present application. The objects and other advantages of the present application can be realized and attained by the structure particularly pointed out in the description, claims and drawings.
[0016] In order to make the above objectives, characteristics and advantages of the present application more apparent and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are referred to for detailed description. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0018] Figure 1 The system architecture diagram for communicating between the applet and the webpage provided by the embodiments of the present application is shown in the figure.
[0019] Figure 2 The flowchart of the method for communicating between the applet and the webpage provided by the embodiments of the present application is shown in the figure.
[0020] Figure 3 The flowchart of another method for communicating between the applet and the webpage provided by the embodiments of the present application is shown in the figure.
[0021] Figure 4 The schematic diagram of an applet page provided by the embodiments of the present application is shown in the figure.
[0022] Figure 5Another schematic diagram of a method for communicating between an applet and a webpage provided by an embodiment of the present application is provided;
[0023] Figure 6 A structural schematic diagram of a webpage client provided by an embodiment of the present application is provided;
[0024] Figure 7 Another structural schematic diagram of a webpage client provided by an embodiment of the present application is provided;
[0025] Figure 8 A structural schematic diagram of an applet client provided by an embodiment of the present application is provided;
[0026] Figure 9 Another structural schematic diagram of an applet client provided by an embodiment of the present application is provided. DETAILED DESCRIPTION
[0027] In order to make the objectives, technical solutions and advantages of embodiments of the present application clearer, the technical solutions of the present application will be described below in connection with embodiments. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0028] At present, an applet can usually use a Web-View component as a container for carrying a webpage. When a webpage in the applet Web-View component communicates with the applet through an API (Application Programming Interface) provided by an application program, the webpage in the applet Web-View component sends a message to the applet, and only at a specific time (such as applet back, Web-View component destruction, applet sharing, etc.) can the applet Web-View component trigger the message event and obtain the content of the message. Therefore, the above communication method cannot send a message from the applet to the webpage in the applet Web-View component. However, if it is desired to directly use the webpage resources in the applet Web-View component to realize part of the functions of the applet during webpage browsing, the above communication method obviously cannot meet the use requirement, and thus the user experience is poor. Based on this, the method for communicating between an applet and a webpage, the related device and the system provided by an embodiment of the present application can send a message from the applet to the webpage in the applet Web-View component, and directly use the webpage resources in the applet Web-View component to realize part of the functions of the applet during webpage browsing, thereby improving the user experience.
[0029] For the convenience of understanding the present embodiment, first, a small program and web communication system disclosed by the present embodiment is introduced in detail, referring to Figure 1 The system architecture diagram of the small program and web communication method shown in FIG. 1. The system includes a web client 100, a WebSocket server 300 and a small program client 200. The web client 100 and the small program client 200 are connected in communication through the WebSocket server 300. The web client 100 and the small program client 200 are respectively configured with an identity. The WebSocket server 300 and the web client 100 can be connected with an application program through an API interface. The application program can be an application program installed in the operating system of a terminal device. The application program stores native data resources of the small program. The web client 100 can directly call the corresponding native data resources through the WebSocket server 300 to generate a corresponding page, and send the generated page to the Web-View component of the small program client 200 through the WebSocket server 300 to display the page in the Web-View component.
[0030] In the present embodiment, the web client 100 is deployed with a Web-View component of the small program, which can be used to display the H5 page of the small program. The small program client 200 is deployed with a virtual environment of the small program, which can be used to run the logic code of the small program developer to realize the business logic of the small program.
[0031] Next, the small program and web communication method provided by the present embodiment is introduced from the perspective of the H5 page in the web client, i.e. the small program Web-View component.
[0032] Referring to Figure 2 The flowchart of the small program and web communication method shown in FIG. 2. The execution subject of the method is the web client. The method includes the following steps:
[0033] Step S202, receiving the first message of the small program client forwarded by the WebSocket server.
[0034] Specifically, when the small program client communicates with the web client through the WebSocket server, the small program client sends the first message to the WebSocket server. The WebSocket server forwards the first message after receiving the first message. Since the WebSocket server has specified the sender of the first message (i.e. the small program client) and the receiver of the first message (i.e. the web client) when creating the connection, the WebSocket server forwards the first message to the web client.
[0035] In step S204, the content of the first message is acquired.
[0036] Specifically, the web client parses the first message to acquire the content of the first message after receiving the first message. In actual application, the content of the first message can usually include a message header, a method name, a message body, etc., which can be determined according to actual needs, and is not limited herein.
[0037] In step S206, the processing instruction corresponding to the content of the first message is executed.
[0038] Specifically, since the web client needs to execute the processing instruction corresponding to the content of the first message according to a certain method after acquiring the content of the first message, the parameters for executing the processing instruction need to be pre-configured on the web client or carried by the first message. Taking the case that the parameters for executing the processing instruction are pre-configured on the web client as an example, the web client can acquire the parameters for executing the processing instruction by searching local data resources after acquiring the content of the first message, and execute the processing instruction corresponding to the content of the first message according to the parameters. Taking the case that the parameters for executing the processing instruction are carried by the first message as an example, the web client can determine the parameters for executing the processing instruction according to the content of the first message after acquiring the content of the first message, and execute the processing instruction corresponding to the content of the first message according to the parameters.
[0039] In step S208, the native data resource corresponding to the web client is called from the WebSocket server to generate a first page corresponding to the processing instruction execution result.
[0040] Specifically, after the web client executes the processing instruction corresponding to the content of the first message, the WebSocket server can call the native data resource corresponding to the web client through a specified APK interface, and send the native data resource to the web client. After receiving the native data resource, the web client generates a corresponding page (i.e., the first page) according to the native data resource, and the content in the page represents the processing instruction execution result (e.g., execution success or failure).
[0041] In step S210, the first page is sent to the Web-View component of the applet client through the WebSocket server; wherein the Web-View component is used to display the first page.
[0042] Specifically, the web client sends the first page to the WebSocket server after generating the first page; the WebSocket server forwards the first page to the Web-View component of the applet client after receiving the first page, so as to display the first page through the Web-View component of the applet client.
[0043] The method for communication between the applet and the webpage provided by the embodiment of the present application comprises the following steps: the web client acquires the content of the first message and executes the processing instruction corresponding to the content of the first message after receiving the first message forwarded by the WebSocket server; then the web client calls the native data resource corresponding to the web client from the WebSocket server and generates the first page corresponding to the processing instruction execution result; and finally the web client sends the first page to the Web-View component of the applet client through the WebSocket server to display the first page. By using the above-mentioned technology, the communication between the applet and the webpage in the Web-View component of the applet can be realized through the forwarding of the WebSocket server, and the communication opportunity can be selected according to actual needs. In the process of webpage browsing, the webpage resource in the Web-View component of the applet can be directly used to realize part of the function of the applet, thereby improving the user experience.
[0044] On the basis of the above-mentioned method for communication between the applet and the webpage, in order to further improve the communication efficiency, a plurality of parameters of the execution processing instruction can be configured in advance on the web client; based on this, the execution of the processing instruction corresponding to the content of the first message in the above-mentioned step S206 can adopt the following operation mode: the first parameter of the execution processing instruction corresponding to the content of the first message is acquired from the plurality of parameters of the execution processing instruction, and the processing instruction corresponding to the content of the first message is executed according to the first parameter.
[0045] On the basis of the above-mentioned method for communication between the applet and the webpage, in order to ensure the accuracy of the communication, the above-mentioned method can further comprise the following operation mode: a connection request is sent to the WebSocket server to create a connection through the WebSocket server; wherein the connection request carries the identity of the web client.
[0046] Specifically, the identity identifier can be an ID number. In order to realize normal communication between the WebSocket server and the webpage client, the webpage client first sends a connection request to the WebSocket server, and then the WebSocket server parses the received connection request to obtain the content of the connection request, and obtains the ID number of the webpage client. The WebSocket server can create a corresponding connection according to the ID number, generate a response message corresponding to the connection request, and return the response message to the webpage client. By using this operation mode, a unique correspondence between different webpage clients and the WebSocket server can be established, thereby ensuring the accuracy of communication between the webpage client and the WebSocket server.
[0047] In addition, for the case that multiple webpage clients need to communicate with the WebSocket server, after receiving the connection requests sent by the multiple webpage clients, the WebSocket server can determine the sender of the connection request (i.e. the receiver of the response message corresponding to the connection request) according to the identity identifier of the different webpage clients, and then create a connection containing the identity identifiers of all webpage clients that need to communicate. By using this operation mode, the WebSocket server only needs to establish one connection to realize normal communication with different webpage clients respectively, which can further improve the communication efficiency compared with the mode of creating a connection for each webpage client that sends a connection request.
[0048] In view of the fact that the user needs to close the page after browsing the page in actual application, the above method can further include the following operation mode: in response to a first trigger operation on the first page, the first page is displayed. Specifically, in order to facilitate operation, a close control can be provided in the above first page, and the above first trigger operation can be a finger pressing operation on the close control; after the user presses the close control in the first page by the finger, the webpage client will cancel the display of the first page in response to the operation.
[0049] Next, the method for communicating between the applet and the webpage provided by the embodiment of the application is introduced from the perspective of the applet client, i.e. the applet business logic.
[0050] Referring to Figure 3 The execution subject of the method is an applet client, and the method includes the following steps:
[0051] Step S302: sending a first message to the webpage client through the WebSocket server.
[0052] Step S304: Receive the second page corresponding to the execution result of the first message returned by the web client through the WebSocket server; wherein, the second page is generated by the web client based on the result of calling the native data resources corresponding to the web client from the WebSocket server and executing the processing instructions corresponding to the content of the first message.
[0053] Step S306: Display the second page through the Web-View component of the mini-program client.
[0054] The above method may also include the following operation: sending a connection request to a WebSocket server to create a connection through the WebSocket server; wherein the connection request carries the identity identifier of the mini-program client.
[0055] The above method may also include the following operation: in response to a second trigger operation targeting the second page, cancel the display of the second page. The second trigger operation is similar to the first trigger operation and will not be described in detail here.
[0056] For ease of description, the working process of the above-mentioned method for communication between the mini-program and the webpage is described below using a real-world application scenario as an example.
[0057] See Figure 4 The diagram shows a mini-program page. The content displayed on the mini-program page includes a mini-program Web-View component, which displays an H5 page. The H5 page displays a payment button. Figure 4 (Represented by a rounded rectangle with the word "payment" inscribed on it). Based on Figure 4 This invention also provides another method for communication between a mini-program and a webpage, see [link to relevant documentation]. Figure 5 The diagram illustrates another method of communication between a mini-program and a webpage. This is for ease of description. Figure 5 In this method, "H5 page" represents the web client, "mini-program page" represents the mini-program client, and "WebSocket service" represents the WebSocket server; the method adopts the following operation mode:
[0058] The user first clicks a payment button by a finger; the web page client sends a payment instruction to the WebSocket server in response to the operation; the WebSocket server forwards the payment instruction to the applet client; the applet client receives the payment instruction and executes the instruction and sends an instruction execution result to the web page client, and the web page client generates a payment interface to represent that the instruction execution result is that the instruction is executed successfully; the user performs a corresponding payment operation on the payment interface, and the web page client sends a payment completion result to the applet client in response to successful completion of the payment operation; the applet client receives the payment completion result and sends a payment completion instruction to the WebSocket server; the WebSocket server forwards the payment completion instruction to the web page client; the web page client receives the payment completion instruction, executes the instruction, and generates a payment completion interface to represent that the instruction execution result is that the instruction is executed successfully.
[0059] Based on the above method embodiment, the embodiment of the application further provides a web page client, as shown in Figure 6 The web page client comprises:
[0060] A first receiving module 602 is configured to receive a first message of an applet client forwarded by a WebSocket server.
[0061] A first obtaining module 604 is configured to obtain content of the first message.
[0062] A first execution module 606 is configured to execute a processing instruction corresponding to the content of the first message.
[0063] A first page generation module 608 is configured to call native data resources corresponding to the web page client from the WebSocket server, and generate a first page corresponding to a processing instruction execution result.
[0064] A first page sending module 610 is configured to send the first page to a Web-View component of the applet client through the WebSocket server; the Web-View component is configured to display the first page.
[0065] The web page client can be preconfigured with a plurality of parameters of execution processing instructions; based on this, the first execution module 606 is further configured to obtain a first parameter of an execution processing instruction corresponding to the content of the first message from the plurality of parameters of execution processing instructions, and execute the execution processing instruction corresponding to the content of the first message according to the first parameter.
[0066] Based on the above web page client, the embodiment of the application further provides another web page client, as shown in Figure 7 The web page client further comprises:
[0067] The first connection module 612 is configured to send a connection request to the WebSocket server to create a connection through the WebSocket server, wherein the connection request carries an identity of the web client.
[0068] The first display canceling module 614 is configured to cancel display of the first page in response to a first trigger operation on the first page.
[0069] Based on the above method embodiments, the embodiments of the present application further provide a mini-program client, as shown in Figure 8 The mini-program client comprises:
[0070] The second sending module 802 is configured to send a first message to a web client through the WebSocket server.
[0071] The second receiving module 804 is configured to receive a second page corresponding to an execution result of the first message returned by the web client through the WebSocket server, wherein the second page is generated by the web client according to a result of calling a native data resource corresponding to the web client from the WebSocket server and a processing instruction corresponding to content of the first message.
[0072] The second page display module 806 is configured to display the second page through a Web-View component of the mini-program client.
[0073] Based on the above mini-program client, the embodiments of the present application further provide another mini-program client, as shown in Figure 9 The mini-program client further comprises:
[0074] The second connection module 808 is configured to send a connection request to the WebSocket server to create a connection through the WebSocket server, wherein the connection request carries an identity of the mini-program client.
[0075] The second display canceling module 810 is configured to cancel display of the second page in response to a second trigger operation on the second page.
[0076] Based on the above method embodiments, the embodiments of the present application further provide a system for communication between a mini-program and a web page, the system comprising at least a web client, a WebSocket server and a mini-program client, the web client and the mini-program client being communicatively connected through the WebSocket server, and the web client and the mini-program client being respectively configured with an identity;
[0077] The web page client is configured to receive the first message of the applet client forwarded by the WebSocket server, obtain the content of the first message, execute a processing instruction corresponding to the content of the first message, call native data resources corresponding to the web page client from the WebSocket server, generate a first page corresponding to an execution result of the processing instruction, send the first page to a Web-View component of the applet client through the WebSocket server, and display the first page on the Web-View component.
[0078] The applet client is configured to send a first message to a web page client through the WebSocket server, receive a second page corresponding to an execution result of the first message returned by the web page client through the WebSocket server, display the second page on a Web-View component of the applet client, and generate the second page according to the execution of native data resources corresponding to the web page client from the WebSocket server and a processing instruction corresponding to the content of the first message.
[0079] The system provided by the embodiments of the present application has the same implementation principle and technical effects as the method embodiments, and for brevity, the part not mentioned in the system embodiment can be referred to the corresponding content in the method embodiments.
[0080] Finally, it should be noted that: the above-described embodiments are merely specific implementations of the present application, which are used to illustrate the technical solutions of the present application, but not to limit the present application, the protection scope of the present application is not limited to this, although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art in the technical range disclosed by the present application, it can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and all should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for communicating between an applet and a web page, characterized by, The application is applied to a webpage client, the webpage client and a small program client are connected through a WebSocket server, the webpage client and the small program client are respectively configured with an identity, and the webpage client is pre-configured with a plurality of parameters of execution processing instructions; the method comprises the following steps: receiving a first message of the small program client forwarded by the WebSocket server; obtaining the content of the first message; obtaining a first parameter of a processing instruction corresponding to the content of the first message from the plurality of parameters of execution processing instructions, and executing the processing instruction corresponding to the content of the first message according to the first parameter; calling native data resources corresponding to the webpage client from the WebSocket server to generate a first page corresponding to the processing instruction execution result; the content in the first page is used to represent the processing instruction execution result; the small program client is used to receive a second page corresponding to the processing instruction execution result returned by the webpage client through the WebSocket server; wherein the second page is generated by the webpage client according to the results of calling native data resources corresponding to the webpage client from the WebSocket server and executing the processing instruction corresponding to the content of the first message; sending the first page to a Web-View component of the small program client through the WebSocket server; wherein the Web-View component is used to display the first page; the small program client is also used to display the second page through the Web-View component of the small program client.
2. The method of claim 1, wherein the applet communicates with the web page by, The method further comprises: sending a connection request to the WebSocket server to create a connection through the WebSocket server; wherein the connection request carries the identity of the webpage client.
3. The method of claim 1, wherein the applet communicates with the web page by, The method further comprises: in response to a first trigger operation on the first page, canceling the display of the first page.
4. A method for communicating between an applet and a web page, characterized by, The application is applied to a small program client, the small program client and a webpage client are connected through a WebSocket server, the small program client and the webpage client are respectively configured with an identity, and the webpage client is pre-configured with a plurality of parameters of execution processing instructions; the method comprises the following steps: sending a first message to a webpage client through the WebSocket server; the webpage client is used to obtain the content of the first message, and obtain a first parameter of a processing instruction corresponding to the content of the first message from the plurality of parameters of execution processing instructions, and then execute the processing instruction corresponding to the content of the first message according to the first parameter; receive, by the WebSocket server, a second page corresponding to an execution result of the first message returned by the web page client; wherein the second page is generated by the web page client according to a result of calling native data resources corresponding to the web page client from the WebSocket server and executing a processing instruction corresponding to the content of the first message; the web page client is further configured to call the native data resources corresponding to the web page client from the WebSocket server to generate a first page corresponding to an execution result of the processing instruction; and the content in the first page is used to represent the execution result of the processing instruction; display, by a Web-View component of the applet client, the second page; the web page client is further configured to send the first page to the Web-View component of the applet client through the WebSocket server; and the Web-View component is configured to display the first page.
5. The method of claim 4, wherein the applet communicates with the web page by, The method further comprises: sending a connection request to the WebSocket server to create a connection through the WebSocket server; wherein the connection request carries an identity of the applet client.
6. The method of claim 4, wherein the applet communicates with the web page by, The method further comprises: in response to a second triggering operation on the second page, cancel displaying the second page.
7. A web page client, characterized by The web page client and the applet client are connected through a WebSocket server, and the web page client and the applet client are respectively configured with an identity; the web page client is pre-configured with a plurality of execution processing instruction parameters; The web page client comprises: a first receiving module configured to receive a first message of an applet client forwarded by the WebSocket server; a first obtaining module configured to obtain content of the first message; a first execution module configured to obtain a first parameter of a processing instruction corresponding to the content of the first message from the plurality of execution processing instruction parameters, and execute the processing instruction corresponding to the content of the first message according to the first parameter; a first page generation module configured to call native data resources corresponding to the web page client from the WebSocket server to generate a first page corresponding to an execution result of the processing instruction; the content in the first page is used to represent the execution result of the processing instruction; the applet client is configured to receive, by the WebSocket server, a second page corresponding to the execution result of the processing instruction returned by the web page client; wherein the second page is generated by the web page client according to a result of calling native data resources corresponding to the web page client from the WebSocket server and executing a processing instruction corresponding to the content of the first message; The first page sending module is configured to send the first page to a Web-View component of the applet client through the WebSocket server; the Web-View component is configured to display the first page; and the applet client is further configured to display the second page through the Web-View component of the applet client.
8. An applet client, characterized by The applet client and the webpage client are connected through a WebSocket server, and the applet client and the webpage client are respectively configured with an identity; the webpage client is pre-configured with a plurality of parameters of execution processing instructions; The applet client comprises: The second sending module is configured to send a first message to the webpage client through the WebSocket server; the webpage client is configured to obtain the content of the first message, and obtain a first parameter of a processing instruction corresponding to the content of the first message from the plurality of parameters of execution processing instructions, and then execute the processing instruction corresponding to the content of the first message according to the first parameter; The second receiving module is configured to receive a second page corresponding to an execution result of the first message returned by the webpage client through the WebSocket server; the second page is generated by the webpage client according to a native data resource corresponding to the webpage client and a result of executing the processing instruction corresponding to the content of the first message by calling the native data resource from the WebSocket server; the webpage client is further configured to generate a first page corresponding to the execution result of the processing instruction by calling the native data resource corresponding to the webpage client from the WebSocket server; and the content in the first page is used to represent the execution result of the processing instruction. The second page display module is configured to display the second page through a Web-View component of the applet client; the webpage client is further configured to send the first page to the Web-View component of the applet client through the WebSocket server; and the Web-View component is configured to display the first page.
9. A system for applet to web page communication, characterized by The system comprises at least a webpage client, a WebSocket server and an applet client; the webpage client and the applet client are connected through the WebSocket server; the webpage client and the applet client are respectively configured with an identity; and the webpage client is pre-configured with a plurality of parameters of execution processing instructions; The webpage client is configured to receive a first message of an applet client forwarded by the WebSocket server; obtain the content of the first message; obtain a first parameter of a processing instruction corresponding to the content of the first message from the plurality of parameters of execution processing instructions, and execute the processing instruction corresponding to the content of the first message according to the first parameter; The WebSocket server is called to invoke a native data resource corresponding to the webpage client, and a first page corresponding to the processing instruction execution result is generated; the WebSocket server is used to send the first page to a Web-View component of the applet client; the Web-View component is used to display the first page, and content in the first page is used to represent the processing instruction execution result. The applet client is configured to: send a first message to a webpage client through the WebSocket server; receive a second page corresponding to an execution result of the first message returned by the webpage client through the WebSocket server; the second page is generated by the webpage client according to a result of invoking a native data resource corresponding to the webpage client from the WebSocket server and executing a processing instruction corresponding to content of the first message; and display the second page through a Web-View component of the applet client.
Citation Information
Patent Citations
A 3D door and window display method and system based on a WeChat applet
CN109684002A
Customer service function access method and related device
CN111371676A