Quellcode durchsuchen

添加用户接口

导入导出可以使用,加了一个用户表,注册,登录和修改用户接口,输入框设置只能使用数字,在本地缓存用户表id和用户名。修改团队信息颜色,模型选择加了选择反酸或降酸
DIng vor 4 Monaten
Ursprung
Commit
2754b53f63
36 geänderte Dateien mit 1184 neuen und 1040 gelöschten Zeilen
  1. BIN
      api/SoilAcidification.db
  2. BIN
      api/__pycache__/api_db.cpython-38.pyc
  3. 460 59
      api/app/routes.py
  4. 1 1
      api/run.py
  5. BIN
      api/uploads/ZJ2sHtQaARY0a4efa7139426d31b443702b72512a378.xlsx
  6. BIN
      api/uploads/datasets/jcJa5b7CL03c75dde3087d805fee3c5d1afbd15c9c3b.xlsx
  7. 1 0
      app.json
  8. 1 1
      pages/Home/Home.wxml
  9. 1 1
      pages/Home/Home.wxss
  10. 13 28
      pages/Staff/Staff.js
  11. 27 11
      pages/Visualizatio/Visualizatio.js
  12. 97 81
      pages/Visualization/Visualization.js
  13. 18 13
      pages/Visualization/Visualization.wxml
  14. 42 34
      pages/admin/admin.js
  15. 11 47
      pages/admin/admin.wxss
  16. 64 151
      pages/b/b.js
  17. 4 1
      pages/b/b.json
  18. 4 35
      pages/b/b.wxml
  19. 16 151
      pages/b/b.wxss
  20. 1 1
      pages/threshold/threshold.wxml
  21. 10 6
      pages/threshold/threshold.wxss
  22. 1 1
      project.private.config.json
  23. 32 21
      shoping/AcidNeutralizationModel/AcidNeutralizationModel.js
  24. 8 4
      shoping/AcidNeutralizationModel/AcidNeutralizationModel.wxml
  25. 5 4
      shoping/AcidNeutralizationModel/AcidNeutralizationModel.wxss
  26. 31 38
      shoping/Calculation/Calculation.js
  27. 61 55
      shoping/Calculation/Calculation.wxml
  28. 3 3
      shoping/Calculation/Calculation.wxss
  29. 94 180
      shoping/EditProfile/EditProfile.js
  30. 12 16
      shoping/EditProfile/EditProfile.wxml
  31. 32 34
      shoping/EditProfile/EditProfile.wxss
  32. 56 38
      shoping/Model Selection/Model Selection.js
  33. 20 15
      shoping/Model Selection/Model Selection.wxml
  34. 54 10
      shoping/Model Selection/Model Selection.wxss
  35. 2 0
      shoping/Soil Acidification/Soil Acidification.wxml
  36. 2 0
      shoping/Soil Deacidification/Soil Deacidification.wxml

BIN
api/SoilAcidification.db


BIN
api/__pycache__/api_db.cpython-38.pyc


+ 460 - 59
api/app/routes.py

@@ -1,12 +1,15 @@
 import os
-import logging
 import pickle
 import sqlite3
-
 import pandas as pd
-from flask import Blueprint, request, jsonify, current_app
+from flask import current_app, send_file
 from sqlalchemy.orm import sessionmaker
-from .model import predict, train_and_save_model, calculate_model_score
+
+from flask import Blueprint, request, jsonify, current_app as app
+from werkzeug.security import generate_password_hash
+from werkzeug.utils import secure_filename
+import logging
+from .model import predict, train_and_save_model
 from .database_models import Models, ModelParameters, Datasets, CurrentReduce, CurrentReflux
 from . import db
 from .utils import create_dynamic_table, allowed_file, infer_column_types, rename_columns_for_model_predict, \
@@ -15,6 +18,10 @@ from .utils import create_dynamic_table, allowed_file, infer_column_types, renam
 from sqlalchemy import text
 from sqlalchemy.engine.reflection import Inspector
 from sqlalchemy import MetaData, Table, select
+from io import BytesIO
+from flask import Blueprint, request, jsonify
+from flask import Flask, request, jsonify
+from werkzeug.security import check_password_hash
 
 # 配置日志
 logging.basicConfig(level=logging.DEBUG)
@@ -23,6 +30,38 @@ logger = logging.getLogger(__name__)
 # 创建蓝图 (Blueprint)
 bp = Blueprint('routes', __name__)
 
+# 密码加密
+def hash_password(password):
+    return generate_password_hash(password)
+
+def get_db():
+    """ 获取数据库连接 """
+    return sqlite3.connect(app.config['DATABASE'])
+
+def get_column_names(table_name):
+    """
+    动态获取数据库表的列名。
+    """
+    try:
+        conn = get_db()
+        query = f"PRAGMA table_info({table_name});"
+        result = conn.execute(query).fetchall()
+        conn.close()
+        return [row[1] for row in result]  # 第二列是列名
+    except Exception as e:
+        logger.error(f"Error getting column names for table {table_name}: {e}", exc_info=True)
+        return []
+
+def get_model_class_for_table(table_name):
+    """
+    根据表名动态获取对应的 SQLAlchemy 模型类。
+    """
+    model_mapping = {
+        'current_reduce': CurrentReduce,
+        'current_reflux': CurrentReflux,
+        # 添加更多模型映射
+    }
+    return model_mapping.get(table_name)
 
 def complex_reflux_calculation(parameters):
     """
@@ -44,7 +83,6 @@ def complex_reflux_calculation(parameters):
         logger.error('Failed to calculate reflux model prediction:', exc_info=True)
         return {'error': str(e)}
 
-
 @bp.route('/upload-dataset', methods=['POST'])
 def upload_dataset():
     session = None
@@ -341,11 +379,11 @@ def get_all_model_parameters():
 def add_item():
     """
     接收 JSON 格式的请求体,包含表名和要插入的数据。
