Files
lichebao/pages/channel/index.js
T
2021-09-15 15:15:32 +08:00

250 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import _ from '../../commons/js/commons'
import * as echarts from '../../ecCanvas/components/ec-canvas/echarts';
const app = getApp()
Page({
data: {
imgUrl:_.config.imgUrl,
shoplist:[
{
id:'1',
title:'泉州鲤城区4s店',
tag:[
'东风EX·1',
'雷丁',
],
},
{
id:'1',
title:'泉州鲤城区4s店',
tag:[
'东风EX·1',
'雷丁',
],
},
],
deallist:'',
hoursTip:'',
cityarray: ['厦门', '泉州', '福州', ],
cityobj: [
{
id: 0,
name: '厦门'
},
{
id: 1,
name: '泉州'
},
{
id: 2,
name: '福州'
},
],
cityIndex: 0,
},
onLoad(options) {
for (let key in options) {
this.setData({
[key]: options[key]
})
}
this.getUserInfo()
this.getBar()
this.getLine()
},
onShow: function () {
this.getHoursTip()
},
//候取时间
getHoursTip(){
let hoursTip = '';
let date=new Date();
  if(date.getHours()>=0&&date.getHours()<12){
  hoursTip="上午好!"
  }else if(date.getHours()>=12&&date.getHours()<18){
  hoursTip="下午好!"
  }else{
  hoursTip="晚上好!"
  }
this.setData({
hoursTip:hoursTip
})
},
//获取用户信息
getUserInfo(){
_.apiQuery.getUserInfo().then(res => {
this.setData({
userInfo: res
})
});
},
//选择城市
changeCity(e) {
this.setData({
cityIndex: e.detail.value
})
},
getBar(){
this.setData({
ecBar: {
onInit: function (canvas, width, height, dpr) {
const barChart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
canvas.setChart(barChart);
barChart.setOption(getBarOption());
return barChart;
}
},
})
},
getLine(){
this.setData({
ecLine: {
onInit: function (canvas, width, height, dpr) {
const lineChart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
canvas.setChart(lineChart);
lineChart.setOption(getLineOption());
return lineChart;
}
}
})
},
//推送链接
pushLink(e) {
if(e.currentTarget.dataset.url){
_.$router.openUrlScheme(e.currentTarget.dataset.url)
}
},
//客服电话
call(e) {
wx.makePhoneCall({
phoneNumber: '18965133055',
})
},
//页面相关事件处理函数--监听用户下拉动作
onPullDownRefresh: function () {
},
})
function getBarOption() {
return {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
top: 'bottom',
data: ['丰泽店', '鲤城区', '南安店',]
},
grid: {
top: '8%',
left: '2%',
right: '5%',
bottom: '12%',
containLabel: true
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01]
},
yAxis: {
type: 'category',
data: ['1月', '2月', '3月',]
},
series: [
{
name: '丰泽店',
type: 'bar',
data: [18, 23, 29,]
},
{
name: '鲤城区',
type: 'bar',
data: [19, 23, 31,]
},
{
name: '南安店',
type: 'bar',
data: [19, 23, 31, ]
},
]
};
}
function getLineOption() {
return{
tooltip: {
trigger: 'axis'
},
legend: {
top: 'bottom',
data: ['丰泽店', '鲤城区', '南安店',]
},
grid: {
top: '10%',
left: '2%',
right: '5%',
bottom: '12%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['1月', '2月', '3月',]
},
yAxis: {
type: 'value'
},
series: [
{
name: '丰泽店',
type: 'line',
stack: '总量',
data: [120, 132, 101,]
},
{
name: '鲤城区',
type: 'line',
stack: '总量',
data: [220, 182, 191, ]
},
{
name: '南安店',
type: 'line',
stack: '总量',
data: [820, 932, 901, ]
}
]
};
}