myMattress.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // subpages/myMattress/myMattress.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. mList:[]
  8. },
  9. getList() {
  10. const that = this;
  11. wx.request({
  12. url: 'https://aipush.aidsleep.cn/customerlist',
  13. method: 'POST',
  14. data: {
  15. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  16. udi: wx.getStorageSync('unionid'),
  17. },
  18. success: (res) => {
  19. var loadData = res.data.data;
  20. if (loadData) {
  21. that.setData({
  22. mList: loadData
  23. })
  24. } else {
  25. }
  26. },
  27. fail: () => {
  28. }
  29. });
  30. },
  31. showMenu(e) {
  32. const item = e.currentTarget.dataset.item;
  33. console.log(item);
  34. const that = this;
  35. wx.showActionSheet({
  36. itemList: ['编辑', '删除'],
  37. success: function (e) {
  38. console.log(e.tapIndex) //没有item项下的key或index
  39. if (e.tapIndex == 0) {
  40. // 编辑
  41. wx.navigateTo({
  42. url:"/subpages/addMattresses/addMattresses?type=edit"
  43. })
  44. } else {
  45. // 删除
  46. that.deleteItem(item);
  47. }
  48. }
  49. })
  50. },
  51. deleteItem(item) {
  52. const that = this;
  53. wx.request({
  54. url: 'https://aipush.aidsleep.cn/customerlist',
  55. method: 'POST',
  56. data: {
  57. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  58. pid: item.pid,
  59. },
  60. success: (res) => {
  61. var code = res.data.code;
  62. if (code) {
  63. wx.showToast({
  64. icon: 'none',
  65. title: "删除成功"
  66. });
  67. that.getList();
  68. } else {
  69. wx.showToast({
  70. icon: 'none',
  71. title: "删除失败"
  72. });
  73. }
  74. },
  75. fail: () => {
  76. wx.showToast({
  77. icon: 'none',
  78. title: "删除失败"
  79. });
  80. }
  81. });
  82. },
  83. /**
  84. * 生命周期函数--监听页面加载
  85. */
  86. onLoad(options) {
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow() {
  97. this.getList();
  98. },
  99. /**
  100. * 生命周期函数--监听页面隐藏
  101. */
  102. onHide() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面卸载
  106. */
  107. onUnload() {
  108. },
  109. /**
  110. * 页面相关事件处理函数--监听用户下拉动作
  111. */
  112. onPullDownRefresh() {
  113. },
  114. /**
  115. * 页面上拉触底事件的处理函数
  116. */
  117. onReachBottom() {
  118. },
  119. /**
  120. * 用户点击右上角分享
  121. */
  122. onShareAppMessage() {
  123. }
  124. })