// 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_: ["麻花官网", "第三方平台"], page: 1 }, //回到顶部 goTop: function (e) { // 一键回到顶部 if (wx.pageScrollTo) { wx.pageScrollTo({ scrollTop: 0 }) } }, 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 + '&_type=' + this.data._type, }) }, pay(e) { wx.navigateTo({ url: '/pages/user/order_detail/order_detail?order_no=' + e.currentTarget.dataset.order_no + '&_type=' + this.data._type, }) }, dele(e) { var that = this wx.showModal({ content: '订单删除不可恢复,是否删除?', success(res) { if (res.confirm) { http("/api/v1/order-delete", "get", { order_no: e.currentTarget.dataset.order_no }).then(res => { wx.showToast({ title: '删除成功!', duration: 1000 }) setTimeout(() => { that.init_order(1) }, 200); }) } } }) }, 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: 1000 }) setTimeout(() => { that.init_order(1) }, 200); }) } } }) }, /** * 生命周期函数--监听页面加载 */ 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 page = this.data.page + 1 let _data = { type: this.data._type, page } 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 }) }) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })