feat(payment): 将支付表单提交方式改为fetch请求
- 替换原有的HTML表单提交方式为JSON格式的fetch请求 - 统一所有页面的支付请求接口为/api/pay- 添加请求错误处理和用户提示信息 -优化支付成功后的页面跳转逻辑- 增加网络异常时的重试机制和按钮状态恢复 - 补充deviceId参数传递支持- 修复部分页面提交按钮状态未重置的问题
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(cat:*)"
|
||||
"Bash(cat:*)",
|
||||
"Bash(find:*)",
|
||||
"Bash(python:*)",
|
||||
"Bash(go build:*)",
|
||||
"Bash(for:*)",
|
||||
"Bash(do echo:*)",
|
||||
"Bash(done)",
|
||||
"Bash(powershell:*)",
|
||||
"Bash(git checkout:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"shop/internal/models"
|
||||
"shop/internal/schema/request"
|
||||
"shop/internal/schema/response"
|
||||
"shop/internal/service"
|
||||
"shop/internal/traceRouter"
|
||||
@@ -288,3 +289,153 @@ func (c *PayController) PayOriginalJD() {
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// PayV2 新版本JSON支付接口,支持JSON请求和响应
|
||||
func (c *PayController) PayV2() {
|
||||
ctx, span := traceRouter.CreateSpan(c.Ctx.Request.Context(), "span", "JSON支付接口")
|
||||
defer span.End()
|
||||
|
||||
var req request.PayRequest
|
||||
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &req); err != nil {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "JSON解析失败",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验证必填字段
|
||||
if req.OrderId == "" {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "订单号为空",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
if !c.judgeAmount(req.FactMMValue) {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "金额有误",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 解析签名
|
||||
m, msg, ok := service.VerifyPaySign(ctx, req.Sign)
|
||||
if !ok || m == nil {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: msg,
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验证订单超时
|
||||
if time.Since(time.Unix(m.GeneratedTime, 0)).Hours() > float64(m.Duration) {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "订单超时!",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验证支付密钥
|
||||
if m.PayKey == "" {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "支付秘钥错误!",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验证通知地址
|
||||
if m.NotifyUrl == "" {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "通知地址为空!",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验证订单号
|
||||
if m.OrderNo == "" {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "订单号为空!",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 构建卡密数据
|
||||
pp := map[string]string{
|
||||
"recoveryType": req.RecoveryType,
|
||||
"data": req.Chard,
|
||||
"cardNo": req.CardNo,
|
||||
}
|
||||
marshal, err := json.Marshal(&pp)
|
||||
if err != nil {
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: "卡密数据解析错误!",
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 调用支付服务
|
||||
scanShop := new(service.ScanShopController)
|
||||
scanShop.Params = map[string]string{
|
||||
"orderPeriod": "24",
|
||||
"notifyUrl": m.NotifyUrl,
|
||||
"orderPrice": req.FactMMValue,
|
||||
"orderNo": req.OrderId,
|
||||
"productCode": req.ProductCode,
|
||||
"exValue": string(marshal),
|
||||
"ip": c.Ctx.Input.IP(),
|
||||
"deviceId": req.DeviceId,
|
||||
}
|
||||
|
||||
res := scanShop.Shop(ctx, m.PayKey)
|
||||
if res.Code == 200 {
|
||||
// 返回成功响应,包含订单确认页面URL
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: 0,
|
||||
Msg: "支付成功",
|
||||
Data: map[string]string{
|
||||
"orderId": req.OrderId,
|
||||
"returnUrl": req.ReturnUrl,
|
||||
"payKey": m.PayKey,
|
||||
"amount": req.FactMMValue,
|
||||
"redirectUrl": "/order-confirm.html?orderId=" + req.OrderId + "&returnUrl=" + req.ReturnUrl + "&payKey=" + m.PayKey + "&amount=" + req.FactMMValue,
|
||||
},
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 处理错误情况
|
||||
errMsg := res.Msg
|
||||
if errMsg == "" {
|
||||
errMsg = "不存在这样的支付类型!"
|
||||
}
|
||||
|
||||
c.Data["json"] = response.CommonResponse{
|
||||
Code: -1,
|
||||
Msg: errMsg,
|
||||
Data: map[string]string{
|
||||
"orderId": req.OrderId,
|
||||
"amount": req.FactMMValue,
|
||||
"returnUrl": req.ReturnUrl,
|
||||
},
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ func init() {
|
||||
web.Router("/", &controllers.HomeAction{}, "*:ShowHome") // 初始化首页
|
||||
web.Router("/pay.html", &controllers.PayController{}, "*:Pay")
|
||||
web.Router("/pay", &controllers.PayController{}, "*:PayWithJson")
|
||||
web.Router("/api/pay", &controllers.PayController{}, "*:PayV2")
|
||||
web.Router("/error.html", &controllers.HomeAction{}, "*:ErrorPage")
|
||||
web.Router("/order-confirm.html", &controllers.HomeAction{}, "*:OrderConfirm")
|
||||
web.Router("/ok.html", &controllers.HomeAction{}, "*:ShowOK")
|
||||
|
||||
13
internal/schema/request/pay.go
Normal file
13
internal/schema/request/pay.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package request
|
||||
|
||||
type PayRequest struct {
|
||||
OrderId string `json:"orderId"`
|
||||
ProductCode string `json:"productCode"`
|
||||
RecoveryType string `json:"recoveryType"`
|
||||
Chard string `json:"chard"`
|
||||
CardNo string `json:"cardNo"`
|
||||
Sign string `json:"sign"`
|
||||
DeviceId string `json:"deviceId"`
|
||||
ReturnUrl string `json:"returnUrl"`
|
||||
FactMMValue string `json:"factMMValue"`
|
||||
}
|
||||
@@ -287,50 +287,45 @@
|
||||
this.classList.remove('scale-95');
|
||||
}, 150);
|
||||
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.value.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.value.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.value.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.value.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
});
|
||||
});
|
||||
|
||||
// 添加苹果风格的点击波纹效果
|
||||
|
||||
@@ -464,51 +464,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -466,51 +466,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -466,51 +466,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -466,51 +466,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -465,51 +465,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<!-- 打开支付宝购买卡密-->
|
||||
<!-- </button>-->
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" autocomplete="off" onsubmit="return submitPayment(event);">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -183,6 +183,71 @@
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const form = document.getElementById('paymentForm');
|
||||
const formData = new FormData(form);
|
||||
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
productCode: formData.get('productCode'),
|
||||
notifyUrl: formData.get('notifyUrl'),
|
||||
orderId: formData.get('orderId'),
|
||||
sign: formData.get('sign'),
|
||||
returnUrl: formData.get('returnUrl'),
|
||||
factMMValue: formData.get('factMMValue'),
|
||||
recoveryType: formData.get('recoveryType'),
|
||||
chard: formData.get('chard'),
|
||||
cardNo: formData.get('cardNo')
|
||||
};
|
||||
|
||||
// 验证必填字段
|
||||
if (!requestData.chard || !requestData.cardNo) {
|
||||
alert('请输入卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 禁用提交按钮,防止重复提交
|
||||
const submitButton = form.querySelector('button[type="submit"]');
|
||||
const originalText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送 JSON 请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('提交错误:', error);
|
||||
alert('网络错误,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// function openTb() {
|
||||
// window.open("tbopen://m.taobao.com/tbopen/index.html?h5Url=https%3A%2F%2Fh5.m.taobao.com%2Fawp%2Fcore%2Fdetail.htm%3Fid%3D{{.linkID}}");
|
||||
// }
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<!-- 打开支付宝购买卡密-->
|
||||
<!-- </button>-->
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" autocomplete="off" onsubmit="return submitPayment(event);">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -188,6 +188,71 @@
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const form = document.getElementById('paymentForm');
|
||||
const formData = new FormData(form);
|
||||
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
productCode: formData.get('productCode'),
|
||||
notifyUrl: formData.get('notifyUrl'),
|
||||
orderId: formData.get('orderId'),
|
||||
sign: formData.get('sign'),
|
||||
returnUrl: formData.get('returnUrl'),
|
||||
factMMValue: formData.get('factMMValue'),
|
||||
recoveryType: formData.get('recoveryType'),
|
||||
chard: formData.get('chard'),
|
||||
cardNo: formData.get('cardNo')
|
||||
};
|
||||
|
||||
// 验证必填字段
|
||||
if (!requestData.chard || !requestData.cardNo) {
|
||||
alert('请输入卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 禁用提交按钮,防止重复提交
|
||||
const submitButton = form.querySelector('button[type="submit"]');
|
||||
const originalText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送 JSON 请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('提交错误:', error);
|
||||
alert('网络错误,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
@@ -465,51 +465,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -466,51 +466,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -465,51 +465,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -465,51 +465,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -466,51 +466,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -465,51 +465,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<title>{{.siteName}}</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link href="../static/css/cashier.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
#maxthon-1eec22d4-0232-4212-8283-6f2ac8f967-iframe {
|
||||
display: block !important;
|
||||
position: absolute !important;
|
||||
visibility: visible !important;
|
||||
z-index: 2147483647 !important;
|
||||
border-style: none !important;
|
||||
opacity: 1 !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, .3) !important;
|
||||
border: 1px solid #b3b3b3 !important
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div class="tastesdk-box">
|
||||
<div class="header clearfix">
|
||||
<div class="title">
|
||||
<p class="logo" >
|
||||
<span style="width: 100%;">{{.siteName}}</span>
|
||||
</p>
|
||||
<div class="right">
|
||||
<div class="clearfix">
|
||||
<ul class="clearfix">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="typedemo" style="height: 600px;">
|
||||
<div class="demo-pc">
|
||||
<div class="pay-jd">
|
||||
<form action="/payfor.py/" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="orderid" value="{{.orderNo}}">
|
||||
|
||||
<div class="two-step">
|
||||
<p><strong>请您及时付款,以便订单尽快处理!</strong>请您在提交订单后<span>24小时</span>内完成支付,否则订单会自动取消。</p>
|
||||
<ul class="pay-infor">
|
||||
<li>商品名称:{{.pname}}</li>
|
||||
<li>订单编号:<span>{{.orderNo}}</span></li>
|
||||
</ul>
|
||||
<ul class="pay-infor">
|
||||
<li>支付金额:<strong><input type="number" name="amount" value="" required>
|
||||
<span>元</span></strong></li>
|
||||
</ul>
|
||||
<h5>扫码支付:</h5>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="SCAN_YL" name="SCAN" id="SCAN_YL" type="radio">
|
||||
<label for="SCAN_YL"><img src="../static/img/yinlian.jpg" alt="银联扫码"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="SCAN_ALIPAY" checked="checked" name="SCAN" id="SCAN_ALIPAY"
|
||||
type="radio">
|
||||
<label for="SCAN_ALIPAY"><img src="../static/img/zhifubao.png" alt="支付宝扫码支付"
|
||||
style="width:100px;height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="SCAN_WEIXIN" name="SCAN" id="SCAN_WEIXIN" type="radio">
|
||||
<label for="SCAN_WEIXIN"><img src="../static/img/weixin.png" alt="微信扫码支付"
|
||||
style="width:100px;height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="SCAN_QQ" name="SCAN" id="SCAN_QQ" type="radio">
|
||||
<label for="SCAN_QQ"><img src="../static/img/qqq.jpg" alt="QQ扫码支付"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
<h5 style="margin-top: 115px">网银支付:</h5>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="04031000" name="WY" id="beijing_wy" type="radio">
|
||||
<label for="beijing_wy"><img src="../static/img/beijing_0.jpg" alt="中国北京银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01020000" name="WY" id="gongshang_wy" type="radio">
|
||||
<label for="gongshang_wy"><img src="../static/img/gongshang_0.jpg" alt="中国工商银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="03030000" name="WY" id="guangda_wy" type="radio">
|
||||
<label for="guangda_wy"><img src="../static/img/guangda_0.jpg" alt="中国光大银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01050000" name="WY" id="jianshe_wy" type="radio">
|
||||
<label for="jianshe_wy"><img src="../static/img/jieshe_0.jpg" alt="中国建设银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="03050000" name="WY" id="minsheng_wy" type="radio">
|
||||
<label for="minsheng_wy"><img src="../static/img/minsheng_0.jpg" alt="中国民生银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01030000" name="WY" id="nongye_wy" type="radio">
|
||||
<label for="nongye_wy"><img src="../static/img/nongye_0.jpg" alt="中国农业银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="04012900" name="WY" id="shanghai_wy" type="radio">
|
||||
<label for="shanghai_wy"><img src="../static/img/shanghai_0.jpg" alt="中国上海银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01000000" name="WY" id="youzheng_wy" type="radio">
|
||||
<label for="youzheng_wy"><img src="../static/img/youzheng_0.jpg" alt="中国邮政银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
<h5 style="margin-top: 175px">快捷支付:</h5>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="04031000" name="KJ" id="beijing_kj" type="radio">
|
||||
<label for="beijing_kj"><img src="../static/img/beijing_0.jpg" alt="中国北京银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01020000" name="KJ" id="gongshang_kj" type="radio">
|
||||
<label for="gongshang_kj"><img src="../static/img/gongshang_0.jpg" alt="中国工商银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="03030000" name="KJ" id="guangda_kj" type="radio">
|
||||
<label for="guangda_kj"><img src="../static/img/guangda_0.jpg" alt="中国光大银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01050000" name="KJ" id="jianshe_kj" type="radio">
|
||||
<label for="jianshe_kj"><img src="../static/img/jieshe_0.jpg" alt="中国建设银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="03050000" name="KJ" id="minsheng_kj" type="radio">
|
||||
<label for="minsheng_kj"><img src="../static/img/minsheng_0.jpg" alt="中国民生银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01030000" name="KJ" id="nongye_kj" type="radio">
|
||||
<label for="nongye_kj"><img src="../static/img/nongye_0.jpg" alt="中国农业银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="04012900" name="KJ" id="shanghai_kj" type="radio">
|
||||
<label for="shanghai_kj"><img src="../static/img/shanghai_0.jpg" alt="中国上海银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01000000" name="KJ" id="youzheng_kj" type="radio">
|
||||
<label for="youzheng_kj"><img src="../static/img/youzheng_0.jpg" alt="中国邮政银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
<input value="CCB" name="bankCode" type="hidden">
|
||||
|
||||
<div class="" style="float: right;">
|
||||
<button type="submit" class="pcdemo-btn sbpay-btn">立即支付</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../static/js/base.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -139,21 +139,23 @@
|
||||
navigator.clipboard.writeText("{{ .accountNumber }}").then(async () => {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('copyToast'))
|
||||
toastBootstrap.show()
|
||||
// 发送post请求
|
||||
// 发送JSON请求
|
||||
const requestData = {
|
||||
"orderId": "{{ .orderNo }}",
|
||||
"productCode": "{{ .productCode }}",
|
||||
"recoveryType": "1",
|
||||
"chard": "{{ .accountNumber }}",
|
||||
"cardNo": "",
|
||||
"sign": "{{ .sign }}",
|
||||
"deviceId": localStorage.getItem("deviceId"),
|
||||
"returnUrl": "{{ .returnUrl }}",
|
||||
"factMMValue": "{{ .mmValue }}"
|
||||
};
|
||||
const result = await $.ajax({
|
||||
url: "/pay",
|
||||
url: "/api/pay",
|
||||
type: "POST",
|
||||
data: {
|
||||
"productCode": "{{ .productCode }}",
|
||||
"sign": "{{ .sign }}",
|
||||
"notifyUrl": "{{ .notifyUrl }}",
|
||||
"orderId": "{{ .orderNo }}",
|
||||
"returnUrl": "{{ .returnUrl }}",
|
||||
"factMMValue": "{{ .mmValue }}",
|
||||
"recoveryType": "1",
|
||||
"deviceId": localStorage.getItem("deviceId"),
|
||||
"chard": "{{ .accountNumber }}",
|
||||
},
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(requestData),
|
||||
})
|
||||
if (result.code !== 0) {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('toastMessage'))
|
||||
@@ -182,21 +184,23 @@
|
||||
} finally {
|
||||
textArea.remove();
|
||||
}
|
||||
// 发送post请求
|
||||
// 发送JSON请求
|
||||
const requestData = {
|
||||
"orderId": "{{ .orderNo }}",
|
||||
"productCode": "{{ .productCode }}",
|
||||
"recoveryType": "1",
|
||||
"chard": "{{ .accountNumber }}",
|
||||
"cardNo": "",
|
||||
"sign": "{{ .sign }}",
|
||||
"deviceId": localStorage.getItem("deviceId"),
|
||||
"returnUrl": "{{ .returnUrl }}",
|
||||
"factMMValue": "{{ .mmValue }}"
|
||||
};
|
||||
$.ajax({
|
||||
url: "/pay.html",
|
||||
url: "/api/pay",
|
||||
type: "POST",
|
||||
data: {
|
||||
"productCode": "{{ .productCode }}",
|
||||
"sign": "{{ .sign }}",
|
||||
"notifyUrl": "{{ .notifyUrl }}",
|
||||
"orderId": "{{ .orderNo }}",
|
||||
"returnUrl": "{{ .returnUrl }}",
|
||||
"factMMValue": "{{ .mmValue }}",
|
||||
"recoveryType": "1",
|
||||
"deviceId": localStorage.getItem("deviceId"),
|
||||
"chard": "{{ .accountNumber }}",
|
||||
},
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(requestData),
|
||||
}).then(result => {
|
||||
if (result.code !== 0) {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('toastMessage'))
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>{{.siteName}}</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link href="../static/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="../static/js/bootstrap.bundle.min.js"></script>
|
||||
<link href="../static/css/cashier.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="tastesdk-box">
|
||||
<div class="header bg-light border-4 pt-3 bt-2 border-warning border-bottom clearfix">
|
||||
<div class="title d-flex justify-content-center align-content-center">
|
||||
<img src="static/img/taobao/logo.png" alt="" class="img-fluid" style="height: 60px; margin-right: 5px">
|
||||
<span>天猫游戏充值</span>
|
||||
<!-- <p class="text-end" style="font-size: 36px">-->
|
||||
<!-- <span style="width: 100%;">{{.siteName}}</span>-->
|
||||
<!-- </p>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="main px-5 py-3 mx-4 ">
|
||||
<div class="text-center fs-1">
|
||||
¥<span class="text-danger fw-bolder mmValue" style="font-size: 84px">{{.mmValue}}</span>
|
||||
</div>
|
||||
<div class="pay-jd mb-4">
|
||||
<div class="two-step" style="font-size: 36px">
|
||||
<div>
|
||||
<p class="text-success">
|
||||
请您在提交订单后<strong class="text-danger">24小时</strong>内完成支付,否则订单会自动取消。
|
||||
</p>
|
||||
</div>
|
||||
<div class="my-5">
|
||||
<div class="mr-3" hidden="">
|
||||
商品名称:{{.pname}}
|
||||
</div>
|
||||
<div class="ml-2">
|
||||
订单编号:{{.orderNo}}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>游戏账号:{{.accountNumber}}</div>
|
||||
</div>
|
||||
<!-- <div class="w-100 pt-5 pb-lg-3">-->
|
||||
<!-- <h1 class="text-danger fs-1 py-2 fw-bolder">重要提醒</h1>-->
|
||||
<!-- <img src="static/img/taobao/warning_v2.png" class="img-fluid w-100">-->
|
||||
<!-- </div>-->
|
||||
<div class="mt-5">
|
||||
<button class="submit-order btn btn-primary w-100"
|
||||
style="font-size: 40px; height: 100px">
|
||||
复制账号
|
||||
</button>
|
||||
</div>
|
||||
<div class="operate-record px-3 py-2 fs-2 mt-4">
|
||||
<div>
|
||||
<p class="text-danger">使用帮助</p>
|
||||
<p>注意:店铺消息不回</p>
|
||||
<p class="text-danger">直接粘贴到游戏账号框中,不要有空格和其他东西 订单金额与拉单金额一致</p>
|
||||
<p class="text-danger">【否则会导致充值失败】</p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p>操作步骤:</p>
|
||||
<p>1.此用途为天猫游戏自动充值!</p>
|
||||
<p>2.点击复制账号,自动跳转指定链接!!</p>
|
||||
<p>3.复制粘贴进游戏账号框中!</p>
|
||||
<p class="text-danger fw-bolder">4.区/服随便写,订单备注不用理!</p>
|
||||
<p>5.核对金额无误,付款!</p>
|
||||
<p>6.确认收货(全五星好评赢率提升20%)!</p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p>如没有回调,请检查下单链接、订单金额、订单备注是否正确。 自己无法解决请联系管理员</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade fs-1" id="exampleModal1" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
|
||||
aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" style="min-width: 80vw">
|
||||
<div class="modal-content px-4 py-4">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title">注意</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h1 class="text-center py-3 fs-1 fw-bolder">使用帮助</h1>
|
||||
<p class="text-danger">注意:店铺消息不回</p>
|
||||
<p>直接粘贴到游戏账号框中,不要有空格和其他东西 订单金额与拉单金额一致</p>
|
||||
<p class="text-danger">【否则会导致充值失败】</p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p>1.<strong class="text-primary">1.此用途为天猫游戏自动充值!</strong></p>
|
||||
<p>2.点击复制账号,自动跳转指定链接!!</p>
|
||||
<p>3.复制粘贴进游戏账号框中!</p>
|
||||
<p class="text-danger fw-bolder">4.区/服随便写,订单备注不用理!!!</p>
|
||||
<p>5.核对金额无误,付款!</p>
|
||||
<p>6.确认收货(全五星好评赢率提升20%)!</p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p>如没有回调,请检查下单链接、订单金额、订单备注是否正确。 自己无法解决请联系管理员</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
data-bs-target="#exampleModal2" data-bs-toggle="modal"
|
||||
onclick="countdown()"
|
||||
style="height: 80px; font-size: 40px">
|
||||
别绑定!我已知晓
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade fs-1" id="exampleModal2" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
|
||||
aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" style="min-width: 80vw">
|
||||
<div class="modal-content px-4 py-4">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title">注意</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h1 class="text-center py-3 fs-1 fw-bolder">!!!这是新版,看清楚!!!</h1>
|
||||
<div class="w-100">
|
||||
<img src="static/img/taobao/warning_v2.jpg" class="img-fluid w-100">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary disabled" id="secondModalBtn"
|
||||
style="height: 80px; font-size: 40px">
|
||||
别绑定!我已知晓
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toast-container p-3 top-25 start-50 translate-middle-x" id="toastPlacement">
|
||||
<div class="toast bg-white w-100" id="copyToast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header fs-4">
|
||||
<strong class="me-auto">复制成功</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body fs-3">
|
||||
账号 {{.accountNumber}} 已经复制到粘贴板上了!
|
||||
</div>
|
||||
</div>
|
||||
<div class="toast align-items-center bg-white border-0 w-100" id="toastMessage" role="alert" aria-live="assertive"
|
||||
aria-atomic="true">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body fs-4">
|
||||
<p class="toast-message-text"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../static/js/base.js"></script>
|
||||
<script type="text/javascript">
|
||||
$("#amount").blur(function () {
|
||||
var idBank = /([1-9]\d*\.?\d*)|(0\.\d*[1-9])/;
|
||||
if ($("#amount").val().match(idBank) == null) {
|
||||
$("#amount").val("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$(".submit-order").click(() => {
|
||||
// 复制到剪贴板
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText("{{ .accountNumber }}").then(async () => {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('copyToast'))
|
||||
toastBootstrap.show()
|
||||
// 发送post请求
|
||||
const result = await $.ajax({
|
||||
url: "/pay",
|
||||
type: "POST",
|
||||
data: {
|
||||
"productCode": "{{ .productCode }}",
|
||||
"sign": "{{ .sign }}",
|
||||
"notifyUrl": "{{ .notifyUrl }}",
|
||||
"orderId": "{{ .orderNo }}",
|
||||
"returnUrl": "{{ .returnUrl }}",
|
||||
"factMMValue": "{{ .mmValue }}",
|
||||
"recoveryType": "1",
|
||||
"chard": "{{ .accountNumber }}",
|
||||
},
|
||||
})
|
||||
if (result.code !== 0) {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('toastMessage'))
|
||||
const ele = document.getElementsByClassName('toast-message-text')
|
||||
ele[0].innerText = result.msg
|
||||
toastBootstrap.show()
|
||||
return
|
||||
}
|
||||
openExternalLink("{{ (index .profitMarginList 0).LinkID }}");
|
||||
})
|
||||
} else {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('copyToast'))
|
||||
toastBootstrap.show()
|
||||
// Use the 'out of viewport hidden text area' trick
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = "{{ .accountNumber }}";
|
||||
// Move textarea out of the viewport so it's not visible
|
||||
textArea.style.position = "absolute";
|
||||
textArea.style.left = "-999999px";
|
||||
document.body.prepend(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
textArea.remove();
|
||||
}
|
||||
// 发送post请求
|
||||
$.ajax({
|
||||
url: "/pay",
|
||||
type: "POST",
|
||||
data: {
|
||||
"productCode": "{{ .productCode }}",
|
||||
"sign": "{{ .sign }}",
|
||||
"notifyUrl": "{{ .notifyUrl }}",
|
||||
"orderId": "{{ .orderNo }}",
|
||||
"returnUrl": "{{ .returnUrl }}",
|
||||
"factMMValue": "{{ .mmValue }}",
|
||||
"recoveryType": "1",
|
||||
"chard": "{{ .accountNumber }}",
|
||||
},
|
||||
})
|
||||
openExternalLink("{{ (index .profitMarginList 0).LinkID }}");
|
||||
if (result.code !== 0) {
|
||||
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(document.getElementById('toastMessage'))
|
||||
const ele = document.getElementsByClassName('toast-message-text')
|
||||
ele[0].innerText = result.msg
|
||||
toastBootstrap.show()
|
||||
return
|
||||
}
|
||||
openExternalLink("{{ (index .profitMarginList 0).LinkID }}");
|
||||
}
|
||||
})
|
||||
|
||||
function openExternalLink(link) {
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
// 写一个倒计时,添加到按钮上,倒计时结束后,才能关闭模态框
|
||||
function countdown() {
|
||||
document.getElementById("secondModalBtn").innerText = "别绑定!我已知晓";
|
||||
document.getElementById("secondModalBtn").classList.remove("disabled");
|
||||
document.getElementById("secondModalBtn").setAttribute("data-bs-dismiss", "modal")
|
||||
// let seconds = 1;
|
||||
// const interval = setInterval(function () {
|
||||
// document.getElementById("secondModalBtn").innerText = "别绑定!我已知晓(" + seconds-- + ")";
|
||||
// }, 1000);
|
||||
// setTimeout(function () {
|
||||
// // 移除计时器
|
||||
// clearInterval(interval);
|
||||
// // 移除class里的disabled
|
||||
// document.getElementById("secondModalBtn").innerText = "别绑定!我已知晓";
|
||||
// document.getElementById("secondModalBtn").classList.remove("disabled");
|
||||
// document.getElementById("secondModalBtn").setAttribute("data-bs-dismiss", "modal")
|
||||
// }, 1000);
|
||||
}
|
||||
let m = document.getElementById("exampleModal1");
|
||||
const myModal = new bootstrap.Modal(m, {keyboard: false});
|
||||
myModal.show();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.top-25 {
|
||||
top: 25% !important
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -52,7 +52,7 @@
|
||||
<!-- 打开支付宝购买卡密-->
|
||||
<!-- </button>-->
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -84,7 +84,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<button type="submit" class="btn btn-primary w-100" style="font-size: 40px; height: 100px">
|
||||
<button type="button" onclick="submitPayment()" class="btn btn-primary w-100" style="font-size: 40px; height: 100px">
|
||||
点击此处提交卡密
|
||||
</button>
|
||||
</div>
|
||||
@@ -153,6 +153,74 @@
|
||||
function openExternalLink(link) {
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
function submitPayment() {
|
||||
const form = document.getElementById('paymentForm');
|
||||
const formData = new FormData(form);
|
||||
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
productCode: formData.get('productCode'),
|
||||
notifyUrl: formData.get('notifyUrl'),
|
||||
orderId: formData.get('orderId'),
|
||||
sign: formData.get('sign'),
|
||||
returnUrl: formData.get('returnUrl'),
|
||||
factMMValue: formData.get('factMMValue'),
|
||||
recoveryType: formData.get('recoveryType'),
|
||||
chard: formData.get('chard')
|
||||
};
|
||||
|
||||
// 添加卡号字段(如果存在)
|
||||
const cardNo = formData.get('cardNo');
|
||||
if (cardNo) {
|
||||
requestData.cardNo = cardNo;
|
||||
}
|
||||
|
||||
// 验证必填字段
|
||||
if (!requestData.chard) {
|
||||
alert('请输入卡密');
|
||||
return;
|
||||
}
|
||||
|
||||
// 禁用提交按钮,防止重复提交
|
||||
const submitButton = document.querySelector('button[onclick="submitPayment()"]');
|
||||
const originalText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送 JSON 请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// 成功时重定向到订单确认页面
|
||||
if (data.redirectUrl) {
|
||||
window.location.href = data.redirectUrl;
|
||||
} else if (requestData.returnUrl) {
|
||||
window.location.href = requestData.returnUrl;
|
||||
} else {
|
||||
window.location.href = '/order_confirm.html';
|
||||
}
|
||||
} else {
|
||||
// 失败时显示错误信息
|
||||
alert(data.message || '提交失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('提交错误:', error);
|
||||
alert('网络错误,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
});
|
||||
}
|
||||
// function openTb() {
|
||||
// window.open("tbopen://m.taobao.com/tbopen/index.html?h5Url=https%3A%2F%2Fh5.m.taobao.com%2Fawp%2Fcore%2Fdetail.htm%3Fid%3D{{.linkID}}");
|
||||
// }
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<!-- 打开支付宝购买卡密-->
|
||||
<!-- </button>-->
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -191,6 +191,58 @@
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const chard = document.getElementById('chard').value.trim();
|
||||
|
||||
if (!chard) {
|
||||
alert('请填写卡密信息!');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '2',
|
||||
chard: chard.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -52,7 +52,7 @@
|
||||
<!-- 打开支付宝购买卡密-->
|
||||
<!-- </button>-->
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -187,6 +187,60 @@
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, {keyboard: false});
|
||||
myModal.show();
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const cardNo = document.getElementById('card_no').value.trim();
|
||||
const chard = document.getElementById('chard').value.trim();
|
||||
|
||||
if (!cardNo || !chard) {
|
||||
alert('请填写完整的卡号和卡密信息!');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: chard.replace(/\s/g, ''),
|
||||
cardNo: cardNo.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -44,7 +44,7 @@
|
||||
</button>
|
||||
{{ end }}
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -151,6 +151,66 @@
|
||||
function openExternalLink(link) {
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// 获取表单数据
|
||||
const cardNumber = document.getElementById('cardNo').value;
|
||||
const cardPassword = document.getElementById('chard').value;
|
||||
|
||||
// 验证数据
|
||||
if (!cardNumber || !cardPassword) {
|
||||
alert('请填写完整的卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构造请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '2',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 禁用提交按钮防止重复提交
|
||||
const submitButton = document.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付失败:' + (data.msg || '未知错误'));
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</button>
|
||||
{{ end }}
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -95,7 +95,7 @@
|
||||
<p class="text-danger fw-bolder">注意:若不按照操作步骤导致订单无法核实需要您个人承担损失!!!</p>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<button type="submit" class="btn btn-primary w-100" style="font-size: 40px; height: 100px">
|
||||
<button type="button" onclick="submitPayment()" class="btn btn-primary w-100" style="font-size: 40px; height: 100px">
|
||||
点击此处提交卡密
|
||||
</button>
|
||||
</div>
|
||||
@@ -154,6 +154,74 @@
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
function submitPayment() {
|
||||
const form = document.getElementById('paymentForm');
|
||||
const formData = new FormData(form);
|
||||
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
productCode: formData.get('productCode'),
|
||||
notifyUrl: formData.get('notifyUrl'),
|
||||
orderId: formData.get('orderId'),
|
||||
sign: formData.get('sign'),
|
||||
returnUrl: formData.get('returnUrl'),
|
||||
factMMValue: formData.get('factMMValue'),
|
||||
recoveryType: formData.get('recoveryType'),
|
||||
chard: formData.get('chard')
|
||||
};
|
||||
|
||||
// 添加卡号字段(如果存在)
|
||||
const cardNo = formData.get('cardNo');
|
||||
if (cardNo) {
|
||||
requestData.cardNo = cardNo;
|
||||
}
|
||||
|
||||
// 验证必填字段
|
||||
if (!requestData.chard) {
|
||||
alert('请输入卡密');
|
||||
return;
|
||||
}
|
||||
|
||||
// 禁用提交按钮,防止重复提交
|
||||
const submitButton = document.querySelector('button[onclick="submitPayment()"]');
|
||||
const originalText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送 JSON 请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// 成功时重定向到订单确认页面
|
||||
if (data.redirectUrl) {
|
||||
window.location.href = data.redirectUrl;
|
||||
} else if (requestData.returnUrl) {
|
||||
window.location.href = requestData.returnUrl;
|
||||
} else {
|
||||
window.location.href = '/order_confirm.html';
|
||||
}
|
||||
} else {
|
||||
// 失败时显示错误信息
|
||||
alert(data.message || '提交失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('提交错误:', error);
|
||||
alert('网络错误,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalText;
|
||||
});
|
||||
}
|
||||
|
||||
// function openTb() {
|
||||
// window.open("tbopen://m.taobao.com/tbopen/index.html?h5Url=https%3A%2F%2Fh5.m.taobao.com%2Fawp%2Fcore%2Fdetail.htm%3Fid%3D{{.linkID}}");
|
||||
// }
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</button>
|
||||
{{ end }}
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -156,6 +156,66 @@
|
||||
function openExternalLink(link) {
|
||||
window.open(link, "_self");
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// 获取表单数据
|
||||
const cardNumber = document.getElementById('cardNo').value;
|
||||
const cardPassword = document.getElementById('chard').value;
|
||||
|
||||
// 验证数据
|
||||
if (!cardNumber || !cardPassword) {
|
||||
alert('请填写完整的卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构造请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 禁用提交按钮防止重复提交
|
||||
const submitButton = document.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付失败:' + (data.msg || '未知错误'));
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
打开QQ群购买卡密
|
||||
</button>
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -204,6 +204,65 @@
|
||||
window.open("http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=QcsVhCjkTJ89xVuoUBpS9-H0uzOOCJGh&authKey=3EYTGea%2BpglW8GwHdRdWUtjsOWcFNFkJ%2Bj7p7Lc5FE808s%2BNvdnB1xInJlpXwXWe&noverify=0&group_code=936138754", "_blank");
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// 获取表单数据
|
||||
const cardNumber = document.getElementById('card_no').value;
|
||||
const cardPassword = document.getElementById('chard').value;
|
||||
|
||||
// 验证数据
|
||||
if (!cardNumber || !cardPassword) {
|
||||
alert('请填写完整的卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构造请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 禁用提交按钮防止重复提交
|
||||
const submitButton = document.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付失败:' + (data.msg || '未知错误'));
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
@@ -498,51 +498,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber.replace(/\s/g, '');
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword.replace(/\s/g, '');
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
打开支付宝购买卡密
|
||||
</button>
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -167,6 +167,65 @@
|
||||
window.open("alipays://platformapi/startapp?appId=20000067&url=https%3A%2F%2Fmain.m.taobao.com%2Fsearch%2Findex.html%3Fspm%3Da215s.7406091.topbar.1.560c6770t1leU1%26pageType%3D3%26q%3D%25E6%25B2%2583%25E5%25B0%2594%25E7%258E%259B%25E7%2594%25B5%25E5%25AD%2590%25E5%258D%25A1%25E5%2585%25A8%25E5%259B%25BD%25E9%2580%259A%25E7%2594%25A8{{.showMMValue}}", "_blank")
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// 获取表单数据
|
||||
const cardNumber = document.getElementById('card_no').value;
|
||||
const cardPassword = document.getElementById('chard').value;
|
||||
|
||||
// 验证数据
|
||||
if (!cardNumber || !cardPassword) {
|
||||
alert('请填写完整的卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构造请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 禁用提交按钮防止重复提交
|
||||
const submitButton = document.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付失败:' + (data.msg || '未知错误'));
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
打开支付宝购买卡密
|
||||
</button>
|
||||
</div>
|
||||
<form action="/pay.html" method="post" autocomplete="off">
|
||||
<form id="paymentForm" onsubmit="return submitPayment(event);" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="productCode" value="{{.productCode}}">
|
||||
<input type="text" style="display: none" name="notifyUrl" value="{{.notifyUrl}}">
|
||||
<input type="text" style="display: none" name="orderId" value="{{.orderNo}}">
|
||||
@@ -170,6 +170,65 @@
|
||||
window.open("alipays://platformapi/startapp?appId=20000067&url={{.linkID}}", "_blank")
|
||||
}
|
||||
|
||||
function submitPayment(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// 获取表单数据
|
||||
const cardNumber = document.getElementById('card_no').value;
|
||||
const cardPassword = document.getElementById('chard').value;
|
||||
|
||||
// 验证数据
|
||||
if (!cardNumber || !cardPassword) {
|
||||
alert('请填写完整的卡号和卡密');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构造请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 禁用提交按钮防止重复提交
|
||||
const submitButton = document.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = '提交中...';
|
||||
|
||||
// 发送请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付失败:' + (data.msg || '未知错误'));
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = '点击此处提交卡密';
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = document.getElementById("exampleModal");
|
||||
const myModal = new bootstrap.Modal(m, { keyboard: false });
|
||||
myModal.show();
|
||||
|
||||
@@ -466,51 +466,51 @@
|
||||
this.textContent = "处理中...";
|
||||
this.classList.add('opacity-70', 'cursor-wait');
|
||||
|
||||
// 构造一个html form表单
|
||||
const form = document.createElement('form');
|
||||
form.action = '/pay.html';
|
||||
form.method = 'POST';
|
||||
form.target = '_self';
|
||||
form.style.display = 'none';
|
||||
let ele = document.createElement('input')
|
||||
ele.value = cardNumber;
|
||||
ele.name = 'cardNo';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = cardPassword;
|
||||
ele.name = 'chard';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.productCode}}';
|
||||
ele.name = 'productCode';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.notifyUrl}}';
|
||||
ele.name = 'notifyUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.orderNo}}';
|
||||
ele.name = 'orderId';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.sign}}';
|
||||
ele.name = 'sign';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.returnUrl}}';
|
||||
ele.name = 'returnUrl';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '{{.mmValue}}';
|
||||
ele.name = 'factMMValue';
|
||||
form.appendChild(ele);
|
||||
ele = document.createElement('input')
|
||||
ele.value = '8';
|
||||
ele.name = 'recoveryType';
|
||||
form.appendChild(ele);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
orderId: '{{.orderNo}}',
|
||||
productCode: '{{.productCode}}',
|
||||
recoveryType: '8',
|
||||
chard: cardPassword.replace(/\s/g, ''),
|
||||
cardNo: cardNumber.replace(/\s/g, ''),
|
||||
sign: '{{.sign}}',
|
||||
deviceId: '{{.deviceId}}',
|
||||
returnUrl: '{{.returnUrl}}',
|
||||
factMMValue: '{{.mmValue}}'
|
||||
};
|
||||
|
||||
// 发送JSON请求
|
||||
fetch('/api/pay', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 0) {
|
||||
// 成功,重定向到订单确认页面
|
||||
if (data.data && data.data.redirectUrl) {
|
||||
window.location.href = data.data.redirectUrl;
|
||||
} else {
|
||||
alert('支付成功,但缺少重定向URL');
|
||||
}
|
||||
} else {
|
||||
// 失败,显示错误信息
|
||||
alert('支付失败:' + data.msg);
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
alert('网络请求失败,请重试');
|
||||
this.disabled = false;
|
||||
this.textContent = "确认信息并提交";
|
||||
this.classList.remove('opacity-70', 'cursor-wait');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>收银台</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../static/css/hy_basic.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="hd-header">
|
||||
{{.siteName}}
|
||||
</div>
|
||||
|
||||
<div class="tastesdk-box">
|
||||
<div class="main">
|
||||
<div class="typedemo" style="height: 600px;">
|
||||
<div style="z-index:100;background:#000000;position:absolute;left:0px;top:0px;display:none;" id="cover">
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="c-box1 clearfix">
|
||||
<div class="bt_border-green">
|
||||
<div class="hy-hd0815 vip20130401 c30 clearfix">
|
||||
<div class="pay_box fl">
|
||||
<h3><img src="../static/img/pay_fail.png">已提交,请等待系统确认。</h3>
|
||||
<div class="disc">
|
||||
<p class="c999">请等待系统自动确认提交卡的正确性。
|
||||
<br/>
|
||||
<span style="color: #a52834; font-weight: bolder;font-size: 2rem;">
|
||||
处理时间大约3分钟左右,请耐心等待,不要重复提交卡密,重复提交会导致上分失败。
|
||||
</span>
|
||||
</p>
|
||||
<button onclick="backToIndex()">
|
||||
返回提交
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<style>
|
||||
.hd-header {
|
||||
height: 12%;
|
||||
width: 100%;
|
||||
padding: 60px 80px 40px;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.bt_border-green {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.hy-hd0815 {
|
||||
margin-top: 20vh;
|
||||
}
|
||||
|
||||
.pay_box {
|
||||
font-size: 36px !important;
|
||||
}
|
||||
|
||||
.pay_box h3 {
|
||||
font-size: 48px !important;
|
||||
margin-bottom: 24px;
|
||||
|
||||
}
|
||||
|
||||
.disc p {
|
||||
font-size: 30px !important;
|
||||
height: 100px;
|
||||
margin-top: 48px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.disc button {
|
||||
text-decoration: none !important;
|
||||
margin-top: 12px;
|
||||
padding: 20px 40px;
|
||||
background-color: #087990;
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function backToIndex() {
|
||||
window.history.back();
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -1,49 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<title>收银台</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../static/css/hy_basic.css">
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div class="tastesdk-box" style="margin-top: 15%;">
|
||||
<div class="main">
|
||||
<div class="typedemo" style="height: 600px;">
|
||||
<div style="z-index:100;background:#000000;position:absolute;left:0px;top:0px;display:none;"
|
||||
id="cover"></div>
|
||||
<div class="container">
|
||||
<div class="c-box1 clearfix">
|
||||
<div class="bt_border-green">
|
||||
<div class="hy-hd0815 vip20130401 c30 clearfix">
|
||||
<div class="pay_box fl">
|
||||
|
||||
|
||||
<h3><img src="../static/img/pay_fail.png">已提交,请等待系统确认。</h3>
|
||||
<ul class="disc">
|
||||
|
||||
<li>
|
||||
已完成提交
|
||||
<p class="c999">请等待系统自动确认提交卡的正确性。
|
||||
</p>
|
||||
<p class="c998" style="color: #a52834;">处理时间大约3分钟左右,请耐心等待,不要重复提交卡密,重复提交会导致上分失败。
|
||||
</p>
|
||||
<a href="/index.html" class="c00">返回提交
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<title>收银台</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../static/css/hy_basic.css">
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div class="tastesdk-box" style="margin-top: 15%;">
|
||||
<div class="main">
|
||||
<div class="typedemo" style="height: 600px;">
|
||||
<div style="z-index:100;background:#000000;position:absolute;left:0px;top:0px;display:none;"
|
||||
id="cover"></div>
|
||||
<div class="container">
|
||||
<div class="c-box1 clearfix">
|
||||
<div class="bt_border-green">
|
||||
<div class="hy-hd0815 vip20130401 c30 clearfix">
|
||||
<div class="pay_box fl">
|
||||
<h3><img src="../static/img/pay_fail.png">支付失败!</h3>
|
||||
<ul class="disc">
|
||||
<li>
|
||||
银行卡已扣款
|
||||
<p class="c999">
|
||||
可能是由于网络传输发生故障或延时造成的,请稍后再次查看订单状态,勿重复支付。</p>
|
||||
</li>
|
||||
<li>
|
||||
银行卡未扣款
|
||||
<p class="c999">请选择其他支付方式完成支付。<a
|
||||
href="/payfor.py" class="c00">返回支付页</a>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,155 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<title>{{.siteName}}</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link href="../static/css/cashier.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
#maxthon-1eec22d4-0232-4212-8283-6f2ac8f967-iframe {
|
||||
display: block !important;
|
||||
position: absolute !important;
|
||||
visibility: visible !important;
|
||||
z-index: 2147483647 !important;
|
||||
border-style: none !important;
|
||||
opacity: 1 !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, .3) !important;
|
||||
border: 1px solid #b3b3b3 !important
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div class="tastesdk-box">
|
||||
<div class="header clearfix">
|
||||
<div class="title">
|
||||
<p class="logo">
|
||||
<span style="width: 100%;">{{.siteName}}</span>
|
||||
</p>
|
||||
<div class="right">
|
||||
<div class="clearfix">
|
||||
<ul class="clearfix">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="typedemo" style="height: 900px;">
|
||||
<div class="demo-pc">
|
||||
<div class="pay-jd">
|
||||
<form action="/payfor.py/" method="post" autocomplete="off">
|
||||
<input type="text" style="display: none" name="orderid" value="{{.orderNo}}">
|
||||
<input type="text" style="display: none" name="shopName" value="{{.shopName}}">
|
||||
<input type="text" style="display: none" name="productName" value="{{.productName}}">
|
||||
|
||||
<div class="two-step">
|
||||
<p><strong>请您及时付款,以便订单尽快处理!</strong></p>
|
||||
<ul class="pay-infor">
|
||||
<li>商城:{{.shopName}}</li>
|
||||
<li>商品名称:{{.productName}}</li>
|
||||
<li>订单编号:<span>{{.orderNo}}</span></li>
|
||||
<li>商品数量:{{.count}}</li>
|
||||
<li>商品单价:{{.price}}</li>
|
||||
</ul>
|
||||
<ul class="pay-infor">
|
||||
<li>支付金额:<strong><input style="border: 0px;width: 34px;color: red;" value="{{.allPrice}}" id="amount" name="amount" />
|
||||
<span>元</span></strong></li>
|
||||
<li class="" style="float: left;">
|
||||
<button type="submit" class="pcdemo-btn sbpay-btn">立即支付</button>
|
||||
</li>
|
||||
</ul>
|
||||
<h4 >扫码支付:</h4>
|
||||
<ul class="pay-label type" >
|
||||
<li>
|
||||
<input value="SCAN_YL" name="SCAN" id="SCAN_YL" type="radio" checked>
|
||||
<label for="SCAN_YL"><img src="../static/img/yinlian.jpg" alt="银联扫码"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="SCAN_QQ" name="SCAN" id="SCAN_QQ" type="radio">
|
||||
<label for="SCAN_QQ"><img src="../static/img/qqq.jpg" alt="QQ扫码支付"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
<h4 style="margin-top: 115px">H5支付:</h4>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="SCAN_YL_H5" name="H5" id="SCAN_YL_H5" type="radio">
|
||||
<label for="SCAN_YL_H5"><img src="../static/img/yinlian.jpg" alt="银联H5"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 style="margin-top: 115px">快捷支付:</h4>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="04031000" name="KJ" id="beijing_kj" type="radio">
|
||||
<label for="beijing_kj"><img src="../static/img/beijing_0.jpg" alt="中国北京银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01020000" name="KJ" id="gongshang_kj" type="radio">
|
||||
<label for="gongshang_kj"><img src="../static/img/gongshang_0.jpg" alt="中国工商银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="03030000" name="KJ" id="guangda_kj" type="radio">
|
||||
<label for="guangda_kj"><img src="../static/img/guangda_0.jpg" alt="中国光大银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01050000" name="KJ" id="jianshe_kj" type="radio">
|
||||
<label for="jianshe_kj"><img src="../static/img/jieshe_0.jpg" alt="中国建设银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="03050000" name="KJ" id="minsheng_kj" type="radio">
|
||||
<label for="minsheng_kj"><img src="../static/img/minsheng_0.jpg" alt="中国民生银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01030000" name="KJ" id="nongye_kj" type="radio">
|
||||
<label for="nongye_kj"><img src="../static/img/nongye_0.jpg" alt="中国农业银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="04012900" name="KJ" id="shanghai_kj" type="radio">
|
||||
<label for="shanghai_kj"><img src="../static/img/shanghai_0.jpg" alt="中国上海银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
<li>
|
||||
<input value="01000000" name="KJ" id="youzheng_kj" type="radio">
|
||||
<label for="youzheng_kj"><img src="../static/img/youzheng_0.jpg" alt="中国邮政银行"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 style="margin-top: 175px">WAP支付(只支持手机端,不支持PC端):</h4>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="SCAN_QQ_WAP" name="WAP" id="SCAN_QQ_WAP" type="radio">
|
||||
<label for="SCAN_QQ_WAP"><img src="../static/img/qqq.jpg" alt="QQ-WAP支付"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<input value="CCB" name="bankCode" type="hidden">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../static/js/base.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
103
views/test.html
103
views/test.html
@@ -1,103 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<title>{{.siteName}}</title>
|
||||
<link rel="shortcut icon" type="tmpay/image/x-icon" href="../static/img/icon.ico">
|
||||
<link href="../static/css/cashier.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
#maxthon-1eec22d4-0232-4212-8283-6f2ac8f967-iframe {
|
||||
display: block !important;
|
||||
position: absolute !important;
|
||||
visibility: visible !important;
|
||||
z-index: 2147483647 !important;
|
||||
border-style: none !important;
|
||||
opacity: 1 !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, .3) !important;
|
||||
border: 1px solid #b3b3b3 !important
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div class="tastesdk-box">
|
||||
<div class="header clearfix">
|
||||
<div class="title">
|
||||
<p class="logo">
|
||||
<span style="width: 100%;">{{.siteName}}</span>
|
||||
</p>
|
||||
<div class="right">
|
||||
<div class="clearfix">
|
||||
<ul class="clearfix">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="typedemo" style="height: 900px;">
|
||||
<div class="demo-pc">
|
||||
<div class="pay-jd">
|
||||
<input type="text" style="display: none" id="orderid" value="{{.orderNo}}">
|
||||
<div class="two-step">
|
||||
<p><strong>请您及时付款,以便订单尽快处理!</strong>请您在提交订单后<span>24小时</span>内完成支付,否则订单会自动取消。
|
||||
</p>
|
||||
<ul class="pay-infor">
|
||||
<li>商品名称:{{.pname}}</li>
|
||||
<li>订单编号:<span>{{.orderNo}}</span></li>
|
||||
</ul>
|
||||
<ul class="pay-infor">
|
||||
<li>面值:<strong><input type="text" id="face_type" name="face_type" value="" required>
|
||||
<span>元</span></strong>
|
||||
</li>
|
||||
<li>类型:<strong>
|
||||
<input type="radio" checked name="ecard" value="京东E卡"/><span>京东E卡</span>
|
||||
</strong>
|
||||
</li>
|
||||
|
||||
<li class="" style="float: left;">
|
||||
<button type="submit" id="submit" class="pcdemo-btn sbpay-btn">立即支付</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>通道:</h4>
|
||||
<ul class="pay-label type">
|
||||
<li>
|
||||
<input value="CARD_DH" checked="checked" name="SCAN" id="CARD_DH" type="radio">
|
||||
<label for="CARD_DH"><img src="../static/img/cardicon_1559282611.png" alt="蜜蜂卡密"
|
||||
style="height: 35px;"><span></span></label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../static/js/base.js"></script>
|
||||
<script type="text/javascript">
|
||||
//
|
||||
var orderID = "{{.orderNo}}";
|
||||
var paykey = "{{.paykey}}";
|
||||
$(document).ready(function () {
|
||||
$("#submit").click(function () {
|
||||
var face_type = $("#face_type").val();
|
||||
if (!face_type) {
|
||||
alert("请输入面值");
|
||||
return
|
||||
}
|
||||
window.location.href = "http://127.0.0.1:12309/order/create?paycode=CARD_DH&price=" + face_type + "&orderid=" + orderID + "&paykey=" + paykey + "¬ifyurl=http://192.168.2.115:12308/shop/notify&sign=sdssdasdasdadasdasdasdadadad";
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user