Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
2117a8ed
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6018
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看板
提交
2117a8ed
编写于
8月 13, 2024
作者:
zhaofengliang920817
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整定位和支付示例|适配新增方法 uni.getProviderSync。
上级
8d6619e2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
66 deletion
+43
-66
pages/API/get-location/get-location.uvue
pages/API/get-location/get-location.uvue
+20
-33
pages/API/provider/provider.uvue
pages/API/provider/provider.uvue
+1
-1
pages/API/request-payment/request-payment.uvue
pages/API/request-payment/request-payment.uvue
+22
-32
未找到文件。
pages/API/get-location/get-location.uvue
浏览文件 @
2117a8ed
...
@@ -84,13 +84,13 @@
...
@@ -84,13 +84,13 @@
jest_provider: '',
jest_provider: '',
jest_type: 'wgs84' as GetLocationType,
jest_type: 'wgs84' as GetLocationType,
jest_isAltitude: false,
jest_isAltitude: false,
jest_isGeocode: false,
jest_isGeocode: false,
jest_isHighAccuracy: false,
jest_isHighAccuracy: false,
jest_altitude: -1000,
jest_altitude: -1000,
jest_longitude: 200,
jest_longitude: 200,
jest_latitude: 100,
jest_latitude: 100,
jest_address: '',
jest_address: '',
jest_errCode: 0,
jest_errCode: 0,
jest_complete: false
jest_complete: false
}
}
},
},
...
@@ -102,31 +102,18 @@
...
@@ -102,31 +102,18 @@
methods: {
methods: {
getProvider() {
getProvider() {
// #ifdef APP
// #ifdef APP
uni.getProvider({
service: "location",
success: (e) => {
console.log("location success:" + JSON.stringify(e), e.providerObjects.length);
let array = e.providerIds as string[]
array.forEach((value : string) => {
let locationProvider = e.providerObjects.find((item) : boolean => {
return item.id == value
})
if (locationProvider != null) {
this.providerList.push({
name: locationProvider.description,
id: locationProvider.id,
provider: e.providerObjects.find((item) : boolean => {
return item.id == locationProvider.id
})
} as LocationItem);
}
})
},
fail: (e) => {
console.log("获取定位服务商失败:", e);
}
});
let provider = uni.getProviderSync({
service: "location",
} as GetProviderSyncOptions)
console.log(provider)
provider.providerObjects.forEach((value : UniProvider) => {
this.providerList.push({
name: value.description,
id: value.id,
provider: value
} as LocationItem);
})
this.providerList.forEach((value, index) => {
this.providerList.forEach((value, index) => {
if (value.id == "system") {
if (value.id == "system") {
...
@@ -203,8 +190,8 @@
...
@@ -203,8 +190,8 @@
},
},
// 仅用于自动化测试
// 仅用于自动化测试
jestGetLocation() {
jestGetLocation() {
this.jest_complete = false
this.jest_complete = false
this.jest_errCode = 0
this.jest_errCode = 0
uni.getLocation(({
uni.getLocation(({
// #ifdef APP
// #ifdef APP
...
@@ -214,17 +201,17 @@
...
@@ -214,17 +201,17 @@
altitude: this.jest_isAltitude,
altitude: this.jest_isAltitude,
isHighAccuracy: this.jest_isHighAccuracy,
isHighAccuracy: this.jest_isHighAccuracy,
geocode: this.jest_isGeocode,
geocode: this.jest_isGeocode,
success: (res) => {
success: (res) => {
if (res.address != null) {
if (res.address != null) {
this.jest_address = res.address!
this.jest_address = res.address!
}
}
this.jest_longitude = res.longitude
this.jest_longitude = res.longitude
this.jest_latitude = res.latitude
this.jest_latitude = res.latitude
this.jest_altitude = res.altitude
this.jest_altitude = res.altitude
this.jest_complete = true
this.jest_complete = true
},
},
fail: (err) => {
fail: (err) => {
this.jest_errCode = err.errCode
this.jest_errCode = err.errCode
this.jest_complete = true
this.jest_complete = true
}
}
}));
}));
...
...
pages/API/provider/provider.uvue
浏览文件 @
2117a8ed
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
</view>
</view>
</view>
</view>
<button class="btn-get-provider" type="primary" @click="getProvider">getProvider</button>
<button class="btn-get-provider" type="primary" @click="getProvider">getProvider
Sync
</button>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
...
...
pages/API/request-payment/request-payment.uvue
浏览文件 @
2117a8ed
...
@@ -22,40 +22,30 @@
...
@@ -22,40 +22,30 @@
}
}
},
},
onLoad: function () {
onLoad: function () {
uni.getProvider
({
let provider = uni.getProviderSync
({
service: "payment",
service: "payment",
success: (e) => {
} as GetProviderSyncOptions)
console.log("payment success:" + JSON.stringify(e));
console.log(provider)
let array = e.providerIds as string[]
provider.providerObjects.forEach((value : UniProvider) => {
array.forEach((value : string) => {
switch (value.id) {
switch (value) {
case 'alipay':
case 'alipay':
this.providerList.push({
this.providerList.push({
name: '支付宝',
name: '支付宝',
id: "alipay",
id: "alipay",
provider: value
provider: e.providerObjects.find((item) : boolean => {
} as PayItem);
return item.id == 'alipay'
break;
})
case 'wxpay':
} as PayItem);
this.providerList.push({
break;
name: '微信',
case 'wxpay':
id: "wxpay",
this.providerList.push({
provider: value
name: '微信',
} as PayItem);
id: "wxpay",
break;
provider: e.providerObjects.find((item) : boolean => {
default:
return item.id == 'wxpay'
break;
})
} as PayItem);
break;
default:
break;
}
})
},
fail: (e) => {
console.log("获取支付通道失败:", e);
}
}
})
;
})
},
},
methods: {
methods: {
requestPayment(e : PayItem) {
requestPayment(e : PayItem) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录