Commit 50ab9278 by 张天炜

修改文案

parent debb239c
...@@ -3,203 +3,204 @@ import api from '../../../utils/Api.js' ...@@ -3,203 +3,204 @@ import api from '../../../utils/Api.js'
import Wx from '../../../utils/Wx.js' import Wx from '../../../utils/Wx.js'
import Schedule from '../../../utils/Schedule.js' import Schedule from '../../../utils/Schedule.js'
const { const {
$Toast $Toast
} = require('../../../iview/base/index'); } = require('../../../iview/base/index');
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
projects: [], projects: [],
currentPage: 1, currentPage: 1,
loading: true, loading: true,
hasMore: true, hasMore: true,
is_transfer:0, is_transfer: 0,
title: '', title: '',
tags: [], tags: [],
catalog: '0', catalog: '0',
filters: { filters: {
region_params: {}, region_params: {},
order: 'default' order: 'default'
} }
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function(options) {
let _title = options.title let _title = options.title
let _tags = options.tags let _tags = options.tags
let _catalog = options.catalog let _catalog = options.catalog
console.log(options ) console.log(options)
if (_tags != null && _tags.length > 0) { if (_tags != null && _tags.length > 0) {
this.setData({ this.setData({
tags: JSON.parse(_tags) tags: JSON.parse(_tags)
}) })
} }
if (_title != null && _title.length > 0) { if (_title != null && _title.length > 0) {
this.setData({ this.setData({
title: _title title: _title
}) })
} }
if (_catalog != null && _catalog.length > 0) { if (_catalog != null && _catalog.length > 0) {
this.setData({ this.setData({
catalog: _catalog catalog: _catalog
}) })
if (_catalog === "undefined") { if (_catalog === "undefined") {
this.setData({ this.setData({
is_transfer: 1 is_transfer: 1
}); });
} }
} }
// 页面title // 页面title
let _ptitle = options.ptitle let _ptitle = options.ptitle
if (_ptitle != null && _ptitle.length > 0) { _ptitle = _ptitle == '水果零食' ? '玩皮研学' : _ptitle;
wx.setNavigationBarTitle({ if (_ptitle != null && _ptitle.length > 0) {
title: _ptitle wx.setNavigationBarTitle({
}) title: _ptitle
} })
this.getListData() }
}, this.getListData()
},
/**
* 加载 /**
*/ * 加载
getListData: function(callback) { */
const p = this.data.currentPage getListData: function(callback) {
const is_transfer = this.data.is_transfer const p = this.data.currentPage
let params = { const is_transfer = this.data.is_transfer
p: p, let params = {
is_transfer: is_transfer p: p,
} is_transfer: is_transfer
if (this.data.tags.length > 0) { }
params['tags'] = JSON.stringify(this.data.tags) if (this.data.tags.length > 0) {
} params['tags'] = JSON.stringify(this.data.tags)
if (this.data.title.length > 0) { }
params['title'] = this.data.title if (this.data.title.length > 0) {
} params['title'] = this.data.title
if (parseInt(this.data.catalog) > 0) { }
params['catalog_id'] = this.data.catalog if (parseInt(this.data.catalog) > 0) {
} params['catalog_id'] = this.data.catalog
}
// 地域和排序
params['order'] = this.data.filters.order // 地域和排序
let region_params = this.data.filters.region_params params['order'] = this.data.filters.order
let arr = Object.getOwnPropertyNames(region_params) let region_params = this.data.filters.region_params
if (arr.length > 0) { let arr = Object.getOwnPropertyNames(region_params)
params[region_params['key']] = region_params['value'] if (arr.length > 0) {
} params[region_params['key']] = region_params['value']
console.log('params', params) }
console.log('params', params)
// 请求数据接口
api.search.index(params).then(res => { // 请求数据接口
if (res.code) { api.search.index(params).then(res => {
this.setData({ if (res.code) {
hasMore: false, this.setData({
loading: false, hasMore: false,
currentPage: 2 loading: false,
}) currentPage: 2
$Toast({ })
content: res.msg, $Toast({
type: 'error' content: res.msg,
}); type: 'error'
} else { });
let _projects = this.data.projects } else {
this.setData({ let _projects = this.data.projects
projects: _projects.concat(res.data), this.setData({
loading: false, projects: _projects.concat(res.data),
hasMore: res.data && res.data.length > 0 ? true : false, loading: false,
currentPage: res.data && res.data.length > 0 ? p : (p - 1) hasMore: res.data && res.data.length > 0 ? true : false,
}) currentPage: res.data && res.data.length > 0 ? p : (p - 1)
typeof callback == "function" && callback() })
} typeof callback == "function" && callback()
}) }
}, })
},
/**
* 生命周期函数--监听页面初次渲染完成 /**
*/ * 生命周期函数--监听页面初次渲染完成
onReady: function() { */
onReady: function() {
},
},
/**
* 生命周期函数--监听页面显示 /**
*/ * 生命周期函数--监听页面显示
onShow: function() { */
onShow: function() {
},
},
/**
* 生命周期函数--监听页面隐藏 /**
*/ * 生命周期函数--监听页面隐藏
onHide: function() { */
onHide: function() {
},
},
/**
* 生命周期函数--监听页面卸载 /**
*/ * 生命周期函数--监听页面卸载
onUnload: function() { */
onUnload: function() {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作 /**
*/ * 页面相关事件处理函数--监听用户下拉动作
onPullDownRefresh: function() { */
this.setData({ onPullDownRefresh: function() {
projects: [], this.setData({
loading: true, projects: [],
hasMore: true, loading: true,
currentPage: 1 hasMore: true,
}) currentPage: 1
wx.showNavigationBarLoading() })
wx.showLoading({ wx.showNavigationBarLoading()
title: '加载中...', wx.showLoading({
}) title: '加载中...',
new Schedule().task(this.getListData).delay(800).task(() => { })
wx.hideNavigationBarLoading() new Schedule().task(this.getListData).delay(800).task(() => {
wx.stopPullDownRefresh() wx.hideNavigationBarLoading()
wx.hideLoading() wx.stopPullDownRefresh()
}) wx.hideLoading()
}, })
},
/**
* 页面上拉触底事件的处理函数 /**
*/ * 页面上拉触底事件的处理函数
onReachBottom: function() { */
let that = this onReachBottom: function() {
if (that.data.loading || !that.data.hasMore) { let that = this
return; if (that.data.loading || !that.data.hasMore) {
} else { return;
let page = that.data.currentPage + 1 } else {
new Schedule().task(() => { let page = that.data.currentPage + 1
that.setData({ new Schedule().task(() => {
loading: true, that.setData({
currentPage: page loading: true,
}) currentPage: page
}).delay(1000).task(that.getListData) })
} }).delay(1000).task(that.getListData)
}, }
},
/**
* 用户点击右上角分享 /**
*/ * 用户点击右上角分享
onShareAppMessage: function() { */
onShareAppMessage: function() {
},
},
/**
* 用户进行了筛选操作 /**
*/ * 用户进行了筛选操作
filterChange: function(event) { */
let _filters = event.detail.filters filterChange: function(event) {
this.setData({ let _filters = event.detail.filters
filters: _filters this.setData({
}) filters: _filters
wx.startPullDownRefresh() })
}, wx.startPullDownRefresh()
}) },
\ No newline at end of file })
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