From d8d79bacc651e33b617547b2be188bee170ea7a7 Mon Sep 17 00:00:00 2001
From: Gary <3489015381@qq.com>
Date: Wed, 27 Nov 2024 17:10:16 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90AI=E6=A8=A1=E5=9D=97=E5=92=8C?=
=?UTF-8?q?=E5=90=8E=E7=AB=AF=E7=9A=84=E5=AF=B9=E6=8E=A5=E6=93=8D=E4=BD=9C?=
=?UTF-8?q?=EF=BC=8C=E4=BF=A1=E6=81=AF=E5=A1=AB=E5=86=99=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E5=92=8C=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2=E7=9A=84=E5=AF=B9?=
=?UTF-8?q?=E6=8E=A5=E5=85=A8=E9=83=A8=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
App.vue | 6 +-
.../ai_recongize_fruit/ai_recongize_fruit.vue | 9 +-
.../ai_recongize_hot/ai_recongize_hot.vue | 6 +-
.../ai_recongize_plan/ai_recongize_plan.vue | 6 +-
.../ai_recongize_recipe.vue | 6 +-
components/dictionary/dictionary.vue | 2 +-
.../my_exercise_plan/my_exercise_plan.vue | 7 +-
components/my_recipe_plan/my_recipe_plan.vue | 6 +-
components/read/read.vue | 5 +-
components/swiper/exercise.vue | 6 +-
components/swiper/puppy_chat.vue | 6 +-
components/swiper/read_center.vue | 6 +-
components/tarbar_home/tarbar_home.vue | 4 +-
pages.json | 104 ++++---
.../ai_recognize_fruit/ai_recognize_fruit.vue | 22 +-
.../ai_recognize_hot/ai_recognize_hot.vue | 16 +-
.../ai_recognize_plan/ai_recognize_plan.vue | 256 +++++++++++-----
.../ai_recognize_recipe.vue | 284 +++++++++++++-----
pages/homepages/homes/home/home.vue | 20 +-
.../knowledge_dictionary.vue} | 0
pages/homepages/puppy_chat/puppy_chat.vue | 17 +-
.../boy_height_end/boy_height_end.vue | 12 +-
.../boy_height_start/boy_height_start.vue | 7 +-
.../boy_weight_end/boy_weight_end.vue | 10 +-
.../boy_weight_start/boy_weight_start.vue | 11 +-
.../girl_weight_end/girl_weight_end.vue | 9 +-
.../girl_weight_start/girl_weight_start.vue | 11 +-
pages/information/sex/sex.vue | 14 +-
pages/login/account_login/account_login.vue | 2 +-
pages/transition/page8/page8.vue | 2 +-
.../css/ai_recongnize_hot.scss | 6 +-
.../pictures/go_back_button.png | Bin 0 -> 142341 bytes
.../homepages/puppy_chat/css/puppy_chat.scss | 5 +-
33 files changed, 626 insertions(+), 257 deletions(-)
rename pages/homepages/homes/{knowlege_dictionary/knowlege_dictionary.vue => knowledge_dictionary/knowledge_dictionary.vue} (100%)
create mode 100644 static/homepages/homes/ai_recognize_recipe/pictures/go_back_button.png
diff --git a/App.vue b/App.vue
index a1a29dd..241ac51 100644
--- a/App.vue
+++ b/App.vue
@@ -28,10 +28,10 @@ import ai_recongize_recipe from './components/ai_recongize_recipe/ai_recongize_r
export default {
globalData: {
// 定义后端数据库地址信息
- fit_journey_basic_address: 'http://47.122.61.54:8086',//TODO:已完成
+ fit_journey_basic_address: 'http://127.0.0.1:8086',//TODO:已完成
fit_journey_community_address: 'http://47.122.61.54:8082',//TODO:已完成
- fit_journey_ai_address: 'http://47.122.61.54:8081',//TODO:配置完成
- fit_journey_login_address: 'http://127.0.0.1:8084',//TODO:配置完成
+ fit_journey_ai_address: 'http://127.0.0.1:8081',//TODO:配置完成
+ fit_journey_login_address: 'http://47.122.61.54:8084',//TODO:配置完成
fit_journey_recipe_address: 'http://47.122.61.54:8087',//TODO:配置完成
fit_journey_exercise_address: 'http://47.122.61.54:8080',//TODO:配置完成
fit_journey_admin_address: 'http://47.122.61.54:8085',//TODO:已完成
diff --git a/components/ai_recongize_fruit/ai_recongize_fruit.vue b/components/ai_recongize_fruit/ai_recongize_fruit.vue
index f5b3d56..4463969 100644
--- a/components/ai_recongize_fruit/ai_recongize_fruit.vue
+++ b/components/ai_recongize_fruit/ai_recongize_fruit.vue
@@ -26,9 +26,14 @@ export default {
methods:{
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_fruit/ai_recongize_fruit'
+ url: '/pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit'
})
- }
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
+ })
+ },
+
}
}
diff --git a/components/ai_recongize_hot/ai_recongize_hot.vue b/components/ai_recongize_hot/ai_recongize_hot.vue
index b5a898e..0940959 100644
--- a/components/ai_recongize_hot/ai_recongize_hot.vue
+++ b/components/ai_recongize_hot/ai_recongize_hot.vue
@@ -26,7 +26,11 @@ export default {
methods:{
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_hot/ai_recongize_hot'
+ url: '/pages/homepages/homes/ai_recognize_hot/ai_recognize_hot'
+ })
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
})
}
diff --git a/components/ai_recongize_plan/ai_recongize_plan.vue b/components/ai_recongize_plan/ai_recongize_plan.vue
index 073b083..630884c 100644
--- a/components/ai_recongize_plan/ai_recongize_plan.vue
+++ b/components/ai_recongize_plan/ai_recongize_plan.vue
@@ -26,7 +26,11 @@ export default {
methods:{
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_plan/ai_recongize_plan'
+ url: '/pages/homepages/homes/ai_recognize_plan/ai_recognize_plan'
+ })
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
})
}
diff --git a/components/ai_recongize_recipe/ai_recongize_recipe.vue b/components/ai_recongize_recipe/ai_recongize_recipe.vue
index 6160586..6e7f023 100644
--- a/components/ai_recongize_recipe/ai_recongize_recipe.vue
+++ b/components/ai_recongize_recipe/ai_recongize_recipe.vue
@@ -26,7 +26,11 @@ export default {
methods:{
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_recipe/ai_recongize_recipe'
+ url: '/pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe'
+ })
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
})
}
diff --git a/components/dictionary/dictionary.vue b/components/dictionary/dictionary.vue
index 91e438d..f96c0a3 100644
--- a/components/dictionary/dictionary.vue
+++ b/components/dictionary/dictionary.vue
@@ -26,7 +26,7 @@ export default {
methods: {
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_fruit/ai_recongize_fruit'
+ url: '/pages/homepages/homes/knowledge_dictionary/knowledge_dictionary'
})
}
diff --git a/components/my_exercise_plan/my_exercise_plan.vue b/components/my_exercise_plan/my_exercise_plan.vue
index 463ccba..56931be 100644
--- a/components/my_exercise_plan/my_exercise_plan.vue
+++ b/components/my_exercise_plan/my_exercise_plan.vue
@@ -26,10 +26,15 @@ export default {
methods: {
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_fruit/ai_recongize_fruit'
+ url: '/pages/homepages/homes/my_exercise_plan/my_exercise_plan'
+ }) ;
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
})
}
+
}
}
diff --git a/components/my_recipe_plan/my_recipe_plan.vue b/components/my_recipe_plan/my_recipe_plan.vue
index 69f53cc..3df6ce4 100644
--- a/components/my_recipe_plan/my_recipe_plan.vue
+++ b/components/my_recipe_plan/my_recipe_plan.vue
@@ -26,7 +26,11 @@ export default {
methods: {
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_fruit/ai_recongize_fruit'
+ url: '/pages/homepages/homes/my_exercise_plan/my_exercise_plan'
+ })
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
})
}
diff --git a/components/read/read.vue b/components/read/read.vue
index 409e02d..3394b3f 100644
--- a/components/read/read.vue
+++ b/components/read/read.vue
@@ -26,7 +26,10 @@ export default {
methods: {
go_to_page() {
uni.navigateTo({
- url: '/pages/homepages/homes/ai_recongize_fruit/ai_recongize_fruit'
+ url: '/pages/homepages/homes/choice_book/choice_book'
+ })
+ uni.showToast({
+ title: '跳转成功',
})
}
diff --git a/components/swiper/exercise.vue b/components/swiper/exercise.vue
index a836fab..c7976f6 100644
--- a/components/swiper/exercise.vue
+++ b/components/swiper/exercise.vue
@@ -1,7 +1,7 @@
-
+
@@ -19,6 +19,10 @@ export default {
uni.navigateTo({
url: '/pages/homepages/homes/my_exercise_plan/my_exercise_plan'
})
+ uni.showToast({
+ title: '跳转',
+ icon: 'success',
+ })
}
}
}
diff --git a/components/swiper/puppy_chat.vue b/components/swiper/puppy_chat.vue
index 04aad6f..a931a88 100644
--- a/components/swiper/puppy_chat.vue
+++ b/components/swiper/puppy_chat.vue
@@ -19,7 +19,11 @@ export default {
go_go_puppy_chat(){
uni.navigateTo({
url: '/pages/homepages/puppy_chat/puppy_chat'
- })
+ })
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
+ })
}
}
}
diff --git a/components/swiper/read_center.vue b/components/swiper/read_center.vue
index 7e5a303..c4cacb9 100644
--- a/components/swiper/read_center.vue
+++ b/components/swiper/read_center.vue
@@ -17,7 +17,11 @@ export default {
methods:{
go_to_choice_book() {
uni.navigateTo({
- url: '/pages/homepages/homes/choice_book/choice_book'
+ url: '/pages/homepages/homes/knowledge_dictionary/knowledge_dictionary'
+ })
+ uni.showToast({
+ title: '跳转成功',
+ icon: 'success',
})
}
diff --git a/components/tarbar_home/tarbar_home.vue b/components/tarbar_home/tarbar_home.vue
index 74c2fa1..dc20739 100644
--- a/components/tarbar_home/tarbar_home.vue
+++ b/components/tarbar_home/tarbar_home.vue
@@ -112,7 +112,7 @@ export default {
left: 2.5%; /* 左侧2.5% */
background-color: khaki; /* 初始颜色 */
border-radius: 37px; /* 圆角半径,可以根据需要调整 */
- z-index: -1; /* 使背景框在其他元素后面 */
+ z-index: 100; /* 使背景框在其他元素后面 */
animation: colorTransition 2s ease forwards; /* 添加颜色渐变动画 */
}
@@ -121,6 +121,7 @@ export default {
width: 15%;
height: 6%;
bottom: 2%;
+ z-index: 100; /* 使背景框在其他元素后面 */
transition: opacity 1s ease; /* 添加渐变过渡 */
}
.pick_up_home, .pick_up_community, .pick_up_assistant, .pick_up_user {
@@ -129,6 +130,7 @@ export default {
height: 10%;
bottom: 2%;
transition: opacity 1s ease; /* 添加渐变过渡 */
+ z-index: 100; /* 使背景框在其他元素后面 */
}
/* 图标位置调整 */
diff --git a/pages.json b/pages.json
index 71f508b..4f7ca1f 100644
--- a/pages.json
+++ b/pages.json
@@ -175,37 +175,76 @@
}
},
/*------------------------------------------------------------------进入主页的过渡界面--------------------------------------------*/
-
+ /*------------------------------------------------------------------主页部分内容--------------------------------------------------------*/
{
"path": "pages/homepages/homes/home/home",
"style": {
"navigationStyle": "custom"
}
},
-
- /* {
- "path": "pages/homepages/homes/my_recipe_plan/my_recipe_plan",
- "style": {
+ {
+ "path" : "pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe",
+ "style" :
+ {
"navigationStyle": "custom"
}
- },*/
- /* {
- "path": "pages/homepages/temp/temp",
+ },//饮食专区四个界面
+ {
+ "path": "pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit",
+ "style": {
+ "navigationStyle": "custom"
+ }
+ },//饮食专区四个界面
+ {
+ "path": "pages/homepages/homes/ai_recognize_hot/ai_recognize_hot",
"style": {
"navigationStyle": "custom"
}
- }*/
-
-
- /*{
- "path": "pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit",
- "style": {
+ },//饮食专区四个界面
+ {
+ "path": "pages/homepages/homes/my_recipe_plan/my_recipe_plan",
+ "style": {
+ "navigationStyle": "custom"
+ }
+ },//饮食专区四个界面
+ {
+ "path" : "pages/homepages/homes/ai_recognize_plan/ai_recognize_plan",
+ "style" :
+ {
+ "navigationStyle": "custom"
+ }
+ },//运动专区的两个界面
+ {
+ "path": "pages/homepages/homes/my_exercise_plan/my_exercise_plan",
+ "style" :
+ {
+ "navigationStyle": "custom"
+ }
+ },//运动专区的两个界面
+ {
+ "path": "pages/homepages/homes/choice_book/choice_book",
+ "style" :
+ {
+ "navigationStyle": "custom"
+ }
+ },//阅读专区的两个界面
+ {
+ "path": "pages/homepages/homes/knowledge_dictionary/knowledge_dictionary",
+ "style" :
+ {
"navigationStyle": "custom"
}
- }*/
+ },//阅读专区的两个界面
+
+
+
+
+
+
+
+
/* {
- "path": "pages/homepages/homes/ai_recognize_hot/ai_recognize_hot
- ",
+ "path": "pages/homepages/temp/temp",
"style": {
"navigationStyle": "custom"
}
@@ -271,13 +310,7 @@
"navigationStyle": "custom"
}
},
- {
- "path" : "pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe",
- "style" :
- {
- "navigationStyle": "custom"
- }
- },
+
{
"path" : "pages/homepages/homes/ai_recognize_plan/ai_recognize_plan",
"style" :
@@ -472,27 +505,8 @@
/*--------------------------------------------------------知识图谱界面----------------------------------------------------------------------*/
/*-------------------------------------------------------------------部分组件的测试类---------------------------------------------------*/
- {
- "path": "pages/homepages/homes/my_exercise_plan/my_exercise_plan",
- "style" :
- {
- "navigationStyle": "custom"
- }
- },
- {
- "path": "pages/homepages/homes/choice_book/choice_book",
- "style" :
- {
- "navigationStyle": "custom"
- }
- },
- {
- "path": "pages/homepages/homes/knowlege_dictionary/knowlege_dictionary",
- "style" :
- {
- "navigationStyle": "custom"
- }
- },
+
+
{
"path": "pages/homepages/community/community/community",
"style" :
diff --git a/pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit.vue b/pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit.vue
index 42b83a7..b2103cf 100644
--- a/pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit.vue
+++ b/pages/homepages/homes/ai_recognize_fruit/ai_recognize_fruit.vue
@@ -24,6 +24,7 @@ export default {
return {
calorie: 0,
name: '',
+ token:uni.getStorageSync("access_token")
};
},
methods: {
@@ -52,19 +53,28 @@ export default {
// 上传文件到后端服务器中
uni.uploadFile({
header: {
- 'Authorization': app.globalData.token // 授权 token
+ 'Authorization':this.token
},
url: app.globalData.fit_journey_ai_address + `/ai/fruit`, // 服务器接口地址
-
filePath: filePath,
name: 'file', // 后端接收的文件参数名称
success: (uploadFileRes) => {
- console.log('上传结果:', uploadFileRes);
+
const response = JSON.parse(uploadFileRes.data); // 解析返回的数据
if (response && response.data) {
- // 处理返回的数据
- this.calorie = response.data.calorie || 0;
- this.name = response.data.name || '识别失败,请重新上传图片';
+ let result = response.data; // 获取返回的结果
+ console.log("识别到的果蔬信息:", result);
+
+ // 你可以通过以下方式获取识别的果蔬名称和卡路里
+ for (let [name, calorie] of Object.entries(result)) {
+ this.name = name; // 存储果蔬名称
+ this.calorie = calorie; // 存储卡路里
+ console.log(`水果: ${name}, 卡路里: ${calorie} kcal/100g`);
+ }
+ uni.showToast({
+ title: '恭喜你,AI识别成功了呢~',
+ icon: 'none',
+ });
} else {
uni.showToast({
title: '识别失败,请重新上传图片',
diff --git a/pages/homepages/homes/ai_recognize_hot/ai_recognize_hot.vue b/pages/homepages/homes/ai_recognize_hot/ai_recognize_hot.vue
index 616b2a2..6691d22 100644
--- a/pages/homepages/homes/ai_recognize_hot/ai_recognize_hot.vue
+++ b/pages/homepages/homes/ai_recognize_hot/ai_recognize_hot.vue
@@ -24,6 +24,7 @@ export default {
return {
calorie: 0,
name: '',
+ token :uni.getStorageSync("access_token")
};
},
methods: {
@@ -47,15 +48,13 @@ export default {
success: (chooseImageRes) => {
const filePath = chooseImageRes.tempFilePaths[0]; // 获取选择的图片路径
- console.log('选择的图片路径:', filePath);
- console.log("图片上传成功!");
+
// 上传文件到后端服务器中
uni.uploadFile({
header: {
- 'Authorization': app.globalData.token // 授权 token
+ 'Authorization': this.token
},
- url: app.globalData.fit_journey_ai_address+`/ai/hot`, // 服务器接口地址
-
+ url: app.globalData.fit_journey_ai_address+`/ai/recipe`, // 服务器接口地址
filePath: filePath,
name: 'file', // 后端接收的文件参数名称
success: (uploadFileRes) => {
@@ -65,7 +64,14 @@ export default {
// 处理返回的数据
this.calorie = response.data.calorie || 0;
this.name = response.data.name || '识别失败,请重新上传图片';
+ uni.showToast({
+ title: '恭喜您,AI识别成功啦~',
+ icon: 'none',
+ duration :2000,//设置显示时间为2秒
+ });
} else {
+
+
uni.showToast({
title: '识别失败,请重新上传图片',
icon: 'none',
diff --git a/pages/homepages/homes/ai_recognize_plan/ai_recognize_plan.vue b/pages/homepages/homes/ai_recognize_plan/ai_recognize_plan.vue
index 9edc05a..cc424e5 100644
--- a/pages/homepages/homes/ai_recognize_plan/ai_recognize_plan.vue
+++ b/pages/homepages/homes/ai_recognize_plan/ai_recognize_plan.vue
@@ -1,96 +1,198 @@
-
-
+
+
-
+
+
+
+
+ AI生成的结果是
+
+ {{ result }}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe.vue b/pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe.vue
index 698cd5f..c28b6a2 100644
--- a/pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe.vue
+++ b/pages/homepages/homes/ai_recognize_recipe/ai_recognize_recipe.vue
@@ -1,9 +1,35 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+ AI生成的结果是
+
+ {{ result }}
+
+
+
+
@@ -11,86 +37,190 @@
export default {
data() {
return {
- recipeImage: null // 用于存储图片的本地路径
+ is_create_success: -1,//0是失败,1是成功,-1是什么都没有
+
+ can_generate_button_click: true, // 控制生成按钮是否可点击
+ recipeImage: null, // 用于存储图片的本地路径
+ result: '这个',
+ token:uni.getStorageSync("access_token"),
};
},
methods: {
- generate() {
- uni.request({
- url: app.globalData.fit_journey_ai_address+`/ai/recipe`, // 请替换为实际的后端接口URL
- method: 'GET',
- success: (res) => {
- if (res.data && res.data.base64) {
- this.saveBase64Image(res.data.base64);
- }
- }
- });
- },
- saveBase64Image(base64Data) {
- // 创建文件系统对象
- plus.io.resolveLocalFileSystemURL(plus.io.convertLocalFileSystemURL('_doc/'), (entry) => {
- // 生成文件名
- const fileName = `_doc/${new Date().getTime()}.png`;
- // 创建文件
- entry.getFile(fileName, {create: true}, (fileEntry) => {
- // 将base64转换为Blob对象
- const arr = base64Data.split(',');
- const mime = arr[0].match(/:(.*?);/)[1];
- const bstr = atob(arr[1]);
- let n = bstr.length;
- const u8arr = new Uint8Array(n);
- while (n--) {
- u8arr[n] = bstr.charCodeAt(n);
- }
- const blob = new Blob([u8arr], {type: mime});
- // 写入文件
- fileEntry.createWriter((fileWriter) => {
- fileWriter.write(blob);
- // 更新图片路径
- this.recipeImage = plus.io.convertLocalFileSystemURL(fileName);
- }, (e) => {
- console.log("Write file failed: " + e.message);
- });
- }, (e) => {
- console.log("Get file failed: " + e.message);
- });
- }, (e) => {
- console.log("Resolve file system failed: " + e.message);
- });
- }
+ go_back_to_home() {
+ uni.navigateTo({
+ url: '/pages/homepages/homes/home/home'
+ });
+ },
+ generate() {
+ uni.showToast({
+ title: '正在生成...',
+ icon: 'loading',
+ duration: 12000, // Toast 显示时间为 2 秒
+ });
+ //向后端发送请求生成结果
+ const app= getApp();
+ uni.request({
+ url: app.globalData.fit_journey_ai_address + '/ai/recipe/generate',
+ method: 'POST',
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'Authorization':this.token
+ },
+ data: {
+ },
+ success: (res) => {
+ if(res.data.code===200){
+ console.log("请求成功!请求数据是", res);
+ this.result = res.data.data;
+ }else {
+ uni.showToast({
+ title:"AI生成失败",
+ icon: 'none',
+ duration: 2000
+ })
+ this.result = res.data.msg;
+ }
+
+ },
+ error: (res) => {
+ console.log("请求失败!请求数据是", res);
+ }
+ });
+ //延迟显示结果
+ setTimeout(() => {
+ this.can_generate_button_click= false;
+ this.is_create_success = 0;
+ }, 12000);
+ /* //在20秒的时候清空result
+ setTimeout(() => {
+ this.result="";
+ }, 20000);*/
+ },
+
+ go_back(){
+ this.is_create_success = -1;
+ this.can_generate_button_click=true;
+ }
+
}
}
-
\ No newline at end of file
diff --git a/pages/homepages/homes/home/home.vue b/pages/homepages/homes/home/home.vue
index e02eb8b..49fc326 100644
--- a/pages/homepages/homes/home/home.vue
+++ b/pages/homepages/homes/home/home.vue
@@ -40,10 +40,10 @@
-
+
-
+
@@ -71,6 +71,22 @@ export default {
};
},
methods:{
+ go_to_choice_book(){
+ uni.navigateTo({
+ url: '/pages/homepages/homes/choice_book/choice_book'
+ });
+ uni.showToast({
+ title: '跳转成功',
+ })
+ },
+ go_to_knowledge_dictionary(){
+ uni.navigateTo({
+ url: '/pages/homepages/homes/knowledge_dictionary/knowledge_dictionary'
+ });
+ uni.showToast({
+ title: '跳转成功',
+ })
+ },
onSwiperChange(e){
this.current = e.detail.current;
}
diff --git a/pages/homepages/homes/knowlege_dictionary/knowlege_dictionary.vue b/pages/homepages/homes/knowledge_dictionary/knowledge_dictionary.vue
similarity index 100%
rename from pages/homepages/homes/knowlege_dictionary/knowlege_dictionary.vue
rename to pages/homepages/homes/knowledge_dictionary/knowledge_dictionary.vue
diff --git a/pages/homepages/puppy_chat/puppy_chat.vue b/pages/homepages/puppy_chat/puppy_chat.vue
index 45257e0..26c5333 100644
--- a/pages/homepages/puppy_chat/puppy_chat.vue
+++ b/pages/homepages/puppy_chat/puppy_chat.vue
@@ -38,10 +38,11 @@
export default {
data() {
return {
+ token:uni.getStorageSync("access_token"),
input_message: '',
send_message:'',
send_messages: [], // 存储消息的数组
- conversation_id: 'e97ec0f2-2a94-42e7-b6db-b04883d349e8',
+ conversation_id: 'e97ec0f2-2a94-42e7-b6db-b04883d349e8',//默认的聊天回话id
answer: '', // AI的回答
};
},
@@ -57,7 +58,7 @@ export default {
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': app.globalData.token // TODO:暂时写为临时的token 后期替换
+ 'Authorization': this.token
},
data: {
@@ -70,6 +71,14 @@ export default {
console.log("请求失败!请求数据是", res);
}
});
+ this.send_messages.push({
+ sender: 'ai', // 标记为用户消息
+ message: ":" +"我是fit journey的专属AI小助手,有什么问题都可以问我哦~"
+ });
+
+
+
+
},
methods: {
handleSendMessage() {
@@ -116,11 +125,11 @@ export default {
// 向后端发送请求
uni.request({
- url: 'http://localhost:8081' + '/ai/chat-with-no-stream',//TODO:后期这里改成服务器地址!
+ url: app.globalData.fit_journey_ai_address + '/ai/chat-with-no-stream',//TODO:后期这里改成服务器地址!
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': app.globalData.token // TODO:暂时写为临时的token 后期替换
+ 'Authorization': this.token
},
data: {
conversationId: this.conversation_id,
diff --git a/pages/information/boy_height_end/boy_height_end.vue b/pages/information/boy_height_end/boy_height_end.vue
index aa974c5..f79d597 100644
--- a/pages/information/boy_height_end/boy_height_end.vue
+++ b/pages/information/boy_height_end/boy_height_end.vue
@@ -19,7 +19,8 @@
export default {
data(){
return{
- height:''
+ height:'',
+ token: uni.getStorageSync('access_token'),
};
},
onLoad(options){
@@ -33,22 +34,25 @@ export default {
console.log(app.globalData.token);
console.log(app.globalData.fit_journey_basic_address);
console.log("当前的身高是" + this.height);
-
// 转换 height 字符串为数字,去掉 "cm" 后缀
const numericHeight = parseFloat(this.height.replace('cm', '').trim());
-
+ console.log("本地存储的token是"+this.token)
// 向后端发送请求
uni.request({
url: app.globalData.fit_journey_basic_address + '/height/write_user_height',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': app.globalData.token // TODO:暂时写为临时的token 后期替换
+ 'Authorization': this.token
},
data: {
height: numericHeight, // 发送数字类型
},
success: (res) => {
+ uni.showToast({
+ title: '提交成功',
+ icon: 'success',
+ })
console.log("请求成功!请求数据是", res);
// 如果成功则跳转到使用的目的界面
uni.navigateTo({
diff --git a/pages/information/boy_height_start/boy_height_start.vue b/pages/information/boy_height_start/boy_height_start.vue
index 97a135a..7ed37f1 100644
--- a/pages/information/boy_height_start/boy_height_start.vue
+++ b/pages/information/boy_height_start/boy_height_start.vue
@@ -17,6 +17,11 @@