Request processing method and device and electronic equipment

A technology for request processing and sub-pages, applied in the field of data processing, which can solve the problems of providing shopping cart data and server difficulties.

Active Publication Date: 2021-01-08
BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
7 Cites 0 Cited by

AI-Extracted Technical Summary

Problems solved by technology

If the user is not logged in, the server cannot identify which user sent the shopping cart update request, and can only save the shopping cart data of the IP address based on the IP address in the request; and if the u...
View more

Abstract

The invention provides a request processing method and device and electronic equipment, and the method comprises the steps: responding to a request for adding a target commodity to a shopping cart, and detecting the login state of a current client; and if the current client does not log in, storing the commodity information of the target commodity in a local storage area of the current client. Inthe mode, when the client is in the non-login state, the commodity information added to the shopping cart is stored in the local storage area of the current client, and compared with the mode of storing the shopping cart data through a server, on one hand, complete shopping cart data can be provided for a user in different network environments, and on the other hand, unnecessary server overhead and network overhead are also reduced.

Application Domain

Buying/selling/leasing transactionsTransmission

Technology Topic

Web environmentEngineering +5

Image

  • Request processing method and device and electronic equipment
  • Request processing method and device and electronic equipment
  • Request processing method and device and electronic equipment

Examples

  • Experimental program(1)

Example Embodiment