-    尝试将数据插入到指定的表中。
+    尝试将数据插入到指定的表中,并进行字段查重
     :return:
     """
     try:
-        # 确保请求体是JSON格式
+        # 确保请求体是 JSON 格式
         data = request.get_json()
         if not data:
             raise ValueError("No JSON data provided")
@@ -355,16 +393,43 @@ def add_item():
 
         if not table_name or not item_data:
             return jsonify({'error': 'Missing table name or item data'}), 400
-        cur = db.cursor()
 
-        # 动态构建 SQL 语句
+        # 定义各个表的字段查重规则
+        duplicate_check_rules = {
+            'users': ['email', 'username'],
+            'products': ['product_code'],
+            'current_reduce': [ 'Q_over_b', 'pH', 'OM', 'CL', 'H', 'Al'],
+            'current_reflux': ['OM', 'CL', 'CEC', 'H_plus', 'N', 'Al3_plus', 'Delta_pH'],
+            # 其他表和规则
+        }
+
+        # 获取该表的查重字段
+        duplicate_columns = duplicate_check_rules.get(table_name)
+
+        if not duplicate_columns:
+            return jsonify({'error': 'No duplicate check rule for this table'}), 400
+
+        # 动态构建查询条件,逐一检查是否有重复数据
+        condition = ' AND '.join([f"{column} = :{column}" for column in duplicate_columns])
+        duplicate_query = f"SELECT 1 FROM {table_name} WHERE {condition} LIMIT 1"
+
+        result = db.session.execute(text(duplicate_query), item_data).fetchone()
+
+        if result:
+            return jsonify({'error': '重复数据,已有相同的数据项存在。'}), 409
+
+        # 动态构建 SQL 语句,进行插入操作
         columns = ', '.join(item_data.keys())
-        placeholders = ', '.join(['?'] * len(item_data))
+        placeholders = ', '.join([f":{key}" for key in item_data.keys()])
         sql = f"INSERT INTO {table_name} ({columns}) VALUES ({placeholders})"
-        cur.execute(sql, tuple(item_data.values()))
-        db.commit()
 
-        # 返回更详细的成功响应
+        # 直接执行插入操作,无需显式的事务管理
+        db.session.execute(text(sql), item_data)
+
+        # 提交事务
+        db.session.commit()
+
+        # 返回成功响应
         return jsonify({'success': True, 'message': 'Item added successfully'}), 201
 
     except ValueError as e:
@@ -372,18 +437,15 @@ def add_item():
     except KeyError as e:
         return jsonify({'error': f'Missing data field: {e}'}), 400
     except sqlite3.IntegrityError as e:
-        # 处理例如唯一性约束违反等数据库完整性错误
-        return jsonify({'error': 'Database integrity error', 'details': str(e)}), 409
+        return jsonify({'error': '数据库完整性错误', 'details': str(e)}), 409
     except sqlite3.Error as e:
-        # 处理其他数据库错误
-        return jsonify({'error': 'Database error', 'details': str(e)}), 500
-    finally:
-        db.close()
-
+        return jsonify({'error': '数据库错误', 'details': str(e)}), 500
 
-# 定义删除数据库记录的 API 接口
 @bp.route('/delete_item', methods=['POST'])
 def delete_item():
+    """
+    删除数据库记录的 API 接口
+    """
     data = request.get_json()
     table_name = data.get('table')
     condition = data.get('condition')
@@ -395,39 +457,50 @@ def delete_item():
             "message": "缺少表名或条件参数"
         }), 400
 
-    # 尝试从条件字符串中分离键和值
+    # 尝试从条件字符串中解析键和值
     try:
         key, value = condition.split('=')
+        key = key.strip()  # 去除多余的空格
+        value = value.strip().strip("'\"")  # 去除多余的空格和引号
     except ValueError:
         return jsonify({
             "success": False,
             "message": "条件格式错误,应为 'key=value'"
         }), 400
 
-    cur = db.cursor()
+    # 准备 SQL 删除语句
+    sql = f"DELETE FROM {table_name} WHERE {key} = :value"
 
     try:
-        # 执行删除操作
-        cur.execute(f"DELETE FROM {table_name} WHERE {key} = ?", (value,))
-        db.commit()
-        # 如果没有错误发生,返回成功响应
+        # 使用 SQLAlchemy 执行删除
+        with db.session.begin():
+            result = db.session.execute(text(sql), {"value": value})
+
+        # 检查是否有记录被删除
+        if result.rowcount == 0:
+            return jsonify({
+                "success": False,
+                "message": "未找到符合条件的记录"
+            }), 404
+
         return jsonify({
             "success": True,
             "message": "记录删除成功"
         }), 200
-    except sqlite3.Error as e:
-        # 发生错误,回滚事务
-        db.rollback()
-        # 返回失败响应,并包含错误信息
+
+    except Exception as e:
         return jsonify({
             "success": False,
             "message": f"删除失败: {e}"
-        }), 400
-
+        }), 500
 
 # 定义修改数据库记录的 API 接口
 @bp.route('/update_item', methods=['PUT'])
 def update_record():
+    """
+    接收 JSON 格式的请求体,包含表名和更新的数据。
+    尝试更新指定的记录。
+    """
     data = request.get_json()
 
     # 检查必要的数据是否提供
@@ -440,53 +513,55 @@ def update_record():
     table_name = data['table']
     item = data['item']
 
-    # 假设 item 的第一个元素是 ID
-    if not item or next(iter(item.keys())) is None:
+    # 假设 item 的第一个键是 ID
+    id_key = next(iter(item.keys()))  # 获取第一个键
+    record_id = item.get(id_key)
+
+    if not record_id:
         return jsonify({
             "success": False,
-            "message": "记录数据为空"
+            "message": "缺少记录 ID"
         }), 400
 
-    # 获取 ID 和其他字段值
-    id_key = next(iter(item.keys()))
-    record_id = item[id_key]
-    updates = {key: value for key, value in item.items() if key != id_key}  # 排除 ID
-
-    cur = db.cursor()
+    # 获取更新的字段和值
+    updates = {key: value for key, value in item.items() if key != id_key}
 
-    try:
-        record_id = int(record_id)  # 确保 ID 是整数
-    except ValueError:
+    if not updates:
         return jsonify({
             "success": False,
-            "message": "ID 必须是整数"
+            "message": "没有提供需要更新的字段"
         }), 400
 
-    # 准备参数列表,包括更新的值和 ID
-    parameters = list(updates.values()) + [record_id]
+    # 动态构建 SQL
+    set_clause = ', '.join([f"{key} = :{key}" for key in updates.keys()])
+    sql = f"UPDATE {table_name} SET {set_clause} WHERE {id_key} = :id_value"
+
+    # 添加 ID 到参数
+    updates['id_value'] = record_id
 
-    # 执行更新操作
-    set_clause = ','.join([f"{k} = ?" for k in updates.keys()])
-    sql = f"UPDATE {table_name} SET {set_clause} WHERE {id_key} = ?"
     try:
-        cur.execute(sql, parameters)
-        db.commit()
-        if cur.rowcount == 0:
+        # 使用 SQLAlchemy 执行更新
+        with db.session.begin():
+            result = db.session.execute(text(sql), updates)
+
+        # 检查是否有更新的记录
+        if result.rowcount == 0:
             return jsonify({
                 "success": False,
                 "message": "未找到要更新的记录"
             }), 404
+
         return jsonify({
             "success": True,
             "message": "数据更新成功"
         }), 200
-    except sqlite3.Error as e:
-        db.rollback()
+
+    except Exception as e:
+        # 捕获所有异常并返回
         return jsonify({
             "success": False,
-            "message": f"更新失败: {e}"
-        }), 400
-
+            "message": f"更新失败: {str(e)}"
+        }), 500
 
 # 定义查询数据库记录的 API 接口
 @bp.route('/search/record', methods=['GET'])
@@ -542,6 +617,168 @@ def sql_search():
         # 如果请求数据中缺少必要的键,返回错误信息
         return jsonify({'error': f'缺少必要的数据字段: {e}'}), 400
 
+# 模板下载接口
+@bp.route('/download_template', methods=['GET'])
+def download_template():
+    """
+    根据给定的表名,下载表的模板(如 CSV 或 Excel 格式)。
+    """
+    table_name = request.args.get('table')
+    if not table_name:
+        return jsonify({'error': '表名参数缺失'}), 400
+
+    columns = get_column_names(table_name)
+    if not columns:
+        return jsonify({'error': f"Table '{table_name}' not found or empty."}), 404
+
+    # 不包括 ID 列
+    if 'id' in columns:
+        columns.remove('id')
+
+    df = pd.DataFrame(columns=columns)
+
+    file_format = request.args.get('format', 'excel').lower()
+    try:
+        if file_format == 'csv':
+            output = BytesIO()
+            df.to_csv(output, index=False, encoding='utf-8')
+            output.seek(0)
+            return send_file(output, as_attachment=True, download_name=f'{table_name}_template.csv',
+                             mimetype='text/csv')
+        else:
+            output = BytesIO()
+            df.to_excel(output, index=False, engine='openpyxl')
+            output.seek(0)
+            return send_file(output, as_attachment=True, download_name=f'{table_name}_template.xlsx',
+                             mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
+    except Exception as e:
+        logger.error(f"Failed to generate template: {e}", exc_info=True)
+        return jsonify({'error': '生成模板文件失败'}), 500
+
+# 导出数据
+@bp.route('/export_data', methods=['GET'])
+def export_data():
+    table_name = request.args.get('table')
+    file_format = request.args.get('format', 'excel').lower()
+
+    if not table_name:
+        return jsonify({'error': '缺少表名参数'}), 400
+    if not table_name.isidentifier():
+        return jsonify({'error': '无效的表名'}), 400
+
+    try:
+        conn = get_db()
+        query = "SELECT name FROM sqlite_master WHERE type='table' AND name=?;"
+        table_exists = conn.execute(query, (table_name,)).fetchone()
+        if not table_exists:
+            return jsonify({'error': f"表 {table_name} 不存在"}), 404
+
+        query = f"SELECT * FROM {table_name};"
+        df = pd.read_sql(query, conn)
+
+        output = BytesIO()
+        if file_format == 'csv':
+            df.to_csv(output, index=False, encoding='utf-8')
+            output.seek(0)
+            return send_file(output, as_attachment=True, download_name=f'{table_name}_data.csv', mimetype='text/csv')
+        elif file_format == 'excel':
+            df.to_excel(output, index=False, engine='openpyxl')
+            output.seek(0)
+            return send_file(output, as_attachment=True, download_name=f'{table_name}_data.xlsx',
+                             mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
+        else:
+            return jsonify({'error': '不支持的文件格式,仅支持 CSV 和 Excel'}), 400
+
+    except Exception as e:
+        logger.error(f"Error in export_data: {e}", exc_info=True)
+        return jsonify({'error': str(e)}), 500
+
+# 导入数据接口
+@bp.route('/import_data', methods=['POST'])
+def import_data():
+    logger.debug("Import data endpoint accessed.")
+    if 'file' not in request.files:
+        logger.error("No file in request.")
+        return jsonify({'success': False, 'message': '文件缺失'}), 400
+
+    file = request.files['file']
+    table_name = request.form.get('table')
+
+    if not table_name:
+        logger.error("Missing table name parameter.")
+        return jsonify({'success': False, 'message': '缺少表名参数'}), 400
+
+    if file.filename == '':
+        logger.error("No file selected.")
+        return jsonify({'success': False, 'message': '未选择文件'}), 400
+
+    try:
+        # 保存文件到临时路径
+        temp_path = os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(file.filename))
+        file.save(temp_path)
+        logger.debug(f"File saved to temporary path: {temp_path}")
+
+        # 根据文件类型读取文件
+        if file.filename.endswith('.xlsx'):
+            df = pd.read_excel(temp_path)
+        elif file.filename.endswith('.csv'):
+            df = pd.read_csv(temp_path)
+        else:
+            logger.error("Unsupported file format.")
+            return jsonify({'success': False, 'message': '仅支持 Excel 和 CSV 文件'}), 400
+
+        # 获取数据库列名
+        db_columns = get_column_names(table_name)
+        if 'id' in db_columns:
+            db_columns.remove('id')  # 假设 id 列是自增的,不需要处理
+
+        if not set(db_columns).issubset(set(df.columns)):
+            logger.error(f"File columns do not match database columns. File columns: {df.columns.tolist()}, Expected: {db_columns}")
+            return jsonify({'success': False, 'message': '文件列名与数据库表不匹配'}), 400
+
+        # 清洗数据并删除空值行
+        df_cleaned = df[db_columns].dropna()
+
+        # 统一数据类型,避免 int 和 float 合并问题
+        df_cleaned[db_columns] = df_cleaned[db_columns].apply(pd.to_numeric, errors='coerce')
+
+        # 获取现有的数据
+        conn = get_db()
+        with conn:
+            existing_data = pd.read_sql(f"SELECT * FROM {table_name}", conn)
+
+            # 查找重复数据
+            duplicates = df_cleaned.merge(existing_data, on=db_columns, how='inner')
+
+            # 如果有重复数据,删除它们
+            df_cleaned = df_cleaned[~df_cleaned.index.isin(duplicates.index)]
+            logger.warning(f"Duplicate data detected and removed: {duplicates}")
+
+            # 获取导入前后的数据量
+            total_data = len(df_cleaned) + len(duplicates)
+            new_data = len(df_cleaned)
+            duplicate_data = len(duplicates)
+
+            # 导入不重复的数据
+            df_cleaned.to_sql(table_name, conn, if_exists='append', index=False)
+            logger.debug(f"Imported {new_data} new records into the database.")
+
+        # 删除临时文件
+        os.remove(temp_path)
+        logger.debug(f"Temporary file removed: {temp_path}")
+
+        # 返回结果
+        return jsonify({
+            'success': True,
+            'message': '数据导入成功',
+            'total_data': total_data,
+            'new_data': new_data,
+            'duplicate_data': duplicate_data
+        }), 200
+
+    except Exception as e:
+        logger.error(f"Import failed: {e}", exc_info=True)
+        return jsonify({'success': False, 'message': f'导入失败: {str(e)}'}), 500
 
 # 定义提供数据库列表,用于展示表格的 API 接口
 @bp.route('/table', methods=['POST'])
@@ -577,3 +814,167 @@ def get_table():
     finally:
         # 关闭 session
         session.close()
+
+# 注册用户
+@bp.route('/register', methods=['POST'])
+def register_user():
+    # 获取前端传来的数据
+    data = request.get_json()
+    name = data.get('name')  # 用户名
+    password = data.get('password')  # 密码
+
+    logger.info(f"Register request received: name={name}")
+
+    # 检查用户名和密码是否为空
+    if not name or not password:
+        logger.warning("用户名和密码不能为空")
+        return jsonify({"success": False, "message": "用户名和密码不能为空"}), 400
+
+    # 动态获取数据库表的列名
+    columns = get_column_names('users')
+    logger.info(f"Database columns for 'users' table: {columns}")
+
+    # 检查前端传来的数据是否包含数据库表中所有的必填字段
+    for column in ['name', 'password']:
+        if column not in columns:
+            logger.error(f"缺少必填字段:{column}")
+            return jsonify({"success": False, "message": f"缺少必填字段:{column}"}), 400
+
+    # 对密码进行哈希处理
+    hashed_password = hash_password(password)
+    logger.info(f"Password hashed for user: {name}")
+
+    # 插入到数据库
+    try:
+        # 检查用户是否已经存在
+        query = "SELECT * FROM users WHERE name = :name"
+        conn = get_db()
+        user = conn.execute(query, {"name": name}).fetchone()
+
+        if user:
+            logger.warning(f"用户名 '{name}' 已存在")
+            return jsonify({"success": False, "message": "用户名已存在"}), 400
+
+        # 向数据库插入数据
+        query = "INSERT INTO users (name, password) VALUES (:name, :password)"
+        conn.execute(query, {"name": name, "password": hashed_password})
+        conn.commit()
+
+        logger.info(f"User '{name}' registered successfully.")
+        return jsonify({"success": True, "message": "注册成功"})
+
+    except Exception as e:
+        # 记录错误日志并返回错误信息
+        logger.error(f"Error registering user: {e}", exc_info=True)
+        return jsonify({"success": False, "message": "注册失败"}), 500
+
+@bp.route('/login', methods=['POST'])
+def login_user():
+    # 获取前端传来的数据
+    data = request.get_json()
+    name = data.get('name')  # 用户名
+    password = data.get('password')  # 密码
+
+    logger.info(f"Login request received: name={name}")
+
+    # 检查用户名和密码是否为空
+    if not name or not password:
+        logger.warning("用户名和密码不能为空")
+        return jsonify({"success": False, "message": "用户名和密码不能为空"}), 400
+
+    try:
+        # 查询数据库验证用户名
+        query = "SELECT * FROM users WHERE name = :name"
+        conn = get_db()
+        user = conn.execute(query, {"name": name}).fetchone()
+
+        if not user:
+            logger.warning(f"用户名 '{name}' 不存在")
+            return jsonify({"success": False, "message": "用户名不存在"}), 400
+
+        # 获取数据库中存储的密码(假设密码是哈希存储的)
+        stored_password = user[2]  # 假设密码存储在数据库的第三列
+        user_id = user[0]  # 假设 id 存储在数据库的第一列
+
+        # 校验密码是否正确
+        if check_password_hash(stored_password, password):
+            logger.info(f"User '{name}' logged in successfully.")
+            return jsonify({
+                "success": True,
+                "message": "登录成功",
+                "userId": user_id  # 返回用户 ID
+            })
+        else:
+            logger.warning(f"Invalid password for user '{name}'")
+            return jsonify({"success": False, "message": "用户名或密码错误"}), 400
+
+    except Exception as e:
+        # 记录错误日志并返回错误信息
+        logger.error(f"Error during login: {e}", exc_info=True)
+        return jsonify({"success": False, "message": "登录失败"}), 500
+
+# 更新用户信息接口
+@bp.route('/update_user', methods=['POST'])
+def update_user():
+    # 获取前端传来的数据
+    data = request.get_json()
+
+    # 打印收到的请求数据
+    app.logger.info(f"Received data: {data}")
+
+    user_id = data.get('userId')  # 用户ID
+    name = data.get('name')  # 用户名
+    old_password = data.get('oldPassword')  # 旧密码
+    new_password = data.get('newPassword')  # 新密码
+
+    logger.info(f"Update request received: user_id={user_id}, name={name}")
+
+    # 校验传入的用户名和密码是否为空
+    if not name or not old_password:
+        logger.warning("用户名和旧密码不能为空")
+        return jsonify({"success": False, "message": "用户名和旧密码不能为空"}), 400
+
+    # 新密码和旧密码不能相同
+    if new_password and old_password == new_password:
+        logger.warning(f"新密码与旧密码相同:{name}")
+        return jsonify({"success": False, "message": "新密码与旧密码不能相同"}), 400
+
+    try:
+        # 查询数据库验证用户ID
+        query = "SELECT * FROM users WHERE id = :user_id"
+        conn = get_db()
+        user = conn.execute(query, {"user_id": user_id}).fetchone()
+
+        if not user:
+            logger.warning(f"用户ID '{user_id}' 不存在")
+            return jsonify({"success": False, "message": "用户不存在"}), 400
+
+        # 获取数据库中存储的密码(假设密码是哈希存储的)
+        stored_password = user[2]  # 假设密码存储在数据库的第三列
+
+        # 校验旧密码是否正确
+        if not check_password_hash(stored_password, old_password):
+            logger.warning(f"旧密码错误:{name}")
+            return jsonify({"success": False, "message": "旧密码错误"}), 400
+
+        # 如果新密码非空,则更新新密码
+        if new_password:
+            hashed_new_password = hash_password(new_password)
+            update_query = "UPDATE users SET password = :new_password WHERE id = :user_id"
+            conn.execute(update_query, {"new_password": hashed_new_password, "user_id": user_id})
+            conn.commit()
+            logger.info(f"User ID '{user_id}' password updated successfully.")
+
+        # 如果用户名发生更改,则更新用户名
+        if name != user[1]:
+            update_name_query = "UPDATE users SET name = :new_name WHERE id = :user_id"
+            conn.execute(update_name_query, {"new_name": name, "user_id": user_id})
+            conn.commit()
+            logger.info(f"User ID '{user_id}' name updated to '{name}' successfully.")
+
+        return jsonify({"success": True, "message": "用户信息更新成功"})
+
+    except Exception as e:
+        # 记录错误日志并返回错误信息
+        logger.error(f"Error updating user: {e}", exc_info=True)
+        return jsonify({"success": False, "message": "更新失败"}), 500

+ 1 - 1
api/run.py

@@ -1,7 +1,7 @@
 from flask import request
 
 from app import create_app
-import os
+
 # 创建 Flask 应用
 app = create_app()
 context = ('ssl/cert.crt', 'ssl/cert.key')

BIN
api/uploads/ZJ2sHtQaARY0a4efa7139426d31b443702b72512a378.xlsx


BIN
api/uploads/datasets/jcJa5b7CL03c75dde3087d805fee3c5d1afbd15c9c3b.xlsx


+ 1 - 0
app.json

@@ -1,6 +1,7 @@
 {
   "pages": [
     "pages/Home/Home",
+    "pages/b/b",
     "pages/threshold/threshold",
     "pages/Register/Register",
     "pages/admin/admin",

+ 1 - 1
pages/Home/Home.wxml

@@ -13,7 +13,7 @@
   </view>
   <view class="card" bindtap="Unit_Team_Profile">
     <image class="card-icon" src="/assets/taddar/团队介绍@1x.png" />
-    <text class="card-title">承担单位团队信息</text>
+    <text class="card-title">团队信息</text>
   </view>
 </view>
 

+ 1 - 1
pages/Home/Home.wxss

@@ -54,5 +54,5 @@
 }
 
 .card:nth-child(4) {
-  background-color: #FFD700; /* 团队信息卡片颜色 */
+  background-color: #FFF8DC; /* 团队信息卡片颜色 */
 }

+ 13 - 28
pages/Staff/Staff.js

@@ -1,9 +1,8 @@
 Page({
   data: {
     isLogin: false,  // 登录状态
-    validUsers: {    // 存储用户名、密码和头像信息
+    validUsers: {    // 存储用户名和头像信息
       username: '',
-      password: '',
       avatarUrl: ''
     },
     isHidden: true,  // 登录弹窗状态
@@ -28,12 +27,12 @@ Page({
 
   // 加载用户信息并更新页面
   loadUserInfo() {
-    const storedUserInfo = wx.getStorageSync('userInfo');  // 获取缓存中的用户信息
-    if (storedUserInfo && storedUserInfo.username && storedUserInfo.password) {
-      // 如果缓存中有用户名和密码,更新页面上的数据
+    // 只从缓存获取当前用户名
+    const currentUser = wx.getStorageSync('currentUser');
+    if (currentUser) {
       this.setData({
-        validUsers: storedUserInfo,  // 更新用户信息
-        isLogin: true,  // 设置登录状态为 true
+        'validUsers.username': currentUser,  // 将当前用户名显示到页面
+        isLogin: true,  // 登录状态设为已登录
       });
     }
   },
@@ -46,22 +45,7 @@ Page({
     });
 
     // 保存用户名到缓存
-    let userInfo = wx.getStorageSync('userInfo') || {};
-    userInfo.username = username;
-    wx.setStorageSync('userInfo', userInfo);
-  },
-
-  // 获取用户的密码
-  getPassword(e) {
-    const password = e.detail.value;
-    this.setData({
-      'validUsers.password': password
-    });
-
-    // 保存密码到缓存
-    let userInfo = wx.getStorageSync('userInfo') || {};
-    userInfo.password = password;
-    wx.setStorageSync('userInfo', userInfo);
+    wx.setStorageSync('currentUser', username);  // 只保存用户名到缓存
   },
 
   // 显示登录弹窗
@@ -87,17 +71,18 @@ Page({
 
   // 确认登录弹窗
   popYes() {
-    const { username, password } = this.data.validUsers;
-    if (!username || !password) {
+    const { username } = this.data.validUsers;
+    if (!username) {
       wx.showToast({
         icon: 'error',
-        title: '请填写用户名和密码',
+        title: '请填写用户名',
       });
       return;
     }
 
-    // 保存用户名和密码到缓存
-    wx.setStorageSync('userInfo', this.data.validUsers);
+    // 保存用户名到缓存
+    wx.setStorageSync('currentUser', username);  // 只保存用户名
+
     this.setData({
       isLogin: true,  // 设置登录状态为 true
       isHidden: true, // 隐藏弹窗

+ 27 - 11
pages/Visualizatio/Visualizatio.js

@@ -12,13 +12,12 @@ Page({
     // 新增数据弹窗的输入框内容
     newData: {
       id: "",
+      Q_over_b: "",
+      pH: "",
       OM: "",
       CL: "",
-      CEC: "",
-      H_plus: "",
-      HN: "",
-      Al3_plus: "",
-      Delta_pH: ""
+      H: "",
+      Al: ""
     },
     // 中文表头内容,动态生成
     tableHeaders: [
@@ -327,33 +326,45 @@ Page({
 
   // 输入框绑定:更新新增数据的对应字段
   onInputQ_over_b: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.Q_over_b': e.detail.value
+      'newData.Q_over_b': filteredValue
     });
   },
   onInputpH: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.pH': e.detail.value
+      'newData.pH': filteredValue
     });
   },
   onInputOM: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.OM': e.detail.value
+      'newData.OM': filteredValue
     });
   },
   onInputCL: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.CL': e.detail.value
+      'newData.CL': filteredValue
     });
   },
   onInputH: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.H': e.detail.value
+      'newData.H': filteredValue
     });
   },
   onInputAl: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.Al': e.detail.value
+      'newData.Al': filteredValue
     });
   },
 
@@ -389,6 +400,11 @@ Page({
             icon: 'success'
           });
           this.LoadData();
+        } else if (res.statusCode === 409) {
+          wx.showToast({
+            title: '重复数据,已有相同的数据项存在。',
+            icon: 'none'
+          });
         } else {
           wx.showToast({
             title: '新增失败',

+ 97 - 81
pages/Visualization/Visualization.js

@@ -16,7 +16,7 @@ Page({
       CL: "",
       CEC: "",
       H_plus: "",
-      HN: "",
+      N: "",
       Al3_plus: "",
       Delta_pH: ""
     },
@@ -57,9 +57,10 @@ Page({
             'CL': parseFloat(row.CL).toFixed(2),
             'CEC': parseFloat(row.CEC).toFixed(2),
             'H_plus': parseFloat(row.H_plus).toFixed(2),
-            'HN': parseFloat(row.N).toFixed(2),
+            'N': parseFloat(row.N).toFixed(2),
             'Al3_plus': parseFloat(row.Al3_plus).toFixed(2),
             'Delta_pH': parseFloat(row.Delta_pH).toFixed(2),
+
             };
           });
   
@@ -236,7 +237,7 @@ Page({
       }
     });
   },
-
+  
   // 导入数据功能
   onImport: function () {
     wx.chooseMessageFile({
@@ -310,120 +311,135 @@ Page({
   },  
 
   // 新增按钮点击,显示新增弹窗
-  onAdd: function() {
-    console.log("新增按钮被点击了");  // 调试日志
-    this.setData({
-      showAddModal: true,
-      newData: { // 重置新增数据
-        OM: "",
-        CL: "",
-        CEC: "",
-        H_plus: "",
-        HN: "",
-        Al3_plus: "",
-        free_alumina: "",
-        free_iron_oxides: "",
-        Delta_pH: ""
-      }
-    });
-    console.log("showAddModal: ", this.data.showAddModal);  // 确认数据更新
-  },
+onAdd: function() {
+  console.log("新增按钮被点击了");  // 调试日志
+  this.setData({
+    isEditing: false,  // 这里设置为 false,表示新增操作而非编辑
+    showAddModal: true, // 显示新增数据弹窗
+    newData: { // 重置新增数据
+      OM: "",
+      CL: "",
+      CEC: "",
+      H_plus: "",
+      N: "",
+      Al3_plus: "",
+      Delta_pH: ""
+    }
+  });
+  console.log("showAddModal: ", this.data.showAddModal);  // 确认数据更新
+},
 
   // 输入框绑定:更新新增数据的对应字段
   onInputOM: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.OM': e.detail.value
+      'newData.OM': filteredValue,
     });
   },
   onInputCL: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.CL': e.detail.value
+      'newData.CL': filteredValue,
     });
   },
   onInputCEC: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.CEC': e.detail.value
+      'newData.CEC': filteredValue,
     });
   },
   onInputH_plus: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.H_plus': e.detail.value
+      'newData.H_plus': filteredValue,
     });
   },
-  onInputHN: function(e) {
+  onInputN: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.HN': e.detail.value
+      'newData.N': filteredValue,
     });
   },
   onInputAl3_plus: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.Al3_plus': e.detail.value
-    });
-  },
-  onInputfree_alumina: function(e) {
-    this.setData({
-      'newData.free_alumina': e.detail.value
-    });
-  },
-  onInputfree_iron_oxides: function(e) {
-    this.setData({
-      'newData.free_iron_oxides': e.detail.value
+      'newData.Al3_plus': filteredValue,
     });
   },
   onInputDelta_pH: function(e) {
+    const value = e.detail.value;
+    const filteredValue = value.replace(/[^0-9.]/g, '');
     this.setData({
-      'newData.Delta_pH': e.detail.value
+      'newData.Delta_pH': filteredValue,
     });
   },
 
   // 提交新增数据
-  onSubmitAdd: function() {
-    const newRow = this.data.newData;
-    if (Object.values(newRow).some(value => !value)) {
-      wx.showToast({
-        title: '所有字段都必须填写!',
-        icon: 'none'
-      });
-      return;
-    }
+onSubmitAdd: function() {
+  const newRow = this.data.newData;
+  if (Object.values(newRow).some(value => !value)) {
+    wx.showToast({
+      title: '所有字段都必须填写!',
+      icon: 'none'
+    });
+    return;
+  }
 
-    wx.request({
-      url: 'https://soilgd.com:5000/add_item',
-      method: 'POST',
-      header: {
-        'Content-Type': 'application/json'
-      },
-      data: {
-        table: 'current_reflux',
-        item: newRow
-      },
-      success: (res) => {
-        if (res.data.success) {
-          this.setData({
-            rows: [...this.data.rows, newRow],
-            showAddModal: false
-          });
-          wx.showToast({
-            title: '新增成功',
-            icon: 'success'
-          });
-          this.LoadData();
-        } else {
-          wx.showToast({
-            title: '新增失败',
-            icon: 'none'
-          });
-        }
-      },
-      fail: (err) => {
+  // 在请求之前打印数据,确保发送的数据正确
+  console.log('Sending data:', {
+    table: 'current_reflux',
+    item: newRow
+  });
+
+  wx.request({
+    url: 'https://soilgd.com:5000/add_item',
+    method: 'POST',
+    header: {
+      'Content-Type': 'application/json'
+    },
+    data: {
+      table: 'current_reflux',
+      item: newRow
+    },
+    success: (res) => {
+      // 判断返回的状态码,进行处理
+      if (res.statusCode === 200 && res.data.success) {
+        this.setData({
+          rows: [...this.data.rows, newRow],
+          showAddModal: false
+        });
         wx.showToast({
-          title: '请求失败,请重试',
+          title: '新增成功',
+          icon: 'success'
+        });
+        this.LoadData();
+      } else if (res.statusCode === 409) {
+        wx.showToast({
+          title: '重复数据,已有相同的数据项存在。',
+          icon: 'none'
+        });
+      } else {
+        wx.showToast({
+          title: '新增失败',
           icon: 'none'
         });
-        console.error('请求失败:', err);
       }
-    });
-  },
+    },
+    fail: (err) => {
+      wx.showToast({
+        title: '请求失败,请重试',
+        icon: 'none'
+      });
+      console.error('请求失败:', err);
+    }
+  });
+},
 
   // 取消新增数据
   onCancel: function() {

+ 18 - 13
pages/Visualization/Visualization.wxml

@@ -34,7 +34,7 @@
         <view class="table-cell">{{item.CL}}</view>
         <view class="table-cell">{{item.CEC}}</view>
         <view class="table-cell">{{item.H_plus}}</view>
-        <view class="table-cell">{{item.HN}}</view>
+        <view class="table-cell">{{item.N}}</view>
         <view class="table-cell">{{item.Al3_plus}}</view>
         <view class="table-cell">{{item.Delta_pH}}</view>
       </view>
@@ -47,32 +47,37 @@
   <view class="modal-content">
 
     <view class="modal-item">
-    <view class="item-label">土壤提升单位pH的生石灰施用量%:</view>
-    <input class="input-field" placeholder="比值" data-field="Q_over_b" bindinput="onInputQ_over_b" value="{{newData.Q_over_b}}"/>
+    <view class="item-label">有机质含量(g/kg):</view>
+    <input class="input-field" type="number"  placeholder="比值" data-field="OM" bindinput="onInputOM" value="{{newData.OM}}"/>
   </view>
     <view class="modal-item">
-    <view class="item-label">土壤初始含量:</view>
-    <input class="input-field" placeholder="请输入酸碱度" data-field="pH" bindinput="onInputpH" value="{{newData.pH}}"/>
+    <view class="item-label">土壤粘粒(g/kg):</view>
+    <input class="input-field" type="number"  placeholder="请输入酸碱度" data-field="CL" bindinput="onInputCL" value="{{newData.CL}}"/>
   </view>
 
     <view class="modal-item">
-    <view class="item-label">土壤有机含量:</view>
-    <input class="input-field" placeholder="请输入有机质含量" data-field="OM" bindinput="onInputOM" value="{{newData.OM}}"/>
+    <view class="item-label">阳离子交换量(cmol/kg):</view>
+    <input class="input-field" type="number"  placeholder="请输入有机质含量" data-field="CEC" bindinput="onInputCEC" value="{{newData.CEC}}"/>
   </view>
 
     <view class="modal-item">
-    <view class="item-label">土壤粘粒含量:</view>
-    <input class="input-field" placeholder="请输入氯离子含量" data-field="CL" bindinput="onInputCL" value="{{newData.CL}}"/>
+    <view class="item-label">交换性氢(cmol/kg):</view>
+    <input class="input-field" type="number"  placeholder="请输入氯离子含量" data-field="H_plus" bindinput="onInputH_plus" value="{{newData.H_plus}}"/>
   </view>
 
     <view class="modal-item">
-    <view class="item-label">交换性氢含量:</view>
-    <input class="input-field" placeholder="请输入H含量" data-field="H" bindinput="onInputH" value="{{newData.H}}"/>
+    <view class="item-label">水解氮(g/kg):</view>
+    <input class="input-field" type="number"  placeholder="请输入H含量" data-field="N" bindinput="onInputN" value="{{newData.N}}"/>
   </view>
 
     <view class="modal-item">
-    <view class="item-label">交换性铝含量:</view>
-    <input class="input-field" placeholder="请输入铝离子含量" data-field="Al" bindinput="onInputAl" value="{{newData.Al}}"/>
+    <view class="item-label">交换性铝(cmol/kg):</view>
+    <input class="input-field" type="number"  placeholder="请输入铝离子含量" data-field="Al3_plus" bindinput="onInputAl3_plus" value="{{newData.Al3_plus}}"/>
+  </view>
+
+  <view class="modal-item">
+    <view class="item-label">ΔpH:</view>
+    <input class="input-field" type="number"  placeholder="请输入铝离子含量" data-field="Delta_pH" bindinput="onInputDelta_pH" value="{{newData.Delta_pH}}"/>
   </view>
 
     <view class="button-container">

+ 42 - 34
pages/admin/admin.js

@@ -1,7 +1,7 @@
 Page({
   data: {
     selected: 3,     // 底部导航栏选中的 tab
-    username: '',     // 用户名
+    name: '',         // 用户名
     password: '',     // 密码
     errorMessage: ''   // 错误信息
   },
@@ -9,7 +9,7 @@ Page({
   // 输入用户名
   inputUsername: function (e) {
     this.setData({
-      username: e.detail.value
+      name: e.detail.value
     });
   },
 
@@ -22,16 +22,10 @@ Page({
 
   // 登录逻辑
   login: function () {
-    const { username, password } = this.data;
-
-    // 从本地存储获取有效的用户名和密码
-    const validUsers = wx.getStorageSync('validUsers') || {
-      'admin': '123456',
-      '123': '123'
-    };
+    const { name, password } = this.data;
 
     // 检查用户名和密码是否为空
-    if (!username || !password) {
+    if (!name || !password) {
       wx.showToast({
         title: '用户名和密码不能为空',
         icon: 'none',
@@ -45,31 +39,45 @@ Page({
     });
 
     setTimeout(() => {
-      // 检查用户名和密码是否匹配
-      if (validUsers[username] === password) {
-        wx.hideLoading();
-        
-        // 登录成功后,将当前用户名和密码缓存到本地
-        const updatedUsers = { ...validUsers, [username]: password }; // 仅更新当前登录的用户名
-        wx.setStorageSync('validUsers', updatedUsers); // 更新本地存储
-
-        // 缓存登录记录
-        wx.setStorageSync('currentUser', username); // 将当前登录用户名缓存
+      // 发送请求到后端验证用户名和密码
+      wx.request({
+        url: 'https://soilgd.com:5000/login', // 后端登录接口
+        method: 'POST',
+        data: {
+          name: name,
+          password: password
+        },
+        success: (res) => {
+          wx.hideLoading();
+          if (res.data.success) {
+            // 登录成功后,将当前用户名和 ID 缓存到本地
+            wx.setStorageSync('currentUser', name);  // 将当前登录用户名缓存
+            wx.setStorageSync('userId', res.data.userId);  // 将用户 ID 缓存
 
-        wx.switchTab({ // 跳转到 tabBar 页面
-          url: '/pages/threshold/threshold'
-        });
-      } else {
-        wx.hideLoading();
-        this.setData({
-          errorMessage: '用户名或密码错误'
-        });
-        wx.showToast({
-          title: '用户名或密码错误',
-          icon: 'none',
-          duration: 2000
-        });
-      }
+            wx.switchTab({
+              url: '/pages/threshold/threshold'
+            });
+          } else {
+            this.setData({
+              errorMessage: res.data.message || '用户名或密码错误'
+            });
+            wx.showToast({
+              title: res.data.message || '用户名或密码错误',
+              icon: 'none',
+              duration: 2000
+            });
+          }
+        },
+        fail: (err) => {
+          wx.hideLoading();
+          wx.showToast({
+            title: '网络错误,请重试',
+            icon: 'none',
+            duration: 2000
+          });
+          console.error('登录失败:', err);
+        }
+      });
     }, 1500);
   },
 

+ 11 - 47
pages/admin/admin.wxss

@@ -3,27 +3,28 @@
   flex-direction: column;
   align-items: center;
   justify-content: center;
-  padding: 20rpx 40rpx;
+  padding: 50px 40px;
   height: 50vh; /* 使容器占据整个屏幕高度 */
 }
 
 .input {
   width: 100%;
-  height: 80rpx;
-  margin-bottom: 20rpx;
-  padding: 0 20rpx;
+  height: 30px;
+  margin-bottom: 10px;
+  padding: 0 20px;
   border: 1px solid #ddd;
-  border-radius: var(--border-radius, 10rpx);
+  border-radius: var(--border-radius, 10px);
   box-sizing: border-box;
 }
 
 .btn {
-  width: 50%;            /* 按钮占满宽度 */
-  padding: 5px 0;        /* 按钮内边距,控制高度 */
-  margin: 5px 0;         /* 按钮间距 */
+  width: 30%;            /* 按钮占满宽度 */
+  height: 40px;
+  padding: 1px 0;        /* 按钮内边距,控制高度 */
+  margin: 1px 0;         /* 按钮间距 */
   background-color: #3EC01E; /* 按钮背景颜色 */
   color: white;           /* 按钮文字颜色 */
-  font-size: 18px;        /* 按钮文字大小 */
+  font-size: 16px;        /* 按钮文字大小 */
   border: none;           /* 去除按钮边框 */
   outline: none;          /* 去除焦点边框 */
   text-align: center;     /* 文字居中 */
@@ -38,41 +39,4 @@
 .btn:hover {
   background-color: var(--hover-color, #16b818);
   cursor: pointer;  /* 鼠标悬浮时显示手型 */
-}
-
-.error {
-  color: red;
-  margin-top: 10rpx;
-  animation: fadeIn 0.5s ease;
-}
-
-@keyframes fadeIn {
-  from {
-    opacity: 0;
-  }
-  to {
-    opacity: 1;
-  }
-}
-
-.avatar {
-  width: 150rpx;
-  height: 150rpx;
-  border-radius: 50%;
-  margin-top: 20rpx;
-  object-fit: cover;
-}
-
-@media screen and (max-width: 375px) {
-  .container {
-    padding: 100rpx 20rpx;
-  }
-  .btn {
-    font-size: 28rpx;
-    height: 60rpx;
-    line-height: 60rpx;
-  }
-  .input {
-    height: 60rpx;
-  }
-}
+}

+ 64 - 151
pages/b/b.js

@@ -1,176 +1,89 @@
 Page({
   data: {
-    isLogin: false, // 登录状态
-    isHidden: true, // 弹窗状态
-    avatarUrl: '', // 用户头像
-    nickName: '', // 用户昵称
-    username: '', // 用户名(用户名密码登录)
-    password: '', // 密码(用户名密码登录)
-    errorMessage: '', // 错误信息
+    name: '',     // 用户名
+    password: '', // 密码
+    errorMessage: '', // 错误提示
   },
 
-  // 获取用户头像
-  getAvatar(e) {
-    const avatarUrl = e.detail.avatarUrl; // 从事件中获取头像URL
-
-    if (avatarUrl) {
-      this.setData({
-        avatarUrl: avatarUrl
-      });
-
-      // 授权登录后,自动设置默认密码到缓存
-      wx.setStorageSync('password', '123');
-
-      // 创建userInfo对象,保存头像和昵称到缓存
-      let userInfo = {
-        avatarUrl: avatarUrl,
-        nickName: this.data.nickName
-      };
-      wx.setStorageSync('userinfo', userInfo); // 保存到缓存
-    } else {
-      wx.showToast({
-        title: '头像获取失败',
-        icon: 'error',
-        duration: 2000
-      });
-    }
-  },
-
-  // 获取用户昵称
-  getName(e) {
-    const nickName = e.detail.value; // 获取昵称
+  // 输入用户名
+  inputName: function (e) {
     this.setData({
-      nickName: nickName
+      name: e.detail.value
     });
-
-    // 在授权登录时,将昵称更新到缓存的 userInfo 对象中
-    let userInfo = wx.getStorageSync('userinfo') || {};
-    userInfo.nickName = nickName;
-    wx.setStorageSync('userinfo', userInfo); // 更新缓存
   },
 
-  // 显示登录弹窗
-  gologin() {
-    this.setData({
-      isHidden: false
-    });
-  },
-
-  // 取消登录弹窗
-  potNo() {
-    this.setData({
-      isHidden: true
-    });
-  },
-
-  // 确认登录弹窗
-  popYes() {
-    const { avatarUrl, nickName } = this.data;
-    if (!avatarUrl || !nickName) {
-      wx.showToast({
-        icon: 'error',
-        title: '请获取头像和昵称',
-      });
-      return;
-    }
-
-    this.setData({
-      isLogin: true,
-      isHidden: true,
-    });
-
-    // 登录成功后跳转到指定页面
-    wx.switchTab({
-      url: '/pages/Calculate/Calculate',
-    });
-  },
-
-  // 用户名密码登录
-  inputUsername(e) {
-    this.setData({
-      username: e.detail.value
-    });
-  },
-
-  inputPassword(e) {
+  // 输入密码
+  inputPassword: function (e) {
     this.setData({
       password: e.detail.value
     });
   },
 
-  // 登录验证
-  login() {
-    const { username, password } = this.data;
+  // 注册逻辑
+  register: function () {
+    const { name, password } = this.data;
 
-    if (!username || !password) {
-      this.setData({
-        errorMessage: '用户名和密码不能为空'
+    // 检查用户名和密码是否为空
+    if (!name || !password) {
+      wx.showToast({
+        title: '用户名和密码不能为空',
+        icon: 'none',
+        duration: 2000
       });
       return;
     }
 
     wx.showLoading({
-      title: '登录中...'
+      title: '注册中...'
     });
 
     setTimeout(() => {
-      wx.hideLoading();
-
-      // 假设用户名和密码为123时登录成功
-      if (username === '123' && password === '123') {
-        wx.showToast({
-          title: '登录成功',
-          icon: 'success',
-          duration: 2000
-        });
-        this.setData({
-          isLogin: true,
-          errorMessage: '',
-        });
-
-        // 登录成功后跳转到指定页面
-        wx.switchTab({
-          url: '/pages/Calculate/Calculate',
-        });
-      } else {
-        this.setData({
-          errorMessage: '用户名或密码错误'
-        });
-        wx.showToast({
-          title: '用户名或密码错误',
-          icon: 'none',
-          duration: 2000
-        });
-      }
+      // 发送请求到后端,进行用户注册
+      wx.request({
+        url: 'https://127.0.0.1:5000/register', // 后端注册接口
+        method: 'POST',
+        data: {
+          name: name,        // 修改为 name
+          password: password,
+        },
+        success: (res) => {
+          wx.hideLoading();
+          if (res.data.success) {
+            wx.showToast({
+              title: '注册成功',
+              icon: 'success',
+              duration: 2000
+            });
+
+            // 清空输入框
+            this.setData({
+              name: '',
+              password: '',
+              errorMessage: ''
+            });
+
+            // 跳转到登录页面
+            wx.switchTab({
+              url: '/pages/Home/Home' 
+            });
+          } else {
+            wx.showToast({
+              title: res.data.message || '注册失败',
+              icon: 'none',
+              duration: 2000
+            });
+          }
+        },
+        fail: (err) => {
+          wx.hideLoading();
+          wx.showToast({
+            title: '网络错误,请重试',
+            icon: 'none',
+            duration: 2000
+          });
+          console.error('注册失败:', err);
+        }
+      });
     }, 1500);
   },
-
-  // 页面加载时,检查是否有缓存的密码
-  onLoad() {
-    const storedPassword = wx.getStorageSync('password');
-    const storedUserInfo = wx.getStorageSync('userinfo');
-
-    // 如果有缓存的密码,则自动填充
-    if (storedPassword) {
-      this.setData({
-        password: storedPassword // 自动填充缓存的密码
-      });
-    }
-
-    // 如果有缓存的用户信息,自动填充头像和昵称
-    if (storedUserInfo) {
-      this.setData({
-        avatarUrl: storedUserInfo.avatarUrl || '/assets/taddar/授权管理.png', // 默认头像
-        nickName: storedUserInfo.nickName || '未登录', // 默认昵称
-        isLogin: true, // 设置已登录状态
-      });
-    }
-
-    // 如果没有设置头像,使用默认头像
-    if (!this.data.avatarUrl) {
-      this.setData({
-        avatarUrl: '/assets/taddar/授权管理.png' // 默认头像
-      });
-    }
-  }
 });

+ 4 - 1
pages/b/b.json

@@ -1,3 +1,6 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "navigationBarTitleText": "注册",
+  "navigationBarBackgroundColor": "#f8f8f8",  
+  "navigationBarTextStyle": "black"  
 }

+ 4 - 35
pages/b/b.wxml

@@ -1,37 +1,6 @@
 <view class="container">
-   <!-- 用户名密码登录 -->
-   <view >
-    <input class="input" bindinput="inputUsername" placeholder="请输入用户名" />
-    <input class="input" bindinput="inputPassword" placeholder="请输入密码" type="password" />
-    <button class="gologin" bindtap="login">登录</button>
-    <text class="error">{{errorMessage}}</text>
-  </view>
-  <view class="container">
-<button bindtap="gologin">微信登录</button>
-</view>
-
-  <!-- 登录弹窗 -->
-  <view class="pop_root" hidden="{{isHidden}}">
-    <view class="pop_content">
-      <view class="pot_tip">授权登录弹窗</view>
-      
-      <!-- 获取头像 -->
-      <button class="pop_avatar" open-type="chooseAvatar" bindchooseavatar="getAvatar">
-        <image class="pop_img" wx:if="{{avatarUrl}}" src="{{avatarUrl}}" />
-        <view wx:else>获取头像</view>
-      </button>
-      
-      <!-- 获取昵称 -->
-      <input 
-    class="pop_name" 
-    type="nickname" 
-    bindblur="getName"
-    placeholder="获取昵称"/>
-      
-      <view class="pop_bot">
-        <view class="btn" bind:tap="potNo">取消</view>
-        <view class="btn1" bind:tap="popYes">确定</view>
-      </view>
-    </view>
-  </view>
+  <input class="input" bindinput="inputName" placeholder="请输入用户名" />
+  <input class="input" bindinput="inputPassword" placeholder="请输入密码" type="password" />
+  <button class="btn" bindtap="register">注册</button>
+  <text class="error">{{errorMessage}}</text>
 </view>

+ 16 - 151
pages/b/b.wxss

@@ -3,32 +3,32 @@
   flex-direction: column;
   align-items: center;
   justify-content: center;
-  padding: 20rpx 40rpx;
+  padding: 50px 40px;
   height: 50vh; /* 使容器占据整个屏幕高度 */
 }
 
 .input {
   width: 100%;
-  height: 80rpx;
-  margin-bottom: 20rpx;
-  padding: 0 20rpx;
+  height: 30px;
+  margin-bottom: 10px;
+  padding: 0 20px;
   border: 1px solid #ddd;
-  border-radius: var(--border-radius, 10rpx);
+  border-radius: var(--border-radius, 10px);
   box-sizing: border-box;
 }
 
 .btn {
-  width: 100%;
-  height: 80rpx;
-  background-color: var(--primary-color, #1aad19);
-  color: #fff;
-  border: none;
-  border-radius: var(--border-radius, 10rpx);
-  text-align: center;
-  line-height: 45rpx;
-  font-size: 36rpx;
-  box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.1);  /* 添加阴影 */
-  transition: background-color 0.3s ease, box-shadow 0.3s ease;  /* 背景颜色和阴影过渡效果 */
+  width: 30%;            /* 按钮占满宽度 */
+  height: 40px;
+  padding: 1px 0;        /* 按钮内边距,控制高度 */
+  margin: 1px 0;         /* 按钮间距 */
+  background-color: #3EC01E; /* 按钮背景颜色 */
+  color: white;           /* 按钮文字颜色 */
+  font-size: 16px;        /* 按钮文字大小 */
+  border: none;           /* 去除按钮边框 */
+  outline: none;          /* 去除焦点边框 */
+  text-align: center;     /* 文字居中 */
+  border-radius: 5px;     /* 圆角效果 */
 }
 
 .btn:active {
@@ -39,139 +39,4 @@
 .btn:hover {
   background-color: var(--hover-color, #16b818);
   cursor: pointer;  /* 鼠标悬浮时显示手型 */
-}
-
-.error {
-  color: red;
-  margin-top: 10rpx;
-  animation: fadeIn 0.5s ease;
-}
-
-@keyframes fadeIn {
-  from {
-    opacity: 0;
-  }
-  to {
-    opacity: 1;
-  }
-}
-
-.avatar {
-  width: 150rpx;
-  height: 150rpx;
-  border-radius: 50%;
-  margin-top: 20rpx;
-  object-fit: cover;
-}
-
-@media screen and (max-width: 375px) {
-  .container {
-    padding: 100rpx 20rpx;
-  }
-  .btn {
-    font-size: 28rpx;
-    height: 60rpx;
-    line-height: 60rpx;
-  }
-  .input {
-    height: 60rpx;
-  }
-}
-
-/* pages/demo/demo.wxss */
-.root {
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  flex-direction: column;
-}
-
-.touxiang {
-  width: 300rpx;
-  height: 300rpx;
-  border-radius: 50%;
-  margin-top: 30rpx;
-}
-
-.name {
-  margin-top: 30rpx;
-}
-
-/* 弹窗 */
-.pop_root {
-  position: fixed;
-  top: 0;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  background: rgb(0, 0, 0, 0.6);
-  z-index: 1000;
-}
-
-.pop_content {
-  position: fixed;
-  bottom: 0;
-  left: 0;
-  right: 0;
-  background: white;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  border-radius: 30rpx 30rpx 0 0;
-}
-
-.pot_tip {
-  font-size: 48rpx;
-  margin-top: 30rpx;
-}
-
-.pop_avatar {
-  width: 200rpx;
-  height: 200rpx;
-  border-radius: 50%;
-  background: gainsboro;
-  font-size: 35rpx;
-  display: flex;
-  flex-direction: center;
-  align-items: center;
-  margin: 30rpx;
-  padding: 0;
-}
-
-.pop_img {
-  width: 100%;
-  height: 100%;
-}
-
-.pop_name {
-  width: 300rpx;
-  bottom: 1px solid gray;
-  border-radius: 25epx;
-  padding-left: 160rpx;
-  margin-bottom: 50rpx;
-}
-
-.pop_bot {
-  display: flex;
-  margin-bottom: 50rpx;
-
-}
-
-.btn {
-  width: 150rpx;
-  border: 1px solid gray;
-  border-radius: 20rpx;
-  text-align: center;
-  background: red;
-  color: white;
-}
-
-.btn1 {
-  width: 150rpx;
-  border: 1px solid gray;
-  border-radius: 20rpx;
-  text-align: center;
-  background: green;
-  color: white;
-  margin-left: 90rpx;
 }

+ 1 - 1
pages/threshold/threshold.wxml

@@ -1,4 +1,4 @@
-<view class="card-container">
+<view class="container">
   <view class="card" bindtap="Model_Selection">
     <image class="card-icon" src="/assets/taddar/模型选择.png" />
     <text class="card-title">模型选择</text>

+ 10 - 6
pages/threshold/threshold.wxss

@@ -1,10 +1,10 @@
-.card-container {
+.container {
   display: flex;
   flex-direction: column;
   gap: 20px;
   padding: 20px;
   background-color: #f5f5f5;
-  margin-top: 60px;
+  margin-top: 110px;
 }
 
 .card {
@@ -42,13 +42,17 @@
 }
 
 .card:nth-child(1) {
-  background-color: #FFDDC1;
+  background-color: #FFDDC1; /* 软件简介卡片颜色 */
 }
 
 .card:nth-child(2) {
-  background-color: #C1E1FF;
+  background-color: #C1E1FF; /* 项目简介卡片颜色 */
 }
 
 .card:nth-child(3) {
-  background-color: #D4F4DD;
-}
+  background-color: #D4F4DD; /* 研究成果卡片颜色 */
+}
+
+.card:nth-child(4) {
+  background-color: #FFF8DC; /* 团队信息卡片颜色 */
+}

+ 1 - 1
project.private.config.json

@@ -1,6 +1,6 @@
 {
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-  "projectname": "土壤酸化模型计算",
+  "projectname": "%E5%9C%9F%E5%A3%A4%E9%85%B8%E5%8C%96%E6%A8%A1%E5%9E%8B%E8%AE%A1%E7%AE%97",
   "setting": {
     "compileHotReLoad": true,
     "urlCheck": false

+ 32 - 21
shoping/AcidNeutralizationModel/AcidNeutralizationModel.js

@@ -1,55 +1,66 @@
 Page({
   data: {
     result: '', // 存储计算结果
-    ph: '', // 土壤PH
+    init_pH: '',
+    target_pH: '',
     OM: '', // 有机质含量
     CL: '', // 土壤粘粒重量
     H: '', // 氢离子含量
     Al: '', // 铝离子含量
-    init_pH: '',
-    target_pH: '',
     showModal: false, // 控制弹窗显示与隐藏
   },
 
-  // 更新输入数据
-  onOMChange: function (e) {
-    this.setData({
-      OM: e.detail.value,
-    });
+  // 更新输入数据并验证
+  validateInput: function(value) {
+    // 正则表达式:只允许数字和小数点
+    const regExp = /^[0-9]*\.?[0-9]*$/;
+    // 如果输入符合格式,则返回,否则去掉最后一个字符
+    return regExp.test(value) ? value : value.slice(0, -1);
   },
-  onCLChange: function (e) {
+
+  // 更新土壤初始pH
+  onInitPhChange: function (e) {
     this.setData({
-      CL: e.detail.value,
+      init_pH: this.validateInput(e.detail.value),
     });
   },
-  onHChange: function (e) {
+
+  // 更新土壤目标pH
+  onTargetPhChange: function (e) {
     this.setData({
-      H: e.detail.value,
+      target_pH: this.validateInput(e.detail.value),
     });
   },
-  onAlChange: function (e) {
+
+  // 更新有机质含量
+  onOMChange: function (e) {
     this.setData({
-      Al: e.detail.value,
+      OM: this.validateInput(e.detail.value),
     });
   },
-  onPhChange: function (e) {
+
+  // 更新土壤粘粒重量
+  onCLChange: function (e) {
     this.setData({
-      ph: e.detail.value,
+      CL: this.validateInput(e.detail.value),
     });
   },
-  onInitPhChange: function (e) {
+
+  // 更新氢离子含量
+  onHChange: function (e) {
     this.setData({
-      init_pH: e.detail.value,
+      H: this.validateInput(e.detail.value),
     });
   },
-  onTargetPhChange: function (e) {
+
+  // 更新铝离子含量
+  onAlChange: function (e) {
     this.setData({
-      target_pH: e.detail.value,
+      Al: this.validateInput(e.detail.value),
     });
   },
 
   // 点击按钮后进行计算并提示结果
- // 点击按钮后进行计算并提示结果
 calculate: function () {
   console.log('开始计算...');
   const data = {

+ 8 - 4
shoping/AcidNeutralizationModel/AcidNeutralizationModel.wxml

@@ -1,26 +1,26 @@
 <view class="page-body">
   <view class="white-box">
     <view class="input-row">
-      <view class="page-section-title">土壤初始 pH:
-      </view>
+      <view class="page-section-title">土壤初始 pH:</view>
       <input 
         class="input-field"  
         placeholder="3~6" 
         value="{{init_pH}}" 
         bindinput="onInitPhChange" 
+        inputmode="decimal"  
       />
     </view>
   </view>
 
   <view class="white-box">
     <view class="input-row">
-      <view class="page-section-title">土壤目标 pH:
-      </view>
+      <view class="page-section-title">土壤目标 pH:</view>
       <input 
         class="input-field"  
         placeholder="3~6" 
         value="{{target_pH}}" 
         bindinput="onTargetPhChange" 
+        inputmode="decimal"  
       />
     </view>
   </view>
@@ -34,6 +34,7 @@
         placeholder="10~30" 
         value="{{OM}}" 
         bindinput="onOMChange" 
+        inputmode="decimal"
       />
     </view>
   </view>
@@ -47,6 +48,7 @@
         placeholder="50~600" 
         value="{{CL}}" 
         bindinput="onCLChange" 
+        inputmode="decimal"
       />
     </view>
   </view>
@@ -60,6 +62,7 @@
         placeholder="0~4" 
         value="{{H}}" 
         bindinput="onHChange" 
+        inputmode="decimal"
       />
     </view>
   </view>
@@ -73,6 +76,7 @@
         placeholder="0~4" 
         value="{{Al}}" 
         bindinput="onAlChange" 
+        inputmode="decimal"
       />
     </view>
   </view>

+ 5 - 4
shoping/AcidNeutralizationModel/AcidNeutralizationModel.wxss

@@ -176,7 +176,7 @@
   left: 0;
   right: 0;
   bottom: 0;
-  background: rgba(0, 0, 0, 0.5); /* 背景半透明 */
+  background: rgba(0, 0, 0, 0.9); /* 背景半透明 */
   display: flex;
   justify-content: center;
   align-items: center;
@@ -205,10 +205,11 @@
 /* 关闭按钮 */
 .close-btn {
   position: absolute;  /* 绝对定位 */
-  top: 315px;  /* 距离顶部 10px */
-  left: 335px; /* 距离左侧 10px */
+  top: 300px;  /* 距离顶部 10px */
+  left: 315px; /* 距离左侧 10px */
   background: transparent;
-  border: none;
+  border: none;  /* 隐藏边框 */
+  outline: none; /* 确保没有外部轮廓 */
   font-size: 15px;
   color: red;
   cursor: pointer;

+ 31 - 38
shoping/Calculation/Calculation.js

@@ -4,74 +4,67 @@ Page({
     OM: '', // 有机质含量
     CL: '', // 土壤粘粒重量
     CEC: '', // 阳离子交换量
-    H: '', // 氢离子含量
-    HN: '', // 铵离子含量
-    Al: '', // 铝离子含量
-    free_alumina: '', // 游离氧化铝含量
-    free_iron_oxides: '', // 游离氧化铁含量
+    H_plus: '', // 氢离子含量
+    N: '', // 铵离子含量
+    Al3_plus: '', // 铝离子含量
     delta_ph: '',
     showResultPopup: false, // 控制弹窗显示与否
   },
 
+  // 仅允许输入数字或小数点
+  validateNumberInput: function(value) {
+    // 正则表达式:只允许数字和小数点
+    const regExp = /^[0-9]*\.?[0-9]*$/;
+    if (regExp.test(value)) {
+      return value;
+    }
+    return value.slice(0, -1); // 删除最后一个字符
+  },
+
   // 更新有机质含量
   onOMChange: function(e) {
     this.setData({
-      OM: e.detail.value
+      OM: this.validateNumberInput(e.detail.value)
     });
   },
-  
+
   // 更新土壤粘粒重量
   onCLChange: function(e) {
     this.setData({
-      CL: e.detail.value
+      CL: this.validateNumberInput(e.detail.value)
     });
   },
-  
+
   // 更新阳离子交换量
   onCECChange: function(e) {
     this.setData({
-      CEC: e.detail.value
+      CEC: this.validateNumberInput(e.detail.value)
     });
   },
-  
+
   // 更新氢离子含量
-  onHChange: function(e) {
+  onH_plusChange: function(e) {
     this.setData({
-      H: e.detail.value
+      H_plus: this.validateNumberInput(e.detail.value)
     });
   },
-  
+
   // 更新铵离子含量
-  onHNChange: function(e) {
+  onNChange: function(e) {
     this.setData({
-      HN: e.detail.value
+      N: this.validateNumberInput(e.detail.value)
     });
   },
-  
+
   // 更新铝离子含量
-  onAlChange: function(e) {
-    this.setData({
-      Al: e.detail.value
-    });
-  },
-  
-  // 更新游离氧化铝含量
-  onFreeAluminaChange: function(e) {
-    this.setData({
-      free_alumina: e.detail.value
-    });
-  },
-  
-  // 更新游离氧化铁含量
-  onFreeIronOxidesChange: function(e) {
+  onAl3_plusChange: function(e) {
     this.setData({
-      free_iron_oxides: e.detail.value
+      Al3_plus: this.validateNumberInput(e.detail.value)
     });
   },
-  
   onDeltaPhChange: function(e) {
     this.setData({
-      delta_ph: e.detail.value
+      delta_ph: this.validateNumberInput(e.detail.value)
     });
   },
 
@@ -84,9 +77,9 @@ Page({
         organic_matter: this.data.OM,
         chloride: this.data.CL,
         cec: this.data.CEC,
-        h_concentration: this.data.H,
-        n: this.data.HN,
-        al_concentration: this.data.Al,
+        h_concentration: this.data.H_plus,
+        n: this.data.N,
+        al_concentration: this.data.Al3_plus,
       },
     };
 

+ 61 - 55
shoping/Calculation/Calculation.wxml

@@ -1,91 +1,97 @@
 <!-- pages/Calculation/Calculation.wxml -->
 <view class="page-body">
   <view class="white-box">
-  <view class="input-row">
-    <view class="page-section-title">土壤有机质(g/kg) OM:</view>
-    <input 
-      class="input-field" 
-      type="text" 
-      placeholder="0~30" 
-      value="{{OM}}" 
-      bindinput="onOMChange" 
-    />
-  </view>
+    <view class="input-row">
+      <view class="page-section-title">土壤有机质(g/kg) OM:</view>
+      <input 
+        class="input-field" 
+        type="text" 
+        placeholder="0~30" 
+        value="{{OM}}" 
+        bindinput="onOMChange" 
+        inputmode="decimal"
+      />
+    </view>
   </view>
 </view>
 
 <view class="page-body">
   <view class="white-box">
     <view class="input-row">
-    <view class="page-section-title">土壤粘粒(g/kg) CL:</view>
-    <input 
-      class="input-field" 
-      type="text" 
-      placeholder="50~400" 
-      value="{{CL}}" 
-      bindinput="onCLChange" 
-    />
-  </view>
+      <view class="page-section-title">土壤粘粒(g/kg) CL:</view>
+      <input 
+        class="input-field" 
+        type="text" 
+        placeholder="50~400" 
+        value="{{CL}}" 
+        bindinput="onCLChange" 
+        inputmode="decimal"
+      />
+    </view>
   </view>
 </view>
 
 <view class="page-body">
   <view class="white-box">
     <view class="input-row">
-    <view class="page-section-title">阳离子交换量(cmol/kg) CEC:</view>
-    <input 
-      class="input-field" 
-      type="text" 
-      placeholder="0~15" 
-      value="{{CEC}}" 
-      bindinput="onCECChange" 
-    />
-  </view>
+      <view class="page-section-title">阳离子交换量(cmol/kg) CEC:</view>
+      <input 
+        class="input-field" 
+        type="text" 
+        placeholder="0~15" 
+        value="{{CEC}}" 
+        bindinput="onCECChange" 
+        inputmode="decimal"
+      />
+    </view>
   </view>
 </view>
 
 <view class="page-body">
   <view class="white-box">
     <view class="input-row">
-    <view class="page-section-title">交换性氢(cmol/kg) H+:</view>
-    <input 
-      class="input-field" 
-      type="text" 
-      placeholder="0~1" 
-      value="{{H}}" 
-      bindinput="onHChange" 
-    />
-  </view>
+      <view class="page-section-title">交换性氢(cmol/kg) H+:</view>
+      <input 
+        class="input-field" 
+        type="text" 
+        placeholder="0~1" 
+        value="{{H_plus}}" 
+        bindinput="onH_plusChange" 
+        inputmode="decimal"
+      />
+    </view>
   </view>
 </view>
 
 <view class="page-body">
   <view class="white-box">
     <view class="input-row">
-    <view class="page-section-title">水解氮(g/kg) N:</view>
-    <input 
-      class="input-field" 
-      type="text" 
-      placeholder="0~0.2" 
-      value="{{HN}}" 
-      bindinput="onHNChange" 
-    />
-  </view>
+      <view class="page-section-title">水解氮(g/kg) N:</view>
+      <input 
+        class="input-field" 
+        type="text" 
+        placeholder="0~0.2" 
+        value="{{N}}" 
+        bindinput="onNChange" 
+        inputmode="decimal"
+      />
+    </view>
   </view>
 </view>
 
 <view class="page-body">
   <view class="white-box">
     <view class="input-row">
-    <view class="page-section-title">交换性铝(cmol/kg) Al3+:</view>
-    <input 
-      class="input-field" 
-      type="text" 
-      placeholder="0~6" 
-      value="{{Al}}" 
-      bindinput="onAlChange" 
-    />
-  </view>
+      <view class="page-section-title">交换性铝(cmol/kg) Al3+:</view>
+      <input 
+        class="input-field" 
+        type="text" 
+        placeholder="0~6" 
+        value="{{Al3_plus}}" 
+        bindinput="onAl3_plusChange" 
+        inputmode="decimal"
+      />
+    </view>
   </view>
 </view>
 

+ 3 - 3
shoping/Calculation/Calculation.wxss

@@ -123,7 +123,7 @@
   left: 0;
   right: 0;
   bottom: 0;
-  background: rgba(0, 0, 0, 0.8); /* 背景半透明 */
+  background: rgba(0, 0, 0, 0.9); /* 背景半透明 */
   display: flex;
   justify-content: center;
   align-items: center;
@@ -152,8 +152,8 @@
 /* 关闭按钮 */
 .close-btn {
   position: absolute;  /* 绝对定位 */
-  top: 315px;  /* 距离顶部 10px */
-  left: 335px; /* 距离左侧 10px */
+  top: 300px;  /* 距离顶部 10px */
+  left: 315px; /* 距离左侧 10px */
   background: transparent;
   border: none;  /* 隐藏边框 */
   outline: none; /* 确保没有外部轮廓 */

+ 94 - 180
shoping/EditProfile/EditProfile.js

@@ -1,9 +1,12 @@
 Page({
   data: {
-    isLogin: false,  // 登录状态
-    userInfo: {      // 用户信息
-      nickName: '',  // 用户昵称
+    userInfo: {
+      name: '',  // 用户名
     },
+    oldPassword: '',  // 输入的旧密码
+    newPassword: '',  // 输入的新密码
+    errorMessage: '', // 错误提示信息
+    isSaveDisabled: true,  // 控制保存按钮是否禁用
   },
 
   // 页面加载时从缓存获取用户信息
@@ -11,219 +14,130 @@ Page({
     this.loadUserInfo();  // 加载缓存中的用户信息
   },
 
-  // 页面显示时确保用户信息刷新
+  // 页面显示时确保更新按钮状态
   onShow() {
-    this.loadUserInfo();  // 每次进入页面时刷新用户信息
-    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-      this.getTabBar().setData({
-        selected: 3  // 设置当前tab为选中状态
-      });
-    }
-    // 隐藏返回首页按钮
-    if (wx.canIUse('hideHomeButton')) {
-      wx.hideHomeButton();
-    }
+    this.updateSaveButtonState();  // 更新保存按钮的状态
   },
 
   // 加载缓存的用户信息
   loadUserInfo() {
-    // 获取缓存中的用户信息
-    const storedUserInfo = wx.getStorageSync('userInfo') || {};  // 获取缓存的 userInfo 对象
-    const storedAvatarUrl = storedUserInfo.avatarUrl || '/assets/taddar/me.png';  // 获取缓存的头像
-    const storedPassword = storedUserInfo.password || '';  // 获取缓存的密码
-    const storedUsername = storedUserInfo.username || '';  // 获取缓存的用户名
-    const storedUserRole = wx.getStorageSync('userRole') || '';  // 获取缓存的用户角色
-    
-    // 合并缓存信息
-    const userInfo = {
-      nickName: storedUserInfo.nickName || '',  // 如果没有昵称,设置为空
-      avatarUrl: storedAvatarUrl,  // 如果没有头像,使用默认头像
-      username: storedUsername,  // 设置用户名
-      password: storedPassword,  // 设置密码
-    };
-
-    // 设置页面数据
-    this.setData({
-      userInfo,
-      userRole: storedUserRole,  // 设置用户角色
-    });
-
-    // 调试信息,确认缓存是否加载成功
-    console.log('Loaded userInfo from cache:', userInfo);
-    console.log('Loaded avatarUrl from cache:', storedAvatarUrl);
-    console.log('Loaded password from cache:', storedPassword);
-    console.log('Loaded username from cache:', storedUsername);
-    console.log('Loaded userRole from cache:', storedUserRole);
-  },
+    // 从缓存中获取 currentUser(用户名)和 userId(用户ID)
+    const currentUser = wx.getStorageSync('currentUser') || '';  // 获取缓存的用户名,若无则为空
+    const userId = wx.getStorageSync('userId') || '';  // 获取缓存的用户ID,若无则为空
 
-  // 修改昵称
-  onNicknameChange(e) {
+    // 设置用户名和用户ID
     this.setData({
-      'userInfo.nickName': e.detail.value,  // 更新昵称
+      userInfo: {
+        name: currentUser,  // 设置用户名
+      }
     });
+    this.updateSaveButtonState();  // 更新保存按钮状态
   },
 
-  // 修改用户名
-  onUsernameChange(e) {
+  // 获取用户名输入
+  inputName(e) {
     this.setData({
-      'userInfo.username': e.detail.value,  // 更新用户名
+      'userInfo.name': e.detail.value,  // 更新用户名
     });
+    this.updateSaveButtonState();  // 更新保存按钮状态
   },
 
-  // 修改密码
-  onPasswordChange(e) {
+  // 获取旧密码输入
+  inputOldPassword(e) {
     this.setData({
-      'userInfo.password': e.detail.value,  // 更新密码
+      oldPassword: e.detail.value,  // 更新旧密码
     });
+    this.updateSaveButtonState();  // 更新保存按钮状态
   },
 
-  // 选择头像
-  chooseAvatar() {
-    wx.chooseMedia({
-      count: 1,  // 选择1个文件
-      sizeType: ['original', 'compressed'],  // 原图或压缩图
-      sourceType: ['album', 'camera'],  // 相册或拍照
-      success: (res) => {
-        const avatarUrl = res.tempFiles[0].tempFilePath;
-        this.setData({
-          'userInfo.avatarUrl': avatarUrl,  // 更新头像
-        });
-
-        // 更新缓存中的头像信息
-        let userInfo = wx.getStorageSync('userInfo') || {};
-        userInfo.avatarUrl = avatarUrl;
-        wx.setStorageSync('userInfo', userInfo);
-      },
-      fail: () => {
-        wx.showToast({
-          title: '头像选择失败',
-          icon: 'none',
-        });
-      },
+  // 获取新密码输入
+  inputNewPassword(e) {
+    this.setData({
+      newPassword: e.detail.value,  // 更新新密码
     });
+    this.updateSaveButtonState();  // 更新保存按钮状态
   },
 
-  // 提交表单
-  submitForm() {
-    const { userInfo } = this.data;
-
-    // 打印 userInfo 查看提交的数据
-    console.log('Submitting userInfo:', userInfo);
-
-    // 检查昵称和用户名是否同时为空
-    if (!userInfo.nickName.trim() && !userInfo.username.trim()) {
-      wx.showToast({
-        title: '昵称和用户名至少填写一个',
-        icon: 'none',
+  // 更新保存按钮的状态
+  updateSaveButtonState() {
+    const { oldPassword, newPassword } = this.data;
+    // 判断如果旧密码和新密码都有值,则启用保存按钮,否则禁用
+    if (oldPassword.trim() && newPassword.trim()) {
+      this.setData({
+        isSaveDisabled: false,  // 启用保存按钮
+      });
+    } else {
+      this.setData({
+        isSaveDisabled: true,  // 禁用保存按钮
       });
-      return;
     }
+  },
 
-    // 检查昵称和用户名是否同时填写
-    if (userInfo.nickName.trim() && userInfo.username.trim()) {
-      wx.showToast({
-        title: '只能填写一个:昵称或用户名',
-        icon: 'none',
-      });
+  // 保存修改后的用户名和密码
+  saveChanges() {
+    const { userInfo, oldPassword, newPassword } = this.data;
+
+    // 校验用户名
+    if (!userInfo.name.trim()) {
+      this.setData({ errorMessage: '用户名不能为空' });
       return;
     }
 
-    // 检查密码是否为空
-    if (!userInfo.password || !userInfo.password.trim()) {
-      wx.showToast({
-        title: '密码不能为空',
-        icon: 'none',
-      });
+    // 校验新密码是否为空
+    if (newPassword && !newPassword.trim()) {
+      this.setData({ errorMessage: '新密码不能为空' });
       return;
     }
 
-    // 保存用户信息到缓存
-    wx.setStorageSync('userInfo', userInfo);  // 更新整个 userInfo 对象
-    wx.setStorageSync('avatarUrl', userInfo.avatarUrl);  // 更新头像
-    wx.setStorageSync('username', userInfo.username);  // 更新用户名
-    wx.setStorageSync('password', userInfo.password);  // 更新密码
-    wx.setStorageSync('userRole', this.data.userRole);  // 保存用户角色
-
-    // 重新加载缓存并更新页面
-    this.loadUserInfo();
-
-    // 显示保存成功提示
-    wx.showToast({
-      title: '保存成功',
-      icon: 'success',
-    });
-
-    // 返回上一页
-    wx.navigateBack();
-  },
-
-  // 获取显示的用户名(优先显示昵称,如果没有则显示用户名)
-  getDisplayName() {
-    const { nickName, username } = this.data.userInfo;
-    return nickName.trim() || username.trim() || '未设置';  // 如果昵称为空,则显示用户名,否则显示 '未设置'
-  },
+    // 从缓存中获取 userId
+    const userId = wx.getStorageSync('userId');
 
-  // 显示登录弹窗
-  goLogin() {
-    this.setData({
-      isHidden: false
-    });
-  },
-
-  // 编辑个人资料
-  EditProfile() {
-    wx.navigateTo({
-      url: '/shoping/EditProfile/EditProfile'
-    });
-  },
-
-  // 取消登录弹窗
-  potNo() {
-    this.setData({
-      isHidden: true
-    });
-  },
-
-  // 确认登录弹窗
-  popYes() {
-    const { avatarUrl, nickName, username, password } = this.data.userInfo;
-    if (!avatarUrl || !nickName || !username || !password) {
-      wx.showToast({
-        icon: 'error',
-        title: '请填写头像、昵称、用户名和密码',
-      });
+    if (!userId) {
+      this.setData({ errorMessage: '用户ID不可用' });
       return;
     }
 
-    // 保存头像、昵称、用户名和密码到缓存
-    wx.setStorageSync('userInfo', this.data.userInfo);
-    this.setData({
-      isLogin: true,  // 设置登录状态为 true
-      isHidden: true, // 隐藏弹窗
-    });
-  },
-
-  // 跳转到阈值页面
-  goToThreshold() {
-    wx.navigateTo({
-      url: '/pages/threshold/threshold'
-    });
+    // 调用后端API来保存用户名和密码
+    this.updateUserInfo(userId, userInfo.name, oldPassword, newPassword);
   },
 
-  // 点击退出登录
-  tuichu() {
-    // 清除缓存
-    wx.clearStorageSync();
-
-    // 重置登录状态
-    this.setData({
-      isLogin: false,
-      userInfo: {}
-    });
-
-    // 跳转到登录页面
-    wx.reLaunch({
-      url: '/pages/admin/admin' // 登录页面的路径
+  // 调用后端API更新用户信息
+  updateUserInfo(userId, name, oldPassword, newPassword) {
+    wx.request({
+      url: 'https://soilgd.com:5000/update_user',  // 替换为实际的API地址
+      method: 'POST',
+      data: {
+        userId: userId,  // 传递 userId
+        name: name,
+        oldPassword: oldPassword,
+        newPassword: newPassword,
+      },
+      header: {
+        'Content-Type': 'application/json'  // 确保 Content-Type 设置为 application/json
+      },
+      success: (res) => {
+        if (res.data.success) {
+          wx.setStorageSync('currentUser', name);  // 更新缓存中的用户名
+          this.setData({ errorMessage: '' });
+
+          // 显示成功提示
+          wx.showToast({
+            title: '保存成功',
+            icon: 'success',
+          });
+
+          // 修改成功后跳转到 Staff 页面
+          wx.switchTab({
+            url: '/pages/Staff/Staff',  // 跳转到 Staff 页面
+          });
+        } else {
+          this.setData({ errorMessage: res.data.message || '保存失败' });
+        }
+      },
+      fail: (err) => {
+        console.error('数据库更新失败', err);
+        this.setData({ errorMessage: '更新失败,请稍后重试' });
+      }
     });
   }
 });

+ 12 - 16
shoping/EditProfile/EditProfile.wxml

@@ -1,20 +1,16 @@
 <view class="container">
-  <!-- 用户名 -->
-  <view class="form-item">
-    <text class="label">用户名:</text>
-    <input class="input" 
-           value="{{userInfo.username}}" 
-           bindinput="onUsernameChange" 
-           placeholder="请输入用户名" 
-           wx:if="{{!userInfo.nickName}}" /> <!-- 只有昵称为空时,才显示用户名输入框 -->
-  </view>
-  
-  <!-- 密码 -->
-  <view class="form-item">
-    <text class="label">密码:</text>
-    <input class="input" type="password" value="{{userInfo.password}}" bindinput="onPasswordChange" placeholder="请输入密码" />
-  </view>
+  <!-- 用户名输入框,显示缓存中的用户名 -->
+  <input class="input" bindinput="inputName" placeholder="请输入用户名" value="{{userInfo.name}}" />
+
+  <!-- 旧密码输入框 -->
+  <input class="input" bindinput="inputOldPassword" placeholder="请输入旧密码" type="password" value="{{oldPassword}}" />
+
+  <!-- 新密码输入框 -->
+  <input class="input" bindinput="inputNewPassword" placeholder="请输入新密码" type="password" value="{{newPassword}}" />
 
   <!-- 保存按钮 -->
-  <button class="submit-btn" bindtap="submitForm">保存</button>
+  <button class="btn" bindtap="saveChanges" disabled="{{isSaveDisabled}}">保存修改</button>
+
+  <!-- 错误提示信息 -->
+  <text class="error">{{errorMessage}}</text>
 </view>

+ 32 - 34
shoping/EditProfile/EditProfile.wxss

@@ -1,44 +1,42 @@
+/* 容器样式 */
 .container {
-  padding: 20rpx;
-  background-color: #f7f7f7;
-}
-
-.form-item {
-  margin-bottom: 20rpx;
-  display: flex;
-  align-items: center;
-}
-
-.label {
-  width: 150rpx;
-  font-size: 32rpx;
-  color: #333;
+  padding: 20px;
+  background-color: #f4f4f4;
+  min-height: 100vh;
 }
 
+/* 输入框样式 */
 .input {
-  flex: 1;
-  height: 80rpx;
-  padding: 0 20rpx;
-  font-size: 28rpx;
-  border: 1rpx solid #ccc;
-  border-radius: 10rpx;
+  width: 100%;
+  padding: 12px;
+  margin-bottom: 16px;
+  border: 1px solid #ccc;
+  border-radius: 4px;
   background-color: #fff;
+  font-size: 16px;
+}
+
+/* 按钮样式 */
+.btn {
+  width: 50%;
+  padding: 1px;
+  background-color: #4CAF50;
+  color: white;
+  border: none;
+  border-radius: 4px;
+  font-size: 16px;
+  cursor: pointer;
 }
 
-.avatar {
-  width: 120rpx;
-  height: 120rpx;
-  border-radius: 50%;
-  border: 1rpx solid #ccc;
+.btn:disabled {
+  background-color: #ddd;
+  cursor: not-allowed;
 }
 
-.submit-btn {
-  width: 60%;
-  height: 80rpx;
-  background-color: #3cc51f;
-  color: #fff;
-  font-size: 32rpx;
-  text-align: center;
-  line-height: 80rpx;
-  border-radius: 10rpx;
+/* 错误提示信息样式 */
+.error {
+  color: #f44336;
+  font-size: 14px;
+  margin-top: 10px;
+  display: block;
 }

+ 56 - 38
shoping/Model Selection/Model Selection.js

@@ -1,83 +1,101 @@
 Page({
   data: {
-    modelList: [],         // 可用的模型列表
-    selectedModelName: '', // 选择的模型名称
-    selectedModelId: null, // 选择的模型ID
-    selectedPerformanceScore: '' // 选择的模型性能分数
+    // 定义数据类型
+    Model_name: [
+      { value: 'reduce_model', label: '降酸模型' },
+      { value: 'reflux_model', label: '反酸模型' }
+    ],
+    selectedModelType: '', // 当前选择的模型类型
+    selectedModelLabel: '', // 当前选择的模型类型标签
+    modelList: [], // 从后端获取的所有模型数据
+    filteredModelList: [], // 根据类型过滤后的模型列表
+    selectedModelId: null // 当前选择的模型ID
   },
 
-  onLoad: function() {
-    // 页面加载时获取可用模型列表
+  onLoad: function () {
+    // 页面加载时获取模型列表
     this.fetchModelList();
   },
 
-  // 获取可用的模型列表
-  fetchModelList: function() {
+  // 从后端获取模型数据
+  fetchModelList: function () {
     wx.request({
-      url: 'https://soilgd.com:5000/models',  // 后端接口返回模型列表
-      method: 'GET',  // 获取模型列表应该是 GET 请求
+      url: 'https://soilgd.com:5000/models', // 后端接口
+      method: 'GET',
       success: (res) => {
         if (res.data) {
-          // 只保留 ModelType 和 PerformanceScore,并处理 PerformanceScore 为 null 的情况
-          const filteredModels = res.data.map(model => ({
-            ModelType: model.ModelType,  // 模型类型
-            PerformanceScore: (Number(model.PerformanceScore) || 0).toFixed(2),  // 确保是数字并保留两位小数
-            ModelID: model.ModelID  // 模型ID
+          // 格式化数据并存储
+          const models = res.data.map(model => ({
+            ModelType: model.ModelType,
+            ModelID: model.ModelID,
+            ModelName: model.ModelName, // 包含模型名称
+            PerformanceScore: (Number(model.PerformanceScore) || 0).toFixed(2)
           }));
 
           this.setData({
-            modelList: filteredModels  // 更新模型列表数据
+            modelList: models,
+            filteredModelList: [] // 初始为空,待选择模型类型后填充
           });
         } else {
           wx.showToast({
-            title: '获取模型列表失败',
+            title: '模型数据为空',
             icon: 'none'
           });
         }
       },
       fail: (err) => {
-        console.error("获取模型列表失败", err);
+        console.error('获取模型列表失败', err);
         wx.showToast({
-          title: '获取模型列表失败',
+          title: '获取模型失败',
           icon: 'none'
         });
       }
     });
   },
 
-  // 选择模型时更新 selectedModelId 和 selectedModelName
-  onModelChange: function(e) {
-    const selectedIndex = e.detail.value;
-    const selectedModel = this.data.modelList[selectedIndex];
+  // 切换模型类型时过滤模型列表
+  onModelTypeChange: function (e) {
+    const selectedType = this.data.Model_name[e.detail.value];
+    const filteredModels = this.data.modelList.filter(
+      model => model.ModelName === selectedType.value // 根据模型名称进行过滤
+    );
+
+    this.setData({
+      selectedModelType: selectedType.value, // 记录选择的类型
+      selectedModelLabel: selectedType.label, // 对应显示标签
+      filteredModelList: filteredModels // 更新展示的模型列表
+    });
+  },
+
+  // 选择具体模型
+  onModelSelect: function (e) {
+    const { modelId } = e.currentTarget.dataset;
     this.setData({
-      selectedModelName: selectedModel.ModelType,  // 显示 ModelType
-      selectedModelId: selectedModel.ModelID,  // 使用 ModelID 作为唯一标识
-      selectedPerformanceScore: selectedModel.PerformanceScore  // 显示性能分数
+      selectedModelId: modelId
     });
   },
 
-  // 提交选择的模型
-  onSubmitModel: function() {
-    const { selectedModelId, selectedModelName } = this.data;
+  // 提交选择
+  onSubmitModel: function () {
+    const { selectedModelId, selectedModelType } = this.data;
 
-    if (!selectedModelId || !selectedModelName) {
+    if (!selectedModelId || !selectedModelType) {
       wx.showToast({
-        title: '请选择一个模型',
+        title: '请先选择模型类型和具体模型',
         icon: 'none'
       });
       return;
     }
 
-    // 发送请求切换模型
     wx.request({
-      url: 'https://soilgd.com:5000/switch-model',  // 后端切换模型的接口
+      url: 'https://soilgd.com:5000/switch-model',
       method: 'POST',
       header: {
-        'Content-Type': 'application/json'  // 确保发送的是 JSON 数据
+        'Content-Type': 'application/json'
       },
       data: {
-        model_id: selectedModelId,  // 选择的模型ID
-        model_name: selectedModelName  // 选择的模型名称
+        model_id: selectedModelId,
+        model_type: selectedModelType
       },
       success: (res) => {
         if (res.data && res.data.success) {
@@ -87,13 +105,13 @@ Page({
           });
         } else {
           wx.showToast({
-            title: '切换模型失败',
+            title: '模型切换失败',
             icon: 'none'
           });
         }
       },
       fail: (err) => {
-        console.error("切换模型失败", err);
+        console.error('切换模型失败', err);
         wx.showToast({
           title: '切换模型失败',
           icon: 'none'

+ 20 - 15
shoping/Model Selection/Model Selection.wxml

@@ -1,21 +1,26 @@
-<view> 
-  <!-- picker 用于选择模型 -->
-  <picker bindchange="onModelChange" value="{{selectedModelId}}" range="{{modelList}}" range-key="ModelType">
+<view class="container">
+  <!-- 模型类型选择 -->
+  <picker bindchange="onModelTypeChange" value="{{selectedModelType}}" range="{{Model_name}}" range-key="label">
     <view class="picker">
-      选择模型:{{selectedModelName}} - 性能分数:{{selectedPerformanceScore}}
+      选择模型类型:{{selectedModelLabel || '请选择'}}
     </view>
   </picker>
 
-  <!-- 模型列表显示 
-  <view class="model-list">
-    <block wx:for="{{modelList}}" wx:key="index">
-      <view class="model-item">
-        <text>模型类型:{{item.ModelType}}</text>
-        <text>性能分数:{{item.PerformanceScore}}</text>
-      </view>
-    </block>
+  <!-- 模型列表展示 -->
+  <view wx:for="{{filteredModelList}}" wx:key="ModelID" class="model-item">
+    <radio-group>
+      <label>
+        <radio
+          value="{{item.ModelID}}"
+          data-model-id="{{item.ModelID}}"
+          checked="{{selectedModelId === item.ModelID}}"
+          bindtap="onModelSelect"
+        />
+        {{item.ModelID}}: {{item.ModelType}}: {{item.PerformanceScore}}
+      </label>
+    </radio-group>
   </view>
--->
-  <!-- 提交按钮,用于提交选择的模型 -->
-  <button bindtap="onSubmitModel" class="submit-btn">切换模型</button>
+
+  <!-- 提交按钮 -->
+  <button bindtap="onSubmitModel" class="submit-btn">提交选择</button>
 </view>

+ 54 - 10
shoping/Model Selection/Model Selection.wxss

@@ -1,21 +1,65 @@
+.container {
+  padding: 20px;
+  background-color: #f8f8f8;
+  min-height: 100vh;
+}
+
 .picker {
-  font-size: 16px;
-  margin: 10px;
+  margin-bottom: 20px;
+  background-color: #fff;
   padding: 10px;
-  border: 1px solid #ccc;
+  border-radius: 5px;
+  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
 }
 
-.model-list {
-  margin-top: 20px;
+.picker-label {
+  font-size: 16px;
+  color: #333;
+}
+
+.picker-selected {
+  font-size: 16px;
+  color: #007aff;
+  margin-top: 8px;
 }
 
 .model-item {
+  margin-bottom: 15px;
+  background-color: #fff;
   padding: 10px;
-  margin: 5px 0;
-  border: 1px solid #f1f1f1;
+  border-radius: 5px;
+  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
+}
+
+.model-item-label {
+  display: flex;
+  align-items: center;
+  font-size: 14px;
+  color: #333;
+}
+
+.model-text {
+  margin-left: 10px;
+  font-size: 14px;
+  color: #666;
+}
+
+.submit-btn {
+  margin-top: 20px;
+  background-color: #1AAD19;
+  color: white;
+  padding: 1px;
+  border-radius: 5px;
+  width: 50%;
+  font-size: 16px;
+  text-align: center;
+  cursor: pointer;
+}
+
+.submit-btn:hover {
+  background-color: #3EC01E;
 }
 
-.model-item text {
-  display: block;
-  margin-bottom: 5px;
+.submit-btn:active {
+  background-color: #1AAD19;
 }

+ 2 - 0
shoping/Soil Acidification/Soil Acidification.wxml

@@ -19,11 +19,13 @@
   <button class="full-width-button" bindtap="Soil_Acidification_Iterative_Evolution">反酸模型迭代可视化</button>
 </view>
 <text class="regular-text">
+  <text class="containes">
 <text class="sub-title">3. 技术支持</text>
 如果在使用过程中遇到问题或对模型预测有疑问,请联系技术支持团队。
 邮箱:support@example.com
 单位:广东省生态环境与土壤研究所
 </text>
+</text>
 
 <nav-tabar selected="{{selected}}"></nav-tabar> 
 

+ 2 - 0
shoping/Soil Deacidification/Soil Deacidification.wxml

@@ -17,10 +17,12 @@
 </view>
 
 <text class="regular-text">
+  <text class="containes">
 <text class="sub-title">3. 技术支持</text>
 如果在使用过程中遇到问题或对模型预测有疑问,请联系技术支持团队。
 邮箱:support@example.com
 单位:广东省生态环境与土壤研究所
 </text>
+</text>
 
 <nav-tabar selected="{{selected}}"></nav-tabar>