1
0

footprint.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. if (res.data.data) {
  13. that.setData({
  14. footprintList: res.data.data
  15. });
  16. }
  17. }
  18. });
  19. },
  20. deleteItem (event){
  21. let that = this;
  22. let footprint = event.currentTarget.dataset.footprint;
  23. var touchTime = that.data.touch_end - that.data.touch_start;
  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 + '&&storeId=' + footprint.storeId,
  48. });
  49. }
  50. },
  51. onLoad: function (options) {
  52. },
  53. onReady: function () {
  54. },
  55. onShow: function () {
  56. let that = this;
  57. // 页面显示
  58. if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
  59. if (wx.getStorageSync('storeId')) {
  60. util.request(api.ChooseStoreId, {
  61. storeId: wx.getStorageSync('storeId'),
  62. merchSn: wx.getStorageSync('merchSn'),
  63. isRefusedLogin: wx.getStorageSync('isRefusedLogin')
  64. }, 'POST').then(function (res) {
  65. if (res.errno === 0) {
  66. wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
  67. wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
  68. }
  69. });
  70. this.getFootprintList();
  71. }
  72. } else {
  73. wx.navigateTo({
  74. url: '/pages/ucenter/userLogin/userLogin'
  75. })
  76. }
  77. },
  78. onHide: function () {
  79. // 页面隐藏
  80. },
  81. onUnload: function () {
  82. // 页面关闭
  83. },
  84. //按下事件开始
  85. touchStart: function (e) {
  86. let that = this;
  87. that.setData({
  88. touch_start: e.timeStamp
  89. })
  90. console.log(e.timeStamp + '- touch-start')
  91. },
  92. //按下事件结束
  93. touchEnd: function (e) {
  94. let that = this;
  95. that.setData({
  96. touch_end: e.timeStamp
  97. })
  98. console.log(e.timeStamp + '- touch-end')
  99. },
  100. })