Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

C # how to develop Wechat Portal and apply Wechat Store Shelf Information Management function

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces C# how to develop Wechat portal and apply Wechat store shelf information management function, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

1. Introduction of Wechat store shelves

In the background of the official Wechat account, the shelf information can be maintained, as shown below. The concept of shelf is to show customers a good classification of goods. Shelf is similar to a well-laid-out showcase. We can define different shelves and then publish different URL for experience.

In addition, we generally create shelves, are based on the shelf template library to build, the shelf template for us to quickly build a shelf, providing a visual reference interface, the shelf template interface is shown below.

2. The development model of shelf management

For the development of Wechat stores using API, the shelf management operation interface of Wechat stores is similar to the conventional module, with the following functions and operations.

Although it looks similar to the previous object model, the information on the shelf is very complex, so if you need to restore it to a solid object based on Json data, you need to think about it over and over again, otherwise it is easy to make modeling errors.

Corresponding to the shelf template of the Wechat store management interface, the shelf object information includes five different control models, some of which can be combined.

Models of several shelves are shown below.

Through the above five control models, we can see that they represent different layout effects, and they can be combined on the shelf.

3. Object modeling of shelf information.

According to the interface description of Wechat store, the shelf entity object information we finally defined is very rich and flexible.

By referring to the API description of Wechat store, we can see that the information of the shelf JSON data is very complex, the specific definition is shown below.

