纸通宝SAAS仓库
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.
 

86 lines
2.5 KiB

// pages/index/index.js
import Dialog from '../../../components/dialog/dialog'
import { getFactoryPrice } from "../../../api/ztb"
import util from '../../../utils/util'
const event = require('../../../utils/event')
const app = getApp()
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
/** 页面的初始数据 */
data: {
height: app.globalData.fragmentHeight,
loading: true,
requesting: false,
finished: false,
orderList: [],
form: {
enableSalesAgent: 1,
pageNum: 1,
listType: 1
}
},
lifetimes: {
attached: function () {
this.setData({ height: app.globalData.fragmentHeight })
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
event.remove('EventMessage', this)
}
},
methods: {
onRestart: function () {
if (!this.data.firstShow) {
this.fetchPapersList()
}
this.data.firstShow = true
},
onEvent: function (message) {
if (message.what == 110 || message.what == 111) {
this.onRefreshList()
}
},
// 下拉刷新...
onRefreshList: function () {
if (this.data.requesting) {
return
}
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, 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 })
}
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, total: result.data.total, ['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, })
}).then(() => {
this.refresh = this.refresh || this.selectComponent('#refresh')
this.refresh.setRefresh(false)
})
},
attention: function(){
wx.navigateTo({ url: '/pages/agent/focus-list/index' })
}
}
})