This commit is contained in:
tsf 2025-09-03 19:16:02 +08:00
parent ee943e8613
commit 128e3f9cea
15 changed files with 136 additions and 1063 deletions

View File

@ -1,65 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0 0;
padding: 0 0;
}
#big_box{
width: 100vw;
}
#down_file{
width: 100vw;
height: 20vw;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
}
img{
display: block;
width: 100%;
}
a{
width: 100vw;
text-align: center;
line-height: 10vw;
}
</style>
<script>
var title = '12岁以上青少年长高食谱'
document.addEventListener('DOMContentLoaded', function() {
// Change the page title
document.title = title;
// Insert 48 images in the img_box div
const imgBox = document.getElementById('img_box');
for (let i = 1; i <= 48; i++) {
const img = document.createElement('img');
img.src = `./img/9861b4373f4d41051ea7a931b882e767-${i}.jpg`;
img.alt = `Recipe image ${i}`;
imgBox.appendChild(img);
}
// Update the download link to PDF with forced download
const downloadLink = document.querySelector('#down_file a');
downloadLink.href = 'http://wm.reedaw.com/children_meals_cookbook/'+title+'/'+title+'.pdf';
downloadLink.setAttribute('download', '12岁以上青少年长高食谱.pdf');
downloadLink.textContent = '点击下载文件';
});
</script>
</head>
<body>
<div id="big_box">
<div id="img_box"></div>
<div id="down_file">
<a href=""></a>
</div>
</div>
</body>
</html>

View File

@ -1,211 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>目录</title>
<style>
*{
margin: 0 0;
padding: 0 0;
}
#big_box{
width: 100vw;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
}
.one_box{
width: 95vw;
text-align: center;
min-height: 10vw;
line-height: 10vw;
border: 2px solid wheat;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
}
.two_box{
width: 90vw;
text-align: center;
min-height: 10vw;
line-height: 10vw;
border: 2px solid coral;
}
.child_div{
width: 100%;
text-align: center;
height: 10vw;
line-height: 10vw;
background-color: darkgray;
}
img{
display: block;
width: 100%;
}
a{
width: 100vw;
text-align: center;
line-height: 10vw;
}
/* 添加的折叠样式 */
.one_box_c {
overflow: hidden;
height: 0;
transition: height 0.3s ease;
}
.two_box_c {
overflow: hidden;
height: 0;
transition: height 0.3s ease;
}
</style>
</head>
<body>
<div id="big_box">
<div class="one_box">
<div class="one_box_t">0~6岁宝宝辅食</div>
<div class="one_box_c">
<div class="two_box">
<div class="two_box_t">01-宝宝辅食(文档)</div>
<div class="two_box_c">
<div class="child_div">1岁3个月宝宝辅食.doc</div>
</div>
</div>
<div class="two_box">
<div class="two_box_t">01-宝宝辅食(文档)</div>
<div class="two_box_c">
<div class="child_div">1岁3个月宝宝辅食.doc</div>
</div>
</div>
</div>
</div>
<div class="one_box">
<div class="one_box_t">0~6岁宝宝辅食</div>
<div class="one_box_c">
<div class="two_box">
<div class="two_box_t">01-宝宝辅食(文档)</div>
<div class="two_box_c">
<div class="child_div">1岁3个月宝宝辅食.doc</div>
</div>
</div>
</div>
</div>
<div class="one_box">
<div class="one_box_t">0~6岁宝宝辅食</div>
<div class="one_box_c">
<div class="two_box">
<div class="two_box_t">01-宝宝辅食(文档)</div>
<div class="two_box_c">
<div class="child_div">1岁3个月宝宝辅食.doc</div>
</div>
</div>
</div>
</div>
<div class="one_box">
<div class="one_box_t">0~6岁宝宝辅食</div>
<div class="one_box_c">
<div class="two_box">
<div class="two_box_t">01-宝宝辅食(文档)</div>
<div class="two_box_c">
<div class="child_div">1岁3个月宝宝辅食.doc</div>
</div>
</div>
</div>
</div>
<div class="child_div">12岁以上青少年长高食谱</div>
</div>
</body>
</html>
<script>
document.addEventListener('DOMContentLoaded', function() {
// 获取所有一级和二级容器
const oneBoxes = document.querySelectorAll('.one_box');
const twoBoxes = document.querySelectorAll('.two_box');
// 初始化所有一级容器高度为0
function resetAllOneBoxes() {
oneBoxes.forEach(box => {
const content = box.querySelector('.one_box_c');
content.style.height = '0';
});
}
// 一级菜单点击事件
oneBoxes.forEach(box => {
const title = box.querySelector('.one_box_t');
const content = box.querySelector('.one_box_c');
title.addEventListener('click', function(e) {
e.stopPropagation();
// 如果当前内容已经展开,则关闭它
if (content.style.height !== '0px' && content.style.height !== '') {
content.style.height = '0';
} else {
// 否则关闭所有一级菜单,然后展开当前
resetAllOneBoxes();
// 计算内容高度并展开
const contentHeight = content.scrollHeight;
content.style.height = contentHeight + 'px';
}
});
});
// 二级菜单点击事件 - 修改为不影响其他two_box
twoBoxes.forEach(box => {
const title = box.querySelector('.two_box_t');
const content = box.querySelector('.two_box_c');
title.addEventListener('click', function(e) {
e.stopPropagation();
// 切换当前二级内容的展开/关闭状态
if (content.style.height !== '0px' && content.style.height !== '') {
content.style.height = '0';
} else {
const contentHeight = content.scrollHeight;
content.style.height = contentHeight + 'px';
}
});
});
// 初始化所有内容为关闭状态
resetAllOneBoxes();
});
</script>
<script>
// 获取所有 child_div 元素
const childDivs = document.querySelectorAll('.child_div');
// 定义 jump 函数
function jump() {
const title = this.textContent.trim(); // 获取当前点击的 div 的文本内容
const encodedTitle = encodeURIComponent(title); // 编码标题,确保 URL 有效
// 创建或使用现有的 downloadLink
let downloadLink = window.downloadLink;
if (!downloadLink) {
downloadLink = document.createElement('a');
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
window.downloadLink = downloadLink; // 存储为全局变量以便复用
}
// 设置链接并跳转
// downloadLink.href = `http://wm.reedaw.com/children_meals_cookbook/${encodedTitle}/${encodedTitle}.html`;
downloadLink.href = `https://tc.pcxbc.com/children_meals_cookbook/${encodedTitle}/${encodedTitle}.html`;
downloadLink.click();
}
// 为每个 child_div 添加点击事件
childDivs.forEach(div => {
div.addEventListener('click', jump);
div.style.cursor = 'pointer'; // 添加手型光标,提示可点击
});
</script>

