index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div class="container">
  3. <van-search placeholder="请输入商品关键词" />
  4. <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
  5. <!-- <van-swipe-item v-for="(image, index) in images" :key="index">
  6. <img v-lazy="image" />
  7. </van-swipe-item> -->
  8. <van-swipe-item>1</van-swipe-item>
  9. <van-swipe-item>2</van-swipe-item>
  10. <van-swipe-item>3</van-swipe-item>
  11. <van-swipe-item>4</van-swipe-item>
  12. </van-swipe>
  13. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  14. <van-list
  15. v-model="loading"
  16. :finished="finished"
  17. finished-text="没有更多了~"
  18. @load="onLoad"
  19. >
  20. <!-- <van-card
  21. :desc="item.waresDetail"
  22. :title="item.waresName"
  23. :thumb="item.waresPic"
  24. centered
  25. v-for="item in list"
  26. :key="item.id"
  27. >
  28. </van-card> -->
  29. <div class="list">
  30. <div class="list-item" v-for="item in list" :key="item.src">
  31. <div class="list-item-left">
  32. <img :src="item.waresPic" alt="" srcset="" />
  33. </div>
  34. <div class="list-item-right">
  35. <div class="item-right-top">
  36. {{ item.waresDetail }}
  37. </div>
  38. <div class="item-right-bottom">
  39. {{ item.waresName }}
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </van-list>
  45. </van-pull-refresh>
  46. </div>
  47. </template>
  48. <script type="text/javascript">
  49. import Vue from "vue";
  50. import axios from "axios";
  51. import {
  52. NavBar,
  53. Search,
  54. Swipe,
  55. SwipeItem,
  56. Lazyload,
  57. Card,
  58. PullRefresh,
  59. List,
  60. } from "vant";
  61. Vue.use(NavBar);
  62. Vue.use(Search);
  63. Vue.use(Swipe);
  64. Vue.use(SwipeItem);
  65. Vue.use(Lazyload);
  66. Vue.use(Card);
  67. Vue.use(PullRefresh);
  68. Vue.use(List);
  69. Vue.prototype.$http = axios;
  70. export default {
  71. head() {
  72. return {
  73. title: "智慧易加",
  74. };
  75. },
  76. data() {
  77. return {
  78. images: [],
  79. list: [],
  80. loading: false, //加载状态
  81. finished: false, //是否完成加载
  82. refreshing: false, //是否正在上拉刷新
  83. };
  84. },
  85. beforeCreate() {},
  86. created() {},
  87. beforeMount() {},
  88. mounted() {},
  89. beforeUpdate() {},
  90. updated() {},
  91. beforeDestroy() {},
  92. destroyed() {},
  93. methods: {
  94. onLoad() {
  95. var that = this;
  96. that.$axios
  97. .get("/getIntegralWaresInfoList", {
  98. params: {
  99. stationId: "1",
  100. },
  101. })
  102. .then((res) => {
  103. if (res.data.retCode == 0) {
  104. that.list = res.data.data; //追加数据
  105. // 加载状态结束
  106. that.loading = false;
  107. that.finished = true;
  108. console.log(that.list);
  109. }
  110. });
  111. },
  112. onRefresh() {
  113. // 清空列表数据
  114. that.finished = true;
  115. // 重新加载数据
  116. // 将 loading 设置为 true,表示处于加载状态
  117. that.loading = true;
  118. that.onLoad();
  119. },
  120. },
  121. };
  122. </script>
  123. <style scope>
  124. * {
  125. box-sizing: border-box;
  126. }
  127. .my-swipe .van-swipe-item {
  128. color: #fff;
  129. font-size: 20px;
  130. line-height: 150px;
  131. text-align: center;
  132. background-color: #39a9ed;
  133. border-radius: 4vw;
  134. }
  135. .container {
  136. width: 92vw;
  137. margin: 0 auto;
  138. }
  139. .list {
  140. width: 92vw;
  141. }
  142. .list .list-item {
  143. display: flex;
  144. margin-top: 30px;
  145. width: 92vw;
  146. height: 28.5vw;
  147. }
  148. .list .list-item .list-item-left {
  149. width: 28.5vw;
  150. height: 28.5vw;
  151. border: 0.26vw solid #eeeeee;
  152. flex-shrink: 0;
  153. }
  154. .list .list-item .list-item-left img {
  155. display: inline-block;
  156. width: 100%;
  157. height: 100%;
  158. border-radius: 3vw;
  159. }
  160. .list .list-item .list-item-right {
  161. margin-left: 3vw;
  162. width: 60.5vw;
  163. color: red;
  164. display: flex;
  165. flex-direction: column;
  166. flex-shrink: 0;
  167. font-size: 4.266vw;
  168. font-weight: 400;
  169. color: #111111;
  170. line-height: 6vw;
  171. height: 28.5vw;
  172. }
  173. .list .list-item .list-item-right .item-right-top {
  174. width: 60.5vw;
  175. height: 12vm;
  176. flex-shrink: 0;
  177. word-break:break-all;
  178. height:20vw
  179. }
  180. .list .list-item .list-item-right .item-right-top{
  181. width: 60.5vw;
  182. height: 12vm;
  183. flex-shrink: 0;
  184. }
  185. </style>