|
@@ -1,7 +1,7 @@
|
|
const app = getApp()
|
|
const app = getApp()
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
- frameStyle: { useTop: true, name: '比赛场地', leftArrow: false, useBar: false },
|
|
|
|
|
|
+ frameStyle: { useTop: true, name: '比赛场地', leftArrow: true, useBar: false },
|
|
oldList: [],
|
|
oldList: [],
|
|
list: [],
|
|
list: [],
|
|
total: 0,
|
|
total: 0,
|
|
@@ -9,12 +9,24 @@ Page({
|
|
page: 0,
|
|
page: 0,
|
|
skip: 0
|
|
skip: 0
|
|
},
|
|
},
|
|
|
|
+ // 返回
|
|
|
|
+ back: function () {
|
|
|
|
+ wx.navigateBack({ delta: 1 })
|
|
|
|
+ },
|
|
toCommon: function (e) {
|
|
toCommon: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ list: [] })
|
|
|
|
+ that.setData({ skip: 0 })
|
|
|
|
+ that.setData({ page: 0 })
|
|
const { route } = e.currentTarget.dataset;
|
|
const { route } = e.currentTarget.dataset;
|
|
if (route) wx.navigateTo({ url: `/pages/${route}` });
|
|
if (route) wx.navigateTo({ url: `/pages/${route}` });
|
|
},
|
|
},
|
|
// 修改
|
|
// 修改
|
|
toEdit: function (e) {
|
|
toEdit: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ list: [] })
|
|
|
|
+ that.setData({ skip: 0 })
|
|
|
|
+ that.setData({ page: 0 })
|
|
let { item } = e.currentTarget.dataset;
|
|
let { item } = e.currentTarget.dataset;
|
|
wx.navigateTo({ url: `/pages/address/add?id=${item._id}` })
|
|
wx.navigateTo({ url: `/pages/address/add?id=${item._id}` })
|
|
},
|
|
},
|
|
@@ -30,6 +42,9 @@ Page({
|
|
const arr = await app.$delete(`/newCourt/api/ground/${item._id}`);
|
|
const arr = await app.$delete(`/newCourt/api/ground/${item._id}`);
|
|
if (arr.errcode == '0') {
|
|
if (arr.errcode == '0') {
|
|
wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
|
|
+ that.setData({ list: [] })
|
|
|
|
+ that.setData({ skip: 0 })
|
|
|
|
+ that.setData({ page: 0 })
|
|
that.watchLogin()
|
|
that.watchLogin()
|
|
} else {
|
|
} else {
|
|
wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
@@ -55,23 +70,23 @@ Page({
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: async function () {
|
|
watchLogin: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
- // 监听用户是否登录,
|
|
|
|
- // wx.getStorage({
|
|
|
|
- // key: 'user',
|
|
|
|
- // success: async res => { },
|
|
|
|
- // fail: async res => {
|
|
|
|
- // wx.redirectTo({ url: '/pages/index/index' })
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- let info = { skip: that.data.skip, limit: that.data.limit };
|
|
|
|
- let arr;
|
|
|
|
- arr = await app.$get(`/newCourt/api/ground`, { ...info });
|
|
|
|
- if (arr.errcode == '0') {
|
|
|
|
- if (arr.data && arr.data.length > 0) that.setData({ list: [...that.data.list, ...arr.data] })
|
|
|
|
- else wx.showToast({ title: `没有更多数据`, icon: 'success', duration: 2000 })
|
|
|
|
- that.setData({ total: arr.total })
|
|
|
|
- }
|
|
|
|
- else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'user',
|
|
|
|
+ success: async res => {
|
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit };
|
|
|
|
+ let arr;
|
|
|
|
+ arr = await app.$get(`/newCourt/api/ground`, { ...info });
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ if (arr.data && arr.data.length > 0) that.setData({ list: [...that.data.list, ...arr.data] })
|
|
|
|
+ else wx.showToast({ title: `没有更多数据`, icon: 'success', duration: 2000 })
|
|
|
|
+ that.setData({ total: arr.total })
|
|
|
|
+ }
|
|
|
|
+ else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
|
+ },
|
|
|
|
+ fail: async res => {
|
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|