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.

133 lines
4.3 KiB

const app = getApp();
import sHistogram from "../../option/sColumnarOption"
const color2 = ['#FF4852','#FFBF00', '#FF6E25', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF', '#f8e5f2']
Component({
data: {
showChart: true,
},
onShow() {
this.getTabBar().init();
},
lifetimes: {
attached() {
let sTimeType = wx.getStorageSync("sTimeType2") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
this.getData(sTimeType, sStartTime, sEndTime);
},
},
methods: {
changeTime(e) {
let sTimeType = e.detail.sTimeType;
let sStartTime = e.detail.sStartTime;
let sEndTime = e.detail.sEndTime;
this.getData(sTimeType, sStartTime, sEndTime);
},
getData(sTimeType, sStartTime, sEndTime) {
wx.showToast({
title: '加载中',
icon: 'loading',
duration: 300000
})
Promise.all([
this.getpinpai(sTimeType, sStartTime, sEndTime),
this.getchexing(sTimeType, sStartTime, sEndTime)
])
.then(() => {
setTimeout(() => {
wx.hideToast();
}, 500)
})
},
getpinpai(sTimeType, sStartTime, sEndTime) {
return new Promise((resolve, reject) => {
app.globalData.request({
action: 'getHomeBrandSourceType0528',
sType: 'Home',
sTimeType: sTimeType,
sStartTime: sStartTime,
sEndTime: sEndTime,
sQueryType: 1
}).then(res => {
const arr = []
const arr1 = [
[],
[],
[],
[],
[],
[],
[],
[]
]
const arr2 = []
res.forEach(ele => {
arr.push(ele.key)
ele.value.forEach(e => {
arr2.push(e.key)
})
for (let i = 0; i < ele.value.length; i++) {
arr1[i].push(ele.value[i].value)
}
})
this.setData({
brandOption: sHistogram(arr, arr1, arr2, color2),
})
resolve(true)
}).catch(() => {
reject(false)
})
})
},
getchexing(sTimeType, sStartTime, sEndTime) {
return new Promise((resolve, reject) => {
app.globalData.request({
action: 'getHomeBrandSourceType0528',
sType: 'Home',
sTimeType: sTimeType,
sStartTime: sStartTime,
sEndTime: sEndTime,
sQueryType: 2
}).then(res => {
const arr = []
const arr1 = [
[],
[],
[],
[],
[],
[],
[],
[]
]
const arr2 = []
res.forEach(ele => {
arr.push(ele.key)
ele.value.forEach(e => {
arr2.push(e.key)
})
for (let i = 0; i < ele.value.length; i++) {
arr1[i].push(ele.value[i].value)
}
})
this.setData({
modelOption: sHistogram(arr, arr1, arr2, color2),
})
resolve(true)
}).catch(() => {
reject(false)
})
})
},
priceSel(e) {
this.setData({
intervalSel: e.currentTarget.dataset.index
})
},
}
})