// pages/gridmanagement/gridmanagement.js var api = require('../../../api/grademanagerequest.js') import { $wuxToast } from '../../../dist/index' Page({ /** * 页面的初始数据 */ data: { relieve: "../../../images/relieve.png", data: {}, userId: "" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options) this.setData({ userId: options.userId }) // 获取列表 this.listGrid(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.listGrid(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, listGrid: function () { let that = this let params = { userId: this.data.userId } api.listGrid(params).then(function (res) { that.setData({ data: res.data }) wx.stopPullDownRefresh() console.log(res) }) }, removeGrid: function (options) { let that = this let params = { "gridId": options.currentTarget.dataset.gridid, "userId": this.data.userId } console.log(options.currentTarget.dataset.gridid) api.removeGrid(params).then(function (res) { $wuxToast().show({ type: 'success', duration: 1500, color: '#fff', text: '已完成', success: () => console.log('已完成') }) //解绑之后刷新 that.onPullDownRefresh() wx.startPullDownRefresh() console.log(res) }) } })