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

What are the key points for attention in the development of Wechat Mall Mini Program

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces what are the key points for attention in the development of Mini Program in Wechat Mall. What is introduced in the article is very detailed and has a certain reference value. Interested friends must finish reading it!

⒈ receiving address

When I think of this question, I will be very drunk. At the beginning of the static layout, it took most of the effort to select the entire address, create the address (map location), re-edit and modify the address, delete the address on the page, and then preview it on the phone. Click to select the receiving address and pop up two sets of pages! One set is written by me, and the other is.

At the beginning, I did not expect that the wx.chooseAdress that comes with Mini Program directly calls the underlying methods of Wechat, and all the functions are available. I really want to cry without tears!

Analyze the reasons for this: first of all, when you start to contact Mini Program, it is a big taboo to start writing code without understanding some methods; secondly, this feature cannot preview the effect in lower versions of developer tools, only on mobile phones; again, I really didn't expect it.

As a lesson, I would like to remind all beginners to avoid this hole!

⒉ Mini Program can only jump up to 5 stacks.

Before developing Mini Program, you must be familiar with the business process and try to control the jump page within 5 stacks. For details, please see API.

If you encounter some complex business processes that cannot be controlled within 5 stacks, please refer to a series of articles by a great god.

Pass values on ⒊ page

This is relatively simple, and its usage is similar to html+javascript. There are many ways, and I only say that I use two: passing values through links and passing values by local storage!

Link value:

Wxml code

Write in the js of the receiving page

OnLoad:function (options) {

This.setData ({

Form_id:options.form_id

})

}

In this way, the transmitted value is received.

Local storage: write in the js of the value transfer page

/ / put the selected item id (cartIdString) into local storage for use on the payment page

Wx.setStorage ({

Key: 'cartIdString'

Data: cartIdString

Success:function (res) {

Console.log ('sucess')

}

})

/ / put the total price of the selected item into local storage for payment page use

Wx.setStorage ({

Key: 'total'

Data: that.data.total

Success: function (res) {

Console.log ('sucess')

}

})

Write in the js of the receiving page

OnReady:function (e) {

Var that = this

/ / return the id of the selected item in the shopping cart page to the backend

Wx.getStorage ({

Key: 'cartIdString'

Success: function (res) {

Console.log (res.data)

}

})

/ / returns the total price of the selected item in the shopping cart page

Wx.getStorage ({

Key: 'total'

Success: function (res) {

That.setData ({

Total: res.data

})

}

})

Number of ⒋ request requests the entire Mini Program is running, and the number of simultaneous request requests is limited to 5. The solution is to destroy all request requests for the page when the page is unstacked. Each request request is assigned a variable and then destroyed with the requestTask.abort () method in the onUnload event.

Js code

OnLoad: function () {

Var that = this

Var a = wx.request ({

Url: 'http://192.168.200.146:8080/trwl/xcx/selcar',

Method: 'GET'

DataType: 'json'

Success: function (res) {

That.setData ({

Carts:res.data

})

That.sum ()

}

Fail: function (res) {}

Complete: function (res) {}

})

}

/ / destroy the request

OnUnload: function () {

RequestTask.abort ()

A.abort ()

}

5. When you request a group to the backend, you cannot directly transfer it in Array format. You need to convert it to a string format code as follows:

Var cartIdArray = []

Var cartIdString =''

Var carts = this.data.carts

For (var iTuno Bandi)

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