|
|
|
@ -1,5 +1,5 @@ |
|
|
|
// pages/message/index.js
|
|
|
|
import { getFactoryPrice, getSuccessNotices } from "../../../api/ztb" |
|
|
|
import { getSuccessNotices } from "../../../api/ztb" |
|
|
|
const event = require('../../../utils/event') |
|
|
|
const util = require('../../../utils/util') |
|
|
|
const app = getApp() |
|
|
|
@ -45,26 +45,20 @@ Component({ |
|
|
|
tabIndex: 0, |
|
|
|
firstShow: true |
|
|
|
}) |
|
|
|
this.fetchAgentList() |
|
|
|
} |
|
|
|
this.data.firstShow = true |
|
|
|
if(!this.data.noticeList.length){ |
|
|
|
this.fetchNoticeList() |
|
|
|
} |
|
|
|
this.onResume() |
|
|
|
}, |
|
|
|
onEvent: function (message) { |
|
|
|
console.log('mall>>index>>onEvent', message) |
|
|
|
if (message.what == 10 && app.globalData.isVIP == 1) { |
|
|
|
// this.setData({ token: app.globalData.token })
|
|
|
|
// this.onRefreshList()
|
|
|
|
} else if(message.what == 1001){ |
|
|
|
this.setData({ kg: app.globalData.kg }) |
|
|
|
} else if(message.what == 888){ |
|
|
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) |
|
|
|
this.fetchAgentList() |
|
|
|
} else if(message.what == 444){ |
|
|
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowCity.cityName }) |
|
|
|
this.fetchAgentList() |
|
|
|
this.setData({ cityName: app.nowCity.cityName }) |
|
|
|
} |
|
|
|
}, |
|
|
|
chooseCity: function(){ |
|
|
|
@ -72,15 +66,13 @@ Component({ |
|
|
|
}, |
|
|
|
searchList: function(){ |
|
|
|
|
|
|
|
}, |
|
|
|
postList: function(){ |
|
|
|
|
|
|
|
}, |
|
|
|
onTabChange: function({detail}){ |
|
|
|
if(this.data.tabIndex == Number(detail.index)){ |
|
|
|
return |
|
|
|
} |
|
|
|
this.fetchAgentList() |
|
|
|
this.setData({ tabIndex: Number(detail.index) }) |
|
|
|
this.onResume() |
|
|
|
}, |
|
|
|
fetchNoticeList: function(){ |
|
|
|
if (this.data.loopRequesting) { |
|
|
|
@ -100,30 +92,19 @@ Component({ |
|
|
|
this.data.loopRequesting = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
//*************************************************fetchAgentList************************************************//
|
|
|
|
fetchAgentList: function () { |
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
return |
|
|
|
toNotice: function(e){ |
|
|
|
|
|
|
|
}, |
|
|
|
onResume: function(){ |
|
|
|
var fragment = null |
|
|
|
if(this.data.tabIndex == 0){ |
|
|
|
fragment = this.selectComponent('#recommend') |
|
|
|
} else if(this.data.tabIndex == 1){ |
|
|
|
fragment = this.selectComponent('#attention') |
|
|
|
} |
|
|
|
if (this.data.loading) { |
|
|
|
this.data.requesting = true |
|
|
|
} else { |
|
|
|
this.setData({ requesting: true }) |
|
|
|
if (fragment) { |
|
|
|
fragment.onRestart() |
|
|
|
} |
|
|
|
getFactoryPrice(this.data.form).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 |
|
|
|
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) |
|
|
|
} else { |
|
|
|
this.setData({ requesting: false, finished: true, loading: false }) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
//异常回调
|
|
|
|
this.setData({ requesting: false, finished: true, loading: false }) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|