Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
dec9fb8d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6045
Star
91
Fork
165
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
dec9fb8d
编写于
11月 29, 2024
作者:
VK1688
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uni-pay示例支持微信小程序支付
上级
9b5f6386
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
160 addition
and
42 deletion
+160
-42
pages/API/request-payment/request-payment/request-payment-uni-pay.uvue
...uest-payment/request-payment/request-payment-uni-pay.uvue
+5
-4
uni_modules/uni-pay-x/changelog.md
uni_modules/uni-pay-x/changelog.md
+12
-0
uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue
uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue
+45
-2
uni_modules/uni-pay-x/js_sdk/js_sdk.uts
uni_modules/uni-pay-x/js_sdk/js_sdk.uts
+41
-0
uni_modules/uni-pay-x/package.json
uni_modules/uni-pay-x/package.json
+37
-33
uni_modules/uni-pay-x/readme.md
uni_modules/uni-pay-x/readme.md
+6
-1
uni_modules/uni-pay-x/uniCloud/cloudfunctions/common/uni-pay/index.js
...uni-pay-x/uniCloud/cloudfunctions/common/uni-pay/index.js
+2
-2
uni_modules/uni-pay-x/uniCloud/database/uni-pay-orders.index.json
...les/uni-pay-x/uniCloud/database/uni-pay-orders.index.json
+12
-0
未找到文件。
pages/API/request-payment/request-payment/request-payment-uni-pay.uvue
浏览文件 @
dec9fb8d
...
...
@@ -7,17 +7,18 @@
<view>
<view class="label">支付金额(单位分,100=1元):</view>
<view><input class="input" v-model.number="total_fee" /></view>
</view>
<button class="button" @click="open()">打开收银台(弹窗模式)</button>
</view>
<!-- #ifdef APP || H5 -->
<button class="button" @click="open()">打开收银台(弹窗模式)</button>
<view v-if="!isPcCom">
<button class="button" @click="toPayDesk">打开收银台(新页面模式)</button>
</view>
<!-- #endif -->
<!-- #endif -->
<!-- #ifdef MP-WEIXIN || H5 || APP -->
<button class="button" @click="createOrder('wxpay')">发起支付(微信)</button>
<!-- #endif -->
<!-- #endif -->
<!-- #ifdef MP-ALIPAY || H5 || APP -->
<button class="button" @click="createOrder('alipay')">发起支付(支付宝)</button>
<!-- #endif -->
...
...
uni_modules/uni-pay-x/changelog.md
浏览文件 @
dec9fb8d
## 1.1.0(2024-11-29)
支持微信小程序支付 HBX最低版本 4.41
[
详情
](
https://doc.dcloud.net.cn/uniCloud/uni-pay/uni-app-x.html#config-wxpay-mp
)
## 1.0.5(2024-09-29)
修复 微信支付v3 h5支付兼容性问题
## 1.0.4(2024-08-24)
支持苹果虚拟支付 HBX最低版本 4.26
[
详情
](
https://doc.dcloud.net.cn/uniCloud/uni-pay/uni-app-x.html#appleiap
)
## 1.0.2(2024-04-28)
支持微信支付
## 1.0.1(2024-04-28)
兼容uni-app-x对客户端uniPlatform的调整(uni-app-x内uniPlatform区分app-android、app-ios)
## 1.0.0(2024-03-11)
uni-pay-x 发布
uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue
浏览文件 @
dec9fb8d
...
...
@@ -122,7 +122,7 @@
<script>
// 引入支付云对象
const uniPayCo = uniCloud.importObject("uni-pay-co");
import { checkPlatform, objectAssign } from "../../js_sdk/js_sdk"
import { checkPlatform, objectAssign
, getWeixinCode, getAlipayCode
} from "../../js_sdk/js_sdk"
export default {
name: "uni-pay",
emits: ["success", "cancel", "fail", "create", "mounted", "qrcode"],
...
...
@@ -210,6 +210,30 @@
}
},
mounted() {
// #ifdef MP-WEIXIN || MP-ALIPAY
if (this.openid == "") {
new Promise(async (resolve, reject) => {
let code = await this.getCode();
let res = await this.getOpenid({
// #ifdef MP-WEIXIN
provider: "wxpay",
// #endif
// #ifdef MP-ALIPAY
provider: "alipay",
// #endif
code
});
resolve(res);
}).then((res) => {
if (res['openid'] != null) {
this.openid = res['openid'];
}
}).catch((err) => {
reject(err);
})
}
// #endif
// #ifdef MP-WEIXIN
// 如果是微信小程序,则设置只支持微信支付
this.originalRroviders = ["wxpay"];
...
...
@@ -312,6 +336,11 @@
createOrderData['openid'] = options['openid'];
}
// #endif
// #ifdef MP
if (this.openid != "") {
createOrderData['openid'] = this.openid;
}
// #endif
try {
let res = await uniPayCo.createOrder(createOrderData);
if (res['errCode'] == 0) {
...
...
@@ -379,6 +408,9 @@
uni.requestPayment({
provider: res['provider'] as string,
orderInfo: orderStr,
// #ifdef MP-WEIXIN
..._order,
// #endif
success: (res) => {
console.log("requestPaymentSuccess", JSON.stringify(res))
this._getOrder();
...
...
@@ -780,7 +812,18 @@
uni.hideLoading()
}
// #endif
}
},
// #ifdef MP-WEIXIN || MP-ALIPAY
// 获取code
async getCode() : Promise<string>{
// #ifdef MP-WEIXIN
return getWeixinCode();
// #endif
// #ifdef MP-ALIPAY
return getAlipayCode();
// #endif
},
// #endif
},
watch: {
...
...
uni_modules/uni-pay-x/js_sdk/js_sdk.uts
浏览文件 @
dec9fb8d
...
...
@@ -67,8 +67,49 @@ function objectAssign(json1:UTSJSONObject,json2:UTSJSONObject) :UTSJSONObject{
return json1;
}
function getWeixinCode () : Promise<string>{
return new Promise((resolve, reject) => {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success(res) {
resolve(res.code)
},
fail(err) {
reject(new Error('获取微信code失败'))
}
})
// #endif
// #ifndef MP-WEIXIN
resolve('')
// #endif
})
};
function getAlipayCode () : Promise<string>{
return new Promise((resolve, reject) => {
// #ifdef MP-ALIPAY
uni.login({
provider: 'alipay',
success(res) {
resolve(res.code);
},
fail(err) {
reject(new Error('获取支付宝code失败,可能是没有关联appid或你的支付宝开发者工具还没有登录'));
}
});
// #endif
// #ifndef MP-ALIPAY
resolve('');
// #endif
});
};
export {
checkPlatform,
getH5Env,
objectAssign,
getWeixinCode,
getAlipayCode
};
\ No newline at end of file
uni_modules/uni-pay-x/package.json
浏览文件 @
dec9fb8d
{
"id"
:
"uni-pay-x"
,
"displayName"
:
"uni-pay-x"
,
"version"
:
"1.0.0"
,
"description"
:
"uni-pay-x"
,
"keywords"
:
[
"uni-pay-x"
],
"version"
:
"1.1.0"
,
"description"
:
"uni-pay 的 uni-app x版本,需HBX≥4.02"
,
"keywords"
:
[
"uni-pay-x"
,
"微信支付"
,
"支付宝"
,
"苹果虚拟支付"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^
3.1.0
"
"HBuilderX"
:
"^
4.02
"
},
"dcloudext"
:
{
"type"
:
"unicloud-template-page"
,
...
...
@@ -24,9 +27,9 @@
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
"ads"
:
"
无
"
,
"data"
:
"
插件不采集任何数据
"
,
"permissions"
:
"
无
"
},
"npmurl"
:
""
},
...
...
@@ -41,41 +44,42 @@
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"
u
"
,
"vue2"
:
"
n
"
,
"vue3"
:
"y"
},
"App"
:
{
"app-vue"
:
"n"
,
"app-nvue"
:
"n"
,
"app-uvue"
:
"y"
"app-vue"
:
"n"
,
"app-nvue"
:
"n"
,
"app-uvue"
:
"y"
,
"app-harmony"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"
u
"
,
"Android Browser"
:
"
u
"
,
"微信浏览器(Android)"
:
"
u
"
,
"QQ浏览器(Android)"
:
"
u
"
"Safari"
:
"
y
"
,
"Android Browser"
:
"
y
"
,
"微信浏览器(Android)"
:
"
y
"
,
"QQ浏览器(Android)"
:
"
y
"
},
"H5-pc"
:
{
"Chrome"
:
"
u
"
,
"IE"
:
"
u
"
,
"Edge"
:
"
u
"
,
"Firefox"
:
"
u
"
,
"Safari"
:
"
u
"
"Chrome"
:
"
y
"
,
"IE"
:
"
n
"
,
"Edge"
:
"
y
"
,
"Firefox"
:
"
y
"
,
"Safari"
:
"
y
"
},
"小程序"
:
{
"微信"
:
"
u
"
,
"阿里"
:
"
u
"
,
"百度"
:
"
u
"
,
"字节跳动"
:
"
u
"
,
"QQ"
:
"
u
"
,
"钉钉"
:
"
u
"
,
"快手"
:
"
u
"
,
"飞书"
:
"
u
"
,
"京东"
:
"
u
"
"微信"
:
"
n
"
,
"阿里"
:
"
n
"
,
"百度"
:
"
n
"
,
"字节跳动"
:
"
n
"
,
"QQ"
:
"
n
"
,
"钉钉"
:
"
n
"
,
"快手"
:
"
n
"
,
"飞书"
:
"
n
"
,
"京东"
:
"
n
"
},
"快应用"
:
{
"华为"
:
"
u
"
,
"联盟"
:
"
u
"
"华为"
:
"
n
"
,
"联盟"
:
"
n
"
}
}
}
...
...
uni_modules/uni-pay-x/readme.md
浏览文件 @
dec9fb8d
# uni-pay-x
\ No newline at end of file
`uni-pay-x`
是
`uni-pay`
的
`uni-app x`
版
[
文档地址
](
https://doc.dcloud.net.cn/uniCloud/uni-pay/uni-app-x.html
)
**线上体验地址**
![](
https://web-ext-storage.dcloud.net.cn/unicloud/uni-pay-x/518.png
)
uni_modules/uni-pay-x/uniCloud/cloudfunctions/common/uni-pay/index.js
浏览文件 @
dec9fb8d
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
uni_modules/uni-pay-x/uniCloud/database/uni-pay-orders.index.json
浏览文件 @
dec9fb8d
...
...
@@ -94,5 +94,17 @@
],
"MgoIsUnique"
:
false
}
},
{
"IndexName"
:
"appleiap_account_token"
,
"MgoKeySchema"
:
{
"MgoIndexKeys"
:
[
{
"Name"
:
"appleiap_account_token"
,
"Direction"
:
"1"
}
],
"MgoIsUnique"
:
false
}
}
]
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录