完成个性化功能

This commit is contained in:
539943419 committed 2023-11-20 05:05:07 +08:00
1 parent 3b2d536880
commit ac2e6bf800
6 files changed
+588 -285

No files matched your search

+248 -219
View File
@@ -1,5 +1,14 @@
/**index.wxss**/
page{
// // 主要为各个背景
// --main-color:rgb(246, 255, 252);
// // 目前为主界面的那几个按钮
// --secondary-color:rgba(125, 235, 202, 0.205);
// // 各界面顶部栏的颜色
// --tertiary-color:rgba(123, 245, 245, 0.5);
// // 标题文字颜色
--text-color:rgb(199, 255, 204);
}
.container{
display: flex;
@@ -7,7 +16,7 @@
height: 100%;
width:100%;
justify-content: center;
background-color: rgba($color: #fff5d2, $alpha: 1.0);
// background-color: var(--main-color);
}
#startPage{
@@ -16,15 +25,16 @@
height: 100%;
width:100%;
justify-content: center;
background-color: rgba($color: #fff5d2, $alpha: 1.0);
background-color: var(--main-color);
}
.text_startPage{
font-size: 60rpx;
color:var(--text-color)
}
.buttom_startPage{
background-color: rgba($color: #d2fff4, $alpha: 1);
background-color: var(--secondary-color);
border-radius: 20rpx;
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
display: flex;
@@ -162,7 +172,8 @@
display: flex;
align-items: center;
justify-content: center;
// background-color: aquamarine;
background-color: rgb(240, 255, 247);
border-radius: 50%;
bottom: 140rpx;
right:80rpx;
// font-size: 150rpx;
@@ -174,13 +185,15 @@
.title{
width: 100%;
height: 10%;
background-color: aqua;
background-color: var(--tertiary-color);
position:absolute;
top:0rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: x-large;
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
letter-spacing:10rpx;
.page_back{
height: 70rpx;
width: 70rpx;
@@ -188,8 +201,9 @@
display: flex;
align-items: center;
justify-content: center;
// rotate: -90deg;
// background-color: aquamarine;
top: 50rpx;
// top: 20%;
left:30rpx;
// font-size: 150rpx;
// font-weight: 900;
@@ -260,7 +274,7 @@
// 知识库界面
#page_lib{
background-color: rgba($color: #fff5d2, $alpha: 1.0);
background-color: var(--main-color);
display: flex;
align-items: center;
justify-content: center;
@@ -268,7 +282,7 @@
.content{
display: flex;
flex-direction: column;
padding-top: 20rpx;
padding-top: 30rpx;
// padding-bottom: 40rpx;
.lib_search{
margin-bottom: 20rpx;
@@ -276,206 +290,196 @@
// // background-color: yellow;
// }
}
.node{
background-color: rgba($color: #ffffff, $alpha: 1);
}
}
// 单配料卡片样式
.ingredient_card{
background-color: rgba($color: #ffffff, $alpha: 1);
border-radius: 15rpx;
height: 200rpx;
width: auto;
margin:15rpx 20rpx 15rpx 10rpx;
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
.node_content{
position: relative;
display: block;
height: 100%;
width: auto;
margin-left: 25rpx;
border-radius: 15rpx;
background-color: rgba($color: #ffffff, $alpha: 1);
// background-color: var(--tertiary-color);
// overflow: hidden;
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.node_name{
font-size: 31rpx;
height:50rpx;
width:max-content;
background-color: rgba(150, 145, 138, 0.5);
padding:0rpx 10rpx;
display: flex;
align-items: center;
border-radius: 15rpx;
height: 200rpx;
width: auto;
margin:15rpx 20rpx 15rpx 10rpx;
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
.node_content{
position: relative;
display: block;
height: 100%;
width: auto;
margin-left: 25rpx;
position: absolute;
top:15rpx;
left:20rpx;
max-width: 230rpx;
overflow: scroll;
white-space: nowrap;
// justify-content: center;
}
.node_name_en{
height:45rpx;
position: absolute;
top:80rpx;
left:20rpx;
max-width: 338rpx;
}
.node_adi{
font-size: 31rpx;
height:45rpx;
max-width:338rpx;
// background-color: rgba(150, 145, 138, 0.5);
// padding:0rpx 10rpx;
display: flex;
align-items: center;
border-radius: 15rpx;
position: absolute;
bottom:20rpx;
left:20rpx;
overflow: scroll;
white-space: nowrap;
.adi_title{
height:45rpx;
background-color:salmon;
padding:0rpx 10rpx;
}
.adi_content{
height:45rpx;
background-color:rgb(224, 224, 224);
padding:0rpx 10rpx;
}
}
.node_danger{
font-size: 31rpx;
height:50rpx;
width: 80rpx;
background-color: rgba(150, 145, 138, 0.5);
position: absolute;
left:299rpx;
top:15rpx;
// padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15rpx;
background-color: tomato;
// view{
// position: relative;
// top:-0.5rpx;
// }
}
.node_safe{
font-size: 31rpx;
height:50rpx;
width: 80rpx;
background-color: rgba(150, 145, 138, 0.5);
position: absolute;
left:299rpx;
top:15rpx;
// padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15rpx;
background-color:springgreen;
// view{
// position: relative;
// top:-0.5rpx;
// }
}
.node_scores{
font-size: 31rpx;
height:50rpx;
width: 135rpx;
background-color: rgba(150, 145, 138, 0.5);
position: absolute;
left:399rpx;
top:15rpx;
// padding: 4rpx 0rpx 6rpx 10rpx;
// padding-left: 10rpx;
display: flex;
align-items: center;
// justify-content: center;
border-radius: 15rpx;
overflow: hidden;
.scores_title{
height:50rpx;
width: 80rpx;
background-color:salmon;
display: flex;
align-items: center;
justify-content: center;
}
.scores_num{
height:50rpx;
width: 65rpx;
background-color:rgb(224, 224, 224);
display: flex;
align-items: center;
justify-content: center;
}
}
.node_risk{
font-size: 31rpx;
height:50rpx;
width: 120rpx;
position: absolute;
left:560rpx;
top:15rpx;
// padding: 0rpx 6rpx 6rpx 13rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15rpx;
overflow: hidden;
}
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.node_extra{
height:95rpx;
width: 256rpx;
// background-color: white;
border: 3rpx solid rgba(0, 0, 0, 0.356);
position: absolute;
left:400rpx;
bottom:15rpx;
padding: 5rpx 10rpx 10rpx 10rpx;
border-radius: 15rpx;
display: flex;
flex-direction: column;
align-items: center;
overflow: scroll;
.node_extra_empty{
margin: auto;
font-size: 45rpx;
}
.node_ex_content{
margin:5rpx;
height: 40rpx;
width: 240rpx;
display: flex;
border-radius: 15rpx;
background-color: rgba($color: #ffffff, $alpha: 1);
// overflow: hidden;
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
// .node_nameBar{
// background-color: teal;
// position: absolute;
// top:20rpx;
// left:20rpx;
// overflow: scroll;
// height: 500rpx;
// width: 350rpx;
// display:flex;
// // flex-direction: column;
// justify-content: center;
// align-items: flex-start;
// }
.node_name{
font-size: 31rpx;
height:50rpx;
width:max-content;
background-color: rgba(150, 145, 138, 0.5);
padding:0rpx 10rpx;
display: flex;
align-items: center;
border-radius: 15rpx;
position: absolute;
top:15rpx;
left:20rpx;
max-width: 230rpx;
overflow: scroll;
white-space: nowrap;
// justify-content: center;
}
.node_name_en{
height:45rpx;
position: absolute;
top:80rpx;
left:20rpx;
max-width: 338rpx;
}
.node_adi{
font-size: 31rpx;
height:45rpx;
max-width:338rpx;
// background-color: rgba(150, 145, 138, 0.5);
// padding:0rpx 10rpx;
display: flex;
align-items: center;
border-radius: 15rpx;
position: absolute;
bottom:20rpx;
left:20rpx;
overflow: scroll;
white-space: nowrap;
.adi_title{
height:45rpx;
background-color:salmon;
padding:0rpx 10rpx;
}
.adi_content{
height:45rpx;
background-color:rgb(224, 224, 224);
padding:0rpx 10rpx;
}
}
.node_danger{
font-size: 31rpx;
height:50rpx;
width: 80rpx;
background-color: rgba(150, 145, 138, 0.5);
position: absolute;
left:299rpx;
top:15rpx;
// padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15rpx;
background-color: tomato;
// view{
// position: relative;
// top:-0.5rpx;
// }
}
.node_safe{
font-size: 31rpx;
height:50rpx;
width: 80rpx;
background-color: rgba(150, 145, 138, 0.5);
position: absolute;
left:299rpx;
top:15rpx;
// padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15rpx;
background-color:springgreen;
// view{
// position: relative;
// top:-0.5rpx;
// }
}
.node_scores{
font-size: 31rpx;
height:50rpx;
width: 135rpx;
background-color: rgba(150, 145, 138, 0.5);
position: absolute;
left:399rpx;
top:15rpx;
// padding: 4rpx 0rpx 6rpx 10rpx;
// padding-left: 10rpx;
display: flex;
align-items: center;
// justify-content: center;
border-radius: 15rpx;
overflow: hidden;
.scores_title{
height:50rpx;
width: 80rpx;
background-color:salmon;
display: flex;
align-items: center;
justify-content: center;
}
.scores_num{
height:50rpx;
width: 65rpx;
background-color:rgb(224, 224, 224);
display: flex;
align-items: center;
justify-content: center;
}
}
.node_risk{
font-size: 31rpx;
height:50rpx;
width: 120rpx;
position: absolute;
left:560rpx;
top:15rpx;
// padding: 0rpx 6rpx 6rpx 13rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15rpx;
overflow: hidden;
}
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.node_extra{
height:95rpx;
width: 256rpx;
background-color: white;
border: 3rpx solid rgba(0, 0, 0, 0.356);
position: absolute;
left:400rpx;
bottom:15rpx;
padding: 5rpx 10rpx 10rpx 10rpx;
border-radius: 15rpx;
display: flex;
flex-direction: column;
align-items: center;
overflow: scroll;
.node_extra_empty{
margin: auto;
font-size: 45rpx;
}
.node_ex_content{
margin:5rpx;
height: 40rpx;
width: 240rpx;
display: flex;
border-radius: 15rpx;
align-items: center;
justify-content: center;
}
}
align-items: center;
justify-content: center;
}
}
}
@@ -484,7 +488,7 @@
// 历史记录
#page_history{
background-color: rgba($color: #fff5d2, $alpha: 1.0);
background-color: var(--main-color);
// .date1{
// background-color: rgba($color: #fff5d2, $alpha: 1);
// height: 50rpx;
@@ -509,7 +513,7 @@
height: 210rpx;
width: auto;
border-radius: 15rpx;
background-color: rgba(167, 180, 176, 0.863);
background-color: rgba(91, 95, 94, 0.263);
margin:15rpx 25rpx;
// margin-top:30rpx;
// margin-left: 30rpx;
@@ -582,7 +586,7 @@
// 收藏界面
#page_collect{
background-color: rgba($color: #fff5d2, $alpha: 1.0);
background-color: var(--main-color);
translate:0 100%;
.content{
display: flex;
@@ -704,11 +708,32 @@
//个性化界面
#page_style{
background-color: rgba($color: #fff5d2, $alpha: 1.0);
display: flex;
align-items: center;
justify-content: center;
background-color: var(--main-color);
translate:0 100%;
.content{
display: flex;
flex-wrap: wrap;
justify-content:center;
padding-top: 20rpx;
padding-bottom: 40rpx;
.choose_color{
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
width: 300rpx;
height: 300rpx;
margin: 20rpx;
border-radius: 30rpx;
display:flex;
flex-direction: row;
overflow: hidden;
.node{
width:34%;
height: 300rpx;
background-color: white;
}
// background-color: white;
// background: linear-gradient(to right,rgb(255, 255, 255) 33%,blue 66%,rgb(0, 0, 0)100%);
}
}
}
//遮罩
@@ -725,15 +750,16 @@
}
//查询结果
#page_result{
height: 90%;
height: 89%;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
overflow: hidden;
translate: 0 100%;
background-color: rgba($color: #ffffff, $alpha: 1.0);
border-radius: 50rpx;
// background-color: rgba($color: #ffffff, $alpha: 1.0);
background-color: var(--main-color);
border-radius: 40rpx;
.title{
.page_star{
height: 70rpx;
@@ -743,7 +769,7 @@
align-items: center;
justify-content: center;
// background-color: aquamarine;
top: 50rpx;
// top: 50rpx;
right:30rpx;
// font-size: 150rpx;
// font-weight: 900;
@@ -757,7 +783,7 @@
align-items: center;
justify-content: center;
// background-color: aquamarine;
top: 50rpx;
// top: 50rpx;
right:100rpx;
// font-size: 150rpx;
// font-weight: 900;
@@ -1051,6 +1077,7 @@
.title{
height: 30%;
border-radius: 25rpx 25rpx 0 0;
letter-spacing:0rpx;
}
.input{
height: 120rpx;
@@ -1113,6 +1140,7 @@
.title{
height: 30%;
border-radius: 25rpx 25rpx 0 0;
letter-spacing:0rpx;
}
.input{
height: 120rpx;
@@ -1234,3 +1262,4 @@
left:450rpx;
background-color: royalblue;
}
+319 -56
View File
@@ -2,17 +2,106 @@
// 获取应用实例
const app = getApp<IAppOption>()
const serverAddr = "127.0.0.1:5000"
const serverAddr = "http://127.0.0.1:5000"
Page({
data: {
miao_style:`
--main-color:rgb(246, 255, 252);
--secondary-color:rgba(125, 235, 202, 0.205);
--tertiary-color:rgba(123, 245, 245, 0.5);
--text-color:rgb(0, 0, 0);
`,
active_style:"warm",
style_lib:{
bios:{
name:"生命",
intro:"我好像成为你的鹿",
style:{
main:'rgb(179, 57, 47)',
secondary:'rgb(214, 212, 205)',
tertiary:'rgb(234, 255, 208)',
text:'rgb(0, 0, 0)',
}
},
warm:{
name:"被爱灌溉成长的人",
intro:"我好像成为你的鹿",
style:{
main:'rgb(206, 90, 103)',
secondary:'rgb(252, 245, 237)',
tertiary:'rgb(244, 191, 150)',
text:'rgb(0, 0, 0)',
}
},
bin:{
name:"冰岛",
intro:"我好像成为你的鹿",
style:{
main:'rgb(57, 62, 70)',
secondary:'rgb(238, 238, 238)',
tertiary:'rgb(66, 125, 157)',
text:'rgb(0, 0, 0)',
}
},
purple:{
name:"紫罗兰",
intro:"我好像成为你的鹿",
style:{
main:'rgb(208, 162, 247)',
secondary:'rgb(241, 234, 255)',
tertiary:'rgb(229, 212, 255)',
text:'rgb(0, 0, 0)',
}
},
Ukraine:{
name:"乌克兰",
intro:"我好像成为你的鹿",
style:{
main:'rgb(12, 53, 106)',
secondary:'rgb(255, 196, 54)',
tertiary:'rgb(1, 116, 190)',
text:'rgb(0, 0, 0)',
}
},
watermelon:{
name:"西瓜",
intro:"我好像成为你的鹿",
style:{
main:'rgb(255, 170, 167)',
secondary:'rgb(213, 236, 194)',
tertiary:'rgb(255, 211, 180)',
text:'rgb(0, 0, 0)',
}
},
shine:{
name:"ta",
intro:"我好像成为你的鹿",
style:{
main:'rgb(242, 190, 209)',
secondary:'rgb(248, 232, 238)',
tertiary:'rgb(253, 206, 223)',
text:'rgb(0, 0, 0)',
}
},
tree:{
name:"乌克兰",
intro:"我好像成为你的鹿",
style:{
main:'rgb(60, 98, 85)',
secondary:'rgb(234, 231, 177)',
tertiary:'rgb(97, 135, 110)',
text:'rgb(0, 0, 0)',
}
},
},
// motto: 'Hello World',
text_startPage1: "知识库",
imgUrl_startPage1: "./static/icons/lib.svg",
function_startPage1: "popup_lib",
imgUrl_startPage2: "./static/icons/history.svg",
function_startPage2: "popup_history",
imgUrl_startPage3: "./static/icons/heart.svg",
imgUrl_startPage3: `./static/icons/heart.svg`,
function_startPage3: "popup_collect",
text_startPage4: "个性化",
imgUrl_startPage4: "./static/icons/self.svg",
@@ -24,6 +113,7 @@ Page({
remarkTemp: '',
resultTitle: "查询结果",
// 没用到
pageStack: [],
curtain_hidden: true,
@@ -155,6 +245,23 @@ Page({
hidden: false,
riskBgColor: "tomato",
riskStr: "高风险"
}, {
name: {
zh: "生牛乳",
en: "Hatsune Miku"
},
scores: 93,
info: "HAHA",
extra: [
{ type: "safe", name: "好喝" },
],
ADI: "",
// 搜索用,前端赋值
hidden: false,
//前端赋值
"riskBgColor": "springgreen",
"riskStr": "低风险"
}
],
@@ -195,15 +302,60 @@ Page({
// 启动时获取session
async onLoad() {
await this.updateSession()
setInterval(()=>{
this.updateSession()
},60*1000*5)
// this.data.session_key = wx.getStorageSync("session_key")
// await this.updateSession()
this.readStorageData()
this.updateLib()
this.updateHistory()
this.set_miaoStyle(this.data.active_style)
// this.edit_svg_color()
// this.updateLib()
// this.updateCollection()
// this.updateHistory()
},
// 好像微信小程序没有atob处理base64,此函数放弃
edit_svg_color(rgb="#000000"){
return;
rgb
var lib=`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697811750837" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="38161" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M454.5083 1023.996806H340.163697a57.4917 57.4917 0 0 1-57.4917-57.4917V59.413839a57.4917 57.4917 0 0 1 57.4917-57.4917H454.5083a57.4917 57.4917 0 0 1 57.4917 57.4917v907.091267a57.4917 57.4917 0 0 1-57.4917 57.4917z m-107.956637-63.879667H448.120333V65.801806H346.551663zM198.350837 1023.996806H84.006233a57.4917 57.4917 0 0 1-57.4917-57.4917V59.413839a57.4917 57.4917 0 0 1 57.4917-57.4917h114.344604A57.4917 57.4917 0 0 1 256.481333 59.413839v907.091267a57.4917 57.4917 0 0 1-58.130496 57.4917zM90.3942 960.117139H192.601667V65.801806H90.3942z" fill="#000000" p-id="38162"></path><path d="M223.902703 234.444126H58.454367a31.939833 31.939833 0 0 1 0-63.879667h165.448336a31.939833 31.939833 0 0 1 0 63.879667zM480.060167 234.444126H314.61183a31.939833 31.939833 0 0 1 0-63.879667H480.060167a31.939833 31.939833 0 0 1 0 63.879667zM831.398333 1023.996806a56.852903 56.852903 0 0 1-55.57531-42.799377L538.82946 104.768403A58.130497 58.130497 0 0 1 579.712447 33.861973l110.511823-31.939834a57.4917 57.4917 0 0 1 70.267633 40.882987l235.077174 875.79023a58.130497 58.130497 0 0 1-40.882987 70.90643L844.174267 1023.996806zM602.07033 93.908859L831.398333 960.117139l98.374687-26.190663L703.639 65.801806z m96.458297-58.769293z" fill="#000000" p-id="38163"></path><path d="M767.518667 866.214029a31.939833 31.939833 0 0 1-30.66224-23.635476 31.301037 31.301037 0 0 1 22.357883-38.966597l160.337963-42.799377a31.301037 31.301037 0 0 1 38.966597 22.357884 31.939833 31.939833 0 0 1-22.99668 38.966596l-159.699167 42.799377a19.1639 19.1639 0 0 1-8.304356 1.277593z" fill="#000000" p-id="38164"></path></svg>`;
var history=`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697812141935" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="52846" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M411.733333 885.333333H192c-6.4 0-10.666667-4.266667-10.666667-10.666666V149.333333c0-6.4 4.266667-10.666667 10.666667-10.666666h576c6.4 0 10.666667 4.266667 10.666667 10.666666v219.733334c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V149.333333c0-40.533333-34.133333-74.666667-74.666667-74.666666H192C151.466667 74.666667 117.333333 108.8 117.333333 149.333333v725.333334c0 40.533333 34.133333 74.666667 74.666667 74.666666h219.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z" fill="#000000" p-id="52847"></path><path d="M704 458.666667c-134.4 0-245.333333 110.933333-245.333333 245.333333S569.6 949.333333 704 949.333333 949.333333 838.4 949.333333 704 838.4 458.666667 704 458.666667z m0 426.666666c-100.266667 0-181.333333-81.066667-181.333333-181.333333s81.066667-181.333333 181.333333-181.333333 181.333333 81.066667 181.333333 181.333333-81.066667 181.333333-181.333333 181.333333z" fill="#000000" p-id="52848"></path><path d="M802.133333 716.8l-66.133333-29.866667V597.333333c0-17.066667-14.933333-32-32-32s-32 14.933333-32 32v110.933334c0 12.8 8.533333 23.466667 19.2 29.866666l85.333333 38.4c4.266667 2.133333 8.533333 2.133333 12.8 2.133334 12.8 0 23.466667-6.4 29.866667-19.2 6.4-17.066667 0-34.133333-17.066667-42.666667zM693.333333 298.666667c0-17.066667-14.933333-32-32-32H298.666667c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h362.666666c17.066667 0 32-14.933333 32-32zM298.666667 437.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h106.666666c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-106.666666z" fill="#000000" p-id="52849"></path></svg>`;
var heart=`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697812442065" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="57278" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M702.131071 124.121212c-93.893818 0-161.150707 84.605414-190.140768 129.353697C482.974384 208.726626 415.747232 124.121212 321.858586 124.121212 187.126303 124.121212 77.550545 245.53503 77.550545 394.757172c0 69.772929 47.327677 169.808162 104.782869 222.157576 79.475071 102.110384 302.898424 285.923556 330.484364 285.923556 28.070788 0 246.702545-180.236929 327.611475-284.696566 58.46497-53.272566 106.020202-153.439677 106.020202-223.384566C946.449455 245.53503 836.858182 124.121212 702.131071 124.121212M888.84299 394.757172c0 55.802828-40.468687 139.081697-88.362667 181.838869-1.313616 1.197253-2.505697 2.504404-3.697778 3.944727C725.586101 673.303273 582.242909 788.363636 512.970343 838.758141 461.474263 801.065374 306.369293 683.62602 226.742949 580.176162c-1.071838-1.408-2.323394-2.721616-3.63701-3.943434-47.706505-42.702869-87.964444-125.763232-87.964444-181.475556 0-117.474263 83.752081-213.060525 186.717091-213.060525 66.368646 0 130.267798 71.83903 164.141253 143.066505 4.490343 9.438384 14.449778 15.317333 25.995636 15.317333 11.544566 0 21.500121-5.878949 26.020202-15.317333 33.842424-71.227475 97.711838-143.066505 164.115394-143.066505C805.090909 181.696646 888.84299 277.282909 888.84299 394.757172" fill="#000000" p-id="57279"></path></svg>`;
var self=`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697812304038" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="55172" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M957.8 625.2c-5-15.4-17.4-27.4-33-32l-116.6-34.4-68.8-100.2c-9.2-13.4-24.4-21.4-40.6-21.4-16.2 0-31.4 8-40.6 21.4l-68.8 100.2-116.6 34.4c-15.6 4.6-27.8 16.6-33 32-5 15.4-2.2 32.4 7.8 45.2l74.2 96.4-3.4 121.6c-0.4 16.2 7.2 31.6 20.2 41.2 8.6 6.2 18.6 9.4 29 9.4 5.6 0 11.2-1 16.6-2.8l114.6-40.8 114.6 40.8c15.4 5.4 32.4 3 45.4-6.6 13.2-9.6 20.8-25 20.2-41.2l-3.4-121.6 74.2-96.4c10-12.8 13-29.8 8-45.2z m-131.8 108c-6.8 9-10.6 20.2-10.2 31.4l3 109.6-103.4-36.8c-10.6-3.8-22.4-3.8-33 0l-103.4 36.8 3-109.6c0.4-11.2-3.4-22.4-10.2-31.4l-66.8-87 105.2-31c10.8-3.2 20.4-10 26.8-19.4l62-90.4 62 90.4c6.4 9.4 15.8 16.2 26.8 19.4l105.2 31-67 87z" fill="#000000" p-id="55173"></path><path d="M641 660c-16.6 0-30 13.4-30 30v27.4c0 16.6 13.4 30 30 30s30-13.4 30-30V690c0-16.6-13.6-30-30-30zM756.6 660c-16.6 0-30 13.4-30 30v27.4c0 16.6 13.4 30 30 30s30-13.4 30-30V690c0-16.6-13.4-30-30-30zM406.4 737.2H179.6c-30.8 0-55.8-25-55.8-55.8V200.8c0-30.8 25-55.8 55.8-55.8h543.4c30.8 0 55.8 25 55.8 55.8v230.2c0 16.6 13.4 30 30 30s30-13.4 30-30V200.8c0-63.8-52-115.8-115.8-115.8H179.6c-63.8 0-115.8 52-115.8 115.8v480.4c0 63.8 52 115.8 115.8 115.8h226.8c16.6 0 30-13.4 30-30s-13.4-29.8-30-29.8z" fill="#000000" p-id="55174"></path><path d="M629 343.2h58.2c16.6 0 30-13.4 30-30s-13.4-30-30-30h-58.2c-12.8-41.6-51.6-72-97.4-72-45.8 0-84.6 30.4-97.4 72H218.8c-16.6 0-30 13.4-30 30s13.4 30 30 30H434c12.8 41.6 51.6 72 97.4 72 45.8 0 84.6-30.2 97.6-72z m-139.6-30c0-23.2 18.8-42 42-42s42 18.8 42 42-18.8 42-42 42-42-18.8-42-42zM388.2 503.2c-12.8-41.6-51.6-72-97.4-72-56.2 0-102 45.8-102 102s45.8 102 102 102c45.8 0 84.6-30.4 97.4-72h63c16.6 0 30-13.4 30-30s-13.4-30-30-30h-63z m-97.4 72c-23.2 0-42-18.8-42-42s18.8-42 42-42 42 18.8 42 42-18.8 42-42 42z" fill="#000000" p-id="55175"></path></svg>`
var camera=`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697812002437" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="50178" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M273.066667 102.4h494.933333c94.2592 0 170.666667 76.407467 170.666667 170.666667v494.933333c0 94.2592-76.407467 170.666667-170.666667 170.666667H273.066667c-94.2592 0-170.666667-76.407467-170.666667-170.666667V273.066667c0-94.2592 76.407467-170.666667 170.666667-170.666667z m0 68.266667a102.4 102.4 0 0 0-102.4 102.4v494.933333a102.4 102.4 0 0 0 102.4 102.4h494.933333a102.4 102.4 0 0 0 102.4-102.4V273.066667a102.4 102.4 0 0 0-102.4-102.4H273.066667z" fill="#000000" p-id="50179"></path><path d="M517.973333 699.733333c94.2592 0 170.666667-76.407467 170.666667-170.666666s-76.407467-170.666667-170.666667-170.666667-170.666667 76.407467-170.666666 170.666667 76.407467 170.666667 170.666666 170.666666z m0-68.266666a102.4 102.4 0 1 1 0-204.8 102.4 102.4 0 0 1 0 204.8z" fill="#000000" p-id="50180"></path><path d="M750.933333 335.121067a34.133333 34.133333 0 1 0 0-68.266667 34.133333 34.133333 0 0 0 0 68.266667z" fill="#000000" p-id="50181"></path></svg>`
lib=(lib)
this.setData({
imgUrl_startPage1: lib,
imgUrl_startPage2: history,
imgUrl_startPage3: heart,
imgUrl_startPage4: self,
})
},
// 编辑wxss那几个css变量实现风格转换
set_miaoStyle(e){
var name = ''
if(typeof e == "string")name = e
else{
name = e.currentTarget.dataset.index
}
console.log(name)
var style = this.data.style_lib[name].style
var str = `
--main-color:${style.main};
--secondary-color:${style.secondary};
--tertiary-color:${style.tertiary};
--text-color:${style.text};
`
this.setData({
miao_style:str,
active_style:name
})
this.save2storage()
},
//开始界面的按钮相关动画
startPage_Bottons_leave() {
// var fd = wx.createSelectorQuery()
@@ -678,7 +830,7 @@ Page({
//更新成分数据
updateLib() {
wx.request({
url: 'http://' + serverAddr + '/getLib', //仅为示例,并非真实的接口地址
url: serverAddr + '/getLib', //仅为示例,并非真实的接口地址
data: {
session_key:this.data.session_key
},
@@ -737,7 +889,7 @@ Page({
//更新历史记录
updateHistory() {
wx.request({
url: 'http://' + serverAddr + '/getHistory', //仅为示例,并非真实的接口地址
url: '' + serverAddr + '/getHistory', //仅为示例,并非真实的接口地址
data: {
session_key:this.data.session_key
},
@@ -760,40 +912,145 @@ Page({
})
},
// 更新session
updateSession() {
return new Promise((resolve, reject) => {
this.getCode().then(code => {
wx.request({
url: 'http://' + serverAddr + '/updateSession',
data: {
userCode: code
},
method: "POST",
header: {
'content-type': 'application/json'
},
success: res => {
console.log(res)
var data = res.data
this.setData(
{ "session_key": data }
)
resolve()
// setTimeout(this.updateSession,1000*60*5)
},
fail: res => {
console.log(res)
// setTimeout(this.updateSession,1000)
reject()
}
})
})
//更新收藏
updateCollection() {
wx.request({
url: '' + serverAddr + '/getCollection', //仅为示例,并非真实的接口地址
data: {
session_key:this.data.session_key
},
method: "POST",
header: {
'content-type': 'application/json' // 默认值
},
success: res => {
console.log(res)
var data = res.data
this.setData(
{ "data_collect": data }
)
this.save2storage()
},
fail(res) {
console.log(res)
}
})
},
// 更新session
updateSession() {
return new Promise((resolve, reject) => {
// 仅测试
if(this.data.session_key == '' || true){
this.getCode().then(code => {
wx.request({
url: '' + serverAddr + '/updateSession',
data: {
userCode: code
},
method: "POST",
header: {
'content-type': 'application/json'
},
success: res => {
console.log(res)
var data = res.data
this.setData(
{ "session_key": data }
)
resolve()
// setTimeout(this.updateSession,1000*60*5)
},
fail: res => {
console.log(res)
// setTimeout(this.updateSession,1000)
reject()
}
})
})
}else{
wx.checkSession({
success:resolve,
fail:()=>{
this.getCode().then(code => {
wx.request({
url: '' + serverAddr + '/updateSession',
data: {
userCode: code
},
method: "POST",
header: {
'content-type': 'application/json'
},
success: res => {
console.log(res)
var data = res.data
this.setData(
{ "session_key": data }
)
resolve()
// setTimeout(this.updateSession,1000*60*5)
},
fail: res => {
console.log(res)
// setTimeout(this.updateSession,1000)
reject()
}
})
})
}
})
}
})
},
// 检查session是否过期
// checkSession() {
// return new Promise((resolve, reject) => {
// this
// })
// },
// 上传照片并展示收到的结果
uploadImg(tempImagePath: any) {
wx.showLoading({ // 显示加载中loading效果
title: "查询中喵",
mask: true //开启蒙版遮罩
});
return setTimeout(()=>{
wx.hideLoading();
var fake_data = {
id:70582140,
imgUrl:"./static/icons/history.svg",
res:{
scores: 93,
arr: ["生牛乳"],
}
}
var data = fake_data
var nowdate = new Date();
var nowyear = nowdate.getFullYear();
var nowmonth = nowdate.getMonth() + 1;
var nowday = nowdate.getDate();
var dateStr = nowyear + '.' + nowmonth + '.' + nowday
if (!this.data.data_history[dateStr]) {
this.data.data_history[dateStr] = []
}
var historyTemp =
{
id: data.id,
imgUrl: data.imgUrl,
res: data.res,
hasCollect: false,//目前全是false。。。
}
this.data.data_history[dateStr].push(historyTemp)
this.setData({
data_history: this.data.data_history
})
this.sortHistory()
this.show_result_byId(data.id)
this.save2storage()
},3000)
wx.getFileSystemManager().readFile({
filePath: tempImagePath,
encoding: 'base64',
@@ -801,7 +1058,7 @@ Page({
// console.log('data:image/png;base64,' + res.data)
const imgBase64 = res.data
wx.request({
url: 'http://' + serverAddr + '/rcvImg', //仅为示例,并非真实的接口地址
url: '' + serverAddr + '/rcvImg', //仅为示例,并非真实的接口地址
data: {
imgBase64: imgBase64,
session_key:this.data.session_key
@@ -847,7 +1104,7 @@ Page({
// 向云发送历史记录和收藏记录数据
uploadHistoryAndCollection(){
wx.request({
url: 'http://' + serverAddr + '/uploadHistoryAndCollection', //仅为示例,并非真实的接口地址
url: '' + serverAddr + '/uploadHistoryAndCollection', //仅为示例,并非真实的接口地址
data: {
history : this.data.data_history,
collection:this.data.data_collect,
@@ -871,6 +1128,8 @@ Page({
const ctx = wx.createCameraContext()
console.log('takePhoto..')
ctx.takePhoto({
// quality: 'normal',
quality: 'normal',
//找时间把这里和choosePhoto的success合并一下(算了)
success: res => {
@@ -1001,29 +1260,33 @@ Page({
// 将各种数据存入本地
save2storage() {
var list = ['data_history', 'data_collect', 'data_lib']
var list = ['data_history', 'data_collect', 'data_lib','active_style']
for (var k of list) {
wx.setStorage({
key: k,
data: this.data[k],
})
wx.setStorageSync(k,this.data[k])
console.log(k,this.data[k])
}
},
// 从本地读取各种数据
readStorageData(){
var list = ['data_history', 'data_collect', 'data_lib']
var list = ['data_history', 'data_collect', 'data_lib','active_style']
for (var k of list) {
this.data[k]=wx.getStorageSync(k)
var m = {}
m[k] = wx.getStorageSync(k)
this.setData(m)
console.log(k,this.data[k])
// this.data[k]=wx.getStorageSync(k)
// console.log(wx.getStorageSync(k))
}
this.setData(
{
data_history:this.data["data_history"],
data_collect:this.data["data_collect"],
data_lib:this.data["data_lib"],
}
)
// this.setData(
// {
// data_history:this.data["data_history"],
// data_collect:this.data["data_collect"],
// data_lib:this.data["data_lib"],
// active_style:this.data['']
// }
// )
},
@@ -1170,7 +1433,7 @@ Page({
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths)
wx.uploadFile({
url: 'http://' + serverAddr + '/rcvImg', //仅为示例,非真实的接口地址
url: '' + serverAddr + '/rcvImg', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'Img',
formData: {
+16 -9
View File
@@ -1,5 +1,6 @@
<!--index.wxml-->
<view class="container">
<view class="container" style="{{ miao_style }}">
<!-- <view class="container"> -->
<!-- 开始界面 -->
<view class="miao_page" id = 'startPage'>
@@ -24,7 +25,7 @@
</view>
<view class="buttom_startPage" id="tips_startPage" hidden="{{tip_hidden}}" style="justify-content: left;">
<view class="tip_head" style="margin-left: 15rpx;font-weight: 600;">Daliy Tips:</view>
<view class="tip_content">{{tip_content}}</view>
<view class="tip_content"style="margin-left:15rpx;font-weight: 600;">{{tip_content}}</view>
</view>
<!-- <view class="buttom_startPage test" id='test' bind:tap="startPage_Bottons_leave">测试移去</view>
<view class="buttom_startPage test" id='test2' bind:tap="popup_camera">弹出相机</view> -->
@@ -51,7 +52,7 @@
<view class="title">
<view>知识库</view>
<view class="page_back" bind:tap="exit_lib">
<image src="./static/icons/back.svg" mode="aspectFit" />
<image src="./static/icons/back_black.svg" mode="aspectFit" />
</view>
</view>
<view class="content">
@@ -65,7 +66,7 @@
<!-- <view class="search_button" bind:tap="readInput_lib">搜索</view> -->
</view>
<view wx:for="{{ data_lib }}" wx:for-item="n">
<view class="node" hidden="{{ hidden_lib[n.name.zh] }}" style="background-color: {{ n.riskBgColor }};">
<view class="ingredient_card" hidden="{{ hidden_lib[n.name.zh] }}" style="background-color: {{ n.riskBgColor }};">
<view class="node_content">
<view class="node_name">{{ n.name.zh }}</view>
<view class="node_name node_name_en">{{ n.name.en }}</view>
@@ -102,7 +103,7 @@
<view class="title">
<view>历史记录</view>
<view class="page_back" bind:tap="exit_history">
<image src="./static/icons/back.svg" mode="aspectFit" />
<image src="./static/icons/back_black.svg" mode="aspectFit" />
</view>
</view>
<!-- <view class="date1">{{currentDate}}</view>
@@ -128,7 +129,7 @@
<view class="title">
<view>我的收藏</view>
<view class="page_back" bind:tap="exit_collect">
<image src="./static/icons/back.svg" mode="aspectFit" />
<image src="./static/icons/back_black.svg" mode="aspectFit" />
</view>
</view>
<view class="content">
@@ -151,10 +152,16 @@
<view class="title">
<view>个性化</view>
<view class="page_back" bind:tap="exit_style">
<image src="./static/icons/back.svg" mode="aspectFit" />
<image src="./static/icons/back_black.svg" mode="aspectFit" />
</view>
</view>
<view class="content">
<view wx:for="{{style_lib}}" wx:for-item="n" wx:for-index="index" class="choose_color" bind:tap="set_miaoStyle" data-index="{{index}}">
<view class="node" style="background-color: {{n.style.main}};"></view>
<view class="node" style="background-color: {{n.style.tertiary}};"></view>
<view class="node" style="background-color: {{n.style.secondary}};"></view>
<!-- {{ n.style.main }} -->
</view>
</view>
</view>
@@ -166,7 +173,7 @@
<view class="title">
<view>{{resultTitle}}</view>
<view class="page_back" bind:tap="exit_result">
<image src="./static/icons/back.svg" mode="aspectFit" />
<image src="./static/icons/back_black.svg" mode="aspectFit" />
</view>
<view class="page_star" bind:tap="popup_setRemark" data-index="{{}}" wx:if="{{ data_resultPage.tr=='heart' }}">
<image src="./static/icons/heart.svg" mode="aspectFit" wx:if="{{ data_resultPage.tr=='heart' }}"/>
@@ -201,7 +208,7 @@
<!-- <view class="search_button" bind:tap="readInput_lib">搜索</view> -->
</view>
<view wx:for="{{ data_resultPage.arr }}" wx:for-item="n">
<view class="node" hidden="{{ hidden_result[n.name.zh] }}" style="background-color: {{ n.riskBgColor }};">
<view class="ingredient_card" hidden="{{ hidden_result[n.name.zh] }}" style="background-color: {{ n.riskBgColor }};">
<view class="node_content">
<view class="node_name">{{ n.name.zh }}</view>
<view class="node_name node_name_en">{{ n.name.en }}</view>
@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697982640031" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1466" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M670.608974 895.066254c-7.776956 0-15.656241-2.865194-21.795943-8.697911L298.645348 555.745378c-6.344359-6.037374-9.925852-14.325972-9.925852-23.023883 0-8.697911 3.581493-17.088838 9.925852-23.023883l350.167683-330.725292c12.688718-12.074748 32.847407-11.460777 44.819826 1.330269 12.074748 12.688718 11.460777 32.847407-1.330269 44.819826L366.693714 532.619167l325.711202 307.599081c12.688718 12.074748 13.302688 32.131108 1.330269 44.819826C687.493155 891.791746 678.9999 895.066254 670.608974 895.066254z" p-id="1467" fill="#000000"></path></svg>

After

Width:  |  Height:  |  Size: 883 B

+3
View File
@@ -0,0 +1,3 @@
{
"treeData": []
}
+1 -1
View File
@@ -2,7 +2,7 @@
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "wxProject-w4w",
"setting": {
"compileHotReLoad": false,
"compileHotReLoad": true,
"urlCheck": false
}
}