footprint.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="container">
  3. <view class="footprint" v-if="footprintList.length>0">
  4. <view class="day-item" v-for="(item, index) in footprintList" :key="index">
  5. <view class="day-hd">{{item[0].add_time}}</view>
  6. <view class="day-list">
  7. <view class="item" :data-footprint="iitem" @touchstart="touchStart" @touchend="touchEnd" @tap="deleteItem" v-for="(iitem, iindex) in item"
  8. :key="iitem.id">
  9. <image class="img" :src="iitem.list_pic_url"></image>
  10. <view class="info">
  11. <view class="name">{{iitem.name||''}}</view>
  12. <view class="subtitle">{{iitem.goods_brief||''}}</view>
  13. <view class="price">¥{{iitem.retail_price||''}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <show-empty v-else text="暂无收藏"></show-empty>
  20. </view>
  21. </template>
  22. <script>
  23. const util = require("@/utils/util.js");
  24. const api = require('@/utils/api.js');
  25. export default {
  26. data() {
  27. return {
  28. footprintList: []
  29. }
  30. },
  31. methods: {
  32. getFootprintList() {
  33. let that = this;
  34. var tmpFootPrint;
  35. util.request(api.FootprintList).then(function(res) {
  36. if (res.errno === 0) {
  37. if (res.data.data != undefined) {
  38. tmpFootPrint = res.data.data;
  39. } else {
  40. tmpFootPrint = [];
  41. }
  42. that.footprintList = tmpFootPrint;
  43. }
  44. });
  45. },
  46. deleteItem(event) {
  47. let that = this;
  48. let footprint = event.currentTarget.dataset.footprint;
  49. var touchTime = that.touch_end - that.touch_start;
  50. //如果按下时间大于350为长按
  51. if (touchTime > 350) {
  52. uni.showModal({
  53. title: '',
  54. content: '要删除所选足迹?',
  55. success: function(res) {
  56. if (res.confirm) {
  57. util.request(api.FootprintDelete, {
  58. footprintId: footprint.id
  59. }).then(function(res) {
  60. if (res.errno === 0) {
  61. uni.showToast({
  62. title: res.errmsg,
  63. icon: 'success',
  64. duration: 2000,
  65. complete: function() {
  66. that.getFootprintList();
  67. }
  68. });
  69. } else {
  70. util.showErrorToast(res.errmsg);
  71. }
  72. });
  73. }
  74. }
  75. });
  76. } else {
  77. uni.navigateTo({
  78. url: '/pages/goods/goods?id=' + footprint.goods_id,
  79. });
  80. }
  81. },
  82. //按下事件开始
  83. touchStart: function(e) {
  84. this.touch_start = e.timeStamp
  85. },
  86. //按下事件结束
  87. touchEnd: function(e) {
  88. this.touch_end = e.timeStamp
  89. }
  90. },
  91. onPullDownRefresh() {
  92. // 增加下拉刷新数据的功能
  93. var self = this;
  94. this.getFootprintList();
  95. },
  96. onShow: function() {
  97. this.getFootprintList();
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. page {
  103. background: #f4f4f4;
  104. min-height: 100%;
  105. }
  106. .container {
  107. background: #f4f4f4;
  108. min-height: 100%;
  109. }
  110. .footprint {
  111. height: auto;
  112. overflow: hidden;
  113. width: 100%;
  114. border-top: 1px solid #e1e1e1;
  115. }
  116. .day-item {
  117. height: auto;
  118. overflow: hidden;
  119. width: 100%;
  120. margin-bottom: 20rpx;
  121. }
  122. .day-hd {
  123. height: 94rpx;
  124. width: 100%;
  125. line-height: 94rpx;
  126. background: #fff;
  127. padding-left: 30rpx;
  128. color: #333;
  129. font-size: 28rpx;
  130. }
  131. .day-list {
  132. width: 100%;
  133. height: auto;
  134. overflow: hidden;
  135. background: #fff;
  136. padding-left: 30rpx;
  137. border-top: 1px solid #e1e1e1;
  138. }
  139. .item {
  140. height: 212rpx;
  141. width: 720rpx;
  142. background: #fff;
  143. padding: 30rpx 30rpx 30rpx 0;
  144. border-bottom: 1px solid #e1e1e1;
  145. }
  146. .item:last-child {
  147. border-bottom: 1px solid #fff;
  148. }
  149. .item .img {
  150. float: left;
  151. width: 150rpx;
  152. height: 150rpx;
  153. }
  154. .item .info {
  155. float: right;
  156. width: 540rpx;
  157. height: 150rpx;
  158. display: flex;
  159. flex-direction: column;
  160. justify-content: center;
  161. padding-left: 20rpx;
  162. }
  163. .item .info .name {
  164. font-size: 28rpx;
  165. color: #333;
  166. line-height: 40rpx;
  167. }
  168. .item .info .subtitle {
  169. margin-top: 8rpx;
  170. font-size: 24rpx;
  171. color: #888;
  172. line-height: 40rpx;
  173. }
  174. .item .info .price {
  175. margin-top: 8rpx;
  176. font-size: 28rpx;
  177. color: #333;
  178. line-height: 40rpx;
  179. }
  180. </style>