Compare commits

...

4 Commits

Author SHA1 Message Date
wystan_rin e80ba4d90a 重置 Git 索引,移除不需要的路径引用 2024-11-13 16:13:06 +08:00
wystan_rin e634f7eaee 重置 Git 索引,移除不需要的路径引用 2024-11-13 16:09:26 +08:00
wystan_rin f6272271ca 重置 Git 索引,移除不需要的路径引用 2024-11-13 16:01:54 +08:00
wystan_rin b333804dbe developing 2024-11-13 15:58:47 +08:00
13 changed files with 186 additions and 61 deletions

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
# 对所有文本文件统一使用 LF 作为行尾字符
* text=auto eol=lf
# 指定特定文件使用 CRLF
*.bat text eol=crlf
*.cmd text eol=crlf
# 二进制文件不进行行尾转换
*.png binary
*.jpg binary
*.gif binary

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.idea
*.log
/build/

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="root@192.168.16.207:22 password">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="Flask">
<option name="enabled" value="true" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
</component>
</module>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/payment_headend" vcs="Git" />
</component>
</project>

30
payment_headend/.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
# Python:
*.ipynb
*/__pycache__
/.vagrant
/scrapy.iml
*.pyc
_trial_temp*
dropin.cache
docs/build
*egg-info
.tox
venv
build
dist
.idea
htmlcov/
.coverage
.pytest_cache/
.coverage.*
.cache/
.mypy_cache/
/tests/keys/localhost.crt
/tests/keys/localhost.key
key.txt
key.txt.pub
# Windows
Thumbs.db
ehthumbs.db
Desktop.ini

131
payment_headend/index.html Normal file
View File

@ -0,0 +1,131 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>创建订单</title>
<style>
/* 简单的样式 */
.hidden { display: none; }
.error { color: red; }
</style>
</head>
<body>
<h1>创建订单</h1>
<form id="order-form">
<label for="phone">手机号:</label>
<input type="text" id="phone" name="phone"><br><br>
<label for="email">邮箱:</label>
<input type="email" id="email" name="email"><br><br>
<label for="address">地址:</label>
<input type="text" id="address" name="address"><br><br>
<button type="submit">提交订单</button>
</form>
<div id="message" class="hidden"></div>
<div id="addresses" class="hidden">
<h2>请选择一个地址:</h2>
<ul id="address-list"></ul>
</div>
<div id="error" class="error hidden"></div>
<script>
async function createOrder(phone = "", email = "", address = "") {
try {
const response = await fetch('/create_order', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ phone, email, address })
});
const data = await response.json();
if (response.ok) {
if (data.order_id) {
handleOrderSuccess(data.order_id);
} else if (data.addresses && Array.isArray(data.addresses)) {
handleMultipleAddresses(data.addresses);
}
} else {
if (data.message === "地址不能为空,请输入地址。") {
promptUserForAddress();
} else {
handleError(data.message || '发生未知错误。');
}
}
} catch (error) {
console.error('网络或服务器错误:', error);
handleError('网络或服务器错误,请稍后再试。');
}
}
function handleOrderSuccess(orderId) {
document.getElementById('message').innerText = `订单创建成功!您的订单号是:${orderId}`;
document.getElementById('message').classList.remove('hidden');
document.getElementById('addresses').classList.add('hidden');
document.getElementById('error').classList.add('hidden');
}
function handleMultipleAddresses(addresses) {
const addressList = document.getElementById('address-list');
addressList.innerHTML = ''; // 清空现有列表
addresses.forEach((addr, index) => {
const li = document.createElement('li');
const button = document.createElement('button');
button.innerText = `选择地址 ${index + 1}`;
button.addEventListener('click', () => {
// 选择地址后重新提交订单
createOrder(null, null, addr);
});
li.innerText = addr + ' ';
li.appendChild(button);
addressList.appendChild(li);
});
document.getElementById('addresses').classList.remove('hidden');
document.getElementById('message').classList.add('hidden');
document.getElementById('error').classList.add('hidden');
}
function promptUserForAddress() {
const address = prompt('地址不能为空,请输入您的地址:');
if (address && address.trim() !== "") {
createOrder(null, null, address.trim());
} else {
handleError('地址输入为空,无法创建订单。');
}
}
function handleError(message) {
const errorDiv = document.getElementById('error');
errorDiv.innerText = `错误:${message}`;
errorDiv.classList.remove('hidden');
document.getElementById('message').classList.add('hidden');
document.getElementById('addresses').classList.add('hidden');
}
// 绑定表单提交事件
document.getElementById('order-form').addEventListener('submit', function(event) {
event.preventDefault(); // 阻止表单默认提交行为
// 获取表单输入值
const phone = document.getElementById('phone').value.trim();
const email = document.getElementById('email').value.trim();
const address = document.getElementById('address').value.trim();
// 清除之前的消息
document.getElementById('message').classList.add('hidden');
document.getElementById('addresses').classList.add('hidden');
document.getElementById('error').classList.add('hidden');
// 调用createOrder函数
createOrder(phone, email, address);
});
</script>
</body>
</html>

1
payment_headend/index.js Normal file
View File

@ -0,0 +1 @@
console.log('Happy developing ✨')

View File

@ -0,0 +1,10 @@
{
"name": "payment_headend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"private": true
}