与后端适配

This commit is contained in:
539943419 committed 2023-12-18 14:32:09 +08:00
1 parent 0c62d232b8
commit f16d960ef8
3 files changed
+40 -22

No files matched your search

+15 -7
View File
@@ -383,9 +383,14 @@ page{
justify-content: center; justify-content: center;
border-radius: 15rpx; border-radius: 15rpx;
background-color: tomato; background-color: tomato;
// white-space: nowrap;
// overflow-x: auto;
// overflow-y: hidden;
// view{ // view{
// position: relative; // white-space: nowrap;
// top:-0.5rpx; // width: 999rpx;
// // position: relative;
// // top:-0.5rpx;
// } // }
} }
.node_safe{ .node_safe{
@@ -402,10 +407,11 @@ page{
justify-content: center; justify-content: center;
border-radius: 15rpx; border-radius: 15rpx;
background-color:springgreen; background-color:springgreen;
// view{ view{
// position: relative; white-space: nowrap;
// top:-0.5rpx; // position: relative;
// } // top:-0.5rpx;
}
} }
.node_scores{ .node_scores{
font-size: 31rpx; font-size: 31rpx;
@@ -483,7 +489,9 @@ page{
display: flex; display: flex;
border-radius: 15rpx; border-radius: 15rpx;
align-items: center; align-items: center;
justify-content: center; // justify-content: center;
white-space: nowrap;
overflow-x: scroll;
} }
} }
} }
+23 -13
View File
@@ -2,7 +2,7 @@
// 获取应用实例 // 获取应用实例
const app = getApp<IAppOption>() const app = getApp<IAppOption>()
const serverAddr = "http://127.0.0.1:5000" const serverAddr = "https://www.chenziyang.top:5000"
Page({ Page({
data: { data: {
@@ -346,9 +346,10 @@ Page({
// this.data.session_key = wx.getStorageSync("session_key") // this.data.session_key = wx.getStorageSync("session_key")
// await this.updateSession() // await this.updateSession()
this.readStorageData() this.readStorageData()
this.data.session_key = '12345'
this.set_miaoStyle(this.data.active_style) this.set_miaoStyle(this.data.active_style)
// this.edit_svg_color() // this.edit_svg_color()
// this.updateLib() this.updateLib()
// this.updateCollection() // this.updateCollection()
// this.updateHistory() // this.updateHistory()
}, },
@@ -873,7 +874,7 @@ Page({
//更新成分数据 //更新成分数据
updateLib() { updateLib() {
wx.request({ wx.request({
url: serverAddr + '/getLib', //仅为示例,并非真实的接口地址 url: serverAddr + '/api/ing',
data: { data: {
session_key:this.data.session_key session_key:this.data.session_key
}, },
@@ -884,7 +885,7 @@ Page({
success: res => { success: res => {
// console.log(res) // console.log(res)
var data = res.data var data = res.data
// console.log(data) console.log(data)
// 能跑 // 能跑
// name: { // name: {
@@ -900,14 +901,14 @@ Page({
n.name = {} n.name = {}
n.name.zh = n.chinese_name n.name.zh = n.chinese_name
n.name.en = n.english_name n.name.en = n.english_name
n.scores = n.rating n.scores = parseInt(n.rating)
n.extra = [] n.extra = []
for(var i of n.effects){ // for(var i of n.effects){
n.extra.push({ 'type': "safe", 'name': i },) n.extra.push({ 'type': "safe", 'name': n.effects },)
} // }
for(var i of n.potential_risk_people){ // for(var i of n.potential_risk_people){
n.extra.push({ 'type': "unsafe", 'name': "风险人群:" + i }) n.extra.push({ 'type': "unsafe", 'name': "风险人群:" + n.potential_risk_people })
} // }
n.ADI = n.daily_intake_recommendation n.ADI = n.daily_intake_recommendation
} }
for (var n of data) { for (var n of data) {
@@ -1345,14 +1346,23 @@ Page({
// 从本地读取各种数据 // 从本地读取各种数据
readStorageData(){ readStorageData(){
var list = ['data_history', 'data_collect', 'data_lib','active_style'] var list = ['data_history', 'data_collect', 'data_lib','active_style']
var m = {}
for (var k of list) { for (var k of list) {
var m = {}
m[k] = wx.getStorageSync(k) m[k] = wx.getStorageSync(k)
this.setData(m)
// console.log(k,this.data[k]) // console.log(k,this.data[k])
// this.data[k]=wx.getStorageSync(k) // this.data[k]=wx.getStorageSync(k)
// console.log(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( // this.setData(
// { // {
// data_history:this.data["data_history"], // data_history:this.data["data_history"],
+2 -2
View File
@@ -89,7 +89,7 @@
暂无数据 暂无数据
</view> </view>
<view wx:for="{{n.extra}}" wx:for-item="item"> <view wx:for="{{n.extra}}" wx:for-item="item">
<view class="node_ex_content" style="background-color: {{ item.type=='unsafe'?'tomato':'springgreen' }};">{{item.name}}</view> <view class="node_ex_content" style="background-color: {{ item.type=='unsafe'?'tomato':'springgreen' }}; {{ item.name.length > 7?'':'justify-content: center;' }};"><view>{{item.name}}</view></view>
</view> </view>
</view> </view>
</view> </view>
@@ -231,7 +231,7 @@
暂无数据 暂无数据
</view> </view>
<view wx:for="{{n.extra}}" wx:for-item="item"> <view wx:for="{{n.extra}}" wx:for-item="item">
<view class="node_ex_content" style="background-color: {{ item.type=='unsafe'?'tomato':'springgreen' }};">{{item.name}}</view> <view class="node_ex_content" style="background-color: {{ item.type=='unsafe'?'tomato':'springgreen' }}; {{ item.name.length > 7?'':'justify-content: center;' }};"><view>{{item.name}}</view></view>
</view> </view>
</view> </view>
</view> </view>