Skip to content

Commit 9f1b83a

Browse files
authored
Merge pull request #3117 from JeffreySu/Developer
Developer
2 parents dbb970b + ba7f319 commit 9f1b83a

File tree

10 files changed

+877
-390
lines changed

10 files changed

+877
-390
lines changed

Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/Senparc.Weixin.Sample.net8.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk.Web">
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<Version>6.11.3</Version>
5+
<Version>6.12.0</Version>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<UserSecretsId>35e58786-0820-4cde-b1ff-f4c6198d00f7</UserSecretsId>
88
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>

Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/Views/TenPayApiV3/JsApi.cshtml

Lines changed: 128 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -11,145 +11,170 @@
1111
<!DOCTYPE html>
1212
<html>
1313
<head>
14-
<title>公众号jsapi支付测试网页</title>
15-
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
14+
<title>微信支付 - 确认支付</title>
15+
<meta charset="utf-8">
16+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
1617
<script src="~/lib/jquery/dist/jquery.js"></script>
17-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
1818
<style>
19-
body {
19+
* {
2020
margin: 0;
2121
padding: 0;
22-
background: #eae9e6;
22+
box-sizing: border-box;
2323
}
2424
25-
body, p, table, td, th {
26-
font-size: 14px;
27-
font-family: helvetica,Arial,Tahoma;
25+
body {
26+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
27+
line-height: 1.6;
28+
background: #f8f9fa;
29+
color: #333;
30+
min-height: 100vh;
31+
display: flex;
32+
align-items: center;
33+
justify-content: center;
2834
}
2935
30-
h1 {
31-
font-family: Baskerville,HelveticaNeue-Bold,helvetica,Arial,Tahoma;
36+
.payment-container {
37+
background: white;
38+
border-radius: 16px;
39+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
40+
padding: 30px;
41+
width: 90%;
42+
max-width: 480px;
43+
text-align: center;
3244
}
3345
34-
a {
35-
text-decoration: none;
36-
color: #385487;
46+
.product-info {
47+
margin-bottom: 25px;
48+
padding: 20px;
49+
background: #f8f9fa;
50+
border-radius: 12px;
3751
}
3852
39-
.product {
40-
font-size: 200%;
41-
color: #a5a5a5;
53+
.product-name {
54+
font-size: 1.5rem;
55+
color: #2c3e50;
56+
margin-bottom: 10px;
4257
}
4358
44-
.title h1 {
45-
font-size: 22px;
59+
.product-price {
60+
font-size: 2rem;
61+
color: #e74c3c;
4662
font-weight: bold;
47-
padding: 0;
48-
margin: 0;
49-
line-height: 1.2;
50-
color: #1f1f1f;
63+
margin: 15px 0;
5164
}
5265
53-
.title p {
54-
color: #aaa;
55-
font-size: 12px;
56-
margin: 5px 0 0;
57-
padding: 0;
58-
font-weight: bold;
66+
.payment-title {
67+
font-size: 1.4rem;
68+
color: #2c3e50;
69+
margin-bottom: 15px;
70+
font-weight: 600;
5971
}
6072
61-
.WCPay {
62-
padding-top: 3%;
73+
.payment-subtitle {
74+
color: #666;
75+
font-size: 0.9rem;
76+
margin-bottom: 25px;
6377
}
64-
</style>
65-
<script>
66-
function auto_remove(img) {
67-
div = img.parentNode.parentNode; div.parentNode.removeChild(div);
68-
img.onerror = "";
69-
return true;
78+
79+
.payment-button {
80+
display: inline-block;
81+
background: #07c160;
82+
color: white;
83+
padding: 15px 40px;
84+
border-radius: 30px;
85+
text-decoration: none;
86+
font-size: 1.1rem;
87+
font-weight: 500;
88+
transition: all 0.3s ease;
89+
border: none;
90+
cursor: pointer;
91+
width: 100%;
92+
max-width: 300px;
7093
}
7194
72-
function changefont(fontsize) {
73-
if (fontsize < 1 || fontsize > 4) return;
74-
$('#content').removeClass().addClass('fontSize' + fontsize);
95+
.payment-button:hover {
96+
background: #06ad56;
97+
transform: translateY(-2px);
98+
box-shadow: 0 4px 12px rgba(7, 193, 96, 0.2);
99+
}
100+
101+
.notice {
102+
margin-top: 20px;
103+
padding: 10px;
104+
background: #fff3cd;
105+
border: 1px solid #ffeeba;
106+
color: #856404;
107+
border-radius: 8px;
108+
font-size: 0.9rem;
109+
}
110+
111+
@@media (max-width: 480px) {
112+
.payment-container {
113+
padding: 20px;
114+
width: 95%;
115+
}
116+
117+
.product-price {
118+
font-size: 1.8rem;
119+
}
120+
121+
.payment-title {
122+
font-size: 1.2rem;
123+
}
124+
125+
.payment-button {
126+
padding: 12px 30px;
127+
}
75128
}
129+
</style>
130+
</head>
131+
<body>
132+
<div class="payment-container">
133+
@if (ViewData["product"] is ProductModel product)
134+
{
135+
<div class="product-info">
136+
<div class="product-name">@product.Name</div>
137+
<div class="product-price">@product.Price.ToString("c")</div>
138+
</div>
139+
}
140+
141+
<h1 class="payment-title">确认支付</h1>
142+
<p class="payment-subtitle">请点击下方按钮完成支付</p>
143+
144+
<button id="getBrandWCPayRequest" class="payment-button">立即支付</button>
76145

146+
<div class="notice">
147+
提示:支付成功后可进入退款流程测试
148+
</div>
149+
</div>
150+
151+
<script>
77152
// 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
78153
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
79154
//公众号支付
80-
jQuery('a#getBrandWCPayRequest').click(function (e) {
155+
jQuery('#getBrandWCPayRequest').click(function (e) {
81156
WeixinJSBridge.invoke('getBrandWCPayRequest', {
82-
"appId": "@jsApiUiPackage.AppId", //公众号名称,由商户传入
83-
"timeStamp": "@jsApiUiPackage.Timestamp", //时间戳
84-
"nonceStr": "@jsApiUiPackage.NonceStr", //随机串
85-
"package": "@Html.Raw(jsApiUiPackage.PrepayIdPackage)",//扩展包
86-
"signType": "RSA", //微信V3签名方式:RSA
87-
"paySign": "@Html.Raw(jsApiUiPackage.Signature)" //微信签名
157+
"appId": "@jsApiUiPackage.AppId",
158+
"timeStamp": "@jsApiUiPackage.Timestamp",
159+
"nonceStr": "@jsApiUiPackage.NonceStr",
160+
"package": "@Html.Raw(jsApiUiPackage.PrepayIdPackage)",
161+
"signType": "@Senparc.Weixin.Config.SenparcWeixinSetting.TenpayV3Setting.EncryptionType",
162+
"paySign": "@Html.Raw(jsApiUiPackage.Signature)"
88163
}, function (res) {
89-
90-
//alert(JSON.stringify(res));
91-
92164
if (res.err_msg == "get_brand_wcpay_request:ok") {
93-
if (confirm('支付成功!点击“确定”进入退款流程测试。')) {
94-
location.href = '@Url.Action("Refund", "TenPayApiV3")';
95-
}
96-
//console.log(JSON.stringify(res));
97-
}else{
165+
setTimeout(function() {
166+
if (confirm('支付成功!点击"确定"进入退款流程测试。')) {
167+
location.href = '@Url.Action("Refund", "TenPayApiV3")';
168+
}
169+
}, 300);
170+
} else {
98171
alert(JSON.stringify(res));
99172
}
100-
// 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
101-
//因此微信团队建议,当收到ok返回时,向商户后台询问是否收到交易成功的通知,若收到通知,前端展示交易成功的界面;若此时未收到通知,商户后台主动调用查询订单接口,查询订单的当前状态,并反馈给前端展示相应的界面。
102173
});
103-
104174
});
105175
106-
WeixinJSBridge.log('yo~ ready.');
107-
176+
WeixinJSBridge.log('WeixinJSBridge ready');
108177
}, false);
109-
if (jQuery) {
110-
jQuery(function () {
111-
112-
var width = jQuery('body').width() * 0.87;
113-
jQuery('img').error(function () {
114-
var self = jQuery(this);
115-
var org = self.attr('data-original1');
116-
self.attr("src", org);
117-
self.error(function () {
118-
auto_remove(this);
119-
});
120-
});
121-
jQuery('img').each(function () {
122-
var self = jQuery(this);
123-
var w = self.css('width');
124-
var h = self.css('height');
125-
w = w.replace('px', '');
126-
h = h.replace('px', '');
127-
if (w <= width) {
128-
return;
129-
}
130-
var new_w = width;
131-
var new_h = Math.round(h * width / w);
132-
self.css({ 'width': new_w + 'px', 'height': new_h + 'px' });
133-
self.parents('div.pic').css({ 'width': new_w + 'px', 'height': new_h + 'px' });
134-
});
135-
});
136-
}
137178
</script>
138-
</head>
139-
<body>
140-
<div class="WCPay">
141-
<a id="getBrandWCPayRequest" href="javascript:void(0);">
142-
@if (ViewData["product"] is ProductModel)
143-
{
144-
var product = (ProductModel)ViewData["product"];
145-
<div class="product">
146-
您已选中产品:@product.Name<br />
147-
单价:@product.Price.ToString("c")
148-
</div>
149-
}
150-
<h1 class="title">点击提交可体验微信支付</h1>
151-
<p>提示:支付成功后可退款,并体验退款流程</p>
152-
</a>
153-
</div>
154179
</body>
155180
</html>

0 commit comments

Comments
 (0)