123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data:{
- orderList: [],
- page: 1,
- size: 10,
- loadmoreText: '正在加载更多数据',
- nomoreText: '全部加载完成',
- nomore: false,
- totalPages: 1,
- activeIdx:-1,
- header:[
- {
- icon: 'ct1',
- name: '全部订单',
- id: -1
- },
- {
- icon: 'ct2',
- name: '待付款',
- id: 0
- },
- {
- icon: 'ct3',
- name: '待发货',
- id: 201
- },
- {
- icon: 'ct4',
- name: '待收货',
- id: 300
- },
- {
- icon: 'ct5',
- name: '已完成',
- id: 301
- }
- ]
- },
- onLoad:function(options){
- getApp().checkNetStatu();
- let {id} = options
- this.setData({
- activeIdx:id
- })
- // 页面初始化 options为页面跳转所带来的参数
- // 页面显示
- },
- refresh: function(){
- wx.showLoading({
- title: '加载中...',
- success: function () {
- }
- });
- this.setData({
- orderList: [],
- page: 1
- })
- this.getOrderList();
- },
- onPullDownRefresh() {
- this.refresh()
- getApp().onPullDownRefresh()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getOrderList()
- },
- tabHeader:function(e){
- let {id} = e.currentTarget.dataset
- this.setData({
- activeIdx: id
- })
- this.refresh()
- },
- getOrderList(id){
- let that = this;
- this.setData({loadding: true})
- util.request(api.OrderList, { page: that.data.page, size: that.data.size, orderStatus: that.data.activeIdx}).then(function (res) {
- if (res.errno === 0) {
- that.setData({
- orderList: that.data.orderList.concat(res.data.data),
- page: res.data.currentPage + 1,
- totalPages: res.data.totalPages
- });
- that.setData({loadding: false})
- wx.hideLoading();
- if (res.data.data.length <= 0) {
- that.setData({
- nomore: true
- })
- return;
- }
- }
- });
-
- },
- gotoLogti: function(e){
- let {no,id} = e.currentTarget.dataset
- wx.navigateTo({
- url: '/pages/logistics/index?no=' + no + '&id=' + id
- })
- },
-
- payOrder(event){
- let that = this;
- let orderIndex = event.currentTarget.dataset.orderIndex;
- let order = that.data.orderList[orderIndex];
- wx.redirectTo({
- url: '/pages/pay/pay?orderId=' + order.id + '&actualPrice=' + order.actual_price,
- })
- },
- onReady:function(){
- // 页面渲染完成
- },
- onShow:function(){
- this.refresh()
- },
- onHide:function(){
- // 页面隐藏
- },
- onUnload:function(){
- // 页面关闭
- }
- })
|