carRentalList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view>
  3. <block>
  4. <view :class='{"active" : activeMarkersId == item.id}' class="store-card" v-if="item.admin_id"
  5. @click="navToStore(item.admin_id)" v-for="(item, index) in near_store_list" :key="index">
  6. <view>
  7. <view class="card-top-style flex-row flex-between">
  8. <view class="shop_name">{{item.shop_name}}</view>
  9. <view>{{item.distance}}</view>
  10. </view>
  11. <view class="card-center-ren flex-row">
  12. <view style="color: #0A59F7;border-color: #0A59F7;" v-for="(items,indexs) of item.business_list"
  13. :key="indexs" class=" tag align-c">
  14. {{items.title}}
  15. </view>
  16. <view class="align-c tag">
  17. <text class="card-center-num">{{item.model_list.length}}</text>
  18. 款车型
  19. </view>
  20. </view>
  21. </view>
  22. <view v-if="item.model_list.length===1">
  23. <view @click.stop="$srcFn(`/pages/carDetail/carDetail?model_id=${item.model_list[0].model_id}&shop_type=${shopType}&hire_price=${item.model_list[0].hire_price}`)"
  24. class="card-bottom card-first flex-row">
  25. <view class="second-view flex-row">
  26. <view>
  27. <image
  28. :src="item.model_list[0]!=''?item.model_list[0].model_images:'https://qiniu.bms16.com/FhEvnKUckAHPtWaC04mi2s53IEVj'"
  29. mode="aspectFill"></image>
  30. </view>
  31. <view class="bottom-item">
  32. <view>{{item.model_list[0].model_name}}</view>
  33. <view>
  34. 续航{{ tools.formatDistance(item.model_list[0].endurance-0) }}|重量{{ tools.formatWeight(item.model_list[0].weight-0) }}
  35. </view>
  36. <view class="flex-row flex-between">
  37. <view class="bottom-text">
  38. {{ leaseUnitsResult }} <text
  39. style="margin-left: 10rpx;">¥</text><text>{{item.model_list[0].hire_price}}</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <scroll-view v-if="item.model_list.length>1" :scroll-into-view="'into'+into" scroll-x="true" enable-flex
  47. class="scrollview-box" scroll-with-animation @scroll="onScroll">
  48. <view @click.stop="$srcFn(`/pages/carDetail/carDetail?model_id=${items.model_id}&shop_type=${shopType}&hire_price=${item.model_list[0].hire_price}`)"
  49. v-for="(items,index) in item.model_list" :key="index"
  50. :style="{ marginLeft: index > 0 ? '32rpx' : '0' }" class="form-item" :data-item="items">
  51. <view class="second-view flex-row">
  52. <view>
  53. <image
  54. :src="items.model_images || 'https://qiniu.bms16.com/FhEvnKUckAHPtWaC04mi2s53IEVj'"
  55. mode="aspectFill"></image>
  56. </view>
  57. <view class="bottom-item">
  58. <view>{{ items.model_name }}</view>
  59. <view>
  60. 续航{{ tools.formatDistance(items.endurance-0) }}|重量{{ tools.formatWeight(items.weight-0) }}
  61. </view>
  62. <view class="flex-row flex-between">
  63. <view class="bottom-text">
  64. {{ leaseUnitsResult }}<text
  65. style="margin-left: 10rpx;">¥</text><text>{{(items.hire_price /100).toFixed(1)}}</text>
  66. </view>
  67. <view v-if="items.sell_price && isBuy" class="bottom-text">
  68. 购买<text
  69. style="margin-left: 10rpx;">¥</text><text>{{(items.sell_price /100).toFixed(1)}}</text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </scroll-view>
  76. <view style="margin-top: 20rpx;" class="flex-row flex-between">
  77. <view class="align-center flex-row time-style-view">
  78. <img style="width: 40rpx;height: 40rpx;"
  79. src="https://qiniu.bms16.com/Fp-G1pdXxnTV-G3qFbgS453AuqcU" alt="">
  80. <text style="margin-left: 2rpx;">{{item.work_begin_time+'-'+item.work_end_time}}</text>
  81. </view>
  82. <view class="flex-row align-center">
  83. <view>
  84. <image @click.stop="callFn(item.link_phone)" style="width: 84rpx;height: 64rpx;"
  85. src="https://qiniu.bms16.com/Ft0YA1JYmq66hdoeEN-PgBHy5vLa" mode=""></image>
  86. </view>
  87. <view style="margin-left: 20rpx;">
  88. <image @click.stop="bindToNav(item)" style="width: 112rpx;height: 64rpx;"
  89. src="https://qiniu.bms16.com/Fts38M35doVjK09GfOza5qD-wwkK" mode=""></image>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </block>
  95. </view>
  96. </template>
  97. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  98. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  99. <script>
  100. // let config = require('../../../common/config.js');
  101. // let common = require('../../../common/common.js');
  102. // let http = require('../../../common/http.js');
  103. // let storage = require('../../../common/storage.js');
  104. import {
  105. LEASE_TYPE_ARR
  106. } from '@/common/constant.js'
  107. import {
  108. loginToast
  109. } from '@/utils'
  110. export default {
  111. computed: {
  112. leaseUnitsResult() {
  113. const result = LEASE_TYPE_ARR.find(v => v.value == this.shopType);
  114. return result ? result.label : '';
  115. },
  116. leaseUnits() {
  117. const result = LEASE_TYPE_ARR.find(v => v.value == this.shopType);
  118. return result ? result.unit : '';
  119. }
  120. },
  121. props: {
  122. isBuy: {
  123. type: Boolean,
  124. defult: true
  125. },
  126. shopType: {
  127. type: Number,
  128. defult: 1
  129. },
  130. params: {
  131. type: Object
  132. },
  133. near_store_list: {
  134. type: Array,
  135. defult: []
  136. },
  137. activeMarkersId: {
  138. type: Number,
  139. defult: 0
  140. }
  141. },
  142. data() {
  143. return {
  144. isDropDown: false,
  145. isDropMoney: false,
  146. citycode: '', //城市代码
  147. desc_adress: '', // 我的位置
  148. takeCar: '', // 取车时间
  149. returnCar: '', // 还车时间
  150. leaseTime: '', // 租借时长
  151. rentalUnit: '', // 租借时长单位
  152. longitude: '', // 经度
  153. latitude: '', // 纬度
  154. duration_unit: 0, //周期单位
  155. desc_city: '', //选中城市
  156. startDate: '',
  157. currentCity: true, //是否为当前城市
  158. page: 1,
  159. limit: 20,
  160. hire_return_type: 0, // 还车方式
  161. open_freeze: 0, //是否免押
  162. shopModelList: [],
  163. icBatteryIndex: 0,
  164. into: 0,
  165. // all_num: 0,
  166. // distance: '',
  167. isShowStore: false,
  168. model_list: [],
  169. shopModelListView: []
  170. };
  171. },
  172. watch: {
  173. // params: {
  174. // handler(val, oldVal) {
  175. // if (!val.desc_adress) return
  176. // this.$_getData(val, oldVal)
  177. // }
  178. // }
  179. },
  180. methods: {
  181. bindToNav(item) {
  182. const {
  183. latitude,
  184. longitude,
  185. shop_name
  186. } = item
  187. uni.openLocation({
  188. latitude: latitude - 0,
  189. longitude: longitude - 0,
  190. scale: 15,
  191. name: shop_name,
  192. })
  193. },
  194. callFn(tel) {
  195. uni.showModal({
  196. content: `您是否要拨打电话${tel}?`,
  197. confirmText: '确定',
  198. success: (res) => {
  199. if (res.confirm) {
  200. uni.makePhoneCall({
  201. phoneNumber: tel,
  202. })
  203. }
  204. },
  205. })
  206. },
  207. curType() {
  208. // const obj = LEASE_TYPE_ARR.find(v => v.value == this.duration_unit)
  209. // return obj && obj.label
  210. return '租'
  211. },
  212. async navToStore(admin_id) {
  213. const url = '/pages/storeDetails/storeDetails?admin_id=' + admin_id
  214. uni.navigateTo({
  215. url
  216. })
  217. },
  218. $_getData(val, oldVal = {}) {
  219. const oldValObj = oldVal || {}
  220. this.setData({
  221. rentalUnit: val.rentalUnit || '',
  222. desc_adress: val.desc_adress || '',
  223. takeCar: val.takeCar || '',
  224. leaseTime: val.leaseTime || ''
  225. })
  226. this.returnCar = val.returnCar || ''
  227. this.duration_unit = val.duration_unit || ''
  228. this.longitude = val.longitude || ''
  229. this.latitude = val.latitude || ''
  230. this.desc_city = val.desc_city || ''
  231. this.startDate = val.startDate || ''
  232. // 位置是否改变
  233. const isChangeLocation = (val.latitude !== oldValObj.latitude) || (val.longitude !== oldValObj.longitude)
  234. if (!this.shopModelList.length || isChangeLocation) {
  235. this.loadShopModelList()
  236. } else {
  237. this.loadFilteredList()
  238. }
  239. },
  240. loadShopModelList() {
  241. let me = this
  242. http.postApi(config.API_DAYHIRE_USER_SHOP_MODEL_LIST, {
  243. page: me.page,
  244. limit: me.limit,
  245. hire_return_type: me.hire_return_type,
  246. open_freeze: me.open_freeze,
  247. longitude: me.longitude,
  248. latitude: me.latitude
  249. }, (resp) => {
  250. if (resp.data.code === 200) {
  251. me.shopModelList = resp.data.data.list
  252. me.loadFilteredList()
  253. } else {
  254. common.simpleToast(resp.data.msg)
  255. }
  256. })
  257. },
  258. //加上距离数量门店数据
  259. recombineShopModelList(shopModelList) {
  260. let me = this
  261. shopModelList = shopModelList.map((item, index) => {
  262. if (item.model_list && Array.isArray(item.model_list)) {
  263. let all_num = 0
  264. let distance = ''
  265. for (let i = 0; item.model_list.length > i; i++) {
  266. let model_item = item.model_list[i]
  267. all_num += item.model_list[i].car_num - 0
  268. distance = common.formatDistance(item.distance)
  269. }
  270. item.all_num = all_num
  271. item.distance = distance
  272. item.model_list.map(items => {
  273. items.model_images = items.model_images
  274. items.total_price = (me.leaseTime * (items.price_setting[0].hire_price - 0)) /
  275. 100
  276. return item
  277. })
  278. }
  279. return item;
  280. });
  281. return shopModelList
  282. },
  283. //判断当前是否有租赁周期类型
  284. loadFilteredList() {
  285. let shopModelList = []
  286. const list = this.$u.deepClone(this.shopModelList)
  287. for (let i = 0; list.length > i; i++) {
  288. let searchIndex = false
  289. let item = list[i]
  290. if (!(item.model_list && Array.isArray(item.model_list))) return
  291. item.model_list = item.model_list.filter(items => items.car_num !== 0);
  292. let model_list = []
  293. for (let j = 0; item.model_list.length > j; j++) {
  294. let price_setting_list = item.model_list[j].price_setting
  295. price_setting_list = price_setting_list.filter(items => this.duration_unit == items
  296. .hire_duration_unit);
  297. if (!common.isObjectEmpty(price_setting_list)) {
  298. searchIndex = true
  299. item.model_list[j].price_setting = price_setting_list
  300. model_list.push(item.model_list[j])
  301. }
  302. }
  303. if (searchIndex) {
  304. item.model_list = model_list
  305. shopModelList.push(item)
  306. }
  307. }
  308. shopModelList = this.recombineShopModelList(shopModelList)
  309. this.setData({
  310. shopModelListView: shopModelList
  311. })
  312. },
  313. navToPage(e) {
  314. let url = e.currentTarget.dataset.url;
  315. if (!url) {
  316. return;
  317. }
  318. uni.navigateTo({
  319. url: url
  320. });
  321. },
  322. bindDropDown() {
  323. this.isDropDown = !this.isDropDown
  324. this.isDropMoney = false
  325. },
  326. bindDropMoney() {
  327. this.isDropMoney = !this.isDropMoney
  328. this.isDropDown = false
  329. },
  330. bindWaySelect(e) {
  331. let hire_return_type = e.target.dataset.status;
  332. this.setData({
  333. hire_return_type: hire_return_type
  334. })
  335. this.loadShopModelList()
  336. this.isDropDown = false
  337. },
  338. bindMoneySelect(e) {
  339. this.open_freeze = e.target.dataset.status;
  340. this.loadShopModelList()
  341. this.isDropMoney = false
  342. },
  343. onScroll(e) {
  344. let scrollX = e.detail.scrollLeft
  345. // if (scrollX % 356 > 178) {
  346. this.setData({
  347. into: Math.round(scrollX / 356)
  348. })
  349. // }
  350. },
  351. }
  352. };
  353. </script>
  354. <style scoped>
  355. @import url("./carRentalList.css");
  356. </style>