orderDetail.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { API } from "../../../service/api"
  2. // pages/order/orderDetail/orderDetail.js
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. prods:[],
  9. orderDetail:''
  10. },
  11. // 获取订单详情
  12. getOrderDetail(orderId){
  13. API.getOrderDetail({orderId}).then(res=>{
  14. // console.log(res);
  15. this.setData({
  16. orderDetail:res.orderDTO,
  17. prods:res.orderDTO.orderDetailDTOS
  18. })
  19. })
  20. },
  21. // 进入地址管理
  22. goAddressMange(){
  23. wx.navigateTo({
  24. url: '/pages/my/addressManage/addressManage?moldify=true',
  25. })
  26. },
  27. // 修改地址
  28. editOrderAddress(address){
  29. let orderId = this.data.orderDetail.orderId;
  30. API.orderAddressModify({orderId,userAddressId:address.userAddressId}).then(res=>{
  31. wx.showToast({
  32. title: '地址修改成功',
  33. icon:"success"
  34. })
  35. this.getOrderDetail(orderId);
  36. })
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad(options) {
  42. console.log(options);
  43. this.getOrderDetail(options.orderId);
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady() {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow() {
  54. const pages = getCurrentPages()
  55. const currentPage = pages[pages.length - 1]
  56. if (currentPage.data.returnData) {
  57. let address = currentPage.data.returnData;
  58. console.log('收到返回参数:', currentPage.data.returnData)
  59. // 使用参数...
  60. this.editOrderAddress(address);
  61. // 清除参数避免重复触发
  62. currentPage.setData({ returnData: null })
  63. }
  64. },
  65. /**
  66. * 生命周期函数--监听页面隐藏
  67. */
  68. onHide() {
  69. },
  70. /**
  71. * 生命周期函数--监听页面卸载
  72. */
  73. onUnload() {
  74. },
  75. /**
  76. * 页面相关事件处理函数--监听用户下拉动作
  77. */
  78. onPullDownRefresh() {
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom() {
  84. },
  85. /**
  86. * 用户点击右上角分享
  87. */
  88. onShareAppMessage() {
  89. }
  90. })