|
|
@ -3,7 +3,11 @@ import { paperCategoryList, getMiniProxyList } from "../../api/ztb" |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
const statusList = [1, 2] |
|
|
const statusList = [1, 2] |
|
|
|
|
|
|
|
|
Page({ |
|
|
|
|
|
|
|
|
Component({ |
|
|
|
|
|
options: { |
|
|
|
|
|
addGlobalClass: true, |
|
|
|
|
|
multipleSlots: true |
|
|
|
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 页面的初始数据 |
|
|
* 页面的初始数据 |
|
|
*/ |
|
|
*/ |
|
|
@ -22,121 +26,117 @@ Page({ |
|
|
orderList: [], |
|
|
orderList: [], |
|
|
form: { |
|
|
form: { |
|
|
firstCategoryId: '', |
|
|
firstCategoryId: '', |
|
|
bidType: statusList[1], |
|
|
|
|
|
|
|
|
bidType: statusList[0], |
|
|
pageNum: 1, |
|
|
pageNum: 1, |
|
|
pageSize:15 |
|
|
pageSize:15 |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
|
|
*/ |
|
|
|
|
|
onLoad: function (options) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
height: app.globalData.fragmentHeight - 210, |
|
|
|
|
|
kg: app.globalData.kg, |
|
|
|
|
|
CustomBar: app.globalData.CustomBar, |
|
|
|
|
|
['form.bidType']: options.type ? Number(options.type) : statusList[1] |
|
|
|
|
|
}) |
|
|
|
|
|
this.fetchCateList() |
|
|
|
|
|
this.fetchGoodsList() |
|
|
|
|
|
}, |
|
|
|
|
|
fetchCateList: function(){ |
|
|
|
|
|
paperCategoryList({ type: 1 }).then(result => { |
|
|
|
|
|
var tabList = ['全部'] |
|
|
|
|
|
var size = 0 |
|
|
|
|
|
for (let index = 0; index < result.data.length; index++) { |
|
|
|
|
|
tabList.push(result.data[index].name) |
|
|
|
|
|
size += result.data[index].name.length |
|
|
|
|
|
|
|
|
methods: { |
|
|
|
|
|
onRestart: function(){ |
|
|
|
|
|
if (!this.data.firstShow) { |
|
|
|
|
|
this.setData({ height: app.globalData.fragmentHeight - 210, kg: app.globalData.kg }) |
|
|
|
|
|
this.fetchCateList() |
|
|
|
|
|
this.fetchGoodsList() |
|
|
} |
|
|
} |
|
|
this.data.cateList = result.data |
|
|
|
|
|
this.setData({ tabiList: tabList, cateScroll: size > 14 }) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
onCategoryChange: function ({detail}) { |
|
|
|
|
|
if(this.data.pageIndex == Number(detail.index)){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.data.pageIndex = Number(detail.index) |
|
|
|
|
|
if(this.data.pageIndex == 0){ |
|
|
|
|
|
this.data.form.firstCategoryId = '' |
|
|
|
|
|
} else { |
|
|
|
|
|
this.data.form.firstCategoryId = this.data.cateList[this.data.pageIndex - 1].id |
|
|
|
|
|
} |
|
|
|
|
|
this.onRefreshList() |
|
|
|
|
|
}, |
|
|
|
|
|
onTabChange: function (e) { |
|
|
|
|
|
if (this.data.form.bidType == Number(e.currentTarget.dataset.index)) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var tabIndex = Number(e.currentTarget.dataset.index) |
|
|
|
|
|
// this.data.form.bidType = statusList[this.data.tabIndex]
|
|
|
|
|
|
this.data.form.firstCategoryId = '' |
|
|
|
|
|
this.setData({ pageIndex: 0, ['form.bidType']: tabIndex }) |
|
|
|
|
|
this.onRefreshList() |
|
|
|
|
|
}, |
|
|
|
|
|
// 下拉刷新...
|
|
|
|
|
|
onRefreshList: function () { |
|
|
|
|
|
if (this.data.requesting) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
orderList: [], |
|
|
|
|
|
['form.pageNum']: 1, |
|
|
|
|
|
loading: true, |
|
|
|
|
|
finished: false |
|
|
|
|
|
}) |
|
|
|
|
|
this.fetchGoodsList() |
|
|
|
|
|
}, |
|
|
|
|
|
// 获取特价列表
|
|
|
|
|
|
fetchGoodsList: function () { |
|
|
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.data.loading) { |
|
|
|
|
|
this.data.requesting = true |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ requesting: true }) |
|
|
|
|
|
} |
|
|
|
|
|
getMiniProxyList(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 |
|
|
|
|
|
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 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.data.firstShow = true |
|
|
|
|
|
}, |
|
|
|
|
|
fetchCateList: function(){ |
|
|
|
|
|
paperCategoryList({ type: 1 }).then(result => { |
|
|
|
|
|
var tabList = ['全部'] |
|
|
|
|
|
var size = 0 |
|
|
|
|
|
for (let index = 0; index < result.data.length; index++) { |
|
|
|
|
|
tabList.push(result.data[index].name) |
|
|
|
|
|
size += result.data[index].name.length |
|
|
} |
|
|
} |
|
|
|
|
|
this.data.cateList = result.data |
|
|
|
|
|
this.setData({ tabiList: tabList, cateScroll: size > 14 }) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
onCategoryChange: function ({detail}) { |
|
|
|
|
|
if(this.data.pageIndex == Number(detail.index)){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.data.pageIndex = Number(detail.index) |
|
|
|
|
|
if(this.data.pageIndex == 0){ |
|
|
|
|
|
this.data.form.firstCategoryId = '' |
|
|
} else { |
|
|
} else { |
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
|
|
|
|
|
this.data.form.firstCategoryId = this.data.cateList[this.data.pageIndex - 1].id |
|
|
} |
|
|
} |
|
|
}).catch(err => { |
|
|
|
|
|
this.setData({ requesting: false, finished: true, loading: false }) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
lookItem: function (e) { |
|
|
|
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
|
|
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
|
|
|
|
|
}, |
|
|
|
|
|
offerGood: function(e){ |
|
|
|
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
|
|
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
|
|
|
|
|
|
|
|
this.onRefreshList() |
|
|
|
|
|
}, |
|
|
|
|
|
onTabChange: function (e) { |
|
|
|
|
|
if (this.data.form.bidType == Number(e.currentTarget.dataset.index)) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var tabIndex = Number(e.currentTarget.dataset.index) |
|
|
|
|
|
// this.data.form.bidType = statusList[this.data.tabIndex]
|
|
|
|
|
|
this.data.form.firstCategoryId = '' |
|
|
|
|
|
this.setData({ pageIndex: 0, ['form.bidType']: tabIndex }) |
|
|
|
|
|
this.onRefreshList() |
|
|
|
|
|
}, |
|
|
|
|
|
// 下拉刷新...
|
|
|
|
|
|
onRefreshList: function () { |
|
|
|
|
|
if (this.data.requesting) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
orderList: [], |
|
|
|
|
|
['form.pageNum']: 1, |
|
|
|
|
|
loading: true, |
|
|
|
|
|
finished: false |
|
|
|
|
|
}) |
|
|
|
|
|
this.fetchGoodsList() |
|
|
|
|
|
}, |
|
|
|
|
|
// 获取特价列表
|
|
|
|
|
|
fetchGoodsList: function () { |
|
|
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.data.loading) { |
|
|
|
|
|
this.data.requesting = true |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ requesting: true }) |
|
|
|
|
|
} |
|
|
|
|
|
getMiniProxyList(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 |
|
|
|
|
|
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 }) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
lookItem: function (e) { |
|
|
|
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
|
|
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
|
|
|
|
|
}, |
|
|
|
|
|
offerGood: function(e){ |
|
|
|
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
|
|
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
}) |