123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- var app = getApp()
- Page({
- data: {
- order: [],
- links: null,
- id: '',
- curPage: 1,
- },
- onLoad: function(options) {
- this.setData({
- id: options.id
- })
- this.getList();
- },
- //获取列表
- getList() {
- wx.showLoading({
- title: '加载中...',
- })
- let url = '';
- if (this.data.curPage == 1) {
- url = 'bike/latelyOrders?page = 1';
- } else {
- url = 'bike/latelyOrderRent?page = 1'
- }
- let data = {
- bike_id: this.data.id
- }
- app.request(url, data, 'POST').then(res => {
- wx.hideLoading();
- console.log(res);
- this.setData({
- order: res.data.data,
- links: res.data.links.next
- })
- })
- },
- //跳转到详情页
- skipDetail(e) {
- let index = e.currentTarget.dataset.index
- wx.navigateTo({
- url: '/pages/orderDetail/orderDetail?id=' + this.data.order[index].id + '&index=' + this.data.curPage, //普通订单和日租订单
- })
- },
- //tab切换
- choose(e) {
- this.setData({
- curPage: e.currentTarget.dataset.idx
- })
- this.getList();
- },
-
- onPullDownRefresh: function() {
- let self = this;
- wx.showLoading({
- title: '加载中...',
- })
- let url = "";
- if (self.data.curPage == 1) {
- url = 'bike/latelyOrders?page = 1'
- } else {
- url = 'bike/latelyOrderRent?page =1 '
- }
- let data = {
- bike_id: self.data.id
- }
- app.request(url, data, 'POST').then(res => {
- console.log(res)
- wx.showToast({
- title: '刷新成功',
- icon: 'none'
- })
- wx.hideLoading();
- wx.stopPullDownRefresh();
- self.setData({
- order: res.data.data,
- links: res.data.links.next
- })
- })
- },
- onReachBottom: function() {
- var that = this;
- if (that.data.links != null) {
- wx.request({
- url: that.data.links,
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': 'bearer' + ' ' + wx.getStorageSync('token'),
- },
- method: 'POST',
- data: {
- bike_id: that.data.id
- },
- success: function(res) {
- console.log(res)
- wx.hideLoading()
- that.setData({
- order: that.data.order.concat(res.data.data),
- links: res.data.links.next
- })
- }
- })
- } else {
- wx.hideLoading()
- wx.showToast({
- title: '没数据了~',
- icon: 'none'
- })
- }
- },
- })
|