carDetail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 style="width: 100%;height: 100%;" class="swiper-item-img" :src="item" mode="aspectFit"></image>
  10. </swiper-item>
  11. </swiper>
  12. <image v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" mode="aspectFit">
  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">{{ $t('日租') }}</text>
  24. <text v-if="item.hire_duration_unit==2">{{ $t('月租') }}</text>
  25. <text v-if="item.hire_duration_unit==3">{{ $t('年租') }}</text>
  26. <text v-if="item.hire_duration_unit==4">{{ $t('时租') }}</text>
  27. <text v-if="item.hire_duration_unit==5">{{ $t('分租') }}</text>
  28. <text v-if="item.hire_duration_unit==6">{{ $t('周租') }}</text>
  29. <text v-if="item.hire_duration_unit==7">{{ $t('季租') }}</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':'']">{{ $t('购买') }}</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">{{ $t('免费换电次数') }}</text>
  41. </view>
  42. <view class="free-num-time">1 {{ $t('次') }}/{{ $t('日') }}</view>
  43. </view>
  44. <view class="free-num-tip">{{ $t('日租享') }}1{{ $t('次免费换电数,超出后需要单独支付换电费用;') }}</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.model_desc" :nodes="car_detail.model_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">{{ $t('我要用车') }}</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 config = require('@/common/config.js');
  104. var common = require('@/common/common.js');
  105. var http = require('@/common/http.js');
  106. var storage = require('@/common/storage.js');
  107. export default {
  108. data() {
  109. return {
  110. shop_type:0,
  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. console.log(options.shop_type,99999999)
  132. this.shop_type = options.shop_type
  133. const d = {
  134. hire_duration_unit:options.shop_type,
  135. hire_price:Number(options.hire_price)
  136. }
  137. this.tapSelectType(d)
  138. }
  139. // this.loadCarInfo()
  140. // getFlatternDistance 获取直线距离
  141. },
  142. onPageScroll(e) {
  143. this.scrollTop = e.scrollTop
  144. },
  145. methods: {
  146. locationFn() {
  147. this.loadCarInfo(this.myLocation.longitude, this.myLocation.latitude)
  148. },
  149. loadCarInfo(latitude, longitude) {
  150. const me = this
  151. http.postApi(config.API_FLK_INDEX_CAR_MODEL_DETAIL, {
  152. model_id: me.model_id,
  153. latitude: latitude,
  154. longitude: longitude,
  155. }, (resp) => {
  156. if (resp.data.code === 200) {
  157. // resp.data.data.desc = resp.data.data.desc.replaceAll('/<img\b/gi, '$& style="1"'')
  158. // me.tapSelectType(resp.data.data.rental_setting[0])
  159. resp.data.data.distance = common.formatDistance(Number(resp.data.data.distance))
  160. resp.data.data.desc = this.$htmlData(resp.data.data.desc)
  161. me.setData({
  162. car_detail: resp.data.data,
  163. // price: ((resp.data.data.rental_setting[0]?.hire_price || 0) / 100).toFixed(2)
  164. })
  165. if(!me.shop_type){
  166. resp.data.data.rental_setting.map((item,index)=>{
  167. if(index === 0){
  168. me.tapSelectType({
  169. hire_duration_unit:item.hire_duration_unit,
  170. hire_price:Number(item.hire_price),
  171. })
  172. }
  173. })
  174. }
  175. } else {
  176. common.simpleToast(resp.data.msg);
  177. }
  178. })
  179. },
  180. tapSelectType(e) {
  181. const {
  182. hire_duration_unit,
  183. hire_price
  184. } = e
  185. console.log(66666666)
  186. console.log(hire_price)
  187. console.log(hire_duration_unit)
  188. this.setData({
  189. selectType: hire_duration_unit,
  190. price: (hire_price / 100).toFixed(2)
  191. })
  192. },
  193. tapCallPhone() {
  194. const me = this
  195. const phone = this.car_detail.link_phone
  196. // const phone = 18170410707
  197. uni.showModal({
  198. content: `${this.$t('您是否要拨打电话')+phone}?`,
  199. confirmText: this.$t('确定'),
  200. success: (res) => {
  201. if (res.confirm) {
  202. uni.makePhoneCall({
  203. phoneNumber: phone,
  204. })
  205. }
  206. },
  207. fail: (res) => {}
  208. })
  209. },
  210. navAddress() {
  211. const {
  212. address,
  213. latitude,
  214. longitude,
  215. shop_name
  216. } = this.car_detail
  217. uni.openLocation({
  218. latitude: latitude - 0,
  219. longitude: longitude - 0,
  220. scale: 15,
  221. name: shop_name,
  222. address: address,
  223. success: function(res) {},
  224. })
  225. },
  226. useCarBtn() {
  227. const pData = {
  228. ...this.car_detail,
  229. price: this.price
  230. }
  231. this.setData({
  232. showCarPlan: true,
  233. params: pData
  234. })
  235. },
  236. changeSelectType(select_type, price) {
  237. this.setData({
  238. selectType: select_type,
  239. price: (price / 100).toFixed(2)
  240. })
  241. },
  242. closeShowMore() {
  243. this.setData({
  244. showCarPlan: false
  245. })
  246. }
  247. }
  248. };
  249. </script>
  250. <style>
  251. @import './carDetail.css';
  252. .nodes{
  253. color: #333;
  254. font-size: 28rpx;
  255. padding: 34rpx 32rpx 32rpx;
  256. }
  257. </style>