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.
256 lines
5.2 KiB
256 lines
5.2 KiB
// pages/index/index.js
|
|
var request = require('../../utils/http')
|
|
import * as echarts from "../../components/echarts/echarts";
|
|
var app = getApp();
|
|
|
|
function initChart(canvas, width, height, dpr) {
|
|
const chart = echarts.init(canvas, null, {
|
|
width: width,
|
|
height: height,
|
|
devicePixelRatio: dpr
|
|
});
|
|
canvas.setChart(chart);
|
|
|
|
var option = {
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow'
|
|
}
|
|
},
|
|
legend: {},
|
|
grid: {
|
|
left: '3%',
|
|
right: '4%',
|
|
bottom: '3%',
|
|
containLabel: true
|
|
},
|
|
xAxis: {
|
|
|
|
type: 'category',
|
|
data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十一月', '十二月']
|
|
},
|
|
yAxis: {
|
|
type: 'value',
|
|
boundaryGap: [0, 0.01]
|
|
},
|
|
series: [{
|
|
name: '核收数',
|
|
type: 'bar',
|
|
data: [10, 20, 46, 120, 90, 80, 85, 23, 49, 98, 110, 32]
|
|
},
|
|
{
|
|
name: '接收数',
|
|
type: 'bar',
|
|
data: [20, 56, 46, 30, 45, 60, 10, 20, 46, 120, 90]
|
|
}
|
|
]
|
|
};
|
|
chart.setOption(option);
|
|
return chart;
|
|
};
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
ec: {
|
|
onInit: initChart
|
|
},
|
|
msg: [], //首页中间消息列表
|
|
},
|
|
|
|
//跳转对应界面
|
|
goLogisticsType(e) {
|
|
var tag = e.currentTarget.dataset.id
|
|
var url
|
|
//自建物流
|
|
if (tag == 'goMelogistics') {
|
|
url = '../meLogistics/meLogistics'
|
|
}
|
|
|
|
//第三方
|
|
if (tag == 'goThreelogistics') {
|
|
url = '../threeLogistics/threeLogistics'
|
|
}
|
|
|
|
//货运
|
|
if (tag == 'goLogistics') {
|
|
url = '../freiLogistics/freiLogistics'
|
|
}
|
|
|
|
//物流交接
|
|
if (tag == 'goHandover') {
|
|
url = '../handover/handover'
|
|
}
|
|
wx.navigateTo({
|
|
url: url,
|
|
})
|
|
},
|
|
|
|
//判读是否有token
|
|
isHaveToken() {
|
|
var token = app.globalData.token
|
|
if (token == undefined || token == '') {
|
|
app.judLogin();
|
|
} else {
|
|
console.log('用户已经登录');
|
|
console.log(JSON.stringify(token));
|
|
}
|
|
},
|
|
|
|
//判断是否绑定了微信
|
|
isBindWx(openid) {
|
|
request.post(`/sso/checkBind/${openid}`).then(res => {
|
|
console.log("是否绑定" + JSON.stringify(res));
|
|
if (res.data.data == true) {
|
|
//已绑定 获取用户信息
|
|
request.get('/sso/info').then(res1 => {
|
|
console.log('res1.data.data =' + JSON.stringify(res1.data.data));
|
|
app.globalData.userInfo = res1.data.data
|
|
// console.log(app.globalData.userInfo);
|
|
})
|
|
} else {
|
|
//未绑定 提示登录
|
|
app.judLogin();
|
|
}
|
|
})
|
|
},
|
|
|
|
//查询跳转
|
|
goSelNav(e) {
|
|
var tag = e.currentTarget.dataset.id
|
|
var url
|
|
//自建物流查询
|
|
if (tag == 'goQueryme') {
|
|
url = '../queryme/queryme'
|
|
}
|
|
|
|
//第三方物流查询
|
|
if (tag == 'goQuerythree') {
|
|
url = '../querythree/querythree'
|
|
}
|
|
|
|
//货运物流查询
|
|
if (tag == 'goQueryfrei') {
|
|
url = '../queryfrei/queryfrei'
|
|
}
|
|
|
|
|
|
wx.navigateTo({
|
|
url: url,
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
if (app.globalData.userInfo == undefined) {
|
|
//获取code
|
|
wx.login({
|
|
success: res => {
|
|
// 发送 res.code 到后台换取 openId
|
|
request.get(`/wx/getOpenid?code=${res.code}`).then(res1 => {
|
|
//记录OpenID
|
|
app.globalData.openid = res1.data.openid
|
|
this.isBindWx(res1.data.openid)
|
|
})
|
|
}
|
|
})
|
|
|
|
//检查是否绑定
|
|
// request.post('/sso/checkBind/' + app.globalData.openid).then(res2 => {
|
|
// console.log('检查是否绑定=' + JSON.stringify(res2.data.data));
|
|
// app.globalData.bindvx = res2.data.data
|
|
// })
|
|
}
|
|
|
|
|
|
|
|
wx.login({
|
|
success: res => {
|
|
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
request.get(`/wx/getOpenid?code=${res.code}`).then(res1 => {
|
|
|
|
//记录OpenID
|
|
app.globalData.openid = res1.data.openid
|
|
this.isBindWx(res1.data.openid)
|
|
})
|
|
|
|
// console.log(JSON.stringify(res));
|
|
// if (res.errMsg == 'login:ok') {
|
|
// request.post(`/sso/checkBind/` + res.code).then(res => {
|
|
// console.log('res=' + JSON.stringify(res));
|
|
// if (res.data.code != 200) {
|
|
// //未绑定
|
|
// app.judLogin();
|
|
// } else {
|
|
// //已绑定 设置token 与 用户信息
|
|
// }
|
|
// })
|
|
// } else {
|
|
// wx.showToast({
|
|
// title: res.errMsg,
|
|
// icon: 'error'
|
|
// })
|
|
// }
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |