index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <u-search shape="square" :show-action="false" placeholder="品牌/车系"></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="one">
  10. <view class="one_1">
  11. <view class="list" v-for="(item, index) in $config.searchList" :key="index"
  12. @tap="toRoute(item)">
  13. <view class="icon">
  14. <text class="t-icon" :class="item.icon"></text>
  15. </view>
  16. <view class="title">{{item.title||'暂无'}}</view>
  17. </view>
  18. </view>
  19. <view class="one_1 one_2">
  20. <view class="list" v-for="(item, index) in carList" :key="index" @tap="toCommon(item,'0')">
  21. <view class="icon">
  22. <image class="image"
  23. :src="item.url&&item.url.length>0?item.url[0].url:'/static/logo.png'">
  24. </image>
  25. </view>
  26. <view class="title">{{item.title}}</view>
  27. </view>
  28. </view>
  29. <view class="one_1 one_3">
  30. <view class="list" v-for="(item, index) in typeList" :key="index" @tap="toCommon(item,'1')">
  31. <view class="name">{{item.title||'暂无'}}</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="two">
  36. <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
  37. <view class="left">
  38. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''">
  39. </image>
  40. </view>
  41. <view class="right">
  42. <view class="name textOver">{{item.name||'暂无'}}</view>
  43. <view class="other">
  44. <text v-if="item.year">{{item.year||'暂无'}}| </text>
  45. <text v-if="item.kilometer">{{item.kilometer||'暂无'}} | </text>
  46. <text v-if="item.city">{{item.city||'暂无'}}</text>
  47. </view>
  48. <view class="money">
  49. <text>{{item.money||'0'}}</text>
  50. <text>万</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="is_bottom" v-if="is_bottom">
  56. <text>{{config.bottom_title||'没有更多了!'}}</text>
  57. </view>
  58. </view>
  59. </scroll-view>
  60. </view>
  61. </view>
  62. </template>
  63. <script setup lang="ts">
  64. import { getCurrentInstance, ref } from 'vue';
  65. //该依赖已内置不需要单独安装
  66. import { onLoad } from "@dcloudio/uni-app";
  67. // 请求接口
  68. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  69. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  70. // 基本信息
  71. const config = ref({ logoUrl: [] });
  72. // 列表
  73. const list = ref([
  74. {
  75. id: '1',
  76. file: [{ url: 'https://cdn.uviewui.com/uview/album/1.jpg' }],
  77. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  78. year: '2014年 ',
  79. city: '丹东',
  80. kilometer: '8万公里',
  81. money: '7.80'
  82. },
  83. {
  84. id: '1',
  85. file: [{ url: 'https://cdn.uviewui.com/uview/album/2.jpg' }],
  86. name: '捷豹XEL 2020款 2.0T 200PS S进取优雅版',
  87. year: '2014年 ',
  88. city: '丹东',
  89. kilometer: '8万公里',
  90. money: '7.80'
  91. },
  92. {
  93. id: '1',
  94. file: [{ url: 'https://cdn.uviewui.com/uview/album/3.jpg' }],
  95. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  96. year: '2014年 ',
  97. city: '丹东',
  98. kilometer: '8万公里',
  99. money: '7.80'
  100. },
  101. {
  102. id: '1',
  103. file: [{ url: 'https://cdn.uviewui.com/uview/album/4.jpg' }],
  104. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  105. year: '2014年 ',
  106. city: '丹东',
  107. kilometer: '8万公里',
  108. money: '7.80'
  109. },
  110. {
  111. id: '1',
  112. file: [{ url: 'https://cdn.uviewui.com/uview/album/5.jpg' }],
  113. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  114. year: '2014年 ',
  115. city: '丹东',
  116. kilometer: '8万公里',
  117. money: '7.80'
  118. },
  119. {
  120. id: '1',
  121. file: [{ url: 'https://cdn.uviewui.com/uview/album/6.jpg' }],
  122. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  123. year: '2014年 ',
  124. city: '丹东',
  125. kilometer: '8万公里',
  126. money: '7.80'
  127. },
  128. {
  129. id: '1',
  130. file: [{ url: 'https://cdn.uviewui.com/uview/album/7.jpg' }],
  131. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  132. year: '2014年 ',
  133. city: '丹东',
  134. kilometer: '8万公里',
  135. money: '7.80'
  136. },
  137. {
  138. id: '1',
  139. file: [{ url: 'https://cdn.uviewui.com/uview/album/8.jpg' }],
  140. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  141. year: '2014年 ',
  142. city: '丹东',
  143. kilometer: '8万公里',
  144. money: '7.80'
  145. },
  146. {
  147. id: '1',
  148. file: [{ url: 'https://cdn.uviewui.com/uview/album/9.jpg' }],
  149. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  150. year: '2014年 ',
  151. city: '丹东',
  152. kilometer: '8万公里',
  153. money: '7.80'
  154. },
  155. {
  156. id: '1',
  157. file: [{ url: 'https://cdn.uviewui.com/uview/album/10.jpg' }],
  158. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  159. year: '2014年 ',
  160. city: '丹东',
  161. kilometer: '8万公里',
  162. money: '7.80'
  163. }]);
  164. const total = ref(0);
  165. const skip = ref(0);
  166. const limit = ref(6);
  167. const page = ref(0);
  168. // 数据是否触底
  169. const is_bottom = ref(false);
  170. const scrollTop = ref(0);
  171. // 字典表
  172. const typeList = ref([
  173. {
  174. title: '5万以下',
  175. type: '0',
  176. },
  177. {
  178. title: '5-10万',
  179. type: '1',
  180. },
  181. {
  182. title: '10-15万',
  183. type: '2',
  184. },
  185. {
  186. title: '更多条件',
  187. type: '3',
  188. }
  189. ])
  190. const carList = ref([
  191. {
  192. title: '大众',
  193. type: '0',
  194. },
  195. {
  196. title: '宝马',
  197. type: '1',
  198. },
  199. {
  200. title: '本田',
  201. type: '2',
  202. },
  203. {
  204. title: '丰田',
  205. type: '3',
  206. },
  207. {
  208. title: '更多品牌',
  209. type: '4',
  210. }
  211. ])
  212. onLoad(async () => {
  213. await searchConfig();
  214. await search();
  215. })
  216. // config信息
  217. const searchConfig = async () => {
  218. config.value = uni.getStorageSync('config');
  219. };
  220. // 查询
  221. const search = async () => {
  222. };
  223. const toRoute = (item) => {
  224. uni.navigateTo({
  225. url: `/${item.route}`,
  226. })
  227. };
  228. const toCommon = (item, type) => {
  229. console.log(item);
  230. if (type == '0' && item.type == '4') {
  231. uni.navigateTo({
  232. url: `/pagesHome/brand/index?type=${item.type || ''}`,
  233. })
  234. } else {
  235. uni.navigateTo({
  236. url: `/pagesHome/search/index?type=${item.type || ''}`,
  237. })
  238. }
  239. };
  240. // 查看详情
  241. const toView = (item) => {
  242. uni.navigateTo({
  243. url: `/pagesHome/car/index?id=${item.id || item._id}`
  244. })
  245. };
  246. // 分页
  247. const toPage = () => {
  248. if (total.value > list.value.length) {
  249. uni.showLoading({
  250. title: '加载中',
  251. mask: true
  252. })
  253. page.value = page.value + 1;
  254. skip.value = page.value * limit.value;
  255. search();
  256. uni.hideLoading();
  257. } else is_bottom.value = true
  258. };
  259. // 清空列表
  260. const clearPage = () => {
  261. list.value = []
  262. skip.value = 0
  263. limit.value = 6
  264. page.value = 0
  265. };
  266. </script>
  267. <style lang="scss" scoped>
  268. .content {
  269. display: flex;
  270. flex-direction: column;
  271. width: 100vw;
  272. height: 100vh;
  273. .top {
  274. margin: 2vw;
  275. }
  276. .bottom {
  277. position: relative;
  278. flex-grow: 1;
  279. .one {
  280. .one_1 {
  281. display: flex;
  282. justify-content: space-between;
  283. align-items: center;
  284. padding: 2vw 4vw;
  285. .list {
  286. display: flex;
  287. flex-direction: column;
  288. align-items: center;
  289. .title {
  290. margin: 1vw 0 0 0;
  291. font-size: var(--font14Size);
  292. }
  293. }
  294. }
  295. .one_2 {
  296. .image {
  297. width: 35px;
  298. height: 35px;
  299. border-radius: 35px;
  300. }
  301. }
  302. .one_3 {
  303. padding: 2vw;
  304. .list {
  305. background-color: var(--f9Color);
  306. .name {
  307. padding: 2vw 4vw;
  308. font-size: var(--font14Size);
  309. }
  310. }
  311. }
  312. }
  313. .two {
  314. margin: 2vw;
  315. .list {
  316. display: flex;
  317. margin: 1vw 0 0 0;
  318. padding: 1vw;
  319. height: 100px;
  320. .left {
  321. .image {
  322. width: 130px;
  323. height: 100px;
  324. border-radius: 2px;
  325. }
  326. }
  327. .right {
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: space-between;
  331. margin: 0 0 0 2vw;
  332. width: 100%;
  333. .name {
  334. font-size: var(--font14Size);
  335. }
  336. .other {
  337. color: var(--f85Color);
  338. font-size: var(--font12Size);
  339. }
  340. .money {
  341. color: var(--fF0Color);
  342. font-size: var(--font12Size);
  343. text:first-child {
  344. font-size: var(--font18Size);
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. .scroll-view {
  353. position: absolute;
  354. top: 0;
  355. left: 0;
  356. right: 0;
  357. bottom: 0;
  358. .list-scroll-view {
  359. display: flex;
  360. flex-direction: column;
  361. }
  362. }
  363. .is_bottom {
  364. width: 100%;
  365. text-align: center;
  366. text {
  367. padding: 2vw 0;
  368. display: inline-block;
  369. color: var(--f85Color);
  370. font-size: var(--font12Size);
  371. }
  372. }
  373. </style>