Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
04f01e27
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6007
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看板
提交
04f01e27
编写于
9月 02, 2024
作者:
M
mahaifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[provider]修改示例
上级
cbf69e75
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
36 addition
and
30 deletion
+36
-30
pages/API/get-location/get-location.uvue
pages/API/get-location/get-location.uvue
+9
-3
pages/API/provider/provider.uvue
pages/API/provider/provider.uvue
+10
-14
pages/API/request-payment/request-payment.uvue
pages/API/request-payment/request-payment.uvue
+17
-13
未找到文件。
pages/API/get-location/get-location.uvue
浏览文件 @
04f01e27
...
@@ -108,10 +108,16 @@
...
@@ -108,10 +108,16 @@
} as GetProviderSyncOptions)
} as GetProviderSyncOptions)
console.log(provider)
console.log(provider)
provider.providerObjects.forEach((value : UniProvider) => {
provider.providerObjects.forEach((value : UniProvider) => {
var currentProvider = value
if (value.id == 'system') {
currentProvider = value as UniLocationSystemProvider
} else if (value.id == 'tencent') {
currentProvider = value as UniLocationTencentProvider
}
this.providerList.push({
this.providerList.push({
name:
value
.description,
name:
currentProvider
.description,
id:
value
.id,
id:
currentProvider
.id,
provider:
value
provider:
currentProvider
} as LocationItem);
} as LocationItem);
})
})
...
...
pages/API/provider/provider.uvue
浏览文件 @
04f01e27
...
@@ -34,10 +34,12 @@
...
@@ -34,10 +34,12 @@
title: 'provider',
title: 'provider',
flag: false,
flag: false,
serviceList: [
serviceList: [
{ service: "payment", name: "支付", provider: [], providerObj: []},
{ service: "payment", name: "支付", provider: [], providerObj: []
},
{ service: "location", name: "定位", provider: [], providerObj: []}
{ service: "location", name: "定位", provider: [], providerObj: []
}
] as ProviderItem[],
] as ProviderItem[],
//自动化测试使用
providerIds: [] as string[],
providerIds: [] as string[],
providerObjects: [] as UniProvider[],
providerObjects: [] as UniProvider[],
}
}
},
},
...
@@ -47,32 +49,26 @@
...
@@ -47,32 +49,26 @@
var provider = uni.getProviderSync({
var provider = uni.getProviderSync({
service: item.service,
service: item.service,
} as GetProviderSyncOptions)
} as GetProviderSyncOptions)
console.log('getProvider',provider,provider.providerIds.length)
provider.providerIds.forEach((value) => {
provider.providerIds.forEach((value) => {
console.log('getProvider','value',value)
this.providerIds.push(value)
this.providerIds.push(value)
})
})
this.updateProvider(item.service, provider.providerIds, provider.providerObjects);
this.updateProvider(item.service, provider.providerIds, provider.providerObjects);
})
})
},
},
updateProvider(service : string, provider : string[] | null, uniProvider : UniProvider[]) {
updateProvider(service : string, provider : string[] | null, uniProvider : UniProvider[]) {
//这里需要从新从serviceList 获取item,不能直接用forEach 里面的item,目前存在bug,后续会解决这个问题
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
return item.service == service
return item.service == service
});
});
if (item != null && provider != null) {
if (item != null && provider != null) {
item.provider = provider
item.provider = provider
item.providerObj = uniProvider
item.providerObj = uniProvider
item.providerObj.forEach((obj) => {
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
console.log(isWeChatInstalled)
}
// #endif
})
})
}
}
}
}
}
}
}
}
...
...
pages/API/request-payment/request-payment.uvue
浏览文件 @
04f01e27
...
@@ -29,17 +29,21 @@
...
@@ -29,17 +29,21 @@
provider.providerObjects.forEach((value : UniProvider) => {
provider.providerObjects.forEach((value : UniProvider) => {
switch (value.id) {
switch (value.id) {
case 'alipay':
case 'alipay':
var aliPayProvider = value as UniPaymentAlipayProvider
console.log('alipay', aliPayProvider)
this.providerList.push({
this.providerList.push({
name:
'支付宝'
,
name:
aliPayProvider.description
,
id:
"alipay"
,
id:
aliPayProvider.id
,
provider:
value
provider:
aliPayProvider
} as PayItem);
} as PayItem);
break;
break;
case 'wxpay':
case 'wxpay':
var wxPayProvider = value as UniPaymentWxpayProvider
console.log('wxpay', wxPayProvider)
this.providerList.push({
this.providerList.push({
name:
'微信'
,
name:
wxPayProvider.description
,
id:
"wxpay"
,
id:
wxPayProvider.id
,
provider:
value
provider:
wxPayProvider
} as PayItem);
} as PayItem);
break;
break;
default:
default:
...
@@ -51,7 +55,7 @@
...
@@ -51,7 +55,7 @@
requestPayment(e : PayItem) {
requestPayment(e : PayItem) {
const provider = e.id
const provider = e.id
if (provider == "alipay") {
if (provider == "alipay") {
this.payAli()
this.payAli(
provider
)
} else if (provider == "wxpay") {
} else if (provider == "wxpay") {
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID
if (e.provider != null && e.provider instanceof UniPaymentWxpayProvider && !((e.provider as UniPaymentWxpayProvider).isWeChatInstalled)) {
if (e.provider != null && e.provider instanceof UniPaymentWxpayProvider && !((e.provider as UniPaymentWxpayProvider).isWeChatInstalled)) {
...
@@ -60,7 +64,7 @@
...
@@ -60,7 +64,7 @@
icon: 'error'
icon: 'error'
})
})
} else {
} else {
this.payWX()
this.payWX(
provider
)
}
}
// #endif
// #endif
// #ifdef APP-IOS
// #ifdef APP-IOS
...
@@ -70,12 +74,12 @@
...
@@ -70,12 +74,12 @@
icon: 'error'
icon: 'error'
})
})
} else {
} else {
this.payWX()
this.payWX(
provider
)
}
}
// #endif
// #endif
}
}
},
},
payAli() {
payAli(
id:string
) {
uni.showLoading({
uni.showLoading({
title: "请求中..."
title: "请求中..."
})
})
...
@@ -88,7 +92,7 @@
...
@@ -88,7 +92,7 @@
console.log("====" + this.orderInfo)
console.log("====" + this.orderInfo)
uni.hideLoading()
uni.hideLoading()
uni.requestPayment({
uni.requestPayment({
provider:
"alipay"
,
provider:
id
,
orderInfo: res.data as string,
orderInfo: res.data as string,
fail: (res) => {
fail: (res) => {
console.log(JSON.stringify(res))
console.log(JSON.stringify(res))
...
@@ -113,7 +117,7 @@
...
@@ -113,7 +117,7 @@
},
},
});
});
},
},
payWX() {
payWX(
id:string
) {
uni.showLoading({
uni.showLoading({
title: "请求中..."
title: "请求中..."
})
})
...
@@ -143,7 +147,7 @@
...
@@ -143,7 +147,7 @@
console.log(res.data)
console.log(res.data)
uni.hideLoading()
uni.hideLoading()
uni.requestPayment({
uni.requestPayment({
provider:
"wxpay"
,
provider:
id
,
orderInfo: JSON.stringify(res.data),
orderInfo: JSON.stringify(res.data),
fail: (res) => {
fail: (res) => {
console.log(JSON.stringify(res))
console.log(JSON.stringify(res))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录