orderDetail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. orderId: 0,
  6. orderInfo: {},
  7. orderGoods: [],
  8. handleOption: {},
  9. wuliu: {}
  10. },
  11. onLoad: function (options) {
  12. // 页面初始化 options为页面跳转所带来的参数
  13. this.setData({
  14. orderId: options.id
  15. });
  16. },
  17. getOrderDetail() {
  18. let that = this;
  19. util.request(api.OrderDetail, {
  20. orderId: that.data.orderId
  21. }).then(function (res) {
  22. if (res.errno === 0) {
  23. console.log(res.data);
  24. that.setData({
  25. orderInfo: res.data.orderInfo,
  26. orderGoods: res.data.orderGoods,
  27. handleOption: res.data.handleOption,
  28. wuliu: res.data.wuliu
  29. });
  30. if (that.data.orderInfo.order_status == 0) {
  31. wx.setNavigationBarTitle({ title: "待支付" });
  32. }
  33. //待付款倒计时
  34. if (that.data.orderInfo.pay_status == 0||that.data.orderInfo.pay_status == 1){
  35. util.countdown(that, res.data.orderInfo, 'orderInfo', null)
  36. }
  37. }
  38. });
  39. },
  40. payOrder() {
  41. let that = this;
  42. wx.redirectTo({
  43. url: '/pages/pay/pay?orderId=' + that.data.orderId
  44. + '&actualPrice=' + that.data.orderInfo.actual_price
  45. })
  46. },
  47. onReady: function () {
  48. // 页面渲染完成
  49. },
  50. onShow: function () {
  51. // 页面显示
  52. this.getOrderDetail();
  53. },
  54. onHide: function () {
  55. // 页面隐藏
  56. },
  57. onUnload: function () {
  58. // 页面关闭
  59. },
  60. postComment() {
  61. let that = this;
  62. wx.navigateTo({
  63. url: '/pages/commentPost/commentPost?typeId=0'+ '&orderId='+that.data.orderId,
  64. })
  65. },
  66. lookComment() {
  67. let that = this;
  68. wx.navigateTo({
  69. url: '/pages/comment/comment?typeId=0' + '&orderId=' + that.data.orderId,
  70. })
  71. },
  72. cancelOrder() {
  73. let that = this;
  74. util.request(api.OrderCancel, {
  75. orderId: that.data.orderId
  76. }).then(function (res) {
  77. if (res.errno === 0) {
  78. wx.showToast({
  79. title: '取消成功',
  80. duration: 1500,
  81. success: function () {
  82. setTimeout(function () {
  83. wx.navigateBack({
  84. delta: 1
  85. });
  86. },1500);
  87. }
  88. })
  89. }else {
  90. wx.showToast({
  91. title: res.errmsg,
  92. duration: 1500
  93. })
  94. }
  95. });
  96. },
  97. confirmOrder() {
  98. let that = this;
  99. util.request(api.OrderConfirm, {
  100. orderId: that.data.orderId
  101. }).then(function (res) {
  102. if (res.errno === 0) {
  103. wx.showToast({
  104. title: '订单完成',
  105. duration: 2000,
  106. complete: function () {
  107. wx.redirectTo({
  108. url: '/pages/ucenter/order/order',
  109. });
  110. }
  111. })
  112. }
  113. });
  114. }
  115. })