View File

@ -1,258 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>测试菜谱提交</title>
<style>
.ingredient, .step {
margin: 5px 0;
padding: 5px;
border: 1px solid #ccc;
}
.ingredient button, .step button {
margin-left: 10px;
}
.foot_list {
margin-top: 10px;
}
.foot_list .ingredient {
margin: 5px 0;
}
</style>
<script src="../x_admin/js/jq.js"></script>
</head>
<body>
<p style="font-weight: bold;">菜谱信息</p>
<div class='box1'>
<label for="cover">上传封面:</label>
<input type="file" id="cover" name="cover" accept="image/*" multiple>
<br>
<label for="title">菜谱标题:</label>
<input type="text" id="title" name="title">
<br>
<label for="description">菜谱简介:</label>
<textarea id="description" name="description" rows="4" cols="50"></textarea>
<br>
</div>
<p style="font-weight: bold;">添加食材</p>
<div class='box2'>
<div id="box2_content">
</div>
<div id="box2_action" style="margin:10px 0;display: flex;flex-direction: row;flex-wrap: nowrap;justify-content: space-around;">
<div onclick="clearIngredients()">清空</div>
<div onclick="addIngredient()">添加食材</div>
</div>
</div>
<p style="font-weight: bold;">编辑步骤</p>
<div class='box3'>
<div id="box3_content"></div>
<div id="box3_action">
<button onclick="addStep()">添加步骤</button>
</div>
</div>
<div onclick="saveData()" style="margin:50px 0;">保存</div>
</body>
</html>
<script>
var submit_data;
let ingredientsList = [];
function addIngredient() {
const ingredients = ['鸡肉', '牛肉', '猪肉'];
const randomIngredient = ingredients[Math.floor(Math.random() * ingredients.length)];
const randomWeight = Math.floor(Math.random() * (300 - 100 + 1)) + 100;
const ingredientDiv = document.createElement('div');
ingredientDiv.className = 'ingredient';
ingredientDiv.textContent = `${randomIngredient} ${randomWeight}克`;
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.onclick = function() {
removeIngredient(ingredientDiv, randomIngredient, randomWeight);
};
ingredientDiv.appendChild(deleteButton);
document.getElementById('box2_content').appendChild(ingredientDiv);
ingredientsList.push({ name: randomIngredient, weight: randomWeight });
}
function removeIngredient(divElement, ingredientName, ingredientWeight) {
divElement.remove();
ingredientsList = ingredientsList.filter(item => !(item.name === ingredientName && item.weight === ingredientWeight));
}
function clearIngredients() {
const box2Content = document.getElementById('box2_content');
while (box2Content.firstChild) {
box2Content.removeChild(box2Content.firstChild);
}
ingredientsList = [];
}
function addStep() {
const stepDiv = document.createElement('div');
stepDiv.className = 'step';
// 多图上传
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = 'image/*';
fileInput.name = 'images[]';
fileInput.multiple = true;
stepDiv.appendChild(fileInput);
// 选择食材按钮
const selectIngredientButton = document.createElement('button');
selectIngredientButton.textContent = '选择食材';
selectIngredientButton.onclick = function() {
selectIngredient(stepDiv);
};
stepDiv.appendChild(selectIngredientButton);
// 步骤输入说明
const stepDescription = document.createElement('textarea');
stepDescription.placeholder = '步骤说明';
stepDescription.rows = 4;
stepDescription.cols = 50;
stepDiv.appendChild(stepDescription);
// 每个步骤的 foot_list
const footList = document.createElement('div');
footList.className = 'foot_list';
stepDiv.appendChild(footList);
document.getElementById('box3_content').appendChild(stepDiv);
}
function selectIngredient(stepDiv) {
if (ingredientsList.length === 0) {
alert('没有可用的食材');
return;
}
// 获取当前步骤的 foot_list
const footList = stepDiv.querySelector('.foot_list');
// 获取已经添加过的食材
const addedIngredients = Array.from(footList.getElementsByClassName('ingredient')).map(div => div.textContent);
// 过滤已经添加过的食材
const availableIngredients = ingredientsList.filter(item => {
const ingredientText = `${item.name} ${item.weight}克`;
return !addedIngredients.includes(ingredientText);
});
if (availableIngredients.length === 0) {
alert('所有食材已添加');
return;
}
const randomIndex = Math.floor(Math.random() * availableIngredients.length);
const selectedIngredient = availableIngredients[randomIndex];
const ingredientDiv = document.createElement('div');
ingredientDiv.className = 'ingredient';
ingredientDiv.textContent = `${selectedIngredient.name} ${selectedIngredient.weight}克`;
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.onclick = function() {
removeFootIngredient(ingredientDiv, selectedIngredient.name, selectedIngredient.weight, footList);
};
ingredientDiv.appendChild(deleteButton);
footList.appendChild(ingredientDiv);
}
function removeFootIngredient(divElement, ingredientName, ingredientWeight, footList) {
divElement.remove();
// 重新过滤 ingredientsList 以确保删除后不会重复添加
const addedIngredients = Array.from(footList.getElementsByClassName('ingredient')).map(div => div.textContent);
ingredientsList = ingredientsList.filter(item => {
const ingredientText = `${item.name} ${item.weight}克`;
return !addedIngredients.includes(ingredientText);
});
}
function saveData() {
const formData = new FormData();
// 封面文件
const coverInput = document.getElementById('cover');
if (coverInput.files.length > 0) {
formData.append('cover', coverInput.files[0]);
}
// 菜谱标题
const titleInput = document.getElementById('title');
formData.append('title', titleInput.value);
// 菜谱描述
const descriptionInput = document.getElementById('description');
formData.append('description', descriptionInput.value);
// 食材列表
formData.append('ingredientsList', JSON.stringify(ingredientsList));
// 步骤内容
const steps = document.querySelectorAll('.step');
steps.forEach((step, index) => {
// 步骤说明
const stepDescription = step.querySelector('textarea');
formData.append(`steps[${index}][description]`, stepDescription.value);
// 选择的食材
const footList = step.querySelector('.foot_list');
const ingredients = Array.from(footList.getElementsByClassName('ingredient')).map(div => {
const [name, weightText] = div.textContent.split(' ');
const weight = parseInt(weightText, 10);
return { name, weight };
});
formData.append(`steps[${index}][ingredients]`, JSON.stringify(ingredients));
// 上传的图片
const fileInput = step.querySelector('input[type="file"]');
Array.from(fileInput.files).forEach((file, fileIndex) => {
formData.append(`steps[${index}][images][${fileIndex}]`, file);
});
});
submit_data = formData;
// 打印 formData 内容
console.log('submit_data:', formData);
// 遍历 formData 以查看其内容
for (var pair of formData.entries()) {
console.log(pair[0] + ': ' + pair[1]);
}
console.log(submit_data);
return
$.ajax({
url: "http://wm.tcxbc.com/kitchenscale/add_cookbook", // 请求的url地址
contentType: false,
processData: false,
async: true, // 请求是否异步默认为异步这也是ajax重要特性
data: submit_data, // 参数值
type: "POST", // 请求方式
beforeSend: function() {
// 请求前的处理
},
success: function(req) {
// 请求成功时处理
console.log('成功:', req);
},
complete: function() {
// 请求完成的处理
},
error: function(err) {
// 请求出错处理
console.error('错误:', err);
}
});
}
</script>

