|
|
|
@ -0,0 +1,86 @@ |
|
|
|
import { getMessageList } from "../../../api/saas" |
|
|
|
const event = require('../../../utils/event') |
|
|
|
const util = require('../../../utils/util') |
|
|
|
const app = getApp() |
|
|
|
|
|
|
|
Component({ |
|
|
|
options: { |
|
|
|
addGlobalClass: true, |
|
|
|
multipleSlots: true |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
height: app.globalData.safeFragmentHeight - 100, |
|
|
|
userInfo: null, |
|
|
|
firstShow: false, |
|
|
|
loading: false, |
|
|
|
requesting: false, |
|
|
|
finished: false, |
|
|
|
top: 0, |
|
|
|
orderList: [], |
|
|
|
form: { productType: 'ZTB_FACTORY', pageNum: 1, pageSize: 10 } |
|
|
|
}, |
|
|
|
lifetimes: { |
|
|
|
attached: function () { |
|
|
|
this.setData({ height: app.globalData.safeFragmentHeight - 100 }) |
|
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
|
}, |
|
|
|
detached: function () { |
|
|
|
event.remove('EventMessage', this) |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
onRestart: function () { |
|
|
|
if (this.data.firstShow) { |
|
|
|
return |
|
|
|
} |
|
|
|
// this.fetchList()
|
|
|
|
this.data.firstShow = true |
|
|
|
}, |
|
|
|
onEvent: function (message) { |
|
|
|
if (message.what == 888) { |
|
|
|
this.setData({ userInfo: app.userInfo }) |
|
|
|
} |
|
|
|
}, |
|
|
|
onRefreshList: function () { |
|
|
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) |
|
|
|
// this.fetchList()
|
|
|
|
}, |
|
|
|
fetchList: function () { |
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
return |
|
|
|
} |
|
|
|
this.data.requesting = true |
|
|
|
getMessageList(this.data.form).then(result => { |
|
|
|
if (result.data.records.length) { |
|
|
|
var respList = result.data.records |
|
|
|
let nowList = `orderList[${this.data.orderList.length}]` |
|
|
|
var num = this.data.form.pageNum |
|
|
|
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|
|
|
if(this.data.form.pageNum == 1){ |
|
|
|
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), top: 0, finished, requesting: false, loading: false }) |
|
|
|
} else { |
|
|
|
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
util.showToast(err) |
|
|
|
}).then(() => { |
|
|
|
this.refresh = this.refresh || this.selectComponent('#refresh') |
|
|
|
this.refresh.setRefresh(false) |
|
|
|
}) |
|
|
|
}, |
|
|
|
lookItem: function (e) { |
|
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
|
wx.navigateTo({ url: '/pages/message/detail/index?id=' + item.id }) |
|
|
|
}, |
|
|
|
searchList: function(){ |
|
|
|
// wx.navigateTo({ url: '/pages/message/search-list/index' })
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |