order_details.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // pages/order_details/order_details.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. tuikuan: '退 款',
  8. yipeisong: false,
  9. peisongren :""
  10. },
  11. async onClickRefund(e) {
  12. if (this.data.tuikuan == "已退款") {
  13. return
  14. }
  15. let res = await wx.showModal({
  16. title: '确认退款',
  17. })
  18. console.log(res)
  19. if (res.cancel) return;
  20. wx.showToast({
  21. title: '退款成功',
  22. icon: 'success'
  23. })
  24. this.setData({
  25. tuikuan: '已退款'
  26. })
  27. },
  28. changValue() {
  29. if (onClickRefund(e)) {
  30. this.setData({
  31. tuikuan: '已退款'
  32. })
  33. }
  34. },
  35. // //
  36. // },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad(options) {
  41. // 后期接口出来如果直接调用接口 if 已经配送 那么 yipeisong = true
  42. // 默认不显示 false
  43. wx.request({
  44. url: 'https://www.fastmock.site/mock/f528b4a479c72409aace9493f1c0e880/waimai/getWaiMaiName',
  45. method: 'GET',
  46. header: {
  47. 'content-type': 'application/json' // 默认值
  48. },
  49. success: (res => {
  50. console.log(res);
  51. res.data.isPei = true
  52. if (res.data.isPei == true) {
  53. this.setData({
  54. yipeisong :true,
  55. peisongren : res.data.peisongName
  56. })
  57. }
  58. }),
  59. })
  60. wx.setNavigationBarTitle({ title: '订单详情' })
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完 成
  64. */
  65. onReady() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow() {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide() {
  76. },
  77. })