footprint.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. footprintList: [],
  7. },
  8. getFootprintList() {
  9. let that = this;
  10. util.request(api.FootprintList).then(function (res) {
  11. if (res.errno === 0) {
  12. console.log(res.data);
  13. that.setData({
  14. footprintList: res.data.data
  15. });
  16. }
  17. });
  18. },
  19. deleteItem (event){
  20. let that = this;
  21. let footprint = event.currentTarget.dataset.footprint;
  22. var touchTime = that.data.touch_end - that.data.touch_start;
  23. console.log(touchTime);
  24. //如果按下时间大于350为长按
  25. if (touchTime > 350) {
  26. wx.showModal({
  27. title: '',
  28. content: '要删除所选足迹?',
  29. success: function (res) {
  30. if (res.confirm) {
  31. util.request(api.FootprintDelete, { footprintId: footprint.id }, 'POST').then(function (res) {
  32. if (res.errno === 0) {
  33. wx.showToast({
  34. title: '删除成功',
  35. icon: 'success',
  36. duration: 2000
  37. });
  38. that.getFootprintList();
  39. }
  40. });
  41. console.log('用户点击确定')
  42. }
  43. }
  44. });
  45. } else {
  46. wx.navigateTo({
  47. url: '/pages/goods/goods?id=' + footprint.goods_id,
  48. });
  49. }
  50. },
  51. onLoad: function (options) {
  52. this.getFootprintList();
  53. },
  54. onReady: function () {
  55. },
  56. onShow: function () {
  57. },
  58. onHide: function () {
  59. // 页面隐藏
  60. },
  61. onUnload: function () {
  62. // 页面关闭
  63. },
  64. //按下事件开始
  65. touchStart: function (e) {
  66. let that = this;
  67. that.setData({
  68. touch_start: e.timeStamp
  69. })
  70. console.log(e.timeStamp + '- touch-start')
  71. },
  72. //按下事件结束
  73. touchEnd: function (e) {
  74. let that = this;
  75. that.setData({
  76. touch_end: e.timeStamp
  77. })
  78. console.log(e.timeStamp + '- touch-end')
  79. },
  80. })