提交 3ac60e5e 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

调整 provider 示例,移除重复逻辑。

上级 09ec1a0c
...@@ -54,14 +54,7 @@ ...@@ -54,14 +54,7 @@
} }
}, },
methods: { methods: {
clearProviderObj() {
this.serviceList.forEach((item : ProviderItem) => {
item.providerObj = []
item.providerObjMap = []
})
},
getProviderSync() { getProviderSync() {
this.clearProviderObj()
this.serviceList.forEach((item : ProviderItem) => { this.serviceList.forEach((item : ProviderItem) => {
let provider = uni.getProviderSync({ let provider = uni.getProviderSync({
service: item.service service: item.service
...@@ -71,7 +64,6 @@ ...@@ -71,7 +64,6 @@
}) })
}, },
getProvider() { getProvider() {
this.clearProviderObj()
this.serviceList.forEach((item : ProviderItem) => { this.serviceList.forEach((item : ProviderItem) => {
uni.getProvider({ uni.getProvider({
service: item.service, service: item.service,
...@@ -87,18 +79,17 @@ ...@@ -87,18 +79,17 @@
updateProvider(service : string, provider ?: string[] | null) { updateProvider(service : string, provider ?: string[] | null) {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => { const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
item.providerObj = [] item.providerObj = []
item.providerObjMap = []
return item.service == service return item.service == service
}); });
if (item != null && provider != null) { if (item != null && provider != null) {
item.provider = provider item.provider = provider
} }
}, },
getProviderObjectById() { getProviderObjectById() {
this.flag = true this.flag = true
this.getProvider() this.getProvider()
let objList = [] let objList = []
this.clearProviderObj()
this.serviceList.forEach((value) => { this.serviceList.forEach((value) => {
value.provider.forEach((provider) => { value.provider.forEach((provider) => {
let obj = uni.getProviderObjectById({ let obj = uni.getProviderObjectById({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册