index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <u-search shape="square" :show-action="false" placeholder="品牌/车系" @focus="toChange"></u-search>
  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">
  10. <view class="name textOver">
  11. <text>{{item.brand||'暂无'}} {{item.bank||'暂无'}} {{item.type||'暂无'}}</text>
  12. </view>
  13. <view class="other textOver" v-if="item.start">
  14. <text>上牌日期:</text>
  15. <text>{{item.start||'暂无'}}</text>
  16. </view>
  17. <view class="other textOver" v-if="item.course">
  18. <text>行驶里程:</text>
  19. <text>{{item.course||'暂无'}}</text>
  20. </view>
  21. <view class="other textOver" v-if="item.city">
  22. <text>上牌城市:</text>
  23. <text>{{item.city||'暂无'}}</text>
  24. </view>
  25. <view class="other textOver" v-if="item.place">
  26. <text>估值地区:</text>
  27. <text>{{item.place||'暂无'}}</text>
  28. </view>
  29. <view class="other textOver" v-if="item.estimate">
  30. <text>预估价格:</text>
  31. <text style="color: red;">{{item.estimate||'暂无'}}万元</text>
  32. </view>
  33. <view class="other textOver" v-if="item.status">
  34. <text>状态:</text>
  35. <text style="color: red;">{{getDict(item.status,'status')}}</text>
  36. </view>
  37. </view>
  38. <view class="is_bottom" v-if="is_bottom">
  39. <text>{{config.bottom_title||'没有更多了!'}}</text>
  40. </view>
  41. </view>
  42. </scroll-view>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup lang="ts">
  47. import { getCurrentInstance, computed, ref } from 'vue';
  48. //该依赖已内置不需要单独安装
  49. import { onLoad } from "@dcloudio/uni-app";
  50. // 请求接口
  51. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  52. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  53. // openid
  54. const openid = computed(() => {
  55. return uni.getStorageSync('openid');
  56. })
  57. // 查询
  58. const searchInfo = ref({});
  59. // 基本信息
  60. const config = ref({ logoUrl: [] });
  61. // 列表
  62. const list = ref([]);
  63. const total = ref(0);
  64. const skip = ref(0);
  65. const limit = ref(6);
  66. const page = ref(0);
  67. // 数据是否触底
  68. const is_bottom = ref(false);
  69. const scrollTop = ref(0);
  70. // 字典表
  71. const statusList = ref([]);
  72. onLoad(async () => {
  73. await searchOther();
  74. await searchConfig();
  75. await search();
  76. })
  77. // 查询其他信息
  78. const searchOther = async () => {
  79. let res;
  80. // 状态
  81. res = await $api(`dictData`, 'GET', { code: 'valuation', is_use: '0' });
  82. if (res.errcode === 0) statusList.value = res.data;
  83. };
  84. // config信息
  85. const searchConfig = async () => {
  86. config.value = uni.getStorageSync('config');
  87. };
  88. // 查询
  89. const search = async () => {
  90. const info = {
  91. skip: skip.value,
  92. limit: limit.value,
  93. // openid: openid.value
  94. }
  95. const res = await $api('estimate', 'GET', {
  96. ...info,
  97. ...searchInfo.value
  98. });
  99. if (res.errcode === 0) {
  100. list.value = list.value.concat(res.data)
  101. total.value = res.total
  102. } else {
  103. uni.showToast({
  104. title: res.errmsg || '',
  105. icon: 'error',
  106. });
  107. }
  108. };
  109. // 数据处理
  110. const getDict = (data, model) => {
  111. let list;
  112. switch (model) {
  113. case 'status':
  114. list = statusList.value;
  115. break;
  116. default:
  117. break;
  118. }
  119. if (!list) return;
  120. const res = list.find((f) => f.value == data);
  121. return res?.label || '暂无';
  122. };
  123. // 搜索
  124. const toChange = () => {
  125. uni.navigateTo({
  126. url: `/pagesHome/type/index`
  127. })
  128. };
  129. // 分页
  130. const toPage = () => {
  131. if (total.value > list.value.length) {
  132. uni.showLoading({
  133. title: '加载中',
  134. mask: true
  135. })
  136. page.value = page.value + 1;
  137. skip.value = page.value * limit.value;
  138. search();
  139. uni.hideLoading();
  140. } else is_bottom.value = true
  141. };
  142. // 清空列表
  143. const clearPage = () => {
  144. list.value = []
  145. skip.value = 0
  146. limit.value = 6
  147. page.value = 0
  148. };
  149. </script>
  150. <style lang="scss" scoped>
  151. .content {
  152. display: flex;
  153. flex-direction: column;
  154. width: 100vw;
  155. height: 100vh;
  156. .top {
  157. margin: 2vw;
  158. }
  159. .bottom {
  160. position: relative;
  161. flex-grow: 1;
  162. background-color: var(--f9Color);
  163. .list {
  164. background-color: var(--mainColor);
  165. border: 1px solid var(--f5Color);
  166. padding: 2vw;
  167. margin: 2vw 2vw 0 2vw;
  168. border-radius: 5px;
  169. .name {
  170. font-size: var(--font16Size);
  171. margin: 0 0 1vw 0;
  172. }
  173. .other {
  174. font-size: var(--font14Size);
  175. text:first-child {
  176. color: var(--f85Color);
  177. }
  178. }
  179. }
  180. }
  181. }
  182. .scroll-view {
  183. position: absolute;
  184. top: 0;
  185. left: 0;
  186. right: 0;
  187. bottom: 0;
  188. .list-scroll-view {
  189. display: flex;
  190. flex-direction: column;
  191. }
  192. }
  193. .is_bottom {
  194. width: 100%;
  195. text-align: center;
  196. text {
  197. padding: 2vw 0;
  198. display: inline-block;
  199. color: var(--f85Color);
  200. font-size: var(--font12Size);
  201. }
  202. }
  203. </style>