|
@@ -114,15 +114,34 @@ Page({
|
|
|
// 计算方法
|
|
|
calculate: function() {
|
|
|
console.log('开始计算...');
|
|
|
- console.log('有机质含量:', this.data.OM);
|
|
|
- console.log('土壤粘粒重量:', this.data.CL);
|
|
|
- console.log('阳离子交换量:', this.data.CEC);
|
|
|
- console.log('氢离子含量', this.data.H);
|
|
|
- console.log('铵离子含量:', this.data.HN);
|
|
|
- console.log('铝离子含量:', this.data.Al);
|
|
|
- console.log('游离氧化铝含量:', this.data.free_alumina);
|
|
|
- console.log('游离氧化铁含量:', this.data.free_iron_oxides);
|
|
|
- console.log('采样地点:', this.data.collection_location);
|
|
|
- console.log('采样时间:', this.data.collection_date);
|
|
|
+ const data = {
|
|
|
+ organic_matter: this.data.OM,
|
|
|
+ chloride: this.data.CL,
|
|
|
+ cec: this.data.CEC,
|
|
|
+ h_concentration: this.data.H,
|
|
|
+ hn: this.data.HN,
|
|
|
+ al_concentration: this.data.Al,
|
|
|
+ free_alumina: this.data.free_alumina,
|
|
|
+ free_iron: this.data.free_iron_oxides,
|
|
|
+ delta_ph: this.data.targetPH - this.data.initialPH // 假设delta_ph是目标pH和初始pH的差值
|
|
|
+ };
|
|
|
+
|
|
|
+ wx.request({
|
|
|
+ url: 'http://localhost:5000/predict',
|
|
|
+ method: 'POST',
|
|
|
+ data: JSON.stringify(data),
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json'
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('预测结果:', res.data.predictions);
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/Result/Result?result=${encodeURIComponent(JSON.stringify(res.data.predictions))}`
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.error('请求失败:', error);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
-});
|
|
|
+})
|