View File

@ -1,101 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="full-screen" content="true">
<meta name="screen-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<title>隐私协议</title>
<style>
*{
padding: 0 0;
margin: 0 0;
}
.big_box{
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
overflow: auto;
padding: 10vw;
box-sizing: border-box;
}
.title{
width: 100%;
height: 10vw;
text-align: center;
font-size: 7vw;
font-weight: bold;
margin-bottom: 6vw;
}
.content{
width: 100%;
}
.font_1{
font-size: 4.5vw;
font-weight: bold;
}
.font_2{
font-size: 3.5vw;
margin: 3vw 0;
}
.fint_w{
font-weight: bold;
margin-left: 5vw;
}
</style>
</head>
<body id="box_k">
<div class="big_box">
<div class="title">轻厨记隐私协议</div>
<div class="content">
<div class="font_1">一、前言</div>
<div class="font_2">感谢您选择使用我们的智能厨房秤APP以下简称“本应用”。我们深知您的个人信息安全至关重要在您使用本应用时我们郑重承诺将严格遵守相关法律法规采取合理有效的措施保护您的个人隐私。本隐私协议旨在明确我们在采集、使用、存储、共享及保护您的个人信息方面的责任和义务。请您在使用本应用前仔细阅读并理解本协议内容。一旦您开始使用本应用即视为您同意我们按照本协议的规定处理您的个人信息。</div>
<div class="font_1">二、信息收集</div>
<div class="font_2"><span class="fint_w">1.必要信息:</span>为了提供基本服务,我们可能会收集您的手机号码、电子邮箱等联系方式,以便验证身份、保障账号安全及提供必要的服务支持。</div>
<div class="font_2"><span class="fint_w">2.健康数据:</span>在使用本应用时您可以选择提供身高、体重、BMI等健康数据以便我们为您计算营养摄入建议或生成健康报告。</div>
<div class="font_2"><span class="fint_w">3.饮食记录:</span>本应用会记录您通过厨房秤测量的食材重量、饮食内容及时间等信息,用于分析您的饮食习惯并提供个性化建议。</div>
<div class="font_2"><span class="fint_w">4.设备信息:</span>为了优化服务体验我们可能会采集您的设备型号、操作系统版本、IP地址等必要的技术信息。这些信息将帮助我们了解用户的使用环境以便进行技术调试和服务改进。</div>
<div class="font_1">三、信息使用</div>
<div class="font_2"><span class="fint_w">1.服务提供:</span>我们将根据您提供的信息,为您提供食材称重、营养分析、饮食记录及健康建议等服务。</div>
<div class="font_2"><span class="fint_w">2.个性化推荐:</span>基于您的饮食记录、健康数据和使用习惯,我们可能会向您推荐适合的食谱、营养计划或健康管理方案。</div>
<div class="font_2"><span class="fint_w">3.数据分析:</span>我们会对收集到的数据进行匿名化处理,用于统计分析、产品优化及服务改进。这些统计数据将不包含任何可以识别您个人身份的信息。</div>
<div class="font_1">四、信息共享与披露</div>
<div class="font_2"><span class="fint_w">1.内部共享:</span>我们可能会将您的信息共享给公司内部负责处理您个人信息的部门或人员,以确保为您提供更好的服务。</div>
<div class="font_2"><span class="fint_w">2.第三方合作:</span>在必要且合法的情况下,我们可能会与第三方服务提供商(如云服务提供商、数据分析公司等)共享您的个人信息,以便他们为我们提供技术支持或数据分析服务。我们将与这些第三方签订严格的保密协议,并要求其遵守相关法律法规和本协议的规定。</div>
<div class="font_2"><span class="fint_w">3.法律要求:</span>在法律法规要求或政府部门、司法机关依法要求的情况下,我们可能会披露您的个人信息。</div>
<div class="font_1">五、信息安全</div>
<div class="font_2"><span class="fint_w">1.技术保障:</span>我们将采取合理的技术手段和管理措施,确保您的个人信息在采集、存储、使用及共享过程中的安全。</div>
<div class="font_2"><span class="fint_w">2.数据加密:</span>对于敏感信息(如健康数据、饮食记录等),我们将采用加密技术进行处理,防止数据在传输和存储过程中被非法访问或泄露。</div>
<div class="font_2"><span class="fint_w">3.访问控制:</span>我们将对访问个人信息的员工进行严格的权限管理,确保只有授权人员才能接触相关信息。</div>
<div class="font_1">六、用户权利</div>
<div class="font_2"><span class="fint_w">1.知情权:</span>您有权了解我们采集、使用、共享及保护您个人信息的详细情况。</div>
<div class="font_2"><span class="fint_w">2.选择权:</span>您有权选择是否向我们提供个人信息的具体内容,以及是否接受个性化推荐服务。</div>
<div class="font_2"><span class="fint_w">3.更正权:</span>如果您发现我们采集的个人信息有误,您有权要求我们及时更正。</div>
<div class="font_2"><span class="fint_w">4.删除权:</span>在符合法律法规要求的情况下,您有权要求删除您的个人信息。</div>
<div class="font_1">七、协议变更</div>
<div class="font_2">我们有权根据法律法规的变化或业务发展的需要,对本隐私协议进行修订。修订后的协议将通过本应用内通知或其他适当方式告知您。请您定期查阅本协议,以便及时了解最新政策。</div>
<div class="font_1">八、争议解决</div>
<div class="font_2">如因本协议产生任何争议,双方应首先通过友好协商解决;协商不成的,任何一方均有权向本应用运营方所在地的人民法院提起诉讼。</div>
<div class="font_1">九、生效与终止</div>
<div class="font_2">本协议自您同意并接受之日起生效,并持续有效至您注销账号或本应用终止服务时止。</div>
</div>
</div>
</body>
</html>

