carDetail.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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;" :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="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. console.log(options, 'options');
  114. if(options.model_id){
  115. this.model_id=options.model_id
  116. this.loadCarInfo()
  117. }
  118. // this.loadCarInfo()
  119. // getFlatternDistance 获取直线距离
  120. },
  121. methods: {
  122. async locationFn() {
  123. let res = await uni.getLocation()
  124. if (res[1]) {
  125. return {
  126. latitude: res[1].latitude,
  127. longitude: res[1].longitude,
  128. }
  129. }
  130. },
  131. async loadCarInfo() {
  132. const me = this
  133. // let test = {
  134. // "recommend_id": 3,
  135. // "title": "噢抬哇塞红擦无论谁",
  136. // "image": "https://loremflickr.com/400/400?lock=201810282360670",
  137. // "desc": "voluptate commodo quis fugiat ut",
  138. // "model_id": 1,
  139. // "car_model_name": "电摩-12",
  140. // "sell_price": 100,
  141. // "deposit": 10,
  142. // "rental_setting": [
  143. // {
  144. // "setting_id": 1,
  145. // "admin_id": 1,
  146. // "hire_duration": 1,
  147. // "hire_duration_unit": 1,
  148. // "hire_price": 15,
  149. // "ctime": 1736330909,
  150. // "delete_time": 0
  151. // },
  152. // {
  153. // "setting_id": 2,
  154. // "admin_id": 1,
  155. // "hire_duration": 1,
  156. // "hire_duration_unit": 2,
  157. // "hire_price": 5,
  158. // "ctime": 1736386379,
  159. // "delete_time": 0
  160. // }
  161. // ],
  162. // "services_list": [
  163. // {
  164. // "service_id": 3,
  165. // "admin_id": 1,
  166. // "service_name": "手套",
  167. // "ctime": 1736476283,
  168. // "delete_time": 0
  169. // }
  170. // ],
  171. // "shop_name": "智寻出行 - 测试",
  172. // "longitude": "115.815236",
  173. // "latitude": "28.691463",
  174. // "address": "江西省南昌市新建区友谊路与自强路交叉口北80米",
  175. // "work_begin_time": "03:00:00",
  176. // "work_end_time": "23:59:59",
  177. // "link_phone": "18779187403",
  178. // "distance": 11
  179. // }
  180. // me.destance = common.getFlatternDistance(me.myLocation.latitude, me.myLocation.longitude, test.latitude,test.longitude)
  181. // console.log(me.destance);
  182. // me.setData({
  183. // car_detail: test
  184. // })
  185. let adress = await this.locationFn()
  186. http.postApi(config.API_FLK_INDEX_CAR_MODEL_DETAIL, {
  187. model_id:me.model_id,
  188. latitude: adress.latitude,
  189. longitude: adress.longitude,
  190. }, (resp) => {
  191. if (resp.data.code === 200) {
  192. me.setData({
  193. car_detail:resp.data.data,
  194. price:(resp.data.data.rental_setting[0].hire_price/100).toFixed(2)
  195. })
  196. } else {
  197. common.simpleToast(resp.data.msg);
  198. }
  199. })
  200. },
  201. tapSelectType(e) {
  202. const {select_type,price} = e.currentTarget.dataset
  203. console.log(select_type,price,'select_type,price');
  204. this.setData({
  205. selectType: select_type,
  206. price:(price/100).toFixed(2)
  207. })
  208. },
  209. tapCallPhone(){
  210. const me = this
  211. const phone = this.car_detail.link_phone
  212. // const phone = 18170410707
  213. uni.showModal({
  214. content: `您是否要拨打电话${phone}?`,
  215. confirmText: '确定',
  216. success: (res) => {
  217. if (res.confirm) {
  218. me.clearTimer()
  219. uni.makePhoneCall({
  220. phoneNumber: phone,
  221. success() {},
  222. fail() {}
  223. })
  224. }
  225. },
  226. fail: (res) => {}
  227. })
  228. },
  229. navAddress(){
  230. const {
  231. address,
  232. latitude,
  233. longitude,
  234. shop_name
  235. } = this.car_detail
  236. uni.openLocation({
  237. latitude: latitude - 0,
  238. longitude: longitude - 0,
  239. scale: 15,
  240. name: shop_name,
  241. address: address,
  242. success: function (res) {},
  243. })
  244. },
  245. useCarBtn(){
  246. const pData={
  247. ...this.car_detail,
  248. price:this.price
  249. }
  250. this.setData({
  251. showCarPlan:true,
  252. params:pData
  253. })
  254. },
  255. changeSelectType(select_type,price){
  256. this.setData({
  257. selectType: select_type,
  258. price:(price/100).toFixed(2)
  259. })
  260. },
  261. closeShowMore(){
  262. this.setData({
  263. showCarPlan:false
  264. })
  265. }
  266. }
  267. };
  268. </script>
  269. <style>
  270. @import './carDetail.css';
  271. </style>