123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- var http = require('../../utils/http.js');
- var config = require('../../utils/config.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- current: 1,
- pages: 0,
- sts: 0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- if (options.sts) {
- this.setData({
- sts: options.sts
- });
- this.loadOrderData(options.sts, 1);
- } else {
- this.loadOrderData(0, 1);
- }
- },
- /**
- * 加载订单数据
- */
- loadOrderData: function(sts, current) {
- var ths = this;
- wx.showLoading();
- //加载订单列表
- var params = {
- url: "/p/myOrder/myOrder",
- method: "GET",
- data: {
- current: current,
- size: 10,
- status: sts,
- },
- callBack: function(res) {
- //console.log(res);
- var list = [];
- if (res.current == 1) {
- list = res.records;
- } else {
- list = ths.data.list;
- Array.prototype.push.apply(list, res.records);
- }
- ths.setData({
- list: list,
- pages: res.pages,
- current: res.current
- });
- wx.hideLoading();
- }
- };
- http.request(params);
- },
- /**
- * 状态点击事件
- */
- onStsTap: function(e) {
- var sts = e.currentTarget.dataset.sts;
- this.setData({
- sts: sts
- });
- this.loadOrderData(sts, 1);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- if (this.data.current < this.data.pages) {
- this.loadOrderData(this.data.sts, this.data.current + 1);
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- },
- /**
- * 查看物流
- */
- toDeliveryPage: function(e) {
- wx.navigateTo({
- url: '/pages/express-delivery/express-delivery?orderNum=' + e.currentTarget.dataset.ordernum
- })
- },
- /**
- * 取消订单
- */
- onCancelOrder: function(e) {
- var ordernum = e.currentTarget.dataset.ordernum;
- var ths = this;
- wx.showModal({
- title: '',
- content: '要取消此订单?',
- confirmColor: "#3e62ad",
- cancelColor: "#3e62ad",
- cancelText: '否',
- confirmText: '是',
- success(res) {
- if (res.confirm) {
- wx.showLoading({
- mask: true
- });
- var params = {
- url: "/p/myOrder/cancel/" + ordernum,
- method: "PUT",
- data: {},
- callBack: function(res) {
- //console.log(res);
- ths.loadOrderData(ths.data.sts, 1);
- wx.hideLoading();
- }
- };
- http.request(params);
- } else if (res.cancel) {
- //console.log('用户点击取消')
- }
- }
- })
- },
- /**
- * 付款
- */
- onPayAgain: function(e) {
- wx.showLoading({
- mask: true
- });
- var params = {
- url: "/p/order/pay",
- method: "POST",
- data: {
- payType: 1,
- orderNumbers: e.currentTarget.dataset.ordernum
- },
- callBack: res => {
- //console.log(res);
- wx.hideLoading();
- wx.requestPayment({
- timeStamp: res.timeStamp,
- nonceStr: res.nonceStr,
- package: res.packageValue,
- signType: res.signType,
- paySign: res.paySign,
- success: function() {
- wx.navigateTo({
- url: '/pages/pay-result/pay-result?sts=1&orderNumbers=' + e.currentTarget.dataset.ordernum,
- })
- },
- fail: function(err) {
- //console.log("支付失败");
- }
- })
- }
- };
- http.request(params);
- },
- /**
- * 查看订单详情
- */
- toOrderDetailPage: function(e) {
- wx.navigateTo({
- url: '/pages/order-detail/order-detail?orderNum=' + e.currentTarget.dataset.ordernum,
- })
- },
- /**
- * 确认收货
- */
- onConfirmReceive: function(e) {
- var ths = this;
- wx.showModal({
- title: '',
- content: '我已收到货?',
- confirmColor: "#eb2444",
- success(res) {
- if (res.confirm) {
- wx.showLoading({
- mask: true
- });
- var params = {
- url: "/p/myOrder/receipt/" + e.currentTarget.dataset.ordernum,
- method: "PUT",
- data: {},
- callBack: function(res) {
- //console.log(res);
- ths.loadOrderData(ths.data.sts, 1);
- wx.hideLoading();
- }
- };
- http.request(params);
- } else if (res.cancel) {
- //console.log('用户点击取消')
- }
- }
- })
- },
- //删除已完成||已取消的订单
- delOrderList: function(e) {
- var ths = this
- wx.showModal({
- title: '',
- content: '确定要删除此订单吗?',
- confirmColor: "#eb2444",
- success(res) {
- if (res.confirm) {
- var ordernum = e.currentTarget.dataset.ordernum;
- wx.showLoading();
- var params = {
- url: "/p/myOrder/" + ordernum,
- method: "DELETE",
- data: {},
- callBack: function(res) {
- ths.loadOrderData(ths.data.sts, 1);
- wx.hideLoading();
- }
- }
- http.request(params);
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- }
- })
|