carDetail.vue 6.8 KB

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