May 18, 2021 WeChat Mini Program Development Document
WeChat client 7.0.9 and above versions are supported, iOS is not supported at this time
In order to make it easier for users to use the ride service of the small program, we have added the entry gate of the ride program in the menu of the location message details page.
Developers need to globally configure app.json claims to support access to applets from the location message portal.
Example of configuration:
"entranceDeclare": {
"locationMessage": {
"path": "pages/index/index",
"query": "foo=bar"
}
}
The configuration item
Property | Type | Required | Describe | The lowest version |
---|---|---|---|---|
entranceDeclare | Object | Whether | The entry declares the information | 7.0.9 |
A list of entranceDeclare parameters
Property | Type | Required | Describe | The lowest version |
---|---|---|---|---|
locationMessage | Object | Whether | Declare the Location Message scene to the launch page of the small program | 7.0.9 |
A list of locationMessage parameters
Property | Type | Required | Describe | The lowest version |
---|---|---|---|---|
path | string | Whether | The start page path, which must already be defined in pages | 7.0.9 |
query | string | Whether | Start page parameters | 7.0.9 |
Example code:
//app.js
App({
onLaunch: function (options){
console.log(options)
var scene = options.scene
if (scene == 1146) { // 位置消息场景值
var location = options.locationInfo
var x = location.latitude
var y = location.longitude
var name = location.name
}
},
})
Object startup parameters
Property | Type | Describe |
---|---|---|
scene | number | The scene value of the startup of the small program, the start scene value of Location Message, is 1146 |
locationInfo | Object | Startup information for a special scene |
The structure of locationInfo
Property | Type | Describe |
---|---|---|
latitude | number | Latitudes, ranging from -90 to 90, with negative numbers representing south latitudes |
longtitude | number | Longe longs, ranging from -180 to 180, with negative numbers representing the western long term |
name | string | POI name |
Nightly v1.02.1912062 version has supported conditional compilation to increase the location message entry. Select scene value 1146: Take a ride with a small program in the location message, and you can preview debugging with the real machine after passing in the POI point name and longitude and latitude information.