Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
a64e8b6c
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a64e8b6c
编写于
7月 01, 2024
作者:
zhaofengliang920817
提交者:
DCloud-WZF
7月 08, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge branch 'dev-provider' into dev
上级
466e4880
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
97 addition
and
73 deletion
+97
-73
pages/API/get-provider/get-provider.uvue
pages/API/get-provider/get-provider.uvue
+97
-73
未找到文件。
pages/API/get-provider/get-provider.uvue
浏览文件 @
a64e8b6c
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view class="page">
<page-head :title="title"></page-head>
<view class="service-item" v-for="(item, index) in serviceList" :key="index">
<text class="service-name">{{item.name}}:</text>
<view class="provider-list">
<text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2">{{item2}}</text>
</view>
</view>
<button class="btn-get-provider" type="primary" @click="getProvider">getProvider</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view class="page">
<page-head :title="title"></page-head>
<view class="service-item" v-for="(item, index) in serviceList" :key="index">
<text class="service-name">{{item.name}}:</text>
<view class="provider-list">
<text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2">
{{item2}}
{{item.providerObj.length > 0 ? ':'+ JSON.stringify(item.providerObj[index2]) : '' }}
</text>
</view>
</view>
<button class="btn-get-provider" type="primary" @click="getProviderIds">getProviderIds</button>
<button class="btn-get-provider" type="primary" @click="getProviderObject">getProviderObject</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
type ProviderItem = {
service : string,
name : string,
provider : string[]
}
export default {
data() {
return {
title: 'provider',
serviceList: [
{ service: "oauth", name: "登陆", provider: [] },
{ service: "share", name: "分享", provider: [] },
{ service: "payment", name: "支付", provider: [] },
{ service: "push", name: "推送", provider: [] },
{ service: "location", name: "定位", provider: [] }
] as ProviderItem[]
}
},
methods: {
getProvider() {
this.serviceList.forEach((item : ProviderItem) => {
uni.getProvider({
service: item.service,
success: (e) => {
this.updateProvider(e.service, e.provider);
}
})
})
},
updateProvider(service : string, provider : string[]) {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
return item.service == service
});
if (item != null) {
item.provider = provider
}
}
}
}
type ProviderItem = {
service : string,
name : string,
provider : string[],
providerObj : UniProvider[]
}
export default {
data() {
return {
title: 'provider',
flag: false,
serviceList: [
{ service: "oauth", name: "登陆", provider: [], providerObj: [] },
{ service: "share", name: "分享", provider: [], providerObj: [] },
{ service: "payment", name: "支付", provider: [], providerObj: [] },
{ service: "push", name: "推送", provider: [], providerObj: [] },
{ service: "location", name: "定位", provider: [], providerObj: [] }
] as ProviderItem[],
providerObjList: [] as UniProvider[]
}
},
methods: {
getProviderIds() {
this.serviceList.forEach((item : ProviderItem) => {
let providerIds = uni.getProviderIds({
service: item.service
})
this.updateProvider(item.service, providerIds);
})
},
updateProvider(service : string, provider ?: string[] | null) {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
return item.service == service
});
if (item != null && provider != null) {
item.provider = provider
}
},
getProviderObject() {
this.flag = true
this.getProviderIds()
let objList = []
this.serviceList.forEach((value) => {
value.provider.forEach((provider) => {
let obj = uni.getProviderObject({
service: value.service,
provider: provider
})
if (obj != null) {
value.providerObj.push(obj)
}
})
})
}
},
}
</script>
<style>
.page {
padding: 15px;
}
.page {
padding: 15px;
}
.service-item {
margin-top: 10px;
}
.service-item {
margin-top: 10px;
}
.service-name {
font-weight: bold;
}
.service-name {
font-weight: bold;
}
.provider-list {
margin-left: 32px;
}
.provider-list {
margin-left: 32px;
}
.provider-item {
line-height: 1.5;
}
.provider-item {
line-height: 1.5;
}
.btn-get-provider {
margin-top: 30px;
}
.btn-get-provider {
margin-top: 30px;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录