Commit 620c3116 by 汪睦雄

123

parent fa9a74f2
......@@ -20,6 +20,7 @@ Component({
filter_idx: 0,
selected: {
type: '0',
city: '0',
catalog: '0',
region: '0',
tags: []
......@@ -74,7 +75,13 @@ Component({
_selected.catalog = idx
_selected_titles.catalog = name
} else if (this.data.filter_idx == 3) {
if (name == '国内' || name == '国外') {
// 国内国外筛选
_selected.region = idx
} else {
// 城市筛选
_selected.city = idx
}
_selected_titles.region = name
}
this.setData({
......
......@@ -17,23 +17,47 @@ Page({
currentPage: 1,
loading: true,
hasMore: true,
filters: {
type: '0',
catalog: '0',
city: '0',
region: '0',
tags: []
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
this.getListData()
},
/**
* 加载
*/
getListData: function (callback){
getListData: function(callback) {
const p = this.data.currentPage
api.search.index({
p
}).then(res => {
let params = {
p: p
}
if (this.data.filters.tags.length > 0) {
params['tags'] = JSON.stringify(this.data.filters.tags)
}
if (parseInt(this.data.filters.city) > 0) {
params['city'] = this.data.filters.city
}
if (parseInt(this.data.filters.region) > 0) {
params['region_type'] = this.data.filters.region
}
if (parseInt(this.data.filters.type) > 0) {
params['type'] = this.data.filters.type
}
if (parseInt(this.data.filters.catalog) > 0) {
params['catalog_id'] = this.data.filters.catalog
}
// 请求数据接口
api.search.index(params).then(res => {
if (res.code) {
this.setData({
hasMore: false,
......@@ -55,38 +79,37 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
this.setData({
projects: [],
loading: true,
hasMore: true,
currentPage: 1
......@@ -105,7 +128,7 @@ Page({
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
let that = this
if (that.data.loading || !that.data.hasMore) {
return;
......@@ -123,14 +146,18 @@ Page({
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
},
/**
* 用户进行了筛选操作
*/
filterChange: function (event){
console.log(event)
filterChange: function(event) {
let _filters = event.detail.filters
this.setData({
filters: _filters
})
wx.startPullDownRefresh()
}
})
\ No newline at end of file
/* pages/search/index.wxss */
.page-wrapper{
}
.search-header{
background: white;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment