提交 de0fa709 编写于 作者: dcloud_wdl's avatar dcloud_wdl

Merge remote-tracking branch 'origin/alpha'

## 1.0.46 ## 1.0.47
* update 4.53.2025022409-alpha * update 4.54.2025030608-alpha
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"id": "hello-uniapp-x-alpha", "id": "hello-uniapp-x-alpha",
"name": "hello-uniapp-x-alpha", "name": "hello-uniapp-x-alpha",
"displayName": "hello-uniapp-x-alpha", "displayName": "hello-uniapp-x-alpha",
"version": "1.0.46", "version": "1.0.47",
"description": "演示 uni-app x 框架的组件、接口、模板", "description": "演示 uni-app x 框架的组件、接口、模板",
"scripts": { "scripts": {
"check-commit": "node ./git-hooks/check-commit.cjs" "check-commit": "node ./git-hooks/check-commit.cjs"
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
this.payWX(provider) this.payWX(provider)
} }
// #endif // #endif
// #ifdef APP-IOS // #ifdef APP-IOS || APP-HARMONY
if (e.provider != null && ((e.provider as UniPaymentWxpayProvider).isWeChatInstalled == undefined || ((e.provider as UniPaymentWxpayProvider).isWeChatInstalled != null && (e.provider as UniPaymentWxpayProvider).isWeChatInstalled == false))) { if (e.provider != null && ((e.provider as UniPaymentWxpayProvider).isWeChatInstalled == undefined || ((e.provider as UniPaymentWxpayProvider).isWeChatInstalled != null && (e.provider as UniPaymentWxpayProvider).isWeChatInstalled == false))) {
uni.showToast({ uni.showToast({
title: "微信没有安装", title: "微信没有安装",
......
<template> <template>
<view class="app"> <view class="app">
<view v-if="errMsg != ''">
<text class="err-msg">注意:{{ errMsg }}</text>
</view>
<view> <view>
<view class="label">支付单号:</view> <view class="label">支付单号:</view>
<view><input class="input" v-model="out_trade_no" placeholder="点击发起支付会自动生成" /></view> <view><input class="input" v-model="out_trade_no" placeholder="点击发起支付会自动生成" /></view>
...@@ -121,11 +124,14 @@ ...@@ -121,11 +124,14 @@
adpid: "1000000001", // uni-ad的广告位id adpid: "1000000001", // uni-ad的广告位id
transaction_id: "", // 查询订单接口的查询条件 transaction_id: "", // 查询订单接口的查询条件
getOrderRes: {} as UTSJSONObject, // 查询订单支付成功后的返回值 getOrderRes: {} as UTSJSONObject, // 查询订单支付成功后的返回值
useUniCloud: true,
errMsg: ""
} }
}, },
onLoad(options) { onLoad(options) {
console.log('onLoad: ', options) console.log('onLoad: ', options);
this.useUniCloud = this.checkUniCloud();
// #ifdef H5 // #ifdef H5
// 微信公众号特殊逻辑开始----------------------------------------------------------- // 微信公众号特殊逻辑开始-----------------------------------------------------------
// 以下代码仅为获取openid,正常你自己项目应该是登录后才能支付,登录后已经拿到openid,无需编写下面的代码 // 以下代码仅为获取openid,正常你自己项目应该是登录后才能支付,登录后已经拿到openid,无需编写下面的代码
...@@ -156,7 +162,7 @@ ...@@ -156,7 +162,7 @@
// 微信公众号特殊逻辑结束----------------------------------------------------------- // 微信公众号特殊逻辑结束-----------------------------------------------------------
// #endif // #endif
}, },
methods: { methods: {
/** /**
* 发起支付(唤起收银台,如果只有一种支付方式,则收银台不会弹出来,会直接使用此支付方式) * 发起支付(唤起收银台,如果只有一种支付方式,则收银台不会弹出来,会直接使用此支付方式)
* 在调用此api前,你应该先创建自己的业务系统订单,并获得订单号 order_no,把order_no当参数传给此api,而示例中为了简化跟支付插件无关的代码,这里直接已时间戳生成了order_no * 在调用此api前,你应该先创建自己的业务系统订单,并获得订单号 order_no,把order_no当参数传给此api,而示例中为了简化跟支付插件无关的代码,这里直接已时间戳生成了order_no
...@@ -376,7 +382,10 @@ ...@@ -376,7 +382,10 @@
// 监听事件 - 取消支付 // 监听事件 - 取消支付
onCancel(err : UTSJSONObject) { onCancel(err : UTSJSONObject) {
console.log('cancel: ', err) console.log('cancel: ', err)
uni.showToast({
title: "用户取消了支付",
icon: "none"
});
}, },
// 页面跳转 // 页面跳转
pageTo(url : string) { pageTo(url : string) {
...@@ -404,6 +413,23 @@ ...@@ -404,6 +413,23 @@
} else { } else {
return (totalFee / 100).toFixed(2) return (totalFee / 100).toFixed(2)
} }
},
checkUniCloud() : boolean {
let useUniCloud = false;
if (typeof uniCloud != 'undefined' && typeof uniCloud.config == "object" && uniCloud.config.spaceId != "") {
useUniCloud = true;
}
if (!useUniCloud) {
let errMsg = "本示例依赖 uniCloud,请先关联服务空间,填写正确的支付配置,支付配置文件地址:/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-pay/config.js";
this.errMsg = errMsg;
uni.showModal({
title: "提示",
content: errMsg,
showCancel: false
})
console.error(errMsg);
}
return useUniCloud;
} }
}, },
computed: { computed: {
...@@ -521,5 +547,10 @@ ...@@ -521,5 +547,10 @@
.text { .text {
font-size: 24rpx; font-size: 24rpx;
} }
}
.err-msg {
color: red;
font-size: 14px;
} }
</style> </style>
...@@ -419,10 +419,7 @@ ...@@ -419,10 +419,7 @@
console.log("requestPaymentFail", JSON.stringify(err)) console.log("requestPaymentFail", JSON.stringify(err))
let errCode = err.errCode; let errCode = err.errCode;
let errMsg = err.errMsg; let errMsg = err.errMsg;
if (errCode == 701110) { if (errCode == 700601 || errMsg.indexOf("fail cancel") > -1) {
// 用户取消支付
this.$emit("cancel", err);
} else if (errMsg.indexOf("fail cancel") > -1) {
// 用户取消支付 // 用户取消支付
this.$emit("cancel", err); this.$emit("cancel", err);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册