confirm-receiving.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
  2. import tickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
  3. import { getOrderDetailMethod, orderConfirmMethod } from "../../request";
  4. // module/diet/pages/delivery-address/delivery-address.ts
  5. Page({
  6. behaviors: [
  7. PageContainerBehavior,
  8. tickleBehavior,
  9. ],
  10. async onLoad(options:any) {
  11. console.log("onLoad",options)
  12. if(options.orderId){
  13. this.setData({ id: options.orderId });
  14. await this.load(options.orderId);
  15. }
  16. },
  17. properties: {
  18. },
  19. data: {
  20. id: '',
  21. goodsList: []
  22. },
  23. async load(id:string) {
  24. wx.showLoading({ title: '加载中' });
  25. try {
  26. const res = await getOrderDetailMethod(id);
  27. console.log("res",res)
  28. if(res && res.data && res.data.items && res.data.items.length > 0){
  29. this.setData({ goodsList: res.data.items });
  30. }else{
  31. this.setData({ goodsList: [] });
  32. }
  33. console.log("goodsList",this.data.goodsList)
  34. } catch (error:any) {
  35. getTickleContext.call(this).showWarnMessage(error.errMsg);
  36. }
  37. wx.hideLoading();
  38. },
  39. copyExpressNo(e:any) {
  40. wx.setClipboardData({
  41. data: e.currentTarget.dataset.no,
  42. success: () => wx.showToast({ title: '已复制', icon: 'none' })
  43. });
  44. },
  45. onCancel() {
  46. // 关闭弹窗或返回
  47. wx.navigateBack();
  48. },
  49. // 确认收货逻辑
  50. async onConfirmReceiving() {
  51. let that = this;
  52. wx.showModal({
  53. title: '提示',
  54. content: '确认收货后,订单将无法修改,请确认无误后再进行操作',
  55. success: (res) => {
  56. if (res.confirm) {
  57. that.confirmReceiving();
  58. }
  59. }
  60. });
  61. },
  62. async confirmReceiving() {
  63. try {
  64. await orderConfirmMethod(this.data.id);
  65. // wx.showToast({ title: '确认收货成功', icon: 'success' });
  66. wx.navigateTo({
  67. url: "/module/article/pages/success-page/success-page?title=确认收货成功",
  68. });
  69. } catch (error:any) {
  70. getTickleContext.call(this).showWarnMessage(error.errMsg);
  71. }
  72. }
  73. })