carRentalList.vue 10.0 KB

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