index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <u-subsection mode="subsection" activeColor="#ffbc00" :list="tabList" :current="curNow"
  5. @change="sectionChange"></u-subsection>
  6. </view>
  7. <view class="bottom">
  8. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  9. <view class="list-scroll-view">
  10. <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
  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.name||'暂无'}}</view>
  17. <view class="other">
  18. <text v-if="item.year">{{item.year||'暂无'}}| </text>
  19. <text v-if="item.kilometer">{{item.kilometer||'暂无'}} | </text>
  20. <text v-if="item.city">{{item.city||'暂无'}}</text>
  21. </view>
  22. <view class="right_1">
  23. <view class="money">
  24. <text>{{item.money||'0'}}</text>
  25. <text>万</text>
  26. </view>
  27. <view>
  28. <button @tap.stop="toChat(item)" class="button" size="mini"
  29. type="default">询底价</button>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="is_bottom" v-if="is_bottom">
  35. <text>{{config.bottom_title||'没有更多了!'}}</text>
  36. </view>
  37. </view>
  38. </scroll-view>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup lang="ts">
  43. import { getCurrentInstance, ref } from 'vue';
  44. //该依赖已内置不需要单独安装
  45. import { onLoad } from "@dcloudio/uni-app";
  46. // 请求接口
  47. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  48. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  49. // 偏移
  50. const offset = ref(['-2px', '355px']);
  51. const tabList = ref(['销量榜', '保值榜', '店铺规模榜']);
  52. const curNow = ref(0);
  53. // 基本信息
  54. const config = ref({ logoUrl: [] });
  55. // 列表
  56. const list = ref([
  57. {
  58. id: '1',
  59. file: [{ url: 'https://cdn.uviewui.com/uview/album/1.jpg' }],
  60. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  61. year: '2014年 ',
  62. city: '丹东',
  63. kilometer: '8万公里',
  64. money: '7.80'
  65. },
  66. {
  67. id: '1',
  68. file: [{ url: 'https://cdn.uviewui.com/uview/album/2.jpg' }],
  69. name: '捷豹XEL 2020款 2.0T 200PS S进取优雅版',
  70. year: '2014年 ',
  71. city: '丹东',
  72. kilometer: '8万公里',
  73. money: '7.80'
  74. },
  75. {
  76. id: '1',
  77. file: [{ url: 'https://cdn.uviewui.com/uview/album/3.jpg' }],
  78. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  79. year: '2014年 ',
  80. city: '丹东',
  81. kilometer: '8万公里',
  82. money: '7.80'
  83. },
  84. {
  85. id: '1',
  86. file: [{ url: 'https://cdn.uviewui.com/uview/album/4.jpg' }],
  87. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  88. year: '2014年 ',
  89. city: '丹东',
  90. kilometer: '8万公里',
  91. money: '7.80'
  92. },
  93. {
  94. id: '1',
  95. file: [{ url: 'https://cdn.uviewui.com/uview/album/5.jpg' }],
  96. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  97. year: '2014年 ',
  98. city: '丹东',
  99. kilometer: '8万公里',
  100. money: '7.80'
  101. },
  102. {
  103. id: '1',
  104. file: [{ url: 'https://cdn.uviewui.com/uview/album/6.jpg' }],
  105. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  106. year: '2014年 ',
  107. city: '丹东',
  108. kilometer: '8万公里',
  109. money: '7.80'
  110. },
  111. {
  112. id: '1',
  113. file: [{ url: 'https://cdn.uviewui.com/uview/album/7.jpg' }],
  114. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  115. year: '2014年 ',
  116. city: '丹东',
  117. kilometer: '8万公里',
  118. money: '7.80'
  119. },
  120. {
  121. id: '1',
  122. file: [{ url: 'https://cdn.uviewui.com/uview/album/8.jpg' }],
  123. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  124. year: '2014年 ',
  125. city: '丹东',
  126. kilometer: '8万公里',
  127. money: '7.80'
  128. },
  129. {
  130. id: '1',
  131. file: [{ url: 'https://cdn.uviewui.com/uview/album/9.jpg' }],
  132. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  133. year: '2014年 ',
  134. city: '丹东',
  135. kilometer: '8万公里',
  136. money: '7.80'
  137. },
  138. {
  139. id: '1',
  140. file: [{ url: 'https://cdn.uviewui.com/uview/album/10.jpg' }],
  141. name: '夏朗 2013款 1.8TSI 标配型 欧IV',
  142. year: '2014年 ',
  143. city: '丹东',
  144. kilometer: '8万公里',
  145. money: '7.80'
  146. }]);
  147. const total = ref(0);
  148. const skip = ref(0);
  149. const limit = ref(6);
  150. const page = ref(0);
  151. // 数据是否触底
  152. const is_bottom = ref(false);
  153. const scrollTop = ref(0);
  154. onLoad(async () => {
  155. await searchConfig();
  156. await search();
  157. })
  158. // config信息
  159. const searchConfig = async () => {
  160. config.value = uni.getStorageSync('config');
  161. };
  162. // 查询
  163. const search = async () => {
  164. };
  165. const toRoute = (item) => {
  166. uni.navigateTo({
  167. url: `/${item.route}`,
  168. })
  169. };
  170. // 跳转
  171. const sectionChange = (index) => {
  172. curNow.value = index;
  173. };
  174. // 查看详情
  175. const toView = (item) => {
  176. uni.navigateTo({
  177. url: `/pagesHome/car/index?id=${item.id || item._id}`
  178. })
  179. };
  180. // 联系卖家
  181. const toChat = (item) => {
  182. uni.makePhoneCall({
  183. phoneNumber: item.shop || '110',
  184. success: function () {
  185. console.log('拨打电话成功');
  186. },
  187. fail: function () {
  188. uni.showToast({
  189. title: '拨打电话失败',
  190. icon: 'error',
  191. });
  192. }
  193. });
  194. };
  195. // 清空失效数据
  196. const toDelete = () => {
  197. console.log('清空失效数据');
  198. };
  199. // 分页
  200. const toPage = () => {
  201. if (total.value > list.value.length) {
  202. uni.showLoading({
  203. title: '加载中',
  204. mask: true
  205. })
  206. page.value = page.value + 1;
  207. skip.value = page.value * limit.value;
  208. search();
  209. uni.hideLoading();
  210. } else is_bottom.value = true
  211. };
  212. // 清空列表
  213. const clearPage = () => {
  214. list.value = []
  215. skip.value = 0
  216. limit.value = 6
  217. page.value = 0
  218. };
  219. </script>
  220. <style lang="scss" scoped>
  221. .content {
  222. display: flex;
  223. flex-direction: column;
  224. width: 100vw;
  225. height: 100vh;
  226. .top {
  227. padding: 2vw;
  228. }
  229. .bottom {
  230. position: relative;
  231. flex-grow: 1;
  232. .list {
  233. position: relative;
  234. display: flex;
  235. margin: 1vw 0 0 0;
  236. padding: 1vw;
  237. .left {
  238. .image {
  239. width: 130px;
  240. height: 100px;
  241. border-radius: 2px;
  242. }
  243. }
  244. .right {
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: space-between;
  248. margin: 0 0 0 2vw;
  249. width: 100%;
  250. .name {
  251. font-size: var(--font14Size);
  252. }
  253. .other {
  254. color: var(--f85Color);
  255. font-size: var(--font12Size);
  256. }
  257. .right_1 {
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. .money {
  262. color: var(--fF0Color);
  263. font-size: var(--font12Size);
  264. text:first-child {
  265. font-size: var(--font18Size);
  266. }
  267. }
  268. .button {
  269. background-color: var(--fFFColor);
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. .scroll-view {
  277. position: absolute;
  278. top: 0;
  279. left: 0;
  280. right: 0;
  281. bottom: 0;
  282. .list-scroll-view {
  283. display: flex;
  284. flex-direction: column;
  285. }
  286. }
  287. .is_bottom {
  288. width: 100%;
  289. text-align: center;
  290. text {
  291. padding: 2vw 0;
  292. display: inline-block;
  293. color: var(--f85Color);
  294. font-size: var(--font12Size);
  295. }
  296. }
  297. </style>