You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.8 KiB

const app = getApp();
Page({
data: {
imageUrl: getApp().globalData.imageUrl,
healthCrisis: "background-image: url(" + getApp().globalData.imageUrl + "/health-crisis.png);margin-top: 0px; height: 750rpx;",
healthGood: "background-image: url(" + getApp().globalData.imageUrl + "/health-good.png);",
healthGenerally: "background-image: url(" + getApp().globalData.imageUrl + "/health-generally.png);",
healthMedium: "background-image: url(" + getApp().globalData.imageUrl + "/health-medium.png);",
healthWarning: "background-image: url(" + getApp().globalData.imageUrl + "/health-warning.png);margin-top: 0px; height: 750rpx;",
healthIndex: 100,
healthIndexMsg: '非常健康',
headlBrand: "",
topBg: '',
sBrand: '奥迪'
},
onShow() {
let sTimeType = wx.getStorageSync("sTimeType") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
this.getBrand().then((res) => {
let headlBrand = res;
this.setData({
headlBrand: headlBrand
})
this.getData(sTimeType, sStartTime, sEndTime);
}
)
},
getBrand() {
return new Promise((resolve, reject) => {
app.globalData.request({
action: 'getUserMainBrand',
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}).then(res => {
this.setData({
sBrand: res
})
resolve(res)
}).catch(() => {
reject(false)
})
})
},
getData(sTimeType, sStartTime, sEndTime) {
let obj = {
action: "getHealthIndex",
sType: "BrandOverview",
sTimeType: sTimeType,
sBrand: this.data.sBrand,
sStartTime: sStartTime,
sEndTime: sEndTime,
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
}
app.globalData.request(obj).then(res => {
let healthIndex = res.healthIndex;
let healthIndexMsg = res.healthIndexMsg;
let topBg = "";
if(healthIndex >= 90) {
topBg = '#0084FF'
} else if(80 <= healthIndex && healthIndex < 90) {
topBg = '#00CA2F'
} else if(70 <= healthIndex && healthIndex < 80) {
topBg = '#FFCC01'
} else if(60 <= healthIndex && healthIndex < 70) {
topBg = '#FFA419'
} else {
topBg = '#FF463C'
}
this.setData({
healthIndex: healthIndex,
topBg: topBg,
healthIndexMsg: healthIndexMsg
})
})
}
})