// pages/my_order/my_order.js import { http, login_check } from '../../../utils/util' Page({ /** * 页面的初始数据 */ data: { order_status: [null, '已支付', '待支付', '客服取消', null, null, '已打票', null, null, '重打申请中', '重打申请通过', '重打申请不通过', '已完成', null, null, '已过期'], active: 0, switch_: ["麻花官网", "合作平台"], default_page: 1 }, init_order(type) { http("/api/v1/order-list", "get", { type }).then(res => { this.setData({ order_list: res.order_list, _type: res.type, has_more: res.has_more }) }) }, onChange(event) { this.init_order(event.detail.name + 1) }, detail(e) { wx.navigateTo({ url: '/pages/user/order_detail/order_detail?order_no=' + e.currentTarget.dataset.order_no, }) }, pay(e) { wx.navigateTo({ url: '/pages/user/order_detail/order_detail?order_no=' + e.currentTarget.dataset.order_no, }) }, cancel(e) { var that = this wx.showModal({ content: '是否取消订单', success(res) { if (res.confirm) { http("/api/v1/order-cancel", "post", { order_no: e.currentTarget.dataset.order_no }).then(res => { wx.showToast({ title: '取消订单成功!', duration: 2000 }) that.onLoad() that.onShow() }) } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (login_check(1)) { this.init_order(1) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.has_more) { wx.showNavigationBarLoading(); //在标题栏中显示加载图标 let _data = { type: this.data._type, page: this.data.default_page + 1 } http("/api/v1/order-list", "get", _data).then(res => { wx.hideNavigationBarLoading(); //完成停止加载图标 this.setData({ order_list: this.data.order_list.concat(res.order_list), has_more: res.has_more, page: this.data.default_page + 1 }) }) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })