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.
240 lines
8.7 KiB
240 lines
8.7 KiB
import columnarOption from "../../components/option/columnarOption"
|
|
import Decimal from "decimal.js/decimal.js"
|
|
const app = getApp();
|
|
Page({
|
|
data: {
|
|
imageUrl: getApp().globalData.imageUrl,
|
|
healthCrisis: "background-image: url(" + getApp().globalData.imageUrl + "/health-crisis1.png);margin-top: 0px;",
|
|
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-warning1.png);margin-top: 0px;",
|
|
healthIndex: 100,
|
|
healthIndexMsg: '非常健康',
|
|
headlBrand: "",
|
|
topBg: '',
|
|
sBrand: '奥迪',
|
|
crisisList: [],
|
|
crisisNum: 0,
|
|
totalNum: 0,
|
|
negativeNum: 0,
|
|
frontDx: 0,
|
|
negativeDx: 0,
|
|
neutralDx: 0,
|
|
lowLevelCrisis: 0,
|
|
intermediateCrisis: 0,
|
|
seniorCrisis: 0,
|
|
hotEventsList: [],
|
|
showChart: false,
|
|
dataOption: {}
|
|
},
|
|
onShow() {
|
|
if(!wx.getStorageSync('token')) {
|
|
wx.navigateTo({
|
|
url: '/pages/mine/pages/bindUser/index?isHome=1',
|
|
})
|
|
return;
|
|
}
|
|
this.getTabBar().init();
|
|
this.getBrand().then((res) => {
|
|
let headlBrand = res;
|
|
this.setData({
|
|
headlBrand: headlBrand
|
|
})
|
|
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();
|
|
},
|
|
getBrand() {
|
|
return new Promise((resolve, reject) => {
|
|
app.globalData.request({
|
|
action: 'logOpenid',
|
|
openid: wx.getStorageSync('openid'),
|
|
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
|
|
}).then(res => {
|
|
resolve(res.brandname)
|
|
}).catch(() => {
|
|
reject(false)
|
|
})
|
|
})
|
|
},
|
|
getData() {
|
|
let sTimeType = wx.getStorageSync("sTimeType") || 34;
|
|
let sStartTime = wx.getStorageSync("sStartTime") || '';
|
|
let sEndTime = wx.getStorageSync("sEndTime") || '';
|
|
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
|
|
let obj = {
|
|
action: "getHealthIndex",
|
|
sType: "BrandOverview",
|
|
sTimeType: sTimeType,
|
|
sBrand: this.data.headlBrand,
|
|
sStartTime: sStartTime,
|
|
sEndTime: sEndTime,
|
|
// sSeriesName: sSeriesName,
|
|
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
|
|
}
|
|
app.globalData.request(obj, (val) => {
|
|
this.setData({
|
|
totalNum: val.totalNum
|
|
})
|
|
}).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'
|
|
}
|
|
let negativeNum = 0;
|
|
res.crisis.forEach(ele => {
|
|
negativeNum += ele.value;
|
|
})
|
|
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);
|
|
this.setData({
|
|
healthIndex: healthIndex,
|
|
topBg: topBg,
|
|
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") || '';
|
|
let sCrisis = wx.getStorageSync("sCrisis") || '1,2,3';
|
|
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
|
|
let obj = {
|
|
action: "getList",
|
|
sTimeType: sTimeType,
|
|
sStartTime: sStartTime,
|
|
sEndTime: sEndTime,
|
|
iPageIndex: 1,
|
|
iPageSize: 5,
|
|
sType: "BrandData",
|
|
sCrisis: sCrisis,
|
|
sBrand: this.data.headlBrand,
|
|
// sSeriesName: sSeriesName,
|
|
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") || '';
|
|
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
|
|
let obj = {
|
|
action: "getHotEventsList0528",
|
|
sType: "HotEvent",
|
|
iPageIndex: 1,
|
|
iPageSize: 5,
|
|
sTimeType: sTimeType,
|
|
sBrand: this.data.headlBrand,
|
|
sStartTime: sStartTime,
|
|
sEndTime: sEndTime,
|
|
// sSeriesName: sSeriesName,
|
|
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") || '';
|
|
let sSeriesName = wx.getStorageSync("sSeriesName") || '';
|
|
let obj = {
|
|
action: "getSourceTop",
|
|
sType: "BrandOverview",
|
|
sTimeType: sTimeType,
|
|
sStartTime: sStartTime,
|
|
sEndTime: sEndTime,
|
|
sBrand: this.data.headlBrand,
|
|
// sSeriesName: sSeriesName,
|
|
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
|
|
})
|
|
})
|
|
},
|
|
handlerHEvent(e) {
|
|
let row = e.currentTarget.dataset.row;
|
|
wx.setStorageSync('sRele', row.events_id);
|
|
wx.navigateTo({
|
|
url: "/pages/insight/pages/eventInsight/index" + '?id=' + row.events_id
|
|
})
|
|
},
|
|
handlerCrisis(e) {
|
|
let row = e.currentTarget.dataset.row;
|
|
let id = row._id;
|
|
wx.navigateTo({
|
|
url: '/subPackages/pages/detail/index?id=' + id
|
|
})
|
|
},
|
|
handlerSet() {
|
|
wx.navigateTo({
|
|
url: '/pages/brandCrisis/crisiSet/index?brand=' + this.data.headlBrand
|
|
})
|
|
},
|
|
handlerGoList() {
|
|
console.log('oked',this.data.headlBrand)
|
|
wx.navigateTo({
|
|
url: '/pages/brandCrisis/crisisList/index?brand=' + this.data.headlBrand
|
|
})
|
|
}
|
|
}) |