|
@@ -56,7 +56,7 @@ function initChart(canvas, width, height, dpr, data) {
|
|
|
color: ['#2B2B2B']
|
|
|
}
|
|
|
},
|
|
|
- boundaryGap: false,//1.true 数据点在2个刻度直接 2.fals 数据点在分割线上,即刻度值上
|
|
|
+ boundaryGap: false,//1.true 数据点在2个刻度直接 2.false 数据点在分割线上,即刻度值上
|
|
|
data: data.timeData,
|
|
|
axisLine: {onZero: true},
|
|
|
axisLabel: {
|
|
@@ -81,6 +81,7 @@ function initChart(canvas, width, height, dpr, data) {
|
|
|
// fontStyle:'normal'
|
|
|
// },
|
|
|
splitNumber: 5,//坐标轴的分割段数
|
|
|
+ scale:true,
|
|
|
splitLine: {//坐标轴在 grid 区域中的分隔线。
|
|
|
show: true,
|
|
|
lineStyle: {
|
|
@@ -161,23 +162,27 @@ Page({
|
|
|
userInfo: {},
|
|
|
hasUserInfo: false,
|
|
|
canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
|
+ currPage:1,//当前页
|
|
|
+ pages:0,//每页条数
|
|
|
+ total:0,//总条数
|
|
|
+ aa:[],//列表
|
|
|
|
|
|
imagewidth: 0,//缩放后的宽
|
|
|
imageheight: 0,//缩放后的高
|
|
|
- // chartData:{
|
|
|
- // actual:[552,586,3555,4454,552,556,4455],
|
|
|
- // prediction:[552,546,3585,4424,542,546,35,44,524,56,355,444,2224,421],
|
|
|
- // timeData : [
|
|
|
- // '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7', '2020/6/8', '2020/6/9', '2020/6/10','2020/6/11',
|
|
|
- // '2020/6/12','2020/6/13','2020/6/14',
|
|
|
- // ]
|
|
|
- // },
|
|
|
+ chartData:{
|
|
|
+ // actual:[552,586,3555,4454,552,556,4455],
|
|
|
+ // prediction:[552,546,3585,4424,542,546,35,44,524,56,355,444,2224,421],
|
|
|
+ // timeData : [
|
|
|
+ // '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7', '2020/6/8', '2020/6/9', '2020/6/10','2020/6/11',
|
|
|
+ // '2020/6/12','2020/6/13','2020/6/14',
|
|
|
+ // ]
|
|
|
+ },
|
|
|
chartDatas:{
|
|
|
- actual:[572,556,3555,4744,552,576,3555],
|
|
|
- prediction:[352,246,385,2424,542,546,255],
|
|
|
- timeData : [
|
|
|
- '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7'
|
|
|
- ]
|
|
|
+ // actual:[572,556,3555,4744,552,576,3555],
|
|
|
+ // prediction:[352,246,385,2424,542,546,255],
|
|
|
+ // timeData : [
|
|
|
+ // '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7'
|
|
|
+ // ]
|
|
|
},
|
|
|
ec: {
|
|
|
onInit: initChart,
|
|
@@ -302,25 +307,16 @@ Page({
|
|
|
// },
|
|
|
],
|
|
|
},
|
|
|
- //获取新闻列表
|
|
|
- getNewsList:function(){
|
|
|
- apiServer.getNewsList().then((res)=>{
|
|
|
- if(res.statusCode == 200){
|
|
|
- this.setData({
|
|
|
- aa:res.data.data
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
+
|
|
|
//事件处理函数
|
|
|
bindViewTap: function() {
|
|
|
wx.navigateTo({
|
|
|
url: '../logs/logs'
|
|
|
})
|
|
|
},
|
|
|
- //沪深
|
|
|
- getHushen:function(){
|
|
|
- apiServer.getHushen().then((res) =>{
|
|
|
+ //上证
|
|
|
+ getHz:function(){
|
|
|
+ apiServer.getHz().then((res) =>{
|
|
|
if(res.statusCode == 200){
|
|
|
console.log(res);
|
|
|
this.setData({
|
|
@@ -329,6 +325,17 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ //深证
|
|
|
+ getSz:function(){
|
|
|
+ apiServer.getSz().then((res) =>{
|
|
|
+ if(res.statusCode == 200){
|
|
|
+ console.log(res);
|
|
|
+ this.setData({
|
|
|
+ chartData:this.recursion(res.data.data),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
recursion:function(row,a=[],b=[],c=[],d){
|
|
|
for(let i in row.actuals){
|
|
|
a.unshift(row.actuals[i].industryDate)
|
|
@@ -349,9 +356,10 @@ Page({
|
|
|
// console.log(res.top);
|
|
|
// }).exec();
|
|
|
},
|
|
|
- onLoad: function () {
|
|
|
- this.getNewsList();
|
|
|
- this.getHushen();
|
|
|
+ onLoad: function (options) {
|
|
|
+ this.getHz();
|
|
|
+ this.getSz();
|
|
|
+ getNewsList(this);
|
|
|
let sysinfo = wx.getSystemInfoSync(),
|
|
|
windowHeight = sysinfo.windowHeight,
|
|
|
statusHeight = sysinfo.statusBarHeight,
|
|
@@ -402,6 +410,21 @@ Page({
|
|
|
// }
|
|
|
// })
|
|
|
// }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+ //下拉刷新,重新初始化,isMerge = false
|
|
|
+ console.log("1312432");
|
|
|
+ getNewsList(this);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+ console.log("触发")
|
|
|
+ setPage(this);
|
|
|
},
|
|
|
computeScrollViewHeight() {
|
|
|
var that = this
|
|
@@ -641,3 +664,70 @@ Page({
|
|
|
}
|
|
|
|
|
|
})
|
|
|
+ /**
|
|
|
+ * method:分页加载控制函数
|
|
|
+ *
|
|
|
+ */
|
|
|
+function setPage(that) {
|
|
|
+ const {
|
|
|
+ currPage,
|
|
|
+ pages,
|
|
|
+ total
|
|
|
+ } = that.data;
|
|
|
+ const totalPages = getTotalPages(total,pages);
|
|
|
+
|
|
|
+ if (currPage >= totalPages || that.isLoading) {
|
|
|
+ //控制触底是否加载需要两个条件,满足一下两个条件,都不能调用请求函数
|
|
|
+ // 1.当前页是最后一页,
|
|
|
+ // 2. 正在加载中
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //分页加载需要传递isMerge=true参数,表示需要合并到原来的数组上
|
|
|
+ getList(that,true)
|
|
|
+}
|
|
|
+/**
|
|
|
+ * method:得到总页数
|
|
|
+ * @param {Number,String} total 列表总数
|
|
|
+ * @param {Number,String} pages 每一页的条数
|
|
|
+ * @return {Number} totalPages 总页数
|
|
|
+ */
|
|
|
+function getTotalPages(total,pages){
|
|
|
+ //总数除以每一页条数 如果余数!=0,结果需要+1
|
|
|
+ const remainder = Number(total) % Number(pages);
|
|
|
+ const value = Math.floor(total / pages);
|
|
|
+ const totalPages = remainder == 0 ? value : Number(value) + 1;
|
|
|
+ return totalPages
|
|
|
+}
|
|
|
+ //获取新闻列表
|
|
|
+ function getNewsList(that,isMerge){
|
|
|
+ that.isLoading = true
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中',
|
|
|
+})
|
|
|
+const data = {};
|
|
|
+data.currPage = Number(that.data.currPage) + 1;
|
|
|
+if(!isMerge){
|
|
|
+ //不合并,页码需要重新设置为1
|
|
|
+ data.currPage = 1;
|
|
|
+}
|
|
|
+ apiServer.getNewsList(data).then((res)=>{
|
|
|
+ if(res.statusCode == 200){
|
|
|
+ let aa = that.data.aa;
|
|
|
+ if(!isMerge){
|
|
|
+ aa = [];
|
|
|
+ }
|
|
|
+ aa = aa.concat(res.data.data.incInfos)
|
|
|
+ that.setData({
|
|
|
+ aa,
|
|
|
+ currPage:res.data.data.current,
|
|
|
+ pages: res.data.data.pages,
|
|
|
+ total: res.data.data.total
|
|
|
+ })
|
|
|
+ }
|
|
|
+ that.isLoading = false
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
+ setTimeout(function(){
|
|
|
+ wx.hideLoading()
|
|
|
+ },500)
|
|
|
+ })
|
|
|
+}
|