提交 4e22bbe8 编写于 作者: M mahaifeng

[provider]新增 uni.getProviderSync、uni.getProviderObjectById 同步获取服务供应商信息 #5843

上级 82549387
......@@ -22,8 +22,10 @@
</view>
</view>
<button class="btn-get-provider" type="primary" @click="getProviderIds">getProviderIds</button>
<button class="btn-get-provider" type="primary" @click="getProviderObject">getProviderObject</button>
<button class="btn-get-provider" type="primary" @click="getProviderSync">getProviderSync</button>
<button class="btn-get-provider" type="primary" @click="getProvider">getProvider</button>
<button class="btn-get-provider" type="primary"
@click="getProviderObjectById">getProviderObjectById</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
......@@ -45,39 +47,52 @@
title: 'provider',
flag: false,
serviceList: [
{ service: "oauth", name: "登陆", provider: [], providerObj: [], providerObjMap: [] },
{ service: "share", name: "分享", provider: [], providerObj: [], providerObjMap: [] },
{ service: "payment", name: "支付", provider: [], providerObj: [], providerObjMap: [] },
{ service: "push", name: "推送", provider: [], providerObj: [], providerObjMap: [] },
{ service: "location", name: "定位", provider: [], providerObj: [], providerObjMap: [] }
] as ProviderItem[],
providerObjList: [] as UniProvider[]
}
},
methods: {
getProviderIds() {
getProviderSync() {
this.serviceList.forEach((item : ProviderItem) => {
let providerIds = uni.getProviderIds({
let provider = uni.getProviderSync({
service: item.service
} as GetProviderOptions)
this.updateProvider(item.service, provider.providerIds);
})
this.updateProvider(item.service, providerIds);
},
getProvider() {
this.serviceList.forEach((item : ProviderItem) => {
uni.getProvider({
service: item.service,
success: (e) => {
this.updateProvider(item.service, e.providerIds);
},
fail: (e) => {
console.log("获取provider失败:", e);
}
} as GetProviderOptions)
})
},
updateProvider(service : string, provider ?: string[] | null) {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
item.providerObj = []
return item.service == service
});
if (item != null && provider != null) {
item.provider = provider
}
},
getProviderObject() {
getProviderObjectById() {
this.flag = true
this.getProviderIds()
this.getProvider()
let objList = []
this.serviceList.forEach((value) => {
value.provider.forEach((provider) => {
let obj = uni.getProviderObject({
let obj = uni.getProviderObjectById({
service: value.service,
provider: provider
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册