index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="bg">
  3. <headerSerch v-if="headerData" :dataConfig="headerData"></headerSerch>
  4. <view class="navTitle">
  5. <view class="left_tab" @click="navTabIndex==0">租车</view>
  6. <view class="right_tab">
  7. <tabNav v-if="tabNavData" :dataConfig="tabNavData" @bindSortId="bindSortId"></tabNav>
  8. </view>
  9. </view>
  10. <view v-if="navTabIndex==0">
  11. <swiperBg v-if="swiperBgData" :dataConfig="swiperBgData"></swiperBg>
  12. </view>
  13. <view v-if="navTabIndex==1">
  14. </view>
  15. <view class="acea-row item row-between row-middle">
  16. <view class="acea-row left">
  17. <image class="icon" src="../../static/images/homeLeftIcon.png" mode="scaleToFill"></image>
  18. <view>
  19. 火热租车
  20. </view>
  21. </view>
  22. <!-- <view class="right">
  23. 更多>
  24. </view> -->
  25. </view>
  26. <view class="list acea-row row-between ">
  27. <view class="ls" v-for="(item,ind) in carList" :key='ind'>
  28. <image class="img" :src="item.image" mode="scaleToFill"></image>
  29. <view class="content">
  30. <view class="line1 title">
  31. {{item.title}}
  32. </view>
  33. <view class="info line1">
  34. {{item.info}}
  35. </view>
  36. <view class="acea-row row-middle">
  37. <text class="price">
  38. ¥{{+item.price}}
  39. </text>
  40. <text class="tip">
  41. /月
  42. </text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <pageFoot></pageFoot>
  48. </view>
  49. </template>
  50. <script>
  51. import pageFoot from '@/components/pageFooter/index.vue';
  52. import headerSerch from '../index/diy/components/headerSerch.vue';
  53. import swiperBg from '../index/diy/components/swiperBg';
  54. import tabNav from '../index/diy/components/tabNav';
  55. import {
  56. getDiy
  57. } from '@/api/api.js';
  58. import {
  59. getCarList
  60. } from '@/api/rent.js';
  61. export default {
  62. data() {
  63. return {
  64. headerData: '', //搜索栏设置数据
  65. tabNavData: '', //分类设置数据
  66. swiperBgData: '', //轮播图设置数据
  67. navTabIndex: 0, //0租车1为商品
  68. carList: [],
  69. page: 1,
  70. limit: 10,
  71. loading: 'more', //加载状态more/loding/nomore
  72. }
  73. },
  74. components: {
  75. pageFoot,
  76. headerSerch,
  77. tabNav,
  78. swiperBg
  79. },
  80. onShow() {
  81. uni.hideTabBar()
  82. this.getSearch();
  83. this.getCarList();
  84. },
  85. onReachBottom() {
  86. this.getCarList();
  87. },
  88. methods: {
  89. bindSortId(data) {
  90. console.log(data)
  91. },
  92. // 获取车辆列表
  93. getCarList() {
  94. const that = this;
  95. if (that.loading == 'loding' || that.loading == 'nomore') {
  96. return
  97. }
  98. that.loading = 'loding'
  99. getCarList({
  100. page: that.page,
  101. limit: that.limit,
  102. }).then((res) => {
  103. that.carList = that.carList.concat(res.data.list);
  104. that.page++
  105. if (res.data.list.length == that.limit) {
  106. that.loading = 'more'
  107. } else {
  108. that.loading = 'nomore'
  109. }
  110. }).catch((res) => {
  111. console.log(res);
  112. that.loading = 'more'
  113. })
  114. },
  115. getSearch() {
  116. const that = this;
  117. getDiy(0).then(res => {
  118. let lastArr = that.objToArr(res.data.value);
  119. for (var i = 0; i < lastArr.length; i++) {
  120. if (lastArr[i].name == 'headerSerch') {
  121. that.headerData = lastArr[i]
  122. }
  123. if (lastArr[i].name == 'tabNav') {
  124. that.tabNavData = lastArr[i]
  125. }
  126. if (lastArr[i].name == 'swiperBg') {
  127. that.swiperBgData = lastArr[i]
  128. }
  129. }
  130. })
  131. },
  132. // 对象转数组
  133. objToArr(data) {
  134. let obj = Object.keys(data);
  135. let m = obj.map(key => data[key]);
  136. return m;
  137. },
  138. },
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .navTitle {
  143. display: flex;
  144. align-items: center;
  145. background-color: rgb(31, 33, 52);
  146. line-height: 0;
  147. padding-left: 30rpx;
  148. padding-bottom: 20rpx;
  149. .left_tab {
  150. background-image: url('../../static/images/hometext.png');
  151. background-size: 100%;
  152. width: 120rpx;
  153. text-align: center;
  154. color: #75EFFA;
  155. line-height: 1;
  156. font-size: 34rpx;
  157. font-weight: bold;
  158. padding: 10rpx 0;
  159. }
  160. .right_tab {
  161. width: 600rpx;
  162. }
  163. }
  164. .bg {
  165. background-color: rgb(31, 33, 52);
  166. }
  167. .item {
  168. line-height: 1;
  169. padding: 30rpx 20rpx;
  170. .left {
  171. font-size: $uni-font-size-lg;
  172. color: #FFFFFF;
  173. .icon {
  174. width: 36rpx;
  175. height: 36rpx;
  176. margin-right: 10rpx;
  177. }
  178. }
  179. .right {
  180. color: #999999;
  181. font-size: $uni-font-size-sm;
  182. }
  183. }
  184. .list {
  185. padding: 0rpx 20rpx;
  186. padding-bottom: 128rpx;
  187. .ls {
  188. width: 344rpx;
  189. border-radius: 10rpx;
  190. background-color: #161726;
  191. color: #989898;
  192. margin-bottom: 20rpx;
  193. .content {
  194. padding: 20rpx 10rpx;
  195. .title {
  196. font-size: $uni-font-size-base;
  197. color: #FFFFFF;
  198. font-weight: bold;
  199. }
  200. .info {
  201. padding: 10rpx 0;
  202. }
  203. .price {
  204. font-weight: bold;
  205. color: #75EFFA;
  206. font-size: 36rpx;
  207. }
  208. .tip {
  209. color: #FFFFFF;
  210. font-size: $uni-font-size-sm;
  211. }
  212. }
  213. .img {
  214. width: 344rpx;
  215. height: 344rpx;
  216. border-radius: 10rpx;
  217. background-color: #FFFFFF;
  218. }
  219. }
  220. }
  221. </style>