wx.openSetting(Object object)
【使用場(chǎng)景】如訂閱的功能岳服,用戶(hù)手動(dòng)設(shè)置關(guān)閉了“訂閱”贰拿,需引導(dǎo)用戶(hù)打開(kāi)圃泡,則調(diào)用該方法跳轉(zhuǎn)設(shè)置頁(yè)丐箩,用戶(hù)再手動(dòng)開(kāi)啟“訂閱”,方可使用运杭。
訂閱20004.jpg
客戶(hù)端頁(yè)面展示,此處以騰訊健康小程序手動(dòng)打開(kāi)設(shè)置頁(yè)的步驟為例,如下:
圖3就是wx.openSetting調(diào)起之后顯示的頁(yè)面辟躏,圖4是查看訂閱設(shè)置:
圖1.jpg
圖2.jpg
圖3.jpg
圖4.jpg
示例代碼
wx.requestSubscribeMessage({ //調(diào)用訂閱api
tmplIds: [''], //訂閱的模板id
success (res) { },
fail (res) { },
complete (res) {
if (res.errCode == 20004) {
wx.showModal({
title: '提示',
content: `您關(guān)閉了訂閱消息主開(kāi)關(guān),無(wú)法進(jìn)行訂閱`,
// showCancel: false,
confirmText:"去開(kāi)啟",
confirmColor:"#0091FF",
success (res) {
if (res.confirm) {
console.log('確認(rèn)框-用戶(hù)點(diǎn)擊 確認(rèn)')
wx.openSetting({ //跳轉(zhuǎn)設(shè)置頁(yè)開(kāi)啟訂閱
success (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
} else if (res.cancel) {
console.log('確認(rèn)框-用戶(hù)點(diǎn)擊 取消')
}
}
})
}
},
})