1
0

footprint.js 1.9 KB

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