Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7638b8c5cd | ||
|
|
63adb1653a | ||
|
|
c7bb6c85e7 |
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
36
src/main/java/com/demo/Interceptor.java
Normal file
36
src/main/java/com/demo/Interceptor.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.demo;
|
||||
|
||||
import com.utils.Utils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
public class Interceptor implements HandlerInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Object handler) throws Exception {
|
||||
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
request.setCharacterEncoding("utf-8");
|
||||
|
||||
if(
|
||||
(Utils.getPeoperties("aliNotifyUrl")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("appid")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("private_key")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("public_key")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("pwd")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("dburl")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("dbport")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("dbname")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("dbusername")+"").replace("null","").trim().length()<1
|
||||
|| (Utils.getPeoperties("dbpassword")+"").replace("null","").trim().length()<1
|
||||
){
|
||||
response.sendRedirect("./install.html");
|
||||
return false;
|
||||
}else return true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import com.utils.Utils;
|
||||
public class alipay_core {
|
||||
AlipayClient client = null;
|
||||
/**支付宝回调的接口地址*/
|
||||
private static String aliNotifyUrl = "yourWebUrl/pay/alinotify";
|
||||
private static String aliNotifyUrl = Utils.getPeoperties("aliNotifyUrl")+"";
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,9 +30,9 @@ public class alipay_core {
|
||||
*/
|
||||
public void getConfig() {
|
||||
|
||||
String appid="一串数字ID";
|
||||
String private_key="私钥";
|
||||
String public_key="公钥";
|
||||
String appid = Utils.getPeoperties("appid")+"";
|
||||
String private_key = Utils.getPeoperties("private_key")+"";
|
||||
String public_key = Utils.getPeoperties("public_key")+"";
|
||||
String sign_type="RSA2";
|
||||
|
||||
client =new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",appid,private_key,"json","utf-8",public_key,sign_type);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.demo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RequestMapping(value="/pay",produces="text/html;charset=UTF-8")
|
||||
@RestController
|
||||
public class payController {
|
||||
|
||||
@@ -127,11 +127,136 @@ public class payController {
|
||||
+ "values("+order_id+",?,?,"+param.get("total_amount")+","+s+",?,"+param.get("buyer_pay_amount")+","+param.get("receipt_amount")+",?,?)", new String[]{param.get("trade_no"),param.get("subject"),param.get("buyer_logon_id"),param.get("buyer_id"),param.toString()});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/install", produces = "text/html;charset=UTF-8")
|
||||
public String install(
|
||||
@RequestParam(required = false, defaultValue = "") String p,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response
|
||||
) {
|
||||
|
||||
//检查数据是否已经初始化,若没有,先设置后台密码
|
||||
|
||||
String pwd = Utils.getPeoperties("pwd") + "";
|
||||
if(pwd.replace("null","").trim().length()>0){
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","1");
|
||||
m.put("msg","已经初始化");
|
||||
m.put("url","./settings.html");
|
||||
return Utils.ObjectToJson(m);
|
||||
}else if(p.replace("null","").trim().length()>0) {
|
||||
Utils.setPeoperties("pwd",p);
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","1");
|
||||
m.put("msg","初始化成功");
|
||||
m.put("url","./settings.html");
|
||||
return Utils.ObjectToJson(m);
|
||||
}
|
||||
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","-1");
|
||||
m.put("url","./install.html");
|
||||
return Utils.ObjectToJson(m);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/settings", produces = "text/html;charset=UTF-8")
|
||||
public String setsettings(
|
||||
@RequestParam(required = false, defaultValue = "") String p,//后台密码
|
||||
@RequestParam(required = false, defaultValue = "") String k,//key
|
||||
@RequestParam(required = false, defaultValue = "") String v,//value
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response
|
||||
) {
|
||||
|
||||
String pwd = Utils.getPeoperties("pwd") + "";
|
||||
if(pwd.replace("null","").trim().length()<1){
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","-1");
|
||||
m.put("msg","请前往初始化");
|
||||
m.put("url","./install.html");
|
||||
return Utils.ObjectToJson(m);
|
||||
}else if("get".equals(k)&&pwd.equals(v)){
|
||||
//获取配置
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","1");
|
||||
m.put("pwd#后台密码",Utils.getPeoperties("pwd") + "");
|
||||
m.put("dburl#数据库地址(不含http)",Utils.getPeoperties("dburl")+"");
|
||||
m.put("dbname#数据库库名",Utils.getPeoperties("dbname")+"");
|
||||
m.put("dbport#数据库端口",Utils.getPeoperties("dbport")+"");
|
||||
m.put("dbusername#数据库用户名",Utils.getPeoperties("dbusername")+"");
|
||||
m.put("dbpassword#数据库密码",Utils.getPeoperties("dbpassword")+"");
|
||||
m.put("aliNotifyUrl#当面付回调地址",Utils.getPeoperties("aliNotifyUrl")+"");
|
||||
m.put("appid#当面付APPID",Utils.getPeoperties("appid")+"");
|
||||
m.put("private_key#当面付私钥",Utils.getPeoperties("private_key")+"");
|
||||
m.put("public_key#当面付公钥",Utils.getPeoperties("public_key")+"");
|
||||
return Utils.ObjectToJson(m);
|
||||
|
||||
}else if(pwd.equals(p)){
|
||||
//k,v,写入properties
|
||||
Utils.setPeoperties(k,v);
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","1");
|
||||
m.put("msg","已将["+k+"]的值设置为["+v+"]");
|
||||
return Utils.ObjectToJson(m);
|
||||
}else{
|
||||
Map<String,String> m = new HashMap<>();
|
||||
m.put("code","-1");
|
||||
m.put("msg","密码不正确");
|
||||
return Utils.ObjectToJson(m);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/createTable", produces = "text/html;charset=UTF-8")
|
||||
public String createTable(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response
|
||||
) {
|
||||
Map<String,String> m = new HashMap<>();
|
||||
DBUtil db = new DBUtil();
|
||||
boolean is = db.cktable("_orders");
|
||||
if(is){
|
||||
m.put("code","-1");
|
||||
m.put("msg","表已存在");
|
||||
return Utils.ObjectToJson(m);
|
||||
}else{
|
||||
String sql ="";
|
||||
sql += "CREATE TABLE `_orders` (";
|
||||
sql += " `out_trade_no` bigint(255) NOT NULL COMMENT '商家订单号',";
|
||||
sql += " `trade_no` varchar(255) DEFAULT '' COMMENT '支付宝订单号',";
|
||||
sql += " `otitle` varchar(255) DEFAULT '' COMMENT '交易标题',";
|
||||
sql += " `onum` decimal(11,2) DEFAULT '0.00' COMMENT '交易金额',";
|
||||
sql += " `ostatus` int(11) DEFAULT '0' COMMENT '交易状态 0:无订单,1:等待付款,2:超时关闭,3:支付成功,4:交易结束',";
|
||||
sql += " `qrcode` varchar(255) DEFAULT '' COMMENT '二维码地址',";
|
||||
sql += " `zfbuser` varchar(255) DEFAULT '' COMMENT '买家支付宝账号(已隐藏)',";
|
||||
sql += " `paynum` decimal(11,2) DEFAULT '0.00' COMMENT '买家实付款',";
|
||||
sql += " `getnum` decimal(11,2) DEFAULT '0.00' COMMENT '实际收款',";
|
||||
sql += " `zfbuserid` varchar(255) DEFAULT '' COMMENT '支付宝用户id(16位纯数字)',";
|
||||
sql += " `buytype` int(11) DEFAULT '0' COMMENT '买家用户类型 0个人,1企业',";
|
||||
sql += " `getbody` text COMMENT '订单body',";
|
||||
sql += " `remark` varchar(255) DEFAULT NULL,";
|
||||
sql += " `payuser` varchar(255) DEFAULT '' COMMENT '对应本站用户id',";
|
||||
sql += " `payway` varchar(255) DEFAULT '' COMMENT '对应本站付款原因(可以是打赏,购买等)',";
|
||||
sql += " `paytag` varchar(255) DEFAULT '' COMMENT '绑定物品(若是购买,填写物品id)',";
|
||||
sql += " `createtime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,";
|
||||
sql += " PRIMARY KEY (`out_trade_no`)";
|
||||
sql += ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
|
||||
db.execUpdate(sql,null);
|
||||
if(db.cktable("_orders")){
|
||||
m.put("code","1");
|
||||
m.put("msg","建表成功");
|
||||
return Utils.ObjectToJson(m);
|
||||
}else{
|
||||
m.put("code","-1");
|
||||
m.put("msg","建表失败,请检查参数配置");
|
||||
return Utils.ObjectToJson(m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ import java.util.Map;
|
||||
public class DBUtil {
|
||||
|
||||
// 四大金刚
|
||||
String dname = "scbox";
|
||||
String dname = Utils.getPeoperties("dbname")+"";
|
||||
String driver = "com.mysql.jdbc.Driver";// 驱动名称
|
||||
String url = "jdbc:mysql://127.0.0.1:3306/"+dname+"?useUnicode=false&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
|
||||
String username = "root";// 用户名
|
||||
String password = "root";// 密码
|
||||
String url = "jdbc:mysql://"+Utils.getPeoperties("dburl")+":"+Utils.getPeoperties("dbport")+"/"+dname+"?useUnicode=false&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
|
||||
String username = Utils.getPeoperties("dbusername")+"";// 用户名
|
||||
String password = Utils.getPeoperties("dbpassword")+"";// 密码
|
||||
|
||||
// 三剑客
|
||||
Connection con = null;// 连接对象
|
||||
@@ -257,4 +257,28 @@ public class DBUtil {
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查某个表是否存在
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public boolean cktable(String name){
|
||||
boolean is = false;
|
||||
try {
|
||||
|
||||
this.getConnection();// 获得连接对象
|
||||
ResultSet tables = this.con.getMetaData().getTables(null, null, name, null);
|
||||
if (tables.next()) is = true;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
this.close(this.rs, this.pstmt, this.con);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
|
||||
public class Utils {
|
||||
@@ -139,4 +141,57 @@ public class Utils {
|
||||
return resMatrix;
|
||||
}
|
||||
|
||||
public static Properties readPeoperties(){
|
||||
InputStream inputStream = Utils.class.getClassLoader().getResourceAsStream("t.properties");
|
||||
|
||||
Properties p = new Properties();
|
||||
try{
|
||||
p.load(inputStream);
|
||||
}catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Object getPeoperties(Object k){
|
||||
InputStream inputStream = Utils.class.getClassLoader().getResourceAsStream("t.properties");
|
||||
|
||||
Properties p = new Properties();
|
||||
try{
|
||||
p.load(inputStream);
|
||||
}catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return p.get(k);
|
||||
}
|
||||
|
||||
public static void setPeoperties(String k,Object v){
|
||||
Properties p = new Properties();
|
||||
|
||||
InputStream inputStream = Utils.class.getClassLoader().getResourceAsStream("t.properties");
|
||||
try{
|
||||
p.load(inputStream);
|
||||
}catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
p.put(k,v);
|
||||
|
||||
URL f = Utils.class.getClassLoader().getResource("t.properties");
|
||||
|
||||
try{
|
||||
System.out.println(f.toURI());
|
||||
FileOutputStream fos = new FileOutputStream(new File(f.toURI()));
|
||||
p.store(new BufferedOutputStream(fos),"save");
|
||||
fos.close();
|
||||
}catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Object p = Utils.getPeoperties("1");
|
||||
System.out.println(p.toString());
|
||||
Utils.setPeoperties("1","3");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,25 @@
|
||||
|
||||
<bean id="multipartResolver" class="org.springframework.web.multipart.support.StandardServletMultipartResolver"/>
|
||||
|
||||
<mvc:interceptors>
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/**" />
|
||||
<mvc:exclude-mapping path="/install" />
|
||||
<mvc:exclude-mapping path="/settings" />
|
||||
<mvc:exclude-mapping path="/install.html" />
|
||||
<mvc:exclude-mapping path="/settings.html" />
|
||||
<mvc:exclude-mapping path="/createTable" />
|
||||
<mvc:exclude-mapping path="/**/fonts/*" />
|
||||
<mvc:exclude-mapping path="/**/*.css" />
|
||||
<mvc:exclude-mapping path="/**/*.js" />
|
||||
<mvc:exclude-mapping path="/**/*.png" />
|
||||
<mvc:exclude-mapping path="/**/*.gif" />
|
||||
<mvc:exclude-mapping path="/**/*.jpg" />
|
||||
<mvc:exclude-mapping path="/**/*.jpeg" />
|
||||
<bean class="com.demo.Interceptor" />
|
||||
</mvc:interceptor>
|
||||
|
||||
</mvc:interceptors>
|
||||
|
||||
<!-- 自动扫描装配,扫描controller包的注解,加入到容器中 -->
|
||||
<context:component-scan base-package="com.*"/>
|
||||
|
||||
1
src/main/resources/t.properties
Normal file
1
src/main/resources/t.properties
Normal file
@@ -0,0 +1 @@
|
||||
1=2
|
||||
@@ -38,7 +38,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let response = await fetch('./pay/createOrder?n=' + n + '&t=test');
|
||||
let response = await fetch('./createOrder?n=' + n + '&t=test');
|
||||
let res = JSON.parse(await response.text());
|
||||
|
||||
if (res.code == 1) {
|
||||
@@ -64,7 +64,7 @@
|
||||
*轮询检查支付状态
|
||||
*/
|
||||
async function subscribe(id) {
|
||||
let response = await fetch("./pay/queryPay?id=" + id);
|
||||
let response = await fetch("./queryPay?id=" + id);
|
||||
|
||||
if (response.status == 502) {
|
||||
// 连接超时,重新连接
|
||||
@@ -93,7 +93,7 @@
|
||||
* 手动查询支付状态
|
||||
*/
|
||||
async function selectPay(id) {
|
||||
let response = await fetch('./pay/queryPay?id=' + id);
|
||||
let response = await fetch('./queryPay?id=' + id);
|
||||
let res = JSON.parse(await response.text());
|
||||
|
||||
if (response.status == 200 && res.msg == "已支付") {
|
||||
|
||||
52
src/main/webapp/install.html
Normal file
52
src/main/webapp/install.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang='en'>
|
||||
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>初始化</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 10px auto;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="">
|
||||
<br><br><br>
|
||||
<h3>首次使用</h3>
|
||||
<br><br> 设置后台密码:
|
||||
<input type="text" name="p" id="p"> <button onclick="setp()">提交</button>
|
||||
</div>
|
||||
|
||||
<script src='https://libs.baidu.com/jquery/2.0.0/jquery.min.js'></script>
|
||||
|
||||
<script>
|
||||
async function setp() {
|
||||
var p = $('#p').val();
|
||||
let response = await fetch('./install?p=' + p);
|
||||
let res = JSON.parse(await response.text());
|
||||
|
||||
if(res.msg) alert(res.msg);
|
||||
if(res.url) window.location.href = res.url;
|
||||
|
||||
}
|
||||
|
||||
$.get("./install").done((r =>{
|
||||
let res = JSON.parse(r);
|
||||
if(res.msg)alert(res.msg);
|
||||
if(res.url){
|
||||
var u = res.url.substring(1);
|
||||
var au = window.location.href.substring(window.location.href.length - u.length);
|
||||
if(u != au) window.location.href = res.url;
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
129
src/main/webapp/settings.html
Normal file
129
src/main/webapp/settings.html
Normal file
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang='en'>
|
||||
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>配置</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 10px auto;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br><br><br>
|
||||
<h3>参数配置</h3>
|
||||
<br><br>
|
||||
<div id="kvs">
|
||||
输入后台密码获取配置:
|
||||
<input type="text" name="p" id="p"> <button onclick="setp()">提交</button>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
请先在你的MySql数据库中建好上述填写的数据库名,再点击此按钮<br>
|
||||
<button onclick="createTable()">运行数据库建表程序</button>
|
||||
|
||||
<br> <br> <br>
|
||||
测试环境:tomcat8.5,jdk1.8
|
||||
<br>
|
||||
<br> 支付宝开放平台:https://open.alipay.com/
|
||||
<br> 本人以_创建网页应用_做步骤展示:
|
||||
<br> 1.在控制台点击【网页/移动应用】创建网页移动应用(根据自己需求可以创建其他的)
|
||||
<br>
|
||||
<br> 2.创建成功后,点击“开发设置”,设置【接口加签方式】选择“秘钥”,根据步骤提示下载"秘钥工具"安装,根据提示步骤生成秘钥,按照步骤填写公钥,下载生成的公钥文件,一定要保存好。
|
||||
<br>
|
||||
<br> 3.还是上步骤的“开发设置”里填写【支付宝网关地址】,此地址与上述参数配置里的当面付回调地址是一个东西,本测试代码填写的是:yourweb/war名称[根目录此项去掉]/alinotify。
|
||||
<br> 系统监测到你应该填写:<span style="color: red;" id="al"></span> (仅供参考,若错误请自行填写)
|
||||
<br> 用户支付成功后支付宝会将成功数据发送到你填的这个网关地址上
|
||||
<br>
|
||||
<br> 4.在“产品绑定”页面,点击去绑定,在产品里找到"当面付",选中,点击确定。
|
||||
<br>
|
||||
<br> 5.在当面付“未开通”后面的!上鼠标悬浮,弹框中点击“去开通”,根据要求填写内容,不用上传营业执照,店铺招牌和店铺内景自己从百度找一张高清无水印的,写的什么名称就搜什么名称的图片,一般都能搜到同名的店,内景无所谓,只要合适就行,有能力的可以ps一下,提交审核就可以。
|
||||
<br>
|
||||
<br> 6.回到支付宝开放平台“网页应用”界面,将应用提交审核.
|
||||
|
||||
<br> <br> <br>
|
||||
API接口说明:
|
||||
<br> ./createOrder?n=金额&t=备注 ==> 获取付款码
|
||||
<br>
|
||||
<br> ./queryOrder?id=生成的订单号 ==> 查询订单
|
||||
<br>
|
||||
<br> ./queryPay?id=生成的订单号 ==> 查询订单是否支付成功
|
||||
<br>
|
||||
<br> 一般通过 轮询 查询订单是否支付成功 即可实现支付成功回调.
|
||||
|
||||
|
||||
<script src='https://libs.baidu.com/jquery/2.0.0/jquery.min.js'></script>
|
||||
|
||||
<script>
|
||||
async function setp() {
|
||||
var p = $('#p').val();
|
||||
let response = await fetch('./settings?k=get&v=' + p);
|
||||
let res = JSON.parse(await response.text());
|
||||
if(res.code / 1 == 1){
|
||||
$('#kvs').empty();
|
||||
|
||||
for(var k in res){
|
||||
if(k=='code') continue;
|
||||
var v = res[k];
|
||||
var ks = k.split('#');
|
||||
if(v=='null') v='';
|
||||
|
||||
var span1 = document.createElement('span');
|
||||
|
||||
var e0 = document.createElement('span');
|
||||
e0.innerHTML=ks[1]+":";
|
||||
|
||||
var e1 = document.createElement('input');
|
||||
e1.setAttribute("type","text");
|
||||
e1.setAttribute("name",ks[0]);
|
||||
e1.setAttribute("id",ks[0]);
|
||||
e1.setAttribute("value",v);
|
||||
|
||||
var e2 = document.createElement('button');
|
||||
e2.setAttribute("onclick","setk('"+res['pwd#后台密码']+"','"+ks[0]+"')");
|
||||
e2.innerHTML = "修改";
|
||||
var e3 = document.createElement('hr');
|
||||
|
||||
span1.appendChild(e0);
|
||||
span1.appendChild(e1);
|
||||
span1.appendChild(e2);
|
||||
span1.appendChild(e3);
|
||||
|
||||
$('#kvs').append(span1);
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
if(res.msg)alert(res.msg);
|
||||
if(res.url) window.location.href = res.url;
|
||||
}
|
||||
}
|
||||
|
||||
async function setk(pwd,k) {
|
||||
var p = $('#'+k).val();
|
||||
let response = await fetch('./settings?p='+pwd+'&k='+k+'&v=' + p);
|
||||
let res = JSON.parse(await response.text());
|
||||
if(res.code / 1 == 1){
|
||||
alert(res.msg);
|
||||
}else alert(res.msg);
|
||||
}
|
||||
|
||||
async function createTable(){
|
||||
let response = await fetch('./createTable');
|
||||
let res = JSON.parse(await response.text());
|
||||
|
||||
if(res.msg) alert(res.msg);
|
||||
if(res.url) window.location.href = res.url;
|
||||
}
|
||||
|
||||
var ph = window.location.pathname.split('/');
|
||||
$("#al").html(window.location.protocol+'//'+window.location.host+(ph>2?'/'+ph[1]:ph[0])+'/alinotify');
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user