提交 6a9810ed 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

Revert "no message"

This reverts commit 817f3691.
上级 817f3691
<template> <template>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view class="page-scroll-view"> <scroll-view class="page-scroll-view">
<!-- #endif --> <!-- #endif -->
<view class="page"> <view class="page">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="service-item" v-for="(item, index) in serviceList" :key="index"> <view class="service-item" v-for="(item, index) in serviceList" :key="index">
<text class="service-name">{{item.name}}:</text> <text class="service-name">{{item.name}}:</text>
<view class="provider-list"> <view class="provider-list">
<text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2"> <!-- #ifdef APP-IOS -->
{{item2}} <text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2">
{{item.providerObj.length > 0 ? ':' + JSON.stringify(item.providerObj[index2]) : '' }} {{item2}}
</text> {{item.providerObjMap.length > 0 ? ':' + JSON.stringify(item.providerObjMap[index2]) : '' }}
</view> </text>
</view> <!-- #endif -->
<button class="btn-get-provider" type="primary" @click="getProvider">getProviderSync</button> <!-- #ifdef APP-ANDROID -->
</view> <text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2">
<!-- #ifdef APP --> {{item2}}
</scroll-view> {{item.providerObj.length > 0 ? ':' + JSON.stringify(item.providerObj[index2]) : '' }}
<!-- #endif --> </text>
</template> <!-- #endif -->
<script> </view>
type ProviderItem = { </view>
service : string, <button class="btn-get-provider" type="primary" @click="getProvider">getProviderSync</button>
name : string, </view>
provider : string[], <!-- #ifdef APP -->
providerObj : UniProvider[] </scroll-view>
} <!-- #endif -->
</template>
export default {
data() { <script>
return { type ProviderItem = {
title: 'provider', service : string,
flag: false, name : string,
serviceList: [ provider : string[],
{ service: "payment", name: "支付", provider: [], providerObj: []}, providerObj : UniProvider[],
{ service: "location", name: "定位", provider: [], providerObj: []} providerObjMap : Object[],
] as ProviderItem[], }
providerIds: [] as string[],
providerObjects: [] as UniProvider[], export default {
} data() {
}, return {
methods: { title: 'provider',
getProvider() { flag: false,
this.serviceList.forEach((item : ProviderItem) => { serviceList: [
var provider = uni.getProviderSync({ { service: "payment", name: "支付", provider: [], providerObj: [], providerObjMap: [] },
service: item.service, { service: "location", name: "定位", provider: [], providerObj: [], providerObjMap: [] }
} as GetProviderSyncOptions) ] as ProviderItem[],
console.log('getProvider',provider,provider.providerIds.length) providerIds: [] as string[],
provider.providerIds.forEach((value) => { providerObjects: [] as UniProvider[],
console.log('getProvider','value',value) }
this.providerIds.push(value) },
}) methods: {
this.updateProvider(item.service, provider.providerIds, provider.providerObjects); getProvider() {
}) this.serviceList.forEach((item : ProviderItem) => {
}, var provider = uni.getProviderSync({
updateProvider(service : string, provider : string[] | null, uniProvider : UniProvider[]) { service: item.service,
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => { } as GetProviderSyncOptions)
return item.service == service provider.providerIds.forEach((value) => {
}); this.providerIds.push(value)
if (item != null && provider != null) { })
item.provider = provider this.updateProvider(item.service, provider.providerIds, provider.providerObjects);
})
item.providerObj = uniProvider },
item.providerObj.forEach((obj) => { updateProvider(service : string, provider : string[] | null, uniProvider : UniProvider[]) {
this.providerObjects.push(obj) const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
// #ifdef APP-ANDROID return item.service == service
if (obj instanceof UniPaymentWxpayProvider) {//判断微信是否安装 });
var isWeChatInstalled = (obj as UniPaymentWxpayProvider).isWeChatInstalled if (item != null && provider != null) {
console.log(isWeChatInstalled) item.provider = provider
}
// #endif item.providerObj = uniProvider
}) item.providerObj.forEach((obj) => {
} this.providerObjects.push(obj)
} // #ifdef APP-ANDROID
} if (obj instanceof UniPaymentWxpayProvider) {//判断微信是否安装
} var isWeChatInstalled = (obj as UniPaymentWxpayProvider).isWeChatInstalled
</script> console.log(isWeChatInstalled)
}
<style> // #endif
.page {
padding: 15px; // #ifdef APP-IOS
} const providerObjMap = this.getProviderObjectMap(obj)
console.log(providerObjMap)
.service-item { item.providerObjMap.push(providerObjMap)
margin-top: 10px; // #endif
}
})
.service-name { }
font-weight: bold; },
}
// #ifdef APP-IOS
.provider-list { getProviderObjectMap(provider : UniProvider) {
margin-left: 32px;
} const map = new Map()
if (this.hasProperty(provider, 'id') && provider.id != null) {
.provider-item { map.set('id', provider.id)
line-height: 1.5; }
}
if (this.hasProperty(provider, 'description') && provider.description != null) {
.btn-get-provider { map.set('description', provider.description)
margin-top: 30px; }
}
if (this.hasProperty(provider, 'isAppExist') && provider.isAppExist != null) {
map.set('isAppExist', provider.isAppExist)
}
if (this.hasProperty(provider, 'isWeChatInstalled') && provider.isWeChatInstalled != null) {
map.set('isWeChatInstalled', provider.isWeChatInstalled)
}
if (this.hasMethod(provider, 'uniqueMethodForProvider')) {
map.set('func-uniqueMethodForProvider', provider.uniqueMethodForProvider())
}
return Object.fromEntries(map)
},
hasMethod(provider : UniProvider, methodName : string) {
return typeof provider[methodName] === 'function';
},
hasProperty(provider : UniProvider, propName : string) {
return propName in provider
}
// #endif
}
}
</script>
<style>
.page {
padding: 15px;
}
.service-item {
margin-top: 10px;
}
.service-name {
font-weight: bold;
}
.provider-list {
margin-left: 32px;
}
.provider-item {
line-height: 1.5;
}
.btn-get-provider {
margin-top: 30px;
}
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册