carDetail.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view>
  3. <view class="car-detail-main">
  4. <Navigation :scroll='scrollTop'></Navigation>
  5. <view class="store-img-view">
  6. <swiper v-if="car_detail.model_images && car_detail.model_images.length!=0" class="swiper" :indicator-dots="true" :autoplay="true" :interval="2000"
  7. indicator-color="rgba(0, 0, 0, 0.3)" indicator-active-color="#000000" :duration="1000" circular>
  8. <swiper-item class="swiper-item" v-for="(item,index) in car_detail.model_images" :key="index">
  9. <image class="swiper-item-img" :src="item" mode="aspectFill"></image>
  10. </swiper-item>
  11. </swiper>
  12. <image v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" mode="aspectFill">
  13. </image>
  14. </view>
  15. <view class="car-detail-model">
  16. <view class="car-detail-name">{{car_detail.car_model_name}}</view>
  17. <view class="car-detail-price">
  18. <allPrice :amount="Number(price)" />
  19. </view>
  20. <view style="flex-wrap: wrap;justify-content: flex-start;" class="flex-row car-detail-time">
  21. <view v-for="(item,index) in car_detail.rental_setting" :key="index" @click="tapSelectType(item)"
  22. :class="['time-unit',selectType==item.hire_duration_unit? 'time-unit-i':'']">
  23. <text v-if="item.hire_duration_unit==1">日租</text>
  24. <text v-if="item.hire_duration_unit==2">月租</text>
  25. <text v-if="item.hire_duration_unit==3">年租</text>
  26. <text v-if="item.hire_duration_unit==4">时租</text>
  27. <text v-if="item.hire_duration_unit==5">分租</text>
  28. <text v-if="item.hire_duration_unit==6">周租</text>
  29. <text v-if="item.hire_duration_unit==7">季租</text>
  30. </view>
  31. <view v-if="car_detail.sell_price != 0" @click="tapSelectType({hire_duration_unit:100,hire_price:car_detail.sell_price})"
  32. :data-select_type="100" :data-price="car_detail.sell_price"
  33. :class="['time-unit',selectType==100? 'time-unit-i':'']">购买</view>
  34. </view>
  35. </view>
  36. <!-- <view class="free-num-model">
  37. <view class="flex-row flex-between">
  38. <view class="free-num-view">
  39. <img style="width: 40rpx;height: 40rpx;" src="https://qiniu.bms16.com/FtlfBtBE5-TeTI5EdrciX_u8u_Sx" alt="">
  40. <text class="free-num-text">免费换电次数</text>
  41. </view>
  42. <view class="free-num-time">1 次/日</view>
  43. </view>
  44. <view class="free-num-tip">日租享1次免费换电数,超出后需要单独支付换电费用;</view>
  45. </view> -->
  46. <useGuidance />
  47. <view class="card-car-detail">
  48. <view class="step-title-view flex-row align-center">
  49. <img style="width: 208rpx;height: 40rpx;" src="https://qiniu.bms16.com/Fms8V0l4bNwGUgWwkdRku4dIx_tt"
  50. alt="">
  51. <img style="width: 86rpx;height: 80rpx;" src="https://qiniu.bms16.com/FibAaPERzqi6m95EP2jREUKixjUi"
  52. alt="">
  53. <view class="w-bg flex-row"></view>
  54. </view>
  55. <view class="step-car-view">
  56. <view class="step-img-view"></view>
  57. <view class="flex-row flex-between" style="margin-bottom: 24rpx;">
  58. <view class="store-name-view">
  59. <view>{{car_detail.shop_name}}</view>
  60. <view class="address-txt">{{car_detail.address}}</view>
  61. </view>
  62. <view class="distance-num">{{car_detail.distance}}m</view>
  63. </view>
  64. <view class="flex-row flex-between align-center">
  65. <view class="time-view flex-row alert-center">
  66. <img class="time-icon" src="https://qiniu.bms16.com/FlGVpR2fdrD1GfeHfDgt-dUMgkOq" alt="">
  67. <text>{{car_detail.work_begin_time + '-' + car_detail.work_end_time}}</text>
  68. </view>
  69. <view class="phone-or-nav flex-row">
  70. <view @tap="tapCallPhone">
  71. <img style="width: 84rpx;height: 64rpx;margin-right: 20rpx;"
  72. src="https://qiniu.bms16.com/FkZYljvsgGtXUGnQaA0wk_sbjlUC" alt="">
  73. </view>
  74. <view @tap="navAddress">
  75. <img style="width: 112rpx;height: 64rpx;"
  76. src="https://qiniu.bms16.com/Fts38M35doVjK09GfOza5qD-wwkK" alt="">
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="nodes">
  83. <rich-text v-if="car_detail.desc" :nodes="car_detail.desc"></rich-text>
  84. </view>
  85. <view style="height: 150rpx;"></view>
  86. <view class="use-car-view flex-row">
  87. <view @tap="useCarBtn" class="use-car-btn">我要用车</view>
  88. </view>
  89. <carPlan v-if="showCarPlan" @changeSelectType="changeSelectType" @closeShowMore="closeShowMore" :params="params"
  90. :selectType="selectType" />
  91. </view>
  92. </view>
  93. </template>
  94. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  95. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  96. <script>
  97. import CarPlan from '@/component/carPlan/carPlan';
  98. import UseGuidance from '@/component/useGuidance/useGuidance';
  99. import allPrice from '@/component/allPrice/allPrice';
  100. import {
  101. LEASE_TYPE_ARR
  102. } from '@/common/constant.js'
  103. var app = getApp();
  104. var config = require('@/common/config.js');
  105. var common = require('@/common/common.js');
  106. var http = require('@/common/http.js');
  107. var storage = require('@/common/storage.js');
  108. export default {
  109. data() {
  110. return {
  111. recommend_id: '',
  112. car_detail: {},
  113. showCarPlan: false,
  114. selectType: 1,
  115. destance: 0,
  116. price: 0,
  117. params: {}
  118. };
  119. },
  120. components: {
  121. CarPlan,
  122. UseGuidance,
  123. allPrice
  124. },
  125. onLoad: function(options) {
  126. if (options.model_id) {
  127. this.model_id = options.model_id
  128. this.locationFn()
  129. }
  130. if (options.shop_type) {
  131. const d = {
  132. hire_duration_unit:options.shop_type,
  133. hire_price:Number(options.hire_price)
  134. }
  135. this.tapSelectType(d)
  136. }
  137. // this.loadCarInfo()
  138. // getFlatternDistance 获取直线距离
  139. },
  140. onPageScroll(e) {
  141. this.scrollTop = e.scrollTop
  142. },
  143. methods: {
  144. locationFn() {
  145. this.loadCarInfo(this.myLocation.longitude, this.myLocation.latitude)
  146. },
  147. loadCarInfo(latitude, longitude) {
  148. const me = this
  149. http.postApi(config.API_FLK_INDEX_CAR_MODEL_DETAIL, {
  150. model_id: me.model_id,
  151. latitude: latitude,
  152. longitude: longitude,
  153. }, (resp) => {
  154. if (resp.data.code === 200) {
  155. // resp.data.data.desc = resp.data.data.desc.replaceAll('/<img\b/gi, '$& style="1"'')
  156. // me.tapSelectType(resp.data.data.rental_setting[0])
  157. resp.data.data.distance = common.formatDistance(Number(resp.data.data.distance))
  158. resp.data.data.desc = this.$htmlData(resp.data.data.desc)
  159. me.setData({
  160. car_detail: resp.data.data,
  161. // price: ((resp.data.data.rental_setting[0]?.hire_price || 0) / 100).toFixed(2)
  162. })
  163. } else {
  164. common.simpleToast(resp.data.msg);
  165. }
  166. })
  167. },
  168. tapSelectType(e) {
  169. const {
  170. hire_duration_unit,
  171. hire_price
  172. } = e
  173. this.setData({
  174. selectType: hire_duration_unit,
  175. price: (hire_price / 100).toFixed(2)
  176. })
  177. },
  178. tapCallPhone() {
  179. const me = this
  180. const phone = this.car_detail.link_phone
  181. // const phone = 18170410707
  182. uni.showModal({
  183. content: `您是否要拨打电话${phone}?`,
  184. confirmText: '确定',
  185. success: (res) => {
  186. if (res.confirm) {
  187. uni.makePhoneCall({
  188. phoneNumber: phone,
  189. })
  190. }
  191. },
  192. fail: (res) => {}
  193. })
  194. },
  195. navAddress() {
  196. const {
  197. address,
  198. latitude,
  199. longitude,
  200. shop_name
  201. } = this.car_detail
  202. uni.openLocation({
  203. latitude: latitude - 0,
  204. longitude: longitude - 0,
  205. scale: 15,
  206. name: shop_name,
  207. address: address,
  208. success: function(res) {},
  209. })
  210. },
  211. useCarBtn() {
  212. const pData = {
  213. ...this.car_detail,
  214. price: this.price
  215. }
  216. this.setData({
  217. showCarPlan: true,
  218. params: pData
  219. })
  220. },
  221. changeSelectType(select_type, price) {
  222. this.setData({
  223. selectType: select_type,
  224. price: (price / 100).toFixed(2)
  225. })
  226. },
  227. closeShowMore() {
  228. this.setData({
  229. showCarPlan: false
  230. })
  231. }
  232. }
  233. };
  234. </script>
  235. <style>
  236. @import './carDetail.css';
  237. .nodes{
  238. color: #333;
  239. font-size: 28rpx;
  240. padding: 34rpx 32rpx 32rpx;
  241. }
  242. </style>