[0026] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. the embodiment. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts belong to the protection scope of the present invention.
[0027] In the related technology, the shopping cart service in the shopping website requires the cooperation of the front-end client and the back-end server. For example, when the user adds product A to the shopping cart, the client sends a shopping cart update request to the server, and the server updates the product information of product A to the user's shopping cart data, and the server saves the user's shopping cart data, and Return the user's complete shopping cart data to the client. If the user is not logged in, the server cannot identify which user sent the shopping cart update request, and can only save the shopping cart data of the IP address based on the IP address in the request; and if the user changes the network environment, the IP If the address changes, it will be difficult for the server to provide complete shopping cart data to the user, and at the same time it will bring unnecessary server overhead and network overhead. , this technology can be applied to devices such as mobile phones, computers, tablet computers, etc., and especially can be applied to devices with a shopping function.
[0028] In order to facilitate the understanding of this embodiment, a request processing method disclosed in the embodiment of the present invention is firstly introduced in detail, as shown in figure 1 As shown, the method includes the following steps:
[0029] Step S102, in response to the request of adding the target product to the shopping cart, detect the current login status of the client.
[0030] The aforementioned current client may be a web browser, an application program with a shopping function, and the like. Specifically, when a user conducts cloud shopping through a client in a mobile phone, computer, or other device, he or she can browse the products displayed on the shopping page through the shopping page provided by the current client, and select the target product from it; The control of the shopping cart, which adds the target item to the shopping cart. In response to the request of adding the target product to the shopping cart, the current client can detect the login status of the current client through the shopping page to which the target product belongs, or the subpage loaded by the shopping page to which the target product belongs, that is, whether there is an account (or user ) to log in.
[0031] Step S104, if the current client is not logged in, save the commodity information of the target commodity to the local storage area of ​​the current client.
[0032] The product information of the above-mentioned target product includes information such as the name, attribute, category, and quantity of the product; the above-mentioned local storage area of ​​the current client includes the local storage area corresponding to the first shopping page to which the target product belongs, and may also include the first shopping page to which the target product belongs. A local storage area corresponding to a specified subpage loaded in a shopping page. The local storage area is usually the storage space set by the web browser, which is used to save the shopping data of the current client.
[0033] Specifically, if the current client is not logged in, the product information of the target product can be saved to the local storage area corresponding to the first shopping page to which the target product belongs through the first shopping page to which the target product belongs; The specified subpage loaded on the first shopping page saves the commodity information of the target commodity to a local storage area corresponding to the specified subpage loaded on the first shopping page to which the target commodity belongs.
[0034] In this embodiment, the local storage area of ​​the current client includes: a local storage area corresponding to the specified subpage loaded in the first shopping page to which the target product belongs.
[0035] Wherein, the process of loading the specified subpage in the first shopping page can be completed in the following manner: run the current client, and when the first shopping page is opened, the first shopping page loads a preset front-end SDK (Software Development Kit, software development Toolkit); through the pre-set front-end SDK, set the webpage label to the first shopping page.
[0036]A specified subpage can be loaded through the above webpage tag; usually when the first shopping page contains the webpage tag, it is equivalent to nesting another small browser in the current first shopping page (also called the parent webpage), The small browser can also load designated subpages (also called subpages) like a normal browser. In addition, create a display component of the shopping cart on the first shopping page and display the first shopping page; the webpage label of the first shopping page is hidden and not displayed on the user interface; the display component of the shopping cart is mainly used for display Currently added product information, including product quantity, etc.
[0037] The embodiment of the present invention provides a request processing method, which detects the login status of the current client in response to the request of adding the target product to the shopping cart; if the current client is not logged in, saves the product information of the target product locally on the current client storage area. In this method, when the client is not logged in, the product information added to the shopping cart is saved to the local storage area of ​​the current client. Compared with the method of saving shopping cart data through the server, on the one hand, it can be used in different network environments Both can provide users with complete shopping cart data, on the other hand, it also reduces unnecessary server overhead and network overhead.
[0038] This embodiment also provides another request processing method, which is implemented on the basis of the above-mentioned embodiments. This embodiment focuses on the specific implementation process of the step of detecting the login status of the current client (realized by step S202), and the target The specific implementation process of the step of saving the product information of the product to the local storage area of ​​the current client (realized by step S204), and the specific realization of the steps after the step of saving the product information of the target product to the local storage area of ​​the current client process (realized through steps S206-S210).
[0039] The local storage area in the foregoing embodiments includes: a localstorage storage object; the local storage area of ​​this kind of localstorage storage object, only the first shopping page of the current client can visit; and each webpage domain name has its own independent storage area; for example, the first The domain name of the first shopping page is a.com, and the domain name of the second shopping page is b.com. At this time, the first shopping page cannot access the data stored in the storage area of ​​the second shopping page.
[0040] The localstorage storage object can only be accessed by the client. Compared with the cookie storage object, both the client and the server can access the data in the storage area. The data is sent to the server along with the http request when the user is logged in or not logged in. However, the data stored in the cookie storage object may be redundant to the current request, so it may bring additional network traffic overhead. In this embodiment, the local storage area includes: localstorage storage object, which can avoid the above problems.
[0041] like figure 2 As shown, the method includes the following steps:
[0042] Step S202, in response to the request for adding the target product to the shopping cart, send the request to a specified subpage, so as to detect the current login status of the client through the specified subpage.
[0043] The above request usually includes information about the target product, such as the name, attributes, quantity, etc. of the target product; after receiving the request to add the target product to the shopping cart on the first shopping page, the interface function can be used to The request is sent to the designated subpage; after receiving the request from the first shopping page, the designated subpage will detect the login status of the current client to determine whether the current client is logged in.
[0044] Wherein, the first shopping page communicates with the specified subpage loaded by the first shopping page through the postMessage interface function; wherein, the postMessage interface function is a standard communication mechanism between the parent webpage and the child webpage, through the postMessage interface function, the parent webpage and the child webpage Web pages can send messages to each other and receive messages from each other at the same time. That is, after the first shopping page receives the request to add the target product to the shopping cart, it can send the request to the specified subpage through the postMessage interface function.
[0045] Step S204, if the current client is not logged in, update the product information of the target product to the shopping cart data saved in the local storage area corresponding to the designated subpage through the specified subpage; wherein, the shopping cart data includes: added to the shopping cart The product information of the product.
[0046] Specifically, if the specified subpage detects that the current client is not logged in, the product information of the target product can be incrementally stored and updated to the shopping cart data stored in the local storage area corresponding to the specified subpage; that is, the specified subpage If m data is stored in the shopping cart data stored in the local storage area corresponding to the page, and then n data is stored in it, then the shopping cart data stored in the local storage area corresponding to the specified subpage includes two data m and n. If the product information of the target product is the same as the product in the shopping cart data stored in the local storage area corresponding to the specified subpage, only the quantity of the product is updated, and the product quantity of the target product can be added to the original data.
[0047] In addition, if the specified subpage detects that the current client is logged in, it sends the product information of the target product to the server and saves it in the server; after the save is successful, the server sends the full amount of shopping cart data to the first shopping page through postMessage.
[0048] In step S206, by specifying a subpage, the shopping cart data in the local storage area of ​​the specified subpage is obtained, and the shopping cart data is sent to the first shopping page, so that the shopping cart data is displayed on the first shopping page.
[0049] After updating the product information of the target product to the shopping cart data saved in the local storage area corresponding to the specified subpage by specifying the subpage, the specified subpage is hidden and will not be displayed on the user interface. Therefore, by specifying the subpage, Obtain the shopping cart data in the local storage area of ​​the specified subpage, and send the shopping cart data to the first shopping page through the postMessage interface function. After receiving the shopping cart data, the first shopping page extracts the product information in the shopping cart data , update the product information to the first shopping page, and display it in the shopping cart component of the first shopping page.
[0050] It should be noted that all data in the above steps are stored on the client, and no request is sent to the server. In addition, when the client has added items to the shopping cart without logging in, and then logs in to the client, the data stored on the client can be synchronized as follows:
[0051] Step S208, when the current client logs in to the server, obtain the shopping cart data from the local storage area of ​​the current client.
[0052] Step S210, sending the shopping cart data to the server, so as to store the shopping cart data in association with the account of the current client to the server.
[0053] The local storage area of ​​the current client is the local storage area corresponding to the specified subpage loaded in the first shopping page to which the target product belongs; specifically, after the current client logs in to the server, the specified subpage will save the local storage area corresponding to the specified subpage. The shopping cart data in the storage area is sent to the server. After the server receives the new shopping cart data, it will merge the shopping cart data already stored on the server with the shopping cart data sent from the specified subpage; The shopping cart data associated with the current client account is saved to the server.
[0054] Then the server sends the final shopping cart data saved in association to the designated subpage, and after the designated subpage receives the final shopping cart data sent by the server, it sends the final shopping cart data to the first shopping page through the postMessage interface function; at the same time, the designated subpage Clear the data stored in the corresponding local storage area.
[0055] In this method, the shopping cart data is stored in the local storage area corresponding to the specified subpage loaded on the first shopping page, and at the same time, the postMessage interface function is used to communicate with the first shopping page, and the client is not logged in. Sending an http request to the server can save the shopping cart data to the client's local storage, and ensure that all shopping cart data is saved in the client's local storage area when the user is not logged in, reducing server overhead and network overhead, while reducing Waste of service resources.
[0056] Considering that the localstorage storage object can only take effect under the domain name of the current page, shopping pages of different domain names cannot access the shopping data in the same localstorage storage object at the same time. The shopping page consists of two sub-pages. The domain name of the shopping page of the self-operated mall is a.market.com, and the domain name of the shopping page of the third-party mall is b.market.com; at this time, the shopping page of the self-operated mall and the domain name of the third-party mall The shopping page can only store the corresponding shopping data separately, that is, the shopping data of the shopping page of the self-operated mall is stored in the local storage area corresponding to the subpage loaded in the shopping page of the self-operated mall; the shopping page of the third-party mall The shopping data is stored in the local storage area corresponding to the subpage loaded in the shopping page of the third-party mall; the shopping data of two system pages cannot be stored in the local storage area corresponding to the same subpage at the same time. As a result, the shopping pages of different systems cannot share data, and at the same time, unnecessary waste of service resources will be generated.
[0057] Based on this, this embodiment also provides another request processing method, which is implemented on the basis of the above embodiment; the above-mentioned specified subpage is loaded in the first shopping page through an iframe tag; the iframe tag is placed in the first shopping page is hidden.
[0058] When the iframe tag is set on the first shopping page, it is equivalent to nesting another small browser in the current first shopping page (also called the parent web page), and this small browser can also be used like a normal browser Loads the specified subpage (also known as a subpage). And the main domain name of the specified subpage is the same as the main domain name of the first shopping page.
[0059] The above specified subpage is also used to be loaded into the second shopping page, and the local storage area corresponding to the specified subpage stores the product information of the product added to the shopping cart on the second shopping page. Wherein, the designated subpage may also be called a proxy page.
[0060] The above-mentioned second shopping page and the first shopping page both belong to the current client, and the process of loading the specified subpage in the second shopping page can be completed in the following ways:
[0061] When running the current client, the first shopping page and the second shopping page respectively load the pre-set front-end SDK; through the pre-set front-end SDK, set the same iframe tag in the first shopping page and the second shopping page; through the iframe The tag can load a specified subpage. Since the same iframe tag is set in the first shopping page and the second shopping page, the designated subpage loaded through the iframe tag is the same as the main domain name of the first shopping page and the second shopping page.
[0062]For example, the domain name of the first shopping page is a.market.com and the domain name of the second shopping page is b.market.com; then the specified subpage loaded can be proxy.market.com; the main domain name of the specified subpage is the same as The main domain names of the first shopping page and the second shopping page are the same; since the postMessage interface function can communicate between the parent web page and the sub web page with the same main domain name, the specified sub page can be connected with the first shopping page and the second shopping page respectively. The page communicates, and at the same time, the local storage area corresponding to the specified sub-page can also save the product information of the product added to the shopping cart in the second shopping page. The process of saving the product information of the product added to the shopping cart in the second shopping page, and the process of saving the product information of the product added to the shopping cart in the first shopping page in the local storage area corresponding to the specified subpage Same, no more details here.
[0063] After the step of saving the product information of the target product to the local storage area of ​​the current client, similarly, by specifying a subpage, obtain the shopping cart data in the local storage area of ​​the specified subpage, and send the shopping cart data to the corresponding A shopping page or a second shopping page, so that the shopping cart data is displayed on the first shopping page or the second shopping page.
[0064] In the above method, by cooperating with the iframe tag and the localstorage storage object, the front-end shopping pages of different systems can jointly access the same specified subpage and use the storage area corresponding to the specified subpage, saving service resources; In the case of not logging in, the shopping cart data is saved to the local storage of the client, and in the case of cross-system, the shopping cart data in each page shares the same local storage area, which prevents the client from sending data to the server when the user is not logged in. Send http requests, and at the same time ensure that all shopping cart data is stored in the local storage area of ​​the client when the user is not logged in, reducing server overhead and network overhead.
[0065] Corresponding to the above method embodiment, this embodiment also provides a request processing device, such as image 3 As shown, the device includes:
[0066] The detection module 31 is configured to detect the login status of the current client in response to the request of adding the target product to the shopping cart.
[0067] The storage module 32 is configured to save the commodity information of the target commodity in a local storage area of ​​the current client if the current client is not logged in.
[0068] The embodiment of the present invention provides a request processing device, which detects the login status of the current client in response to the request of adding the target product to the shopping cart; if the current client is not logged in, saves the product information of the target product locally on the current client storage area. In this method, when the client is not logged in, the product information added to the shopping cart is saved to the local storage area of ​​the current client. Compared with the method of saving shopping cart data through the server, on the one hand, it can be used in different network environments Both can provide users with complete shopping cart data, on the other hand, it also reduces unnecessary server overhead and network overhead.
[0069] Further, the local storage area of ​​the current client includes: a local storage area corresponding to the specified subpage loaded in the first shopping page to which the target product belongs.
[0070] Further, the above-mentioned detection module is also used for: sending the request to the specified subpage, so as to detect the login status of the current client through the specified subpage; the above-mentioned storage module is also used for: updating the commodity information of the target commodity to the specified subpage In the shopping cart data saved in the local storage area corresponding to the specified subpage; wherein, the shopping cart data includes: product information of the product added to the shopping cart.
[0071] Further, the above device is also used to: obtain the shopping cart data in the local storage area of ​​the designated subpage by specifying the subpage, and send the shopping cart data to the first shopping page, so that the shopping cart data is displayed on the first shopping page middle.
[0072] Further, the above local storage area includes: localstorage storage object.
[0073] Further, the above-mentioned first shopping page communicates with the specified subpage through the postMessage interface function.
[0074] Further, the above specified subpage is also used to be loaded into the second shopping page, and the local storage area corresponding to the specified subpage stores the commodity information of the commodity added to the shopping cart in the second shopping page.
[0075] Further, the above specified subpage is loaded on the first shopping page through an iframe tag; the iframe tag is in a hidden display state on the first shopping page.
[0076] Further, the local storage area of ​​the current client includes: a local storage area corresponding to the first shopping page to which the target product belongs.
[0077] Further, the above device is also used for: when the current client logs in to the server, obtain the shopping cart data from the local storage area of ​​the current client; send the shopping cart data to the server, so as to link the shopping cart data with the account of the current client The association is saved to the server.
[0078] The request processing device provided in the embodiment of the present invention has the same technical features as the request processing method provided in the above embodiments, so it can also solve the same technical problem and achieve the same technical effect.
[0079] This embodiment also provides an electronic device, including a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the request processing method above.
[0080] see Figure 4 As shown, the electronic device includes a processor 100 and a memory 101, the memory 101 stores machine-executable instructions that can be executed by the processor 100, and the processor 100 executes the machine-executable instructions to implement the above request processing method.
[0081] further, Figure 4 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected through the bus 102 .
[0082] Wherein, the memory 101 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local network, metropolitan area network, etc. can be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into address bus, data bus, control bus and so on. For convenience, Figure 4 Indicated by only a double-headed arrow, but does not mean that there is only one bus or one type of bus.
[0083] The processor 100 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method may be implemented by an integrated logic circuit of hardware in the processor 100 or instructions in the form of software. The above-mentioned processor 100 can be a general-purpose processor, including a central processing unit (Central Processing Unit, referred to as CPU), a network processor (Network Processor, referred to as NP), etc.; it can also be a digital signal processor (Digital Signal Processor, referred to as DSP) , Application Specific Integrated Circuit (ASIC for short), Field Programmable Gate Array (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Various methods, steps and logic block diagrams disclosed in the embodiments of the present invention may be implemented or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the methods disclosed in the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101, and completes the steps of the method in the foregoing embodiments in combination with its hardware.
[0084] This embodiment also provides a machine-readable storage medium. The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions prompt the processor to implement the above request processing method. .
[0085] The computer program product of the request processing method, device, and electronic equipment provided by the embodiments of the present invention includes a computer-readable storage medium storing program codes, and the instructions included in the program codes can be used to execute the method described in the preceding method embodiments. For the specific implementation of the method, reference may be made to the method embodiments, which will not be repeated here.
[0086] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
[0087] In addition, in the description of the embodiments of the present invention, unless otherwise specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a fixed connection or a detachable connection , or integrally connected; it may be mechanically connected or electrically connected; it may be directly connected or indirectly connected through an intermediary, and it may be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood in specific situations.
[0088] If the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes. .
[0089] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" etc. The indicated orientation or positional relationship is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the referred device or element must have a specific orientation, or in a specific orientation. construction and operation, therefore, should not be construed as limiting the invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and should not be construed as indicating or implying relative importance.
[0090]Finally, it should be noted that: the above examples are only specific implementations of the present invention, to illustrate the technical solutions of the present invention, rather than to limit them, and the protection scope of the present invention is not limited thereto, although with reference to the foregoing examples The present invention has been described in detail, and those skilled in the art should understand that: within the technical scope disclosed by the present invention, any person skilled in the art can still modify the technical solutions described in the foregoing embodiments or can easily think of them Changes, or equivalent replacements for some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be covered by the protection scope of the present invention Inside. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products