1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- // pages/index/suggestion/suggestion.js
- const app = getApp();
- import HTTP from "../../../../requestFn/Api"
- Page({
- data: {
- suggestion_list: [],
- status: {
- 1: "待受理",
- 2: "受理中",
- 3: "已完成"
- },
- page: 1,
- garden_id: null,
- page_size: 10,
- hasMore: true,
- },
- onLoad() {
- const {
- garden_id
- } = app.globalData;
- if (garden_id) {
- this.setData({
- garden_id
- })
- }
- },
- onShow(options) {
- this.init();
- },
- init() {
- this.setData({
- page: 1,
- hasMore: true
- })
- this.getSuggestion(true)
- },
- onReachBottom() {
- if (!this.data.hasMore) {
- wx.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- return console.log('没有更多数据了');
- }
- this.getSuggestion();
- },
- async getSuggestion(flag = false) {
- let {
- page,
- suggestion_list,
- garden_id,
- page_size
- } = this.data;
- let res = await HTTP.Suggestion({
- garden_id,
- page,
- page_size
- })
- this.setData({
- suggestion_list: flag ? res.list : [...suggestion_list, ...res.list],
- page: ++page,
- hasMore: res.list.length === page_size
- })
- console.log(res);
- },
- goAddSuggestion() {
- wx.navigateTo({
- url: './addsuggestion/addsuggestion',
- })
- },
- goDetail(e) {
- const {
- id
- } = e.currentTarget
- wx.navigateTo({
- url: `./detail/detail?id=${id}`,
- })
- },
- onPullDownRefresh: function () {
- app.onRefresh();
- this.init();
- },
- })
|