orderDetail.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. currentStoreId: ''
  11. },
  12. onLoad: function (options) {
  13. // 页面初始化 options为页面跳转所带来的参数
  14. this.setData({
  15. orderId: options.id
  16. });
  17. },
  18. getOrderDetail() {
  19. let that = this;
  20. util.request(api.OrderDetail, {
  21. orderId: that.data.orderId
  22. }).then(function (res) {
  23. if (res.errno === 0) {
  24. console.log(res.data);
  25. that.setData({
  26. orderInfo: res.data.orderInfo,
  27. orderGoods: res.data.orderGoods,
  28. handleOption: res.data.handleOption,
  29. wuliu: res.data.wuliu
  30. });
  31. if (that.data.orderInfo.order_status == 0) {
  32. wx.setNavigationBarTitle({ title: "待支付" });
  33. }
  34. //待付款倒计时
  35. if (that.data.orderInfo.pay_status == 0||that.data.orderInfo.pay_status == 1){
  36. util.countdown(that, res.data.orderInfo, 'orderInfo', null)
  37. }
  38. }
  39. });
  40. },
  41. payOrder() {
  42. let that = this;
  43. wx.redirectTo({
  44. url: '/pages/pay/pay?orderId=' + that.data.orderId
  45. + '&actualPrice=' + that.data.orderInfo.actual_price
  46. })
  47. },
  48. onReady: function () {
  49. // 页面渲染完成
  50. },
  51. onShow: function () {
  52. // 页面显示
  53. this.getOrderDetail();
  54. this.setData({
  55. currentStoreId: wx.getStorageSync('storeId')
  56. });
  57. console.log(this.data.currentStoreId);
  58. },
  59. onHide: function () {
  60. // 页面隐藏
  61. },
  62. onUnload: function () {
  63. // 页面关闭
  64. },
  65. postComment() {
  66. let that = this;
  67. wx.navigateTo({
  68. url: '/pages/commentPost/commentPost?typeId=0'+ '&orderId='+that.data.orderId,
  69. })
  70. },
  71. lookComment() {
  72. let that = this;
  73. wx.navigateTo({
  74. url: '/pages/comment/comment?typeId=0' + '&orderId=' + that.data.orderId,
  75. })
  76. },
  77. cancelOrder() {
  78. let that = this;
  79. util.request(api.OrderCancel, {
  80. orderId: that.data.orderId
  81. }).then(function (res) {
  82. if (res.errno === 0) {
  83. wx.showToast({
  84. title: '取消成功',
  85. duration: 1500,
  86. success: function () {
  87. setTimeout(function () {
  88. wx.navigateBack({
  89. delta: 1
  90. });
  91. },1500);
  92. }
  93. })
  94. }else {
  95. wx.showToast({
  96. title: res.errmsg,
  97. duration: 1500
  98. })
  99. }
  100. });
  101. },
  102. confirmOrder() {
  103. let that = this;
  104. util.request(api.OrderConfirm, {
  105. orderId: that.data.orderId
  106. }).then(function (res) {
  107. if (res.errno === 0) {
  108. wx.showToast({
  109. title: '订单完成',
  110. duration: 2000,
  111. complete: function () {
  112. wx.redirectTo({
  113. url: '/pages/ucenter/order/order',
  114. });
  115. }
  116. })
  117. }
  118. });
  119. },
  120. refund(){
  121. let that = this;
  122. util.request(api.refund, {
  123. orderId: that.data.orderId
  124. }).then(function (res) {
  125. if (res.errno === 0) {
  126. wx.showToast({
  127. title: '成功退款',
  128. duration: 2000,
  129. complete: function () {
  130. wx.redirectTo({
  131. url: '/pages/ucenter/order/order',
  132. });
  133. }
  134. })
  135. }else{
  136. wx.showModal({
  137. title: '',
  138. confirmColor: '#b4282d',
  139. content: res.errmsg,
  140. showCancel:false
  141. })
  142. }
  143. });
  144. }
  145. })