index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="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. };
  164. const toRoute = (item) => {
  165. uni.navigateTo({
  166. url: `/${item.route}`,
  167. })
  168. };
  169. // 查看详情
  170. const toView = (item) => {
  171. uni.navigateTo({
  172. url: `/pagesHome/car/index?id=${item.id || item._id}`
  173. })
  174. };
  175. // 联系卖家
  176. const toChat = (item) => {
  177. uni.makePhoneCall({
  178. phoneNumber: item.shop || '110',
  179. success: function () {
  180. console.log('拨打电话成功');
  181. },
  182. fail: function () {
  183. console.log('拨打电话失败');
  184. }
  185. });
  186. };
  187. // 清空失效数据
  188. const toDelete = () => {
  189. console.log('清空失效数据');
  190. };
  191. // 分页
  192. const toPage = () => {
  193. if (total.value > list.value.length) {
  194. uni.showLoading({
  195. title: '加载中',
  196. mask: true
  197. })
  198. page.value = page.value + 1;
  199. skip.value = page.value * limit.value;
  200. search();
  201. uni.hideLoading();
  202. } else is_bottom.value = true
  203. };
  204. // 清空列表
  205. const clearPage = () => {
  206. list.value = []
  207. skip.value = 0
  208. limit.value = 6
  209. page.value = 0
  210. };
  211. </script>
  212. <style lang="scss" scoped>
  213. .content {
  214. display: flex;
  215. flex-direction: column;
  216. width: 100vw;
  217. height: 100vh;
  218. .top {
  219. margin: 2vw;
  220. }
  221. .bottom {
  222. position: relative;
  223. flex-grow: 1;
  224. .text {
  225. display: flex;
  226. justify-content: flex-end;
  227. padding: 2vw;
  228. font-size: var(--font14Size);
  229. color: #606266;
  230. text {
  231. margin: 0 0 0 1vw;
  232. }
  233. }
  234. .list {
  235. display: flex;
  236. margin: 1vw 0 0 0;
  237. padding: 1vw;
  238. height: 100px;
  239. .left {
  240. .image {
  241. width: 130px;
  242. height: 100px;
  243. border-radius: 2px;
  244. }
  245. }
  246. .right {
  247. display: flex;
  248. flex-direction: column;
  249. justify-content: space-between;
  250. width: 100%;
  251. .name {
  252. font-size: var(--font14Size);
  253. }
  254. .other {
  255. color: var(--f85Color);
  256. font-size: var(--font12Size);
  257. }
  258. .right_1 {
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. .money {
  263. color: var(--fF0Color);
  264. font-size: var(--font12Size);
  265. text:first-child {
  266. font-size: var(--font18Size);
  267. }
  268. }
  269. .button {
  270. background-color: var(--fFFColor);
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .scroll-view {
  278. position: absolute;
  279. top: 0;
  280. left: 0;
  281. right: 0;
  282. bottom: 0;
  283. .list-scroll-view {
  284. display: flex;
  285. flex-direction: column;
  286. }
  287. }
  288. .is_bottom {
  289. width: 100%;
  290. text-align: center;
  291. text {
  292. padding: 2vw 0;
  293. display: inline-block;
  294. color: var(--f85Color);
  295. font-size: var(--font12Size);
  296. }
  297. }
  298. </style>