新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)小程序教程:微信小程序API調起客戶端小程序設置界面
wx.openSetting(OBJECT)
基礎庫版本 1.1.0 開始支持,低版本需做兼容處理
成都創(chuàng)新互聯(lián)是專業(yè)的曲麻萊網(wǎng)站建設公司,曲麻萊接單;提供成都網(wǎng)站制作、做網(wǎng)站,網(wǎng)頁設計,網(wǎng)站設計,建網(wǎng)站,PHP網(wǎng)站建設等專業(yè)做網(wǎng)站服務;采用PHP框架,可快速的進行曲麻萊網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
調起客戶端小程序設置界面,返回用戶設置的操作結果
Object 參數(shù)說明:
| 參數(shù) | 類型 | 必填 | 說明 |
|---|---|---|---|
| success | Function | 否 | 接口調用成功的回調函數(shù),返回內容詳見返回參數(shù)說明。 |
| fail | Function | 否 | 接口調用失敗的回調函數(shù) |
| complete | Function | 否 | 接口調用結束的回調函數(shù)(調用成功、失敗都會執(zhí)行) |
success返回參數(shù)說明:
| 參數(shù) | 類型 | 說明 |
|---|---|---|
| authSetting | Object | 用戶授權結果,其中 key 為 scope 值,value 為 Bool 值,表示用戶是否允許授權,詳見 scope 列表 |
示例代碼:
wx.openSetting({
success: (res) => {
/*
* res.authSetting = {
* "scope.userInfo": true,
* "scope.userLocation": true
* }
*/
}
})
OpenSettingButton wx.createOpenSettingButton(string type, string text, string image, Object style)
支持版本 >= 2.0.7
創(chuàng)建打開設置頁面的按鈕。
參數(shù)
string type
按鈕的類型
type 的合法值:
| 值 | 說明 |
|---|---|
| text | 可以設置背景色和文本的按鈕 |
| image | 只能設置背景貼圖的按鈕,背景貼圖會直接拉伸到按鈕的寬高 |
string text
按鈕上的文本,僅當 type 為 text 時有效
string image
按鈕的背景圖片,僅當 type 為 image 時有效
Object style
按鈕的樣式
| 屬性 | 類型 | 默認值 | 是否必填 | 說明 | 支持版本 |
|---|---|---|---|---|---|
| left | number | 是 | 左上角橫坐標 | ||
| top | number | 是 | 左上角縱坐標 | ||
| width | number | 是 | 寬度 | ||
| height | number | 是 | 高度 | ||
| backgroundColor | string | 是 | 背景顏色 | ||
| borderColor | string | 是 | 邊框顏色 | ||
| borderWidth | number | 是 | 邊框寬度 | ||
| borderRadius | number | 是 | 邊框圓角 | ||
| textAlign | string | 是 | 文本的水平居中方式 | ||
| fontSize | number | 是 | 字號 | ||
| lineHeight | number | 是 | 文本的行高 |
style.textAlign 的合法值:
| 值 | 說明 |
|---|---|
| left | 居左 |
| center | 居中 |
| right | 居右 |
返回值
OpenSettingButton
示例代碼
let button = wx.createOpenSettingButton({
type: 'text',
text: '打開設置頁面',
style: {
left: 10,
top: 76,
width: 200,
height: 40,
lineHeight: 40,
backgroundColor: '#ff0000',
color: '#ffffff',
textAlign: 'center',
fontSize: 16,
borderRadius: 4
}
})
wx.getSetting(OBJECT)
基礎庫 1.2.0 開始支持,低版本需做 兼容處理
獲取用戶的當前設置
Object 參數(shù)說明:
| 參數(shù) | 類型 | 必填 | 說明 |
|---|---|---|---|
| success | Function | 否 | 接口調用成功的回調函數(shù),返回內容詳見返回參數(shù)說明。 |
| fail | Function | 否 | 接口調用失敗的回調函數(shù) |
| complete | Function | 否 | 接口調用結束的回調函數(shù)(調用成功、失敗都會執(zhí)行) |
success返回參數(shù)說明:
| 參數(shù) | 類型 | 說明 |
|---|---|---|
| authSetting | Object | 用戶授權結果,其中 key 為 scope 值,value 為 Bool 值,表示用戶是否允許授權,詳見 scope 列表 |
示例代碼:
wx.getSetting({
success: (res) => {
/*
* res.authSetting = {
* "scope.userInfo": true,
* "scope.userLocation": true
* }
*/
}
})
網(wǎng)頁題目:創(chuàng)新互聯(lián)小程序教程:微信小程序API調起客戶端小程序設置界面
文章鏈接:http://www.5511xx.com/article/dhsiihh.html


咨詢
建站咨詢

