myMattress.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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.setStorageSync('item', item);
  42. wx.navigateTo({
  43. url:"/subpages/addMattresses/addMattresses?type=edit"
  44. })
  45. } else {
  46. // 删除
  47. that.deleteItem(item);
  48. }
  49. }
  50. })
  51. },
  52. deleteItem(item) {
  53. const that = this;
  54. wx.request({
  55. url: 'https://aipush.aidsleep.cn/customerdel',
  56. method: 'POST',
  57. data: {
  58. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  59. pid: item.pid,
  60. },
  61. success: (res) => {
  62. var code = res.data.code;
  63. if (code) {
  64. wx.showToast({
  65. icon: 'none',
  66. title: "删除成功"
  67. });
  68. that.getList();
  69. } else {
  70. wx.showToast({
  71. icon: 'none',
  72. title: "删除失败"
  73. });
  74. }
  75. },
  76. fail: () => {
  77. wx.showToast({
  78. icon: 'none',
  79. title: "删除失败"
  80. });
  81. }
  82. });
  83. },
  84. /**
  85. * 生命周期函数--监听页面加载
  86. */
  87. onLoad(options) {
  88. },
  89. /**
  90. * 生命周期函数--监听页面初次渲染完成
  91. */
  92. onReady() {
  93. },
  94. /**
  95. * 生命周期函数--监听页面显示
  96. */
  97. onShow() {
  98. this.getList();
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide() {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload() {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh() {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom() {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage() {
  124. }
  125. })