From f16d960ef85ac829fc89c3822068ec81f207a5e8 Mon Sep 17 00:00:00 2001 From: Miao_Spring <539943419@qq.com> Date: Mon, 18 Dec 2023 14:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8E=E5=90=8E=E7=AB=AF=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/index/index.scss | 22 ++++++++++++------ miniprogram/pages/index/index.ts | 36 +++++++++++++++++++----------- miniprogram/pages/index/index.wxml | 4 ++-- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/miniprogram/pages/index/index.scss b/miniprogram/pages/index/index.scss index e1d90f4..5057b78 100644 --- a/miniprogram/pages/index/index.scss +++ b/miniprogram/pages/index/index.scss @@ -383,9 +383,14 @@ page{ justify-content: center; border-radius: 15rpx; background-color: tomato; + // white-space: nowrap; + // overflow-x: auto; + // overflow-y: hidden; // view{ - // position: relative; - // top:-0.5rpx; + // white-space: nowrap; + // width: 999rpx; + // // position: relative; + // // top:-0.5rpx; // } } .node_safe{ @@ -402,10 +407,11 @@ page{ justify-content: center; border-radius: 15rpx; background-color:springgreen; - // view{ - // position: relative; - // top:-0.5rpx; - // } + view{ + white-space: nowrap; + // position: relative; + // top:-0.5rpx; + } } .node_scores{ font-size: 31rpx; @@ -483,7 +489,9 @@ page{ display: flex; border-radius: 15rpx; align-items: center; - justify-content: center; + // justify-content: center; + white-space: nowrap; + overflow-x: scroll; } } } diff --git a/miniprogram/pages/index/index.ts b/miniprogram/pages/index/index.ts index 9258551..87c8ede 100644 --- a/miniprogram/pages/index/index.ts +++ b/miniprogram/pages/index/index.ts @@ -2,7 +2,7 @@ // 获取应用实例 const app = getApp() -const serverAddr = "http://127.0.0.1:5000" +const serverAddr = "https://www.chenziyang.top:5000" Page({ data: { @@ -346,9 +346,10 @@ Page({ // this.data.session_key = wx.getStorageSync("session_key") // await this.updateSession() this.readStorageData() + this.data.session_key = '12345' this.set_miaoStyle(this.data.active_style) // this.edit_svg_color() - // this.updateLib() + this.updateLib() // this.updateCollection() // this.updateHistory() }, @@ -873,7 +874,7 @@ Page({ //更新成分数据 updateLib() { wx.request({ - url: serverAddr + '/getLib', //仅为示例,并非真实的接口地址 + url: serverAddr + '/api/ing', data: { session_key:this.data.session_key }, @@ -884,7 +885,7 @@ Page({ success: res => { // console.log(res) var data = res.data - // console.log(data) + console.log(data) // 能跑 // name: { @@ -900,14 +901,14 @@ Page({ n.name = {} n.name.zh = n.chinese_name n.name.en = n.english_name - n.scores = n.rating + n.scores = parseInt(n.rating) n.extra = [] - for(var i of n.effects){ - n.extra.push({ 'type': "safe", 'name': i },) - } - for(var i of n.potential_risk_people){ - n.extra.push({ 'type': "unsafe", 'name': "风险人群:" + i }) - } + // for(var i of n.effects){ + n.extra.push({ 'type': "safe", 'name': n.effects },) + // } + // for(var i of n.potential_risk_people){ + n.extra.push({ 'type': "unsafe", 'name': "风险人群:" + n.potential_risk_people }) + // } n.ADI = n.daily_intake_recommendation } for (var n of data) { @@ -1345,14 +1346,23 @@ Page({ // 从本地读取各种数据 readStorageData(){ var list = ['data_history', 'data_collect', 'data_lib','active_style'] + var m = {} for (var k of list) { - 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)) } + if(m['data_history'] == ''){ + m['data_history'] = {} + } + if(m['data_collect'] == ''){ + m['data_collect'] = [] + } + if(m['data_lib'] == ''){ + m['data_lib'] = [] + } + this.setData(m) // this.setData( // { // data_history:this.data["data_history"], diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index a8bedc6..4d21572 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -89,7 +89,7 @@ 暂无数据 - {{item.name}} + {{item.name}} @@ -231,7 +231,7 @@ 暂无数据 - {{item.name}} + {{item.name}}