AI智能定制食谱页面+AI智能定制运动计划页面

master
xiaozhi 2 months ago
parent 68232dfb1b
commit 6d745d1c76

@ -251,7 +251,21 @@
"style": {
"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" :
{
"navigationStyle": "custom"
}
}*/
/*------------------------------------------------------------------------------------------------------------------------------*/
{
"path" : "pages/homepages/homes/dictionary/orange/orange",

@ -0,0 +1,96 @@
<template>
<view>
<image class="background" src="/static/homepages/homes/ai_recognize_plan/pictures/background.png"></image>
<image class="back_button" src="/static/homepages/homes/ai_recognize_plan/pictures/button.png"></image>
<image v-if="planImage" class="plan-image" :src="planImage"></image>
<image class="generate_button" @click="generate()" src="/static/homepages/homes/ai_recognize_plan/pictures/generate.png"></image>
</view>
</template>
<script>
export default {
data() {
return {
planImage: null //
};
},
methods: {
generate() {
uni.request({
url: app.globalData.fit_journey_ai_address+`/ai/plan`, // 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) => {
// base64Blob
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.planImage = 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);
});
}
}
}
</script>
<style lang="scss">
.background {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0%;
}
.back_button {
position: absolute;
width: 3%;
height: 3%;
top: 4%;
left: 7%;
}
.generate_button {
position: absolute;
width: 70%;
height: 12%;
top: 85%;
left: 14%;
}
.plan-image {
position: absolute;
width: 80%; //
height: auto; //
top: 50%; //
left: 50%; //
transform: translate(-50%, -50%); // 使transform
z-index: 10; //
}
</style>

@ -0,0 +1,96 @@
<template>
<view>
<image class="background" src="/static/homepages/homes/ai_recognize_recipe/pictures/background.png"></image>
<image class="back_button" src="/static/homepages/homes/ai_recognize_recipe/pictures/button.png"></image>
<image v-if="recipeImage" class="recipe-image" :src="recipeImage"></image>
<image class="generate_button" @click="generate()" src="/static/homepages/homes/ai_recognize_recipe/pictures/generate.png"></image>
</view>
</template>
<script>
export default {
data() {
return {
recipeImage: null //
};
},
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) => {
// base64Blob
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);
});
}
}
}
</script>
<style lang="scss">
.background {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0%;
}
.back_button {
position: absolute;
width: 3%;
height: 3%;
top: 4%;
left: 7%;
}
.generate_button {
position: absolute;
width: 70%;
height: 12%;
top: 85%;
left: 14%;
}
.recipe-image {
position: absolute;
width: 80%; //
height: auto; //
top: 50%; //
left: 50%; //
transform: translate(-50%, -50%); // 使transform
z-index: 10; //
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Loading…
Cancel
Save