carDetail.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view>
  3. <view class="car-detail-main">
  4. <Navigation :scroll='scrollTop'></Navigation>
  5. <view class="store-img-view">
  6. <swiper v-if="car_detail.model_images && car_detail.model_images.length!=0" class="swiper" :indicator-dots="true" :autoplay="true" :interval="2000"
  7. indicator-color="rgba(0, 0, 0, 0.3)" indicator-active-color="#000000" :duration="1000" circular>
  8. <swiper-item class="swiper-item" v-for="(item,index) in car_detail.model_images" :key="index">
  9. <image style="width: 100%;height: 100%;" class="swiper-item-img" :src="item" mode="aspectFit"></image>
  10. </swiper-item>
  11. </swiper>
  12. <image v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" mode="aspectFit">
  13. </image>
  14. </view>
  15. <view class="car-detail-model">
  16. <view class="car-detail-name">{{car_detail.car_model_name}}</view>
  17. <view class="car-detail-price">
  18. <allPrice :amount="Number(price)" />
  19. </view>
  20. <view style="flex-wrap: wrap;justify-content: flex-start;" class="flex-row car-detail-time">
  21. <view v-for="(item,index) in car_detail.rental_setting" :key="index" @click="tapSelectType(item)"
  22. :class="['time-unit',selectType==item.hire_duration_unit? 'time-unit-i':'']">
  23. <text v-if="item.hire_duration_unit==1">{{ $t('日租') }}</text>
  24. <text v-if="item.hire_duration_unit==2">{{ $t('月租') }}</text>
  25. <text v-if="item.hire_duration_unit==3">{{ $t('年租') }}</text>
  26. <text v-if="item.hire_duration_unit==4">{{ $t('时租') }}</text>
  27. <text v-if="item.hire_duration_unit==5">{{ $t('分租') }}</text>
  28. <text v-if="item.hire_duration_unit==6">{{ $t('周租') }}</text>
  29. <text v-if="item.hire_duration_unit==7">{{ $t('季租') }}</text>
  30. </view>
  31. <view v-if="car_detail.sell_price != 0" @click="tapSelectType({hire_duration_unit:100,hire_price:car_detail.sell_price})"
  32. :data-select_type="100" :data-price="car_detail.sell_price"
  33. :class="['time-unit',selectType==100? 'time-unit-i':'']">{{ $t('购买') }}</view>
  34. </view>
  35. </view>
  36. <!-- <view class="free-num-model">
  37. <view class="flex-row flex-between">
  38. <view class="free-num-view">
  39. <img style="width: 40rpx;height: 40rpx;" src="https://qiniu.bms16.com/FtlfBtBE5-TeTI5EdrciX_u8u_Sx" alt="">
  40. <text class="free-num-text">{{ $t('免费换电次数') }}</text>
  41. </view>
  42. <view class="free-num-time">1 {{ $t('次') }}/{{ $t('日') }}</view>
  43. </view>
  44. <view class="free-num-tip">{{ $t('日租享') }}1{{ $t('次免费换电数,超出后需要单独支付换电费用;') }}</view>
  45. </view> -->
  46. <useGuidance />
  47. <view class="card-car-detail">
  48. <view class="step-title-view flex-row align-center">
  49. <img style="width: 208rpx;height: 40rpx;" src="https://qiniu.bms16.com/Fms8V0l4bNwGUgWwkdRku4dIx_tt"
  50. alt="">
  51. <img style="width: 86rpx;height: 80rpx;" src="https://qiniu.bms16.com/FibAaPERzqi6m95EP2jREUKixjUi"
  52. alt="">
  53. <view class="w-bg flex-row"></view>
  54. </view>
  55. <view class="step-car-view">
  56. <view class="step-img-view"></view>
  57. <view class="flex-row flex-between" style="margin-bottom: 24rpx;">
  58. <view class="store-name-view">
  59. <view>{{car_detail.shop_name}}</view>
  60. <view class="address-txt">{{car_detail.address}}</view>
  61. </view>
  62. <view class="distance-num">{{car_detail.distance}}m</view>
  63. </view>
  64. <view class="flex-row flex-between align-center">
  65. <view class="time-view flex-row alert-center">
  66. <img class="time-icon" src="https://qiniu.bms16.com/FlGVpR2fdrD1GfeHfDgt-dUMgkOq" alt="">
  67. <text>{{car_detail.work_begin_time + '-' + car_detail.work_end_time}}</text>
  68. </view>
  69. <view class="phone-or-nav flex-row">
  70. <view @tap="tapCallPhone">
  71. <img style="width: 84rpx;height: 64rpx;margin-right: 20rpx;"
  72. src="https://qiniu.bms16.com/FkZYljvsgGtXUGnQaA0wk_sbjlUC" alt="">
  73. </view>
  74. <view @tap="navAddress">
  75. <img style="width: 112rpx;height: 64rpx;"
  76. src="https://qiniu.bms16.com/Fts38M35doVjK09GfOza5qD-wwkK" alt="">
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="nodes">
  83. <rich-text v-if="car_detail.model_desc" :nodes="car_detail.model_desc"></rich-text>
  84. </view>
  85. <view style="height: 150rpx;"></view>
  86. <view class="use-car-view flex-row">
  87. <view @tap="useCarBtn" class="use-car-btn">{{ $t('我要用车') }}</view>
  88. </view>
  89. <carPlan v-if="showCarPlan" @changeSelectType="changeSelectType" @closeShowMore="closeShowMore" :params="params"
  90. :selectType="selectType" />
  91. </view>
  92. </view>
  93. </template>
  94. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  95. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  96. <script>
  97. import CarPlan from '@/component/carPlan/carPlan';
  98. import UseGuidance from '@/component/useGuidance/useGuidance';
  99. import allPrice from '@/component/allPrice/allPrice';
  100. import {
  101. LEASE_TYPE_ARR
  102. } from '@/common/constant.js'
  103. var config = require('@/common/config.js');
  104. var common = require('@/common/common.js');
  105. var http = require('@/common/http.js');
  106. var storage = require('@/common/storage.js');
  107. export default {
  108. data() {
  109. return {
  110. shop_type:0,
  111. recommend_id: '',
  112. car_detail: {},
  113. showCarPlan: false,
  114. selectType: 1,
  115. destance: 0,
  116. price: 0,
  117. params: {}
  118. };
  119. },
  120. components: {
  121. CarPlan,
  122. UseGuidance,
  123. allPrice
  124. },
  125. onLoad: function(options) {
  126. if (options.model_id) {
  127. this.model_id = options.model_id
  128. this.locationFn()
  129. }
  130. if (options.shop_type) {
  131. this.shop_type = options.shop_type
  132. const d = {
  133. hire_duration_unit:options.shop_type,
  134. hire_price:Number(options.hire_price)
  135. }
  136. this.tapSelectType(d)
  137. }
  138. // this.loadCarInfo()
  139. // getFlatternDistance 获取直线距离
  140. },
  141. onPageScroll(e) {
  142. this.scrollTop = e.scrollTop
  143. },
  144. methods: {
  145. locationFn() {
  146. this.loadCarInfo(this.myLocation.longitude, this.myLocation.latitude)
  147. },
  148. loadCarInfo(latitude, longitude) {
  149. const me = this
  150. http.postApi(config.API_FLK_INDEX_CAR_MODEL_DETAIL, {
  151. model_id: me.model_id,
  152. latitude: latitude,
  153. longitude: longitude,
  154. }, (resp) => {
  155. if (resp.data.code === 200) {
  156. // resp.data.data.desc = resp.data.data.desc.replaceAll('/<img\b/gi, '$& style="1"'')
  157. // me.tapSelectType(resp.data.data.rental_setting[0])
  158. resp.data.data.distance = common.formatDistance(Number(resp.data.data.distance))
  159. const imgRegex = /<img([^>]*)>/gi;
  160. // 替换函数,设置 width="100%" 和 height="auto"
  161. const updatedRichText = resp.data.data.model_desc.replace(imgRegex, (match) => {
  162. // 使用正则表达式移除已有的 width 和 height 属性
  163. const cleanedMatch = match.replace(/(width|height)="[^"]*"/gi, '');
  164. // 添加新的 width="100%" 和 height="auto"
  165. return cleanedMatch.replace('<img', '<img width="100%" height="auto"');
  166. });
  167. resp.data.data.model_desc = updatedRichText
  168. me.setData({
  169. car_detail: resp.data.data,
  170. // price: ((resp.data.data.rental_setting[0]?.hire_price || 0) / 100).toFixed(2)
  171. })
  172. if(!me.shop_type){
  173. resp.data.data.rental_setting.map((item,index)=>{
  174. if(index === 0){
  175. me.tapSelectType({
  176. hire_duration_unit:item.hire_duration_unit,
  177. hire_price:Number(item.hire_price),
  178. })
  179. }
  180. })
  181. }
  182. } else {
  183. common.simpleToast(resp.data.msg);
  184. }
  185. })
  186. },
  187. tapSelectType(e) {
  188. const {
  189. hire_duration_unit,
  190. hire_price
  191. } = e
  192. console.log(66666666)
  193. console.log(hire_price)
  194. console.log(hire_duration_unit)
  195. this.setData({
  196. selectType: hire_duration_unit,
  197. price: (hire_price / 100).toFixed(2)
  198. })
  199. },
  200. tapCallPhone() {
  201. const me = this
  202. const phone = this.car_detail.link_phone
  203. // const phone = 18170410707
  204. uni.showModal({
  205. content: `${this.$t('您是否要拨打电话')+phone}?`,
  206. confirmText: this.$t('确定'),
  207. success: (res) => {
  208. if (res.confirm) {
  209. uni.makePhoneCall({
  210. phoneNumber: phone,
  211. })
  212. }
  213. },
  214. fail: (res) => {}
  215. })
  216. },
  217. navAddress() {
  218. const {
  219. address,
  220. latitude,
  221. longitude,
  222. shop_name
  223. } = this.car_detail
  224. uni.openLocation({
  225. latitude: latitude - 0,
  226. longitude: longitude - 0,
  227. scale: 15,
  228. name: shop_name,
  229. address: address,
  230. success: function(res) {},
  231. })
  232. },
  233. loadIsLogin() {
  234. uni.navigateTo({
  235. url: '/pages/loginRegister/login',
  236. })
  237. },
  238. useCarBtn() {
  239. const user_token = storage.getUserToken()
  240. if (!user_token) {
  241. this.loadIsLogin()
  242. return
  243. }
  244. const pData = {
  245. ...this.car_detail,
  246. price: this.price
  247. }
  248. this.setData({
  249. showCarPlan: true,
  250. params: pData
  251. })
  252. },
  253. changeSelectType(select_type, price) {
  254. this.setData({
  255. selectType: select_type,
  256. price: (price / 100).toFixed(2)
  257. })
  258. },
  259. closeShowMore() {
  260. this.setData({
  261. showCarPlan: false
  262. })
  263. }
  264. }
  265. };
  266. </script>
  267. <style>
  268. @import './carDetail.css';
  269. .nodes{
  270. color: #333;
  271. font-size: 28rpx;
  272. padding: 34rpx 32rpx 32rpx;
  273. }
  274. </style>