ProductList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  3. <van-list
  4. v-model="loading"
  5. :finished="true"
  6. finished-text="没有更多了~"
  7. @load="onLoad"
  8. >
  9. <div class="shoplist">
  10. <nuxt-link
  11. class="list-item"
  12. v-for="item in wareList"
  13. :key="item.id"
  14. :to="'/point/detail/' + item.id"
  15. tag="div"
  16. >
  17. <div class="list-item-left">
  18. <img :src="item.waresPic" alt="" srcset="" />
  19. </div>
  20. <div class="list-item-right">
  21. <div class="item-right-top">
  22. <span class="info">
  23. {{ item.waresName }}
  24. </span>
  25. {{ item.waresDetail }}
  26. </div>
  27. <div class="item-right-bottom">
  28. <span class="price"><span class="icon"></span>{{ item.saleIntegral }}</span>
  29. <span class="sold">{{ "库存 " + item.waresCount }}</span>
  30. </div>
  31. </div>
  32. </nuxt-link>
  33. </div>
  34. </van-list>
  35. </van-pull-refresh>
  36. </template>
  37. <script>
  38. import Vue from "vue";
  39. import { PullRefresh, List } from "vant";
  40. import { mapState, mapActions } from "vuex";
  41. Vue.use(PullRefresh);
  42. Vue.use(List);
  43. export default {
  44. head() {
  45. return {
  46. title: "商品列表",
  47. };
  48. },
  49. data() {
  50. return {
  51. images: [],
  52. loading: false, //加载状态
  53. finished: false, //是否完成加载
  54. refreshing: false, //是否正在上拉刷新
  55. };
  56. },
  57. mounted() {
  58. this.onLoad();
  59. },
  60. computed: {
  61. ...mapState({
  62. wareList: (state) => state.point.wareList,
  63. }),
  64. },
  65. methods: {
  66. ...mapActions({
  67. getWareList: "point/getWareList",
  68. }),
  69. onLoad() {
  70. var that = this;
  71. this.getWareList().then((res) => {
  72. that.loading = false;
  73. that.finished = true;
  74. });
  75. },
  76. onRefresh() {
  77. // 清空列表数据
  78. that.finished = true;
  79. // 重新加载数据
  80. // 将 loading 设置为 true,表示处于加载状态
  81. that.loading = true;
  82. that.onLoad();
  83. },
  84. },
  85. };
  86. </script>
  87. <style scope>
  88. .shoplist {
  89. width: 92vw;
  90. }
  91. .shoplist .list-item {
  92. display: flex;
  93. margin-top: 30px;
  94. width: 92vw;
  95. height: 28.5vw;
  96. }
  97. .shoplist .list-item .list-item-left {
  98. width: 28.5vw;
  99. height: 28.5vw;
  100. border: 0.26vw solid #eeeeee;
  101. flex-shrink: 0;
  102. }
  103. .shoplist .list-item .list-item-left img {
  104. display: inline-block;
  105. width: 100%;
  106. height: 100%;
  107. border-radius: 3vw;
  108. }
  109. .shoplist .list-item .list-item-right {
  110. margin-left: 3vw;
  111. width: 60.5vw;
  112. color: red;
  113. display: flex;
  114. flex-direction: column;
  115. flex-shrink: 0;
  116. font-size: 4.266vw;
  117. font-weight: 400;
  118. color: #111111;
  119. line-height: 6vw;
  120. height: 28.5vw;
  121. }
  122. .shoplist .list-item .list-item-right .item-right-top {
  123. flex-shrink: 0;
  124. word-break: break-all;
  125. width: 4.53rem;
  126. height: 1.45rem;
  127. font-size: 0.32rem;
  128. font-family: PingFangSC-Regular, PingFang SC;
  129. font-weight: 400;
  130. color: #111111;
  131. line-height: 0.45rem;
  132. }
  133. .shoplist .list-item .list-item-right .item-right-top .info {
  134. font-weight: 500;
  135. }
  136. .shoplist .list-item .list-item-right .item-right-bottom {
  137. width: 4.53rem;
  138. height: 0.9rem;
  139. position: relative;
  140. }
  141. .shoplist .list-item .list-item-right .item-right-bottom .price {
  142. font-size: 0.4rem;
  143. font-family: PingFangSC-Medium, PingFang SC;
  144. font-weight: 500;
  145. color: #fe9700;
  146. line-height: 0.56rem;
  147. position: absolute;
  148. left: 0.1rem;
  149. bottom: 0rem;
  150. }
  151. .shoplist .list-item .list-item-right .item-right-bottom .price .icon {
  152. display: inline-block;
  153. width: 0.3rem;
  154. height: 0.3rem;
  155. background: url("../static/common/a01_jifen@2x.png") no-repeat;
  156. background-size: cover;
  157. margin-right: 0.1rem;
  158. }
  159. .shoplist .list-item .list-item-right .item-right-bottom .sold {
  160. height: 0.4rem;
  161. font-size: 0.28rem;
  162. font-family: PingFangSC-Regular, PingFang SC;
  163. font-weight: 400;
  164. color: #bcbcbc;
  165. line-height: 0.4rem;
  166. position: absolute;
  167. right: 0.1rem;
  168. bottom: 0.03rem;
  169. }
  170. </style>