index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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="text" @tap="toDelete">
  10. <u-icon name="trash" size="15"></u-icon>
  11. <text>清理已失效的车辆</text>
  12. </view>
  13. <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
  14. <view class="left">
  15. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''">
  16. </image>
  17. </view>
  18. <view class="right">
  19. <view class="name textOver">{{item.name||'暂无'}}</view>
  20. <view class="other">
  21. <text v-if="item.year">{{item.year||'暂无'}}| </text>
  22. <text v-if="item.kilometer">{{item.kilometer||'暂无'}} | </text>
  23. <text v-if="item.city">{{item.city||'暂无'}}</text>
  24. </view>
  25. <view class="right_1">
  26. <view class="money">
  27. <text>{{item.money||'0'}}</text>
  28. <text>万</text>
  29. </view>
  30. <view>
  31. <button @tap.stop="toChat(item)" class="button" size="mini"
  32. type="default">询底价</button>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="is_bottom" v-if="is_bottom">
  38. <text>{{config.bottom_title||'没有更多了!'}}</text>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. </template>
  45. <script setup lang="ts">
  46. import { getCurrentInstance, ref } from 'vue';
  47. //该依赖已内置不需要单独安装
  48. import { onLoad } from "@dcloudio/uni-app";
  49. // 请求接口
  50. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  51. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  52. // 基本信息
  53. const config = ref({ logoUrl: [] });
  54. // 列表
  55. const list = ref([
  56. {
  57. id: '1',
  58. file: [{ url: 'https://cdn.uviewui.com/uview/album/1.jpg' }],
  59. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  60. year: '2014年 ',
  61. city: '丹东',
  62. kilometer: '8万公里',
  63. money: '7.80'
  64. },
  65. {
  66. id: '1',
  67. file: [{ url: 'https://cdn.uviewui.com/uview/album/2.jpg' }],
  68. name: '捷豹XEL 2020款 2.0T 200PS S进取优雅版',
  69. year: '2014年 ',
  70. city: '丹东',
  71. kilometer: '8万公里',
  72. money: '7.80'
  73. },
  74. {
  75. id: '1',
  76. file: [{ url: 'https://cdn.uviewui.com/uview/album/3.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/4.jpg' }],
  86. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  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/5.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/6.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/7.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/8.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/9.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/10.jpg' }],
  140. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  141. year: '2014年 ',
  142. city: '丹东',
  143. kilometer: '8万公里',
  144. money: '7.80'
  145. }]);
  146. const total = ref(0);
  147. const skip = ref(0);
  148. const limit = ref(6);
  149. const page = ref(0);
  150. // 数据是否触底
  151. const is_bottom = ref(false);
  152. const scrollTop = ref(0);
  153. onLoad(async () => {
  154. await searchConfig();
  155. await search();
  156. })
  157. // config信息
  158. const searchConfig = async () => {
  159. config.value = uni.getStorageSync('config');
  160. };
  161. // 查询
  162. const search = async () => {
  163. // const info = {
  164. // skip: skip.value,
  165. // limit: limit.value,
  166. // status: '0'
  167. // }
  168. // const res = await $api('car', 'GET', info);
  169. // if (res.errcode === 0) {
  170. // list.value = list.value.concat(res.data)
  171. // total.value = res.total
  172. // } else {
  173. // uni.showToast({
  174. // title: res.errmsg || '',
  175. // icon: 'error',
  176. // });
  177. // }
  178. };
  179. // 搜索
  180. const toChange = () => {
  181. uni.navigateTo({
  182. url: `/pagesHome/type/index`
  183. })
  184. };
  185. const toRoute = (item) => {
  186. uni.navigateTo({
  187. url: `/${item.route}`,
  188. })
  189. };
  190. // 查看详情
  191. const toView = (item) => {
  192. uni.navigateTo({
  193. url: `/pagesHome/car/index?id=${item.id || item._id}`
  194. })
  195. };
  196. // 联系卖家
  197. const toChat = (item) => {
  198. uni.makePhoneCall({
  199. phoneNumber: item.shop || '110',
  200. success: function () {
  201. console.log('拨打电话成功');
  202. },
  203. fail: function () {
  204. uni.showToast({
  205. title: '拨打电话失败',
  206. icon: 'error',
  207. });
  208. }
  209. });
  210. };
  211. // 清空失效数据
  212. const toDelete = () => {
  213. console.log('清空失效数据');
  214. };
  215. // 分页
  216. const toPage = () => {
  217. if (total.value > list.value.length) {
  218. uni.showLoading({
  219. title: '加载中',
  220. mask: true
  221. })
  222. page.value = page.value + 1;
  223. skip.value = page.value * limit.value;
  224. search();
  225. uni.hideLoading();
  226. } else is_bottom.value = true
  227. };
  228. // 清空列表
  229. const clearPage = () => {
  230. list.value = []
  231. skip.value = 0
  232. limit.value = 6
  233. page.value = 0
  234. };
  235. </script>
  236. <style lang="scss" scoped>
  237. .content {
  238. display: flex;
  239. flex-direction: column;
  240. width: 100vw;
  241. height: 100vh;
  242. .top {
  243. margin: 2vw;
  244. }
  245. .bottom {
  246. position: relative;
  247. flex-grow: 1;
  248. .text {
  249. display: flex;
  250. justify-content: flex-end;
  251. padding: 2vw;
  252. font-size: var(--font14Size);
  253. color: #606266;
  254. text {
  255. margin: 0 0 0 1vw;
  256. }
  257. }
  258. .list {
  259. display: flex;
  260. margin: 1vw 0 0 0;
  261. padding: 1vw;
  262. .left {
  263. .image {
  264. width: 130px;
  265. height: 100px;
  266. border-radius: 2px;
  267. }
  268. }
  269. .right {
  270. display: flex;
  271. flex-direction: column;
  272. justify-content: space-between;
  273. margin: 0 0 0 2vw;
  274. width: 100%;
  275. .name {
  276. font-size: var(--font14Size);
  277. }
  278. .other {
  279. color: var(--f85Color);
  280. font-size: var(--font12Size);
  281. }
  282. .right_1 {
  283. display: flex;
  284. justify-content: space-between;
  285. align-items: center;
  286. .money {
  287. color: var(--fF0Color);
  288. font-size: var(--font12Size);
  289. text:first-child {
  290. font-size: var(--font18Size);
  291. }
  292. }
  293. .button {
  294. background-color: var(--fFFColor);
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. .scroll-view {
  302. position: absolute;
  303. top: 0;
  304. left: 0;
  305. right: 0;
  306. bottom: 0;
  307. .list-scroll-view {
  308. display: flex;
  309. flex-direction: column;
  310. }
  311. }
  312. .is_bottom {
  313. width: 100%;
  314. text-align: center;
  315. text {
  316. padding: 2vw 0;
  317. display: inline-block;
  318. color: var(--f85Color);
  319. font-size: var(--font12Size);
  320. }
  321. }
  322. </style>