You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
3.5 KiB

4 years ago
// pages/my_order/my_order.js
import {
4 years ago
http,
login_check
4 years ago
} from '../../../utils/util'
Page({
/**
* 页面的初始数据
*/
data: {
4 years ago
order_status: [null, '已支付', '待支付', '客服取消', null, null, '已打票', null, null, '重打申请中', '重打申请通过', '重打申请不通过', '已完成', null, null, '已过期'],
active: 0,
4 years ago
switch_: ["麻花官网", "第三方平台"],
page: 1
4 years ago
},
//回到顶部
goTop: function (e) { // 一键回到顶部
if (wx.pageScrollTo) {
wx.pageScrollTo({
scrollTop: 0
})
}
},
4 years ago
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
})
})
4 years ago
},
onChange(event) {
4 years ago
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,
4 years ago
})
4 years ago
},
4 years ago
pay(e) {
4 years ago
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);
})
}
}
4 years ago
})
},
4 years ago
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: '取消成功!',
4 years ago
duration: 1000
4 years ago
})
setTimeout(() => {
that.init_order(1)
}, 200);
4 years ago
})
4 years ago
}
}
})
4 years ago
4 years ago
},
4 years ago
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
4 years ago
if (login_check(1)) {
this.init_order(1)
}
4 years ago
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
4 years ago
if (this.data.has_more) {
wx.showNavigationBarLoading(); //在标题栏中显示加载图标
let page = this.data.page + 1
4 years ago
let _data = {
type: this.data._type,
page
4 years ago
}
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,
4 years ago
page
4 years ago
})
})
}
4 years ago
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})