myappointment.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import HTTP from "../../../../requestFn/Api";
  2. const app = getApp();
  3. Page({
  4. data: {
  5. page: 1,
  6. page_size: 1,
  7. has_more: true,
  8. appointment_list: [],
  9. },
  10. onLoad(options) {
  11. },
  12. onShow() {
  13. this.init();
  14. },
  15. init() {
  16. this.setData({
  17. page: 1,
  18. page_size:10,
  19. has_more: true,
  20. })
  21. this.getMyAppointment(true);
  22. },
  23. /**
  24. * 页面相关事件处理函数--监听用户下拉动作
  25. */
  26. onPullDownRefresh() {
  27. app.onRefresh();
  28. this.init(true);
  29. },
  30. /**
  31. * 页面上拉触底事件的处理函数
  32. */
  33. onReachBottom() {
  34. if (!this.data.has_more) {
  35. wx.showToast({
  36. title: '没有更多数据了',
  37. icon: 'none'
  38. })
  39. return
  40. }
  41. this.getMyAppointment()
  42. },
  43. async getMyAppointment(flag=false) {
  44. let {
  45. page,
  46. page_size,
  47. appointment_list
  48. } = this.data;
  49. const {list} = await HTTP.Appointment({
  50. page,
  51. page_size
  52. });
  53. this.setData({
  54. appointment_list:flag?list:[...appointment_list,...list],
  55. page: ++page,
  56. has_more: list.length === page_size
  57. })
  58. },
  59. deleteAppointment(e){
  60. const that = this;
  61. const {id} = e.currentTarget;id;
  62. wx.showModal({
  63. title: "提示",
  64. content: "是否删除该条记录",
  65. success: function (res) {
  66. if (res.confirm) {
  67. that.deleteHTTP(id);
  68. } else if (res.cancel) {
  69. console.log("用户点击取消")
  70. }
  71. }
  72. })
  73. },
  74. async deleteHTTP(id){
  75. const res = await HTTP.DeleteAppointment({id})
  76. if(res.code==0){
  77. this.init();
  78. }
  79. }
  80. })