| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import {
- getSearchList
- } from '../../services/index.js'
- import {
- imgServerUrl} from '../../config/config.js'
- Page({
- data: {
- imgServerUrl: imgServerUrl,
- keyWord: '',
- pageNo: 1, //当前分页
- isScroll: true, //是否可以滚动
- list: [],
- cityName: '',
- showNoMore: "没有更多信息...", //显示已无更多
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
- },
- onLoad: function(options) {
- let {
- searchVal
- } = options
- this.setData({
- keyWord: searchVal
- })
- this.fetchList()
- },
- //获取列表数据
- fetchList() {
- if (!this.data.isScroll) {
- return false
- }
- let paramsObj = {
- pageNo: this.data.pageNo,
- searchName: this.data.keyWord,
- }
- getSearchList(paramsObj).then(data => {
- var pageNo = data.data.pageNo;
- let setData = {};
- // 是否可以滚动加载数据
- if (data.data.isLast) {
- setData.isScroll = false
- }
- if (data.data.searchPosition.length != 0) {
- setData.list = this.data.list.concat(data.data.searchPosition)
- setData.pageNo = pageNo;
- } else {
- setData.list = this.data.list;
- }
- this.setData({
- ...setData
- })
- })
- },
- onReachBottom: function() {
- var pageNo = this.data.pageNo + 1;
- this.setData({
- pageNo
- })
- this.fetchList();
- },
- //去详情页
- toDetail(e) {
- const {
- id,
- cate
- } = e.detail;
- wx.navigateTo({
- url: '../detail/index?hpPositionId=' + id + "&cate=" + cate,
- })
- },
- })
|