index.vue 8.2 KB

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