carDetail.vue 6.7 KB

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