提交 1af09aed 编写于 作者: M mahaifeng

[provider]添加getProviderSync 示例

上级 f6cab979
......@@ -48,24 +48,28 @@
{ service: "location", name: "定位", provider: [], providerObj: [], providerObjMap: [] }
] as ProviderItem[],
providerIds: [] as string[],
providerObjects : [] as UniProvider[],
providerObjects: [] as UniProvider[],
}
},
methods: {
getProvider() {
this.serviceList.forEach((item : ProviderItem) => {
uni.getProvider({
var provider = uni.getProviderSync({
service: item.service,
success: (e) => {
e.providerIds.forEach((value) => {
this.providerIds.push(value)
})
this.updateProvider(item.service, e.providerIds, e.providerObjects);
},
fail: (e) => {
console.log("获取provider失败:", e);
}
} as GetProviderOptions)
// success: (e) => {
// // e.providerIds.forEach((value) => {
// // this.providerIds.push(value)
// // })
// // this.updateProvider(item.service, e.providerIds, e.providerObjects);
// },
// fail: (e) => {
// console.log("获取provider失败:", e);
// }
} as GetProviderSyncOptions)
provider.providerIds.forEach((value) => {
this.providerIds.push(value)
})
this.updateProvider(item.service, provider.providerIds, provider.providerObjects);
})
},
updateProvider(service : string, provider ?: string[] | null, uniProvider : UniProvider[]) {
......@@ -77,7 +81,7 @@
item.providerObj = uniProvider
item.providerObj.forEach((obj) => {
this.providerObjects.push(obj)
this.providerObjects.push(obj)
// #ifdef APP-ANDROID
if (obj instanceof UniPaymentWxpayProvider) {//判断微信是否安装
var isWeChatInstalled = (obj as UniPaymentWxpayProvider).isWeChatInstalled
......@@ -155,4 +159,4 @@
.btn-get-provider {
margin-top: 30px;
}
</style>
</style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册