|
|
@ -1,5 +1,5 @@ |
|
|
// pages/moment/price/index.js
|
|
|
// pages/moment/price/index.js
|
|
|
import { getCategoryPrice } from "../../api/moment" |
|
|
|
|
|
|
|
|
import { getCategoryList, getCategoryPrice } from "../../api/moment" |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const math = require('../../../utils/math') |
|
|
const math = require('../../../utils/math') |
|
|
const storage = require('../../../utils/storage') |
|
|
const storage = require('../../../utils/storage') |
|
|
@ -28,85 +28,41 @@ Page({ |
|
|
*/ |
|
|
*/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
this.fetchChartList() |
|
|
|
|
|
|
|
|
var cateIds = storage.get('cateIdList' + app.globalData.userInfo.userId) |
|
|
|
|
|
if(!util.isEmpty(cateIds)){ |
|
|
|
|
|
this.data.idList = cateIds |
|
|
|
|
|
this.fetchChartList() |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
|
|
|
getCategoryList().then(result => { |
|
|
|
|
|
this.data.idList = '' |
|
|
|
|
|
var size = result.data.records.length >= 5 ? 5 : result.data.records.length |
|
|
|
|
|
for (let index = 0; index < size; index++) { |
|
|
|
|
|
if(util.isEmpty(this.data.idList)){ |
|
|
|
|
|
this.data.idList = result.data.records[index].id |
|
|
|
|
|
} else { |
|
|
|
|
|
this.data.idList += ',' + result.data.records[index].id |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.fetchChartList() |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
//异常回调
|
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
onEvent: function (message) { |
|
|
onEvent: function (message) { |
|
|
if (message.what == 502) { |
|
|
if (message.what == 502) { |
|
|
|
|
|
var cateIds = storage.get('cateIdList' + app.globalData.userInfo.userId) |
|
|
|
|
|
if(!util.isEmpty(cateIds)){ |
|
|
|
|
|
this.data.idList = cateIds |
|
|
|
|
|
} |
|
|
this.fetchChartList() |
|
|
this.fetchChartList() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 下拉刷新...
|
|
|
|
|
|
onRefreshList: function () { |
|
|
|
|
|
if (this.data.requesting) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
orderList: [], |
|
|
|
|
|
['form.pageNum']: 1, |
|
|
|
|
|
loading: true, |
|
|
|
|
|
height: app.globalData.fragmentHeight, |
|
|
|
|
|
finished: false |
|
|
|
|
|
}) |
|
|
|
|
|
this.fetchPapersList() |
|
|
|
|
|
}, |
|
|
|
|
|
// 获取特价列表
|
|
|
|
|
|
fetchPapersList: function () { |
|
|
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.data.loading) { |
|
|
|
|
|
this.data.requesting = true |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ requesting: true }) |
|
|
|
|
|
} |
|
|
|
|
|
getCategoryPrice().then(result => { |
|
|
|
|
|
if (result.data.records.length) { |
|
|
|
|
|
var respList = result.data.records |
|
|
|
|
|
let nowList = `orderList[${this.data.orderList.length}]` |
|
|
|
|
|
var num = result.data.current |
|
|
|
|
|
var finished = result.data.current >= result.data.pages |
|
|
|
|
|
if(this.data.form.pageNum == 1){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
[nowList]: respList, |
|
|
|
|
|
total: result.data.total, |
|
|
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
|
|
top: 0, |
|
|
|
|
|
finished, |
|
|
|
|
|
requesting: false, |
|
|
|
|
|
loading: false |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
[nowList]: respList, |
|
|
|
|
|
total: result.data.total, |
|
|
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
|
|
finished, |
|
|
|
|
|
requesting: false, |
|
|
|
|
|
loading: false |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
finished: true, |
|
|
|
|
|
requesting: false, |
|
|
|
|
|
loading: false |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
//异常回调
|
|
|
|
|
|
this.setData({ |
|
|
|
|
|
requesting: false, |
|
|
|
|
|
finished: true, |
|
|
|
|
|
loading: false |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
//***********************************fetchChartList*****************************************//
|
|
|
//***********************************fetchChartList*****************************************//
|
|
|
fetchChartList: function(){ |
|
|
fetchChartList: function(){ |
|
|
var cateIds = storage.get('cateIdList' + app.globalData.userInfo.userId) |
|
|
|
|
|
if(!util.isEmpty(cateIds)){ |
|
|
|
|
|
this.data.idList = cateIds |
|
|
|
|
|
} |
|
|
|
|
|
getCategoryPrice({idList: this.data.idList}).then(result => { |
|
|
getCategoryPrice({idList: this.data.idList}).then(result => { |
|
|
if(result.data.length <= 0){ |
|
|
if(result.data.length <= 0){ |
|
|
return |
|
|
return |
|
|
@ -199,7 +155,7 @@ Page({ |
|
|
height: 200, |
|
|
height: 200, |
|
|
dataLabel: false, |
|
|
dataLabel: false, |
|
|
dataPointShape: 'circle', |
|
|
dataPointShape: 'circle', |
|
|
enableScroll: true, |
|
|
|
|
|
|
|
|
enableScroll: false, |
|
|
extra: { lineStyle: 'curve' } |
|
|
extra: { lineStyle: 'curve' } |
|
|
}, this) |
|
|
}, this) |
|
|
}, |
|
|
}, |
|
|
|