footprint.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="box">
  3. <div class="null-page" v-show="yes"></div>
  4. <el-card class="box-card foot-print">
  5. <div slot="header" class="clearfix">
  6. <span>我的足迹</span>
  7. </div>
  8. <div v-loading="loading" v-if="timesArr != ''">
  9. <el-timeline>
  10. <el-timeline-item class="ns-time-line" v-for="(item, index) in timesArr" :timestamp="item" placement="top" :key="index">
  11. <el-card>
  12. <div class="ns-goods-list">
  13. <div class="ns-goods-li" v-for="(value, name) in footPrintData" :key="name" v-if="item == value.browse_time" @click="$util.pushToTab('/sku/' + value.sku_id)">
  14. <span class="ns-btn-del" @click.stop="deleteFootprint(value.id)"><i class="iconfont icon-shanchu"></i></span>
  15. <el-image :src="$img(value.goods_image, { size: 'mid' })" fit="contain" @error="imageError(name)"></el-image>
  16. <p class="goods-name" :title="value.goods_name">{{ value.goods_name }}</p>
  17. <span class="goods-price">¥{{ value.goods_price }}</span>
  18. </div>
  19. </div>
  20. </el-card>
  21. </el-timeline-item>
  22. </el-timeline>
  23. </div>
  24. <div v-else class="footprint">
  25. <router-link to="/">暂时没有足迹~</router-link>
  26. </div>
  27. </el-card>
  28. </div>
  29. </template>
  30. <script>
  31. import { footPrint, delFootprint } from "@/api/member/member"
  32. import { mapGetters } from "vuex"
  33. export default {
  34. name: "footprint",
  35. layout: "member",
  36. components: {},
  37. data: () => {
  38. return {
  39. timesArr: [],
  40. footPrintData: [],
  41. loading: true,
  42. yes: true
  43. }
  44. },
  45. created() {
  46. this.getFootPrintData()
  47. },
  48. computed: {
  49. ...mapGetters(["defaultGoodsImage"])
  50. },
  51. mounted() {
  52. let self = this;
  53. setTimeout(function() {
  54. self.yes = false
  55. }, 300)
  56. },
  57. methods: {
  58. /**
  59. * 商品列表
  60. */
  61. getFootPrintData() {
  62. footPrint({
  63. page: 1,
  64. page_size: 0
  65. })
  66. .then(res => {
  67. var data = res.data.list
  68. this.footPrintData = []
  69. this.timesArr = []
  70. for (let i = 0; i < data.length; i++) {
  71. var date = this.$util.timeStampTurnTime(data[i].browse_time).split(" ")[0]
  72. var flag = this.$util.inArray(date, this.timesArr)
  73. if (flag == -1) {
  74. this.timesArr.push(date)
  75. }
  76. var goods = {}
  77. goods.id = data[i].id
  78. goods.sku_id = data[i].sku_id
  79. goods.browse_time = date
  80. goods.goods_image = data[i].sku_image.split(",")[0]
  81. goods.goods_name = data[i].sku_name
  82. goods.goods_price = data[i].discount_price
  83. this.footPrintData.push(goods)
  84. }
  85. this.loading = false
  86. })
  87. .catch(err => {
  88. this.loading = false
  89. })
  90. },
  91. /**
  92. * 图片加载失败
  93. */
  94. imageError(index) {
  95. this.footPrintData[index].goods_image = this.defaultGoodsImage
  96. },
  97. /**
  98. * 删除某个足迹
  99. */
  100. deleteFootprint(id) {
  101. delFootprint({
  102. id: id
  103. })
  104. .then(res => {
  105. this.loading = false
  106. this.getFootPrintData()
  107. this.$message({ message: res.message, type: "success" })
  108. })
  109. .catch(err => {
  110. this.loading = false
  111. this.$message.error(err.message)
  112. })
  113. },
  114. mouseenter(scope) {
  115. this.$set(scope, "del", true)
  116. },
  117. mouseleave(scope) {
  118. this.$set(scope, "del", false)
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .footprint{
  125. width: 100%;
  126. text-align: center;
  127. }
  128. .box {
  129. width: 100%;
  130. position: relative;
  131. }
  132. .null-page {
  133. width: 100%;
  134. height: 730px;
  135. background-color: #FFFFFF;
  136. position: absolute;
  137. top: 0;
  138. left: 0;
  139. z-index: 9;
  140. }
  141. .el-card.is-always-shadow,
  142. .el-card.is-hover-shadow:focus,
  143. .el-card.is-hover-shadow:hover {
  144. box-shadow: unset;
  145. }
  146. .el-card {
  147. border: 0;
  148. }
  149. .ns-goods-list {
  150. display: flex;
  151. flex-wrap: wrap;
  152. .ns-goods-li {
  153. width: 32%;
  154. margin-right: 2%;
  155. margin-bottom: 20px;
  156. padding: 15px;
  157. box-sizing: border-box;
  158. background-color: #f1f1f1;
  159. border-radius: 5px;
  160. cursor: pointer;
  161. position: relative;
  162. .el-image {
  163. width: 100%;
  164. height: 250px;
  165. }
  166. .goods-name {
  167. margin-top: 10px;
  168. display: -webkit-box;
  169. -webkit-box-orient: vertical;
  170. -webkit-line-clamp: 2;
  171. overflow: hidden;
  172. }
  173. .goods-price {
  174. color: $base-color;
  175. font-size: 20px;
  176. }
  177. .ns-btn-del {
  178. position: absolute;
  179. top: -6px;
  180. right: -6px;
  181. color: #999999;
  182. cursor: pointer;
  183. display: none;
  184. width: 20px;
  185. height: 20px;
  186. text-align: center;
  187. line-height: 20px;
  188. i {
  189. font-size: 20px;
  190. }
  191. }
  192. &:hover {
  193. .ns-btn-del {
  194. display: inline-block;
  195. }
  196. }
  197. }
  198. .ns-goods-li:nth-child(3n) {
  199. margin-right: 0;
  200. }
  201. }
  202. </style>
  203. <style lang="scss">
  204. .foot-print .ns-time-line .el-timeline-item__timestamp.is-top {
  205. font-size: 18px;
  206. color: #333333;
  207. }
  208. </style>