carDetail.vue 7.7 KB

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