showMy.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // import Dialog from '../../../dist/dialog/dialog';
  2. const {fetchGraphql, dateTime} = require('../../../utils/util.js');
  3. const {orderbyprops} = require('../../../config/gql.js');
  4. const app = getApp();
  5. Component({
  6. properties: {
  7. kind: {
  8. type: String,
  9. value: 'success',
  10. observer(newVal, oldVal, changedPath) {
  11. this.setData({
  12. loading: true,
  13. orders: ''
  14. });
  15. if (newVal !== '') {
  16. fetchGraphql(orderbyprops,
  17. {
  18. user_id: app.globalData.userID,
  19. orderStatus: newVal
  20. },
  21. null,
  22. 'orderbyprops',
  23. null
  24. )
  25. .then(orders => {
  26. orders.forEach(order => {
  27. order.service_id.formatDate = dateTime(Number(order.service_id.startTime), true).date;
  28. order.service_id.formatStartTime = dateTime(Number(order.service_id.startTime), true).time;
  29. order.service_id.formatEndTime = dateTime(Number(order.service_id.startTime) + Number(order.service_id.lastTime), true).time;
  30. });
  31. this.setData({
  32. loading: false,
  33. orders
  34. });
  35. console.log(orders)
  36. });
  37. }
  38. }
  39. }
  40. },
  41. lifetimes: {
  42. attached() {
  43. // 在组件实例进入页面节点树时执行
  44. fetchGraphql(orderbyprops,
  45. {
  46. user_id: app.globalData.userID,
  47. orderStatus: 'success'
  48. },
  49. null,
  50. 'orderbyprops',
  51. null
  52. )
  53. .then(orders => {
  54. orders.forEach(order => {
  55. order.service_id.formatDate = dateTime(Number(order.service_id.startTime), true).date;
  56. order.service_id.formatStartTime = dateTime(Number(order.service_id.startTime), true).time;
  57. order.service_id.formatEndTime = dateTime(Number(order.service_id.startTime) + Number(order.service_id.lastTime), true).time;
  58. });
  59. this.setData({
  60. loading: false,
  61. orders
  62. })
  63. });
  64. }
  65. },
  66. data: {
  67. loading: true,
  68. orders: ''
  69. },
  70. methods: {
  71. deleteThis() {
  72. wx.showToast({
  73. title: '已删除',
  74. icon: 'success',
  75. duration: 2000
  76. });
  77. console.log('仅做展示,无操作');
  78. },
  79. cancelThis() {
  80. // console.log('函数是进的来的');
  81. // Dialog.confirm({
  82. // title: '您确定取消?',
  83. // message: '取消后30分钟内不能再次执行',
  84. //
  85. // }).then(() => {
  86. // // on confirm
  87. // }).catch(() => {
  88. // // on cancel
  89. // });
  90. wx.showModal({
  91. title: '确定取消?',
  92. content: '取消后30分钟内不能再次预约',
  93. success(res) {
  94. if (res.confirm) {
  95. console.log('仅做展示,无操作');
  96. wx.showToast({
  97. title: '已取消',
  98. icon: 'success',
  99. duration: 2000
  100. });
  101. } else if (res.cancel) {
  102. console.log('你取消了')
  103. }
  104. }
  105. });
  106. }
  107. }
  108. });