{"shelf_data": {"module_infos": [{"group_info": {"filter": {"count": 2}, "group_id": 50}, "eid": 1} {"group_infos": {"groups": [{"group_id": 49}, {"group_id": 50} {"group_id": 51}]}, "eid": 2}, {"group_info": {"group_id": 52 "img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl29nqqObBwFwnIX3licVPnFV5Jm64z4I0TTicv0TjN7Vl9bykUUibYKIOjicAwIt6Oy0Y6a1Rjp5Tos8tg/0"}," eid ": 3}, {" group_infos ": {" groups ": [{" group_id ": 49 "img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl29nqqObBwFwnIX3licVPnFV5uUQx7TLx4tB9qZfbe3JmqR4NkkEmpb5LUWoXF1ek9nga0IkeSSFZ8g/0"}, {" group_id ": 50," img ":" http://mmbiz.qpic.cn/mmbiz/4whpV1VZl29nqqObBwFwnIX3licVPnFV5G1kdy3ViblHrR54gbCmbiaMnl5HpLGm5JFeENyO9FEZAy6mPypEpLibLA/0"}, {"group_id": 52 "img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl29nqqObBwFwnIX3licVPnFV5uUQx7TLx4tB9qZfbe3JmqR4NkkEmpb5LUWoXF1ek9nga0IkeSSFZ8g/0"}]}," eid ": 4}, {" group_infos ": {" groups ": [{" group_id ": 43} {"group_id": 44}, {"group_id": 45}, {"group_id": 46}] "img_background": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl29nqqObBwFwnIX3licVPnFV5uUQx7TLx4tB9qZfbe3JmqR4NkkEmpb5LUWoXF1ek9nga0IkeSSFZ8g/0"}," eid ": 5}]}," shelf_banner ":" http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2ibrWQn8zWFUh2YznsMV0XEiavFfLzDWYyvQOBBszXlMaiabGWzz5B2KhNn2IDemHa3iarmCyribYlZYyw/0", "shelf_name": "Test shelf"}

According to the definition of JSON data, we define several shelf control objects, and their relationship is shown below.

We can model entity objects based on JSON data, and then with these objects, we can further define the relevant operation interfaces of the shelf, as shown below.

# region Shelf Management / add Shelf / call API voucher / Shelf signboard Picture Url / Shelf name / Shelf Control 1, 2, 3, 4, 5, AddShelfResult AddShelf (string accessToken, string shelfBanner, string shelfName, List controls) / / delete shelves / call API vouchers / shelves Id / CommonResult DeleteShelf (string accessToken, int shelfId) / modify the shelf / call the API voucher / / shelf Id / shelf signboard picture Url / shelf name / / shelf control 1, Magi, 3, 4, and 5 types of collection / CommonResult UpdateShelf (string accessToken, int shelfId, string shelfBanner, string shelfName, List controls) / / get all shelves / call API vouchers / List GetAllShelf (string accessToken) / / obtain shelf information according to the shelf ID / call the API voucher / shelf Id / ShelfJson GetShelfById (string accessToken, int shelfId); # endregion

With the definition of these interfaces, we need to implement the corresponding interfaces, thus implementing our encapsulation processing to Wechat API.

The implementation of shelf management in Wechat stores is as follows (part of the content, additions, deletions and modifications).

/ add shelves / call API vouchers / Shelf signboard picture Url / Shelf name / Shelf controls 1, 2, 3, 4, and 5 types of collections / public AddShelfResult AddShelf (string accessToken, string shelfBanner, string shelfName) List controls) {var url = string.Format ("https://api.weixin.qq.com/merchant/shelf/add?access_token={0}", accessToken) Var data = new {shelf_data = new {module_infos = controls}, shelf_banner = shelfBanner, shelf_name = shelfName}; string postData = data.ToJson (); return JsonHelper.ConvertJson (url, postData) } / delete shelves / call API vouchers / shelves Id / public CommonResult DeleteShelf (string accessToken, int shelfId) {var url = string.Format ("https://api.weixin.qq.com/merchant/shelf/del?access_token={0}", accessToken) Var data = new {shelf_id = shelfId}; string postData = data.ToJson (); return Helper.GetExecuteResult (url, postData) } / modify shelf / call API voucher / / shelf Id / shelf signboard picture Url / shelf name / shelf control 1, 2, 3, 4, 5 types of collection / public CommonResult UpdateShelf (string accessToken, int shelfId, string shelfBanner String shelfName, List controls) {var url = string.Format ("https://api.weixin.qq.com/merchant/shelf/mod?access_token={0}", accessToken) Var data = new {shelf_id = shelfId, shelf_data = new {module_infos = controls}, shelf_banner = shelfBanner, shelf_name = shelfName}; string postData = data.ToJson () Return Helper.GetExecuteResult (url, postData);} 4. Interface test of shelf management in Wechat stores.

As the definition of objects and interfaces for shelf management is more complex, it must be tested repeatedly before it can be used formally. If you don't pay attention to the entity class you define, you may not be able to get some field information.

For convenience, I created a Winform project to test each interface separately.

For the interface test of shelf management content, the test code is as follows.

Private void btnShelf_Click (object sender, EventArgs e) {IMerchantApi api = new MerchantApi (); List list = api.GetAllShelf (token); Console.WriteLine (list.ToJson ()); foreach (ShelfJson json in list) {Console.WriteLine ("shelf information:"); ShelfJson getJson = api.GetShelfById (token, json.shelf_id.Value) Console.WriteLine (getJson.ToJson ());} string shelf_banner = "http://mmbiz.qpic.cn/mmbiz/mLqH9gr11Gyb2sgiaelcsxYtQENGePp0RgeNlAQicfZQokjbJMUq4h8MHtjpekJNEWKuMN3gdRz5RxfkYb7NlIrw/0"; string shelf_name =" Test Shelf "; ShelfControl1 c11 = new ShelfControl1 (6, 202797386); ShelfControl1 c12 = new ShelfControl1 (4, 202797397); List controlList = new List () {c11, c12} AddShelfResult result = api.AddShelf (token, shelf_banner, shelf_name, controlList); if (result! = null & & result.shelf_id > 0) {Console.WriteLine ("increased shelf information:"); ShelfJson getJson = api.GetShelfById (token, result.shelf_id); Console.WriteLine (getJson.ToJson ()) Shelf_name = "Test shelf-modification"; controlList = new List () {c11}; CommonResult updateReuslt = api.UpdateShelf (token, result.shelf_id, shelf_banner, shelf_name, controlList); Console.WriteLine ("modify shelf operation: {0}", updateReuslt.Success? "success": "failure"); CommonResult deleteResult = api.DeleteShelf (token, result.shelf_id); Console.WriteLine ("remove shelf operation: {0}", deleteResult.Success? "success": "failure");}

Thank you for reading this article carefully. I hope the article "how to develop Wechat Portal and apply the Information Management function of Wechat Store shelves" shared by the editor is helpful to everyone. At the same time, I also hope that you can support it and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report