carDetail.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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="navAddress">
  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 class="nodes">
  77. <rich-text v-if="car_detail.desc" nodes="car_detail.desc"></rich-text>
  78. </view>
  79. <view style="height: 150rpx;"></view>
  80. <view class="use-car-view flex-row">
  81. <view @tap="useCarBtn" class="use-car-btn">我要用车</view>
  82. </view>
  83. <carPlan v-if="showCarPlan" @changeSelectType="changeSelectType" @closeShowMore="closeShowMore" :params="params"
  84. :selectType="selectType" />
  85. </view>
  86. </view>
  87. </template>
  88. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  89. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  90. <script>
  91. import CarPlan from '@/component/carPlan/carPlan';
  92. import UseGuidance from '@/component/useGuidance/useGuidance';
  93. import allPrice from '@/component/allPrice/allPrice';
  94. import {
  95. LEASE_TYPE_ARR
  96. } from '@/common/constant.js'
  97. var app = getApp();
  98. var config = require('@/common/config.js');
  99. var common = require('@/common/common.js');
  100. var http = require('@/common/http.js');
  101. var storage = require('@/common/storage.js');
  102. export default {
  103. data() {
  104. return {
  105. recommend_id: '',
  106. car_detail: {},
  107. showCarPlan: false,
  108. selectType: 1,
  109. myLocation: {
  110. latitude: 23.099994,
  111. longitude: 113.324004,
  112. },
  113. destance: 0,
  114. price: 0,
  115. params: {}
  116. };
  117. },
  118. components: {
  119. CarPlan,
  120. UseGuidance,
  121. allPrice
  122. },
  123. onLoad: function(options) {
  124. if (options.model_id) {
  125. this.model_id = options.model_id
  126. this.locationFn()
  127. }
  128. // this.loadCarInfo()
  129. // getFlatternDistance 获取直线距离
  130. },
  131. methods: {
  132. locationFn() {
  133. let _this = this
  134. uni.getLocation({
  135. success(res) {
  136. _this.loadCarInfo(res.longitude, res.latitude)
  137. }
  138. })
  139. },
  140. loadCarInfo(latitude, longitude) {
  141. const me = this
  142. http.postApi(config.API_FLK_INDEX_CAR_MODEL_DETAIL, {
  143. model_id: me.model_id,
  144. latitude: latitude,
  145. longitude: longitude,
  146. }, (resp) => {
  147. if (resp.data.code === 200) {
  148. me.tapSelectType(resp.data.data.rental_setting[0])
  149. resp.data.data.distance = common.formatDistance(Number(resp.data.data.distance))
  150. me.setData({
  151. car_detail: resp.data.data,
  152. price: ((resp.data.data.rental_setting[0]?.hire_price || 0) / 100).toFixed(2)
  153. })
  154. } else {
  155. common.simpleToast(resp.data.msg);
  156. }
  157. })
  158. },
  159. tapSelectType(e) {
  160. const {
  161. hire_duration_unit,
  162. hire_price
  163. } = e
  164. this.setData({
  165. selectType: hire_duration_unit,
  166. price: (hire_price / 100).toFixed(2)
  167. })
  168. },
  169. tapCallPhone() {
  170. const me = this
  171. const phone = this.car_detail.link_phone
  172. // const phone = 18170410707
  173. uni.showModal({
  174. content: `您是否要拨打电话${phone}?`,
  175. confirmText: '确定',
  176. success: (res) => {
  177. if (res.confirm) {
  178. uni.makePhoneCall({
  179. phoneNumber: phone,
  180. success() {},
  181. fail() {}
  182. })
  183. }
  184. },
  185. fail: (res) => {}
  186. })
  187. },
  188. navAddress() {
  189. const {
  190. address,
  191. latitude,
  192. longitude,
  193. shop_name
  194. } = this.car_detail
  195. uni.openLocation({
  196. latitude: latitude - 0,
  197. longitude: longitude - 0,
  198. scale: 15,
  199. name: shop_name,
  200. address: address,
  201. success: function(res) {},
  202. })
  203. },
  204. useCarBtn() {
  205. const pData = {
  206. ...this.car_detail,
  207. price: this.price
  208. }
  209. this.setData({
  210. showCarPlan: true,
  211. params: pData
  212. })
  213. },
  214. changeSelectType(select_type, price) {
  215. this.setData({
  216. selectType: select_type,
  217. price: (price / 100).toFixed(2)
  218. })
  219. },
  220. closeShowMore() {
  221. this.setData({
  222. showCarPlan: false
  223. })
  224. }
  225. }
  226. };
  227. </script>
  228. <style>
  229. @import './carDetail.css';
  230. </style>