index.vue 7.2 KB

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