View File

@ -1,428 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>测试菜谱提交</title>
<style>
.yc{
display: none;
}
.ingredient, .step {
margin: 5px 0;
padding: 5px;
border: 1px solid #ccc;
}
.ingredient button, .step button {
margin-left: 10px;
}
.foot_list {
margin-top: 10px;
}
.foot_list .ingredient {
margin: 5px 0;
}
#fileInput{
display: none;
}
#img_chose{
width: 95vw;
height: 100vw;
background-color: #ccc;
position: fixed;
top: 20%;
left: 0;
right: 0;
margin: 0 auto;
display: none;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
align-content: flex-start;
}
#img_chose img{
width:20vw;
height: 20vw;
}
.cover_show img{
width: 30%;
}
.step_show_all img{
width: 20%;
}
</style>
<script src="../x_admin/js/jq.js"></script>
</head>
<body>
<p style="font-weight: bold;">菜谱信息~</p>
<div class='box1'>
<label for="cover">上传封面:</label>
<button onclick="open_img_chose('cover',0)">选择图片</button>
<br>
<div class="cover_show"></div>
<br>
<br>
<label for="title">菜谱标题:</label>
<input type="text" id="title" name="title">
<br>
<br>
<label for="description">菜谱简介:</label>
<textarea id="description" name="description" rows="4" cols="50"></textarea>
<br>
</div>
<p style="font-weight: bold;">添加食材</p>
<div class='box2'>
<div id="box2_content">
</div>
<div id="box2_action" style="margin:10px 0;display: flex;flex-direction: row;flex-wrap: nowrap;justify-content: space-around;">
<div onclick="clearIngredients()">清空</div>
<div onclick="addIngredient()">添加食材</div>
</div>
</div>
<p style="font-weight: bold;">编辑步骤</p>
<div class='box3'>
<div id="box3_content"></div>
<div id="box3_action">
<button onclick="addStep()">添加步骤</button>
</div>
</div>
<div onclick="saveData()" style="margin:50px 0;">保存</div>
<!-- 图片选择组件 -->
<div id="img_chose" class="yc">
<div onclick="upload_action()"><img src="http://tc.pcxbc.com/tsf/upload_pic.jpg" alt=""></div>
<button onclick="close_action()">关闭</button>
</div>
<input type="file" id="fileInput" accept="image/*" name="img_list" multiple>
</body>
</html>
<script>
// 设置最终提交变量important
var post_data = {
"cook_label": '2', //菜谱标签,属于什么菜系之类的
"token": 'caadd1be045a65f30b92aa805f1de54a', //菜谱标签,属于什么菜系之类的
"cover": '', //封面图片
"title": '', //菜谱标题
"description": '', //菜谱简介
"food_list": [], //食材列表
"step_list": [], //步骤列表
};
var what_button = '';//用来判断是封面还是步骤
function open_img_chose(str,num){
what_button = str+','+num;
// $('#img_chose').html('');
var user_img_list = [];
$.ajax({
url:"https://tc.pcxbc.com/kitchenscale/pic_chose_list", //请求的url地址
// url:"http://wm.tcxbc.com/kitchenscale/pic_chose_list", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"token":"caadd1be045a65f30b92aa805f1de54a"}, //参数值
type:"POST", //请求方式
success:function(req){
if(req.code==0){
for (let index = 0; index < req.data.result.length; index++) {
var newDiv = $('<div></div>')
.addClass('pic_box')
.attr('onclick', 'sendParamToParent(\''+req.data.result[index]['id']+'\',\''+req.data.result[index]['pic_url']+'\',\''+what_button+'\')')
.append($('<img></img>')
.attr('src', req.data.result[index]['pic_url'])
.attr('alt', '')
);
$('#img_chose > div:first').after(newDiv);
}
$('#img_chose').css('display', 'flex');
}
},
error:function(){
//请求出错处理
}
});
}
function upload_action(){
document.getElementById('fileInput').click();
}
$('#fileInput').on('change', function() {
// 获取被选择的文件
var files = event.target.files;
if (files.length > 5) {
alert('最多只能选择5张图片,您选择了' + files.length + ' 张图片');
// 清空文件输入,取消选择的文件
$(this).val('');
return
}
console.log('当前选择了' + files.length + ' 张图片');
// 检查是否有文件被选择
if (files.length > 0) {
var formdata = new FormData();
for (var i = 0; i < files.length; i++) {
formdata.append('images[]', files[i]);
}
formdata.append('token', 'caadd1be045a65f30b92aa805f1de54a');
$.ajax({
url:"https://tc.pcxbc.com/kitchenscale/pic_upload_action", //请求的url地址
// url:"http://wm.tcxbc.com/kitchenscale/pic_upload_action", //请求的url地址
contentType:false,
processData:false,
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:formdata, //参数值
type:"POST", //请求方式
success:function(req){
alert('本次添加失败'+req.data.error_data+'张');
for (let index = 0; index < req.data.insert_data.length; index++) {
var newDiv = $('<div></div>')
.addClass('pic_box')
.attr('onclick', 'sendParamToParent(\''+req.data.insert_data[index]['id']+'\',\''+req.data.insert_data[index]['pic_url']+'\',\''+what_button+'\')')
.append($('<img></img>')
.attr('src', req.data.insert_data[index]['pic_url'])
.attr('alt', '')
);
$('#img_chose > div:first').after(newDiv);
}
},
error:function(){
//请求出错处理
}
});
}
});
function sendParamToParent(id,url,parameter){
var parameter_arr = parameter.split(",");
if(parameter_arr[0] == 'cover'){
// 添加数据进最终提交变量important
post_data.cover = id;
$('.cover_show').html('');
$('.cover_show')
.append($('<img></img>')
.attr('src', url)
.attr('alt', '')
);
}else{
// 添加数据进最终提交变量important
post_data.step_list[parameter_arr[1]]['pic_list'].push(id);
$('.step_show_'+parameter_arr[1])
.append($('<img></img>')
.attr('src', url)
.attr('alt', '')
);
}
console.log(post_data)
}
function close_action(){
$('#img_chose').hide();
$('#img_chose .pic_box').remove();
}
</script>
<script>
var submit_data;
let ingredientsList = [];
// 添加随机的食材,从'鸡肉', '牛肉', '猪肉'随机选重量从100-300克随机选
function addIngredient() {
const ingredients = ['鸡肉', '牛肉', '猪肉'];
const randomIngredient = ingredients[Math.floor(Math.random() * ingredients.length)];
const randomWeight = Math.floor(Math.random() * (300 - 100 + 1)) + 100;
const ingredientDiv = document.createElement('div');
ingredientDiv.className = 'ingredient';
ingredientDiv.textContent = `${randomIngredient} ${randomWeight}克`;
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.onclick = function() {
removeIngredient(ingredientDiv, randomIngredient, randomWeight);
};
ingredientDiv.appendChild(deleteButton);
document.getElementById('box2_content').appendChild(ingredientDiv);
post_data.food_list.push({ name: randomIngredient, weight: randomWeight });
console.log(post_data)
}
// 删除单个食材
function removeIngredient(divElement, ingredientName, ingredientWeight) {
divElement.remove();
post_data.food_list = post_data.food_list.filter(item => !(item.name === ingredientName && item.weight === ingredientWeight));
}
// 清除所有食材
function clearIngredients() {
const box2Content = document.getElementById('box2_content');
while (box2Content.firstChild) {
box2Content.removeChild(box2Content.firstChild);
}
post_data.food_list = [];
}
// 添加步骤
function addStep() {
const stepDiv = document.createElement('div');
stepDiv.className = 'step';
// 在步骤里面添加一个空数据
var num = post_data.step_list.push({ pic_list: [], foot_list: [] ,description:""});
// console.log(post_data.step_list.push({ pic_list: [], foot_list: [] ,description:""}))
// <div class="cover_show"></div>
const show_img = document.createElement('div');
show_img.className = 'step_show_all step_show_'+(num-1);
stepDiv.appendChild(show_img);
// 多图上传
const fileInput = document.createElement('button');
fileInput.textContent = '选择图片';
fileInput.onclick = function() {
open_img_chose('step_list',num-1);
};
stepDiv.appendChild(fileInput);
// 选择食材按钮
const selectIngredientButton = document.createElement('button');
selectIngredientButton.textContent = '选择食材';
selectIngredientButton.onclick = function() {
selectIngredient(stepDiv,num-1);
};
stepDiv.appendChild(selectIngredientButton);
// 步骤输入说明
const stepDescription = document.createElement('textarea');
stepDescription.placeholder = '步骤说明';
stepDescription.rows = 4;
stepDescription.cols = 50;
stepDescription.onblur = function() {
writeDescriptionChild(this,num-1);
};
stepDiv.appendChild(stepDescription);
// 每个步骤的 foot_list
const footList = document.createElement('div');
footList.className = 'foot_list';
stepDiv.appendChild(footList);
document.getElementById('box3_content').appendChild(stepDiv);
}
function selectIngredient(stepDiv,num) {
if (post_data.food_list.length === 0) {
alert('没有可用的食材');
return;
}
// 获取当前步骤的 foot_list
const footList = stepDiv.querySelector('.foot_list');
// 获取已经添加过的食材
const addedIngredients = Array.from(footList.getElementsByClassName('ingredient')).map(div => div.textContent);
// 过滤已经添加过的食材
const availableIngredients = post_data.food_list.filter(item => {
const ingredientText = `${item.name} ${item.weight}克`;
return !addedIngredients.includes(ingredientText);
});
if (availableIngredients.length === 0) {
alert('所有食材已添加');
return;
}
const randomIndex = Math.floor(Math.random() * availableIngredients.length);
const selectedIngredient = availableIngredients[randomIndex];
const ingredientDiv = document.createElement('div');
ingredientDiv.className = 'ingredient';
ingredientDiv.textContent = `${selectedIngredient.name} ${selectedIngredient.weight}克`;
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.onclick = function() {
removeFootIngredient(ingredientDiv, selectedIngredient.name, selectedIngredient.weight, footList);
};
ingredientDiv.appendChild(deleteButton);
footList.appendChild(ingredientDiv);
// 添加数据进最终提交变量important
post_data.step_list[num]['foot_list'].push({name:selectedIngredient.name,weight:selectedIngredient.weight});
console.log(post_data)
}
function removeFootIngredient(divElement, ingredientName, ingredientWeight, footList) {
divElement.remove();
// 重新过滤 ingredientsList 以确保删除后不会重复添加
const addedIngredients = Array.from(footList.getElementsByClassName('ingredient')).map(div => div.textContent);
post_data.food_list = post_data.food_list.filter(item => {
const ingredientText = `${item.name} ${item.weight}克`;
return !addedIngredients.includes(ingredientText);
});
}
// 每个步骤的描述写入
function writeDescriptionChild(e,num){
// 添加数据进最终提交变量important
post_data.step_list[num]['description'] = $(e).val();
console.log(post_data)
}
function saveData() {
post_data.title = $("#title").val();
post_data.description = $("#description").val();
// 最终数据格式示意start
// post_data = {
// "cook_label": "早餐",
// "token": "asdasdasda123141321dfsd34123",
// "cover": "1",
// "title": "测试菜谱1",
// "description": "测试菜谱描述",
// "food_list": [
// {"name": " 牛肉","weight": "100"},
// {"name": " 鸡肉","weight": "200"},
// ...
// ],
// "step_list": [
// {
// "pic_list": [1,2],
// "foot_list": [
// {"name": " 牛肉","weight": "100"},
// ...
// ],
// "description": "步骤1说明"
// },
// ...
// ],
// };
// 最终数据格式示意end
console.log(post_data)
// return
$.ajax({
// url:"https://tc.pcxbc.com/kitchenscale/add_cookbook", //请求的url地址
url:"http://wm.tcxbc.com/kitchenscale/add_cookbook", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:post_data, //参数值
type:"POST", //请求方式
success:function(req){
//请求成功时处理
if(req.code == 200){
alert("操作成功");
}else{
alert("操作失败");
}
},
error:function(){
//请求出错处理
}
});
}
</script>

