carDetail.vue 6.8 KB

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