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.

228 lines
8.3 KiB

3 years ago
import columnarOption from "../../components/option/columnarOption"
3 years ago
import Decimal from "decimal.js/decimal.js"
3 years ago
const app = getApp();
Page({
3 years ago
data: {
3 years ago
imageUrl: getApp().globalData.imageUrl,
3 years ago
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: '',
3 years ago
sBrand: '奥迪',
crisisList: [],
crisisNum: 0,
totalNum: 0,
negativeNum: 0,
frontDx: 0,
negativeDx: 0,
neutralDx: 0,
lowLevelCrisis: 0,
intermediateCrisis: 0,
seniorCrisis: 0,
hotEventsList: [],
showChart: false,
dataOption: {}
3 years ago
},
onShow() {
3 years ago
this.getTabBar().init();
3 years ago
this.getBrand().then((res) => {
let headlBrand = res;
this.setData({
headlBrand: headlBrand
})
3 years ago
this.getData();
this.getCrisis();
this.getHotEventsList();
this.getMediaData();
})
},
changeTime(e) {
// let sTimeType = e.detail.sTimeType;
// let sStartTime = e.detail.sStartTime;
// let sEndTime = e.detail.sEndTime;
this.getData();
this.getCrisis();
this.getHotEventsList();
this.getMediaData();
3 years ago
},
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)
})
})
},
3 years ago
getData() {
let sTimeType = wx.getStorageSync("sTimeType") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
3 years ago
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
3 years ago
let obj = {
action: "getHealthIndex",
sType: "BrandOverview",
sTimeType: sTimeType,
sBrand: this.data.sBrand,
sStartTime: sStartTime,
sEndTime: sEndTime,
3 years ago
// sSeriesName: sSeriesName,
3 years ago
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
}
3 years ago
app.globalData.request(obj, (val) => {
this.setData({
totalNum: val.totalNum
})
}).then(res => {
3 years ago
let healthIndex = res.healthIndex;
let healthIndexMsg = res.healthIndexMsg;
let topBg = "";
3 years ago
if (healthIndex >= 90) {
3 years ago
topBg = '#0084FF'
3 years ago
} else if (80 <= healthIndex && healthIndex < 90) {
3 years ago
topBg = '#00CA2F'
3 years ago
} else if (70 <= healthIndex && healthIndex < 80) {
3 years ago
topBg = '#FFCC01'
3 years ago
} else if (60 <= healthIndex && healthIndex < 70) {
3 years ago
topBg = '#FFA419'
} else {
topBg = '#FF463C'
}
3 years ago
let negativeNum = 0;
res.crisis.forEach(ele => {
negativeNum += ele.value;
})
3 years ago
let frontNum = Math.round((new Decimal(res.affections[0].value).div(new Decimal(this.data.totalNum))).toFixed(2) * 100);
let negativeDx = Math.round((new Decimal(res.affections[2].value).div(new Decimal(this.data.totalNum))).toFixed(2) * 100);
let neutralDx = Math.round((new Decimal(res.affections[1].value).div(new Decimal(this.data.totalNum))).toFixed(2) * 100);
let lowLevelCrisis = Math.round((new Decimal(res.crisis[0].value).div(new Decimal(negativeNum))).toFixed(2) * 100);
let intermediateCrisis = Math.round((new Decimal(res.crisis[1].value).div(new Decimal(negativeNum))).toFixed(2) * 100);
let seniorCrisis = Math.round((new Decimal(res.crisis[2].value).div(new Decimal(negativeNum))).toFixed(2) * 100);
3 years ago
this.setData({
3 years ago
healthIndex: 100,
3 years ago
topBg: topBg,
3 years ago
healthIndexMsg: healthIndexMsg,
negativeNum: negativeNum,
frontDx: frontNum,
negativeDx: negativeDx,
neutralDx: neutralDx,
lowLevelCrisis: lowLevelCrisis,
intermediateCrisis: intermediateCrisis,
seniorCrisis: seniorCrisis
})
})
},
getCrisis() {
let sTimeType = wx.getStorageSync("sTimeType") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
3 years ago
let sCrisis = wx.getStorageSync("sCrisis") || '1,2,3';
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
3 years ago
let obj = {
action: "getList",
sTimeType: sTimeType,
sStartTime: sStartTime,
sEndTime: sEndTime,
iPageIndex: 1,
iPageSize: 5,
sType: "BrandData",
3 years ago
sCrisis: sCrisis,
3 years ago
sBrand: this.data.sBrand,
3 years ago
// sSeriesName: sSeriesName,
3 years ago
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}
app.globalData.request(obj, (val) => {
this.setData({
crisisNum: val.totalNum
})
}).then(res => {
this.setData({
crisisList: res
})
})
},
getHotEventsList() {
let sTimeType = wx.getStorageSync("sTimeType") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
3 years ago
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
3 years ago
let obj = {
action: "getHotEventsList0528",
sType: "HotEvent",
iPageIndex: 1,
iPageSize: 5,
sTimeType: sTimeType,
sBrand: this.data.sBrand,
sStartTime: sStartTime,
sEndTime: sEndTime,
3 years ago
// sSeriesName: sSeriesName,
3 years ago
iTimeType: 0,
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}
app.globalData.request(obj).then(res => {
this.setData({
hotEventsList: res
})
})
},
getMediaData() {
this.setData({
showChart: false
})
let sTimeType = wx.getStorageSync("sTimeType") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
3 years ago
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
3 years ago
let obj = {
action: "getWebsite",
sType: "BrandOverview",
sTimeType: sTimeType,
sStartTime: sStartTime,
sEndTime: sEndTime,
sBrand: this.data.sBrand,
3 years ago
// sSeriesName: sSeriesName,
3 years ago
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}
app.globalData.request(obj).then(res => {
let dx = [];
let dy = [];
for (let key in res) {
dx.push(key);
dy.push(res[key])
}
let option = columnarOption(dx, dy, '#0084FF');
this.setData({
dataOption: option,
showChart: true
3 years ago
})
})
3 years ago
},
handlerCrisis(e) {
let row = e.currentTarget.dataset.row;
let id = row._id;
wx.navigateTo({
url: '/pages/detail/index?id=' + id
})
},
handlerSet() {
wx.navigateTo({
3 years ago
url: '/pages/brandCrisis/crisiSet/index?brand=' + this.data.sBrand
3 years ago
})
3 years ago
},
handlerGoList() {
wx.navigateTo({
url: '/pages/brandCrisis/crisisList/index?brand=' + this.data.sBrand
})
3 years ago
}
3 years ago
})