3
public/request_log.txt Normal file
View File

@ -0,0 +1,3 @@
2025-07-23 11:00:42
[]

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
public/tsf/barcode.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Print.js 打印演示</title>
<!-- 引入 Print.js 库 -->
<script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>
<link rel="stylesheet" href="https://printjs-4de6.kxcdn.com/print.min.css">
<style>
/* 页面样式 */
body {
font-family: Arial, sans-serif;
margin: 20px;
}
#printContent {
background-color: #f9f9f9;
padding: 20px;
border: 1px solid #ddd;
max-width: 800px;
}
button {
padding: 10px 15px;
background-color: #2196F3;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
/* 打印样式 - 去除页眉页脚 */
@media print {
@page {
margin: 0; /* 关键:去除页眉页脚空间 */
}
body {
margin: 1cm; /* 保留内容边距 */
}
.no-print {
display: none !important; /* 隐藏不需要打印的元素 */
}
}
</style>
</head>
<body>
<h1>Print.js 打印功能测试</h1>
<p>此页面演示如何使用 Print.js 实现静默打印和自定义打印。</p>
<!-- 打印内容区域 -->
<div id="printContent">
<h2>订单详情</h2>
<p>打印时间:<span id="printTime"></span></p>
<table>
<thead>
<tr>
<th>序号</th>
<th>商品名称</th>
<th>数量</th>
<th>单价</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>笔记本电脑</td>
<td>1</td>
<td>¥5999</td>
</tr>
<tr>
<td>2</td>
<td>无线鼠标</td>
<td>2</td>
<td>¥99</td>
</tr>
</tbody>
</table>
<p class="no-print">* 此文档为测试用途,打印前请确认内容</p>
</div>
<!-- 打印按钮 -->
<div class="print-buttons">
<button onclick="silentPrint()">静默打印</button>
<button onclick="customPrint()">自定义打印</button>
</div>
<script>
// 设置打印时间
document.getElementById('printTime').textContent = new Date().toLocaleString();
// 静默打印(无预览)
function silentPrint() {
printJS({
printable: 'printContent',
type: 'html',
style: '@page { margin: 0; } body { margin: 1cm; }', // 强制覆盖页眉页脚
onPrintDialogClose: () => console.log('打印完成')
});
}
// 自定义打印(带标题和样式)
function customPrint() {
printJS({
printable: 'printContent',
type: 'html',
header: '<h3 style="text-align:center;">订单确认单</h3>', // 自定义页眉
css: 'https://printjs-4de6.kxcdn.com/print.min.css', // 加载默认样式
style: `
@page { margin: 0; }
body { font-size: 12pt; margin: 1cm; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #000; padding: 8px; }
`,
scanStyles: false // 禁用自动扫描页面样式
});
}
</script>
</body>
</html>

BIN
public/tsf/jc.ttf Normal file

Binary file not shown.

BIN
public/tsf/play.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
public/tsf/play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

1
public/tsf/qrcode.min.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.