index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <u-swiper :list="config.file" height="240px" indicator indicatorMode="line" circular></u-swiper>
  5. </view>
  6. <view class="bottom">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  8. <view class="list-scroll-view">
  9. <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
  10. <view class="list_1">
  11. <view class="left">
  12. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''">
  13. </image>
  14. </view>
  15. <view class="right">
  16. <view class="name textOver">{{item.series||'暂无'}} {{item.year||'暂无'}}款
  17. {{item.style||'暂无'}}
  18. </view>
  19. <view class="money">
  20. <text>{{item.total_money||'0'}}</text>
  21. <text>万</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="is_bottom" v-if="is_bottom">
  27. <text>{{config.bottom_title||'没有更多了!'}}</text>
  28. </view>
  29. </view>
  30. </scroll-view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup lang="ts">
  35. import { getCurrentInstance, ref } from 'vue';
  36. //该依赖已内置不需要单独安装
  37. import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  38. // 请求接口
  39. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  40. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  41. // 基本信息
  42. const config = ref({ logo: [], file: [] });
  43. const list = ref([]);
  44. const total = ref(0);
  45. const skip = ref(0);
  46. const limit = ref(6);
  47. const page = ref(0);
  48. // 数据是否触底
  49. const is_bottom = ref(false);
  50. const scrollTop = ref(0);
  51. onShow(async () => {
  52. await searchConfig();
  53. await clearPage();
  54. await search();
  55. })
  56. onPullDownRefresh(async () => {
  57. await clearPage();
  58. await search();
  59. uni.stopPullDownRefresh();
  60. })
  61. // config信息
  62. const searchConfig = async () => {
  63. config.value = uni.getStorageSync('config');
  64. };
  65. // 查询
  66. const search = async () => {
  67. const info = {
  68. skip: skip.value,
  69. limit: limit.value,
  70. status: '0'
  71. }
  72. // const res = await $api('car', 'GET', info);
  73. // if (res.errcode === 0) {
  74. // list.value = list.value.concat(res.data)
  75. // total.value = res.total
  76. // } else {
  77. // uni.showToast({
  78. // title: res.errmsg || '',
  79. // icon: 'error',
  80. // });
  81. // }
  82. };
  83. // 搜索
  84. const toChange = () => {
  85. uni.navigateTo({
  86. url: `/pagesHome/type/index`
  87. })
  88. };
  89. const toCommon = (item) => {
  90. uni.navigateTo({
  91. url: `/pagesHome/search/index?type=${item.type || ''}`
  92. })
  93. };
  94. // 查看详情
  95. const toView = (item) => {
  96. uni.navigateTo({
  97. url: `/pagesHome/car/index?id=${item.id || item._id}`
  98. })
  99. };
  100. // 分页
  101. const toPage = () => {
  102. if (total.value > list.value.length) {
  103. uni.showLoading({
  104. title: '加载中',
  105. mask: true
  106. })
  107. page.value = page.value + 1;
  108. skip.value = page.value * limit.value;
  109. search();
  110. uni.hideLoading();
  111. } else is_bottom.value = true
  112. };
  113. // 清空列表
  114. const clearPage = () => {
  115. list.value = []
  116. skip.value = 0
  117. limit.value = 6
  118. page.value = 0
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. .content {
  123. display: flex;
  124. flex-direction: column;
  125. width: 100vw;
  126. height: 100vh;
  127. .top {}
  128. .bottom {
  129. position: relative;
  130. flex-grow: 1;
  131. .list {
  132. width: 47vw;
  133. margin: 2vw 0 0 0;
  134. border-radius: 5px;
  135. border: 1px solid var(--f5Color);
  136. .list_1 {
  137. .left {
  138. .image {
  139. width: 100%;
  140. height: 120px;
  141. border-radius: 5px 5px 0 0;
  142. }
  143. }
  144. .right {
  145. display: flex;
  146. flex-direction: column;
  147. justify-content: space-between;
  148. padding: 0 2vw;
  149. .name {
  150. font-size: var(--font14Size);
  151. }
  152. .money {
  153. color: var(--fF0Color);
  154. font-size: var(--font12Size);
  155. margin: 0 0 1vw 0;
  156. text:first-child {
  157. font-size: var(--font18Size);
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. .scroll-view {
  166. position: absolute;
  167. top: 0;
  168. left: 0;
  169. right: 0;
  170. bottom: 0;
  171. .list-scroll-view {
  172. display: flex;
  173. justify-content: space-between;
  174. flex-wrap: wrap;
  175. padding: 0 2vw;
  176. }
  177. }
  178. .is_bottom {
  179. width: 100%;
  180. text-align: center;
  181. text {
  182. padding: 2vw 0;
  183. display: inline-block;
  184. color: var(--f85Color);
  185. font-size: var(--font12Size);
  186. }
  187. }
  188. </style>