index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <template>
  2. <view>
  3. <!-- #ifdef APP -->
  4. <u-no-network zIndex='9' @retry='retry'></u-no-network>
  5. <!-- #endif -->
  6. <view v-if="isConnected">
  7. <block v-if="isLogin && car_info.car_sn">
  8. <view class="container-view">
  9. <!-- #ifdef MP-WEIXIN -->
  10. <view :style="{height: `${statusBarHeight + 30}px`}"></view>
  11. <!-- #endif -->
  12. <!-- #ifdef APP -->
  13. <view :style="{height: `${statusBarHeight}px`}"></view>
  14. <!-- #endif -->
  15. <!-- <navBar type="index" /> -->
  16. <view class="flex-row flex-between align-center padding_about_40">
  17. <view class="car-name-view" @tap="navSwitchCar">
  18. <text class="text" style="margin-right: 10rpx;">{{car_info.car_name}}</text>
  19. <img src="https://qiniu.bms16.com/FoSXDpVGvbdmwbX3CMUBvR7X4IzI"
  20. style="width: 14rpx;height: 14rpx;" alt="">
  21. </view>
  22. <view @click="routerLink('/pages/message/index?isSys=0')" class="news">
  23. <view v-if="newsList.device_count > 0" class="num">
  24. {{ newsList.device_count}}
  25. </view>
  26. <image src="https://qiniu.bms16.com/FtlfBtBE5-TeTI5EdrciX_u8u_Sx"
  27. style="width: 48rpx;height: 48rpx;" mode=""></image>
  28. </view>
  29. </view>
  30. <view v-if="isOverdueShow" class="overdue-view flex-row flex-between">
  31. <view class="overdue-view-text flex-row">
  32. <text class="overdue-text-left">{{$t("您已逾期")}}
  33. <text class="overdue-num">
  34. <block v-if="car_info.hire_duration_time">
  35. {{car_info.hire_duration_time.day > 0 ? car_info.hire_duration_time.day :'' }}<text
  36. v-if="car_info.hire_duration_time.day>0">{{$t("日")}}</text>{{car_info.hire_duration_time.hour > 0 ? car_info.hire_duration_time.hour :'' }}<text
  37. v-if="car_info.hire_duration_time.hour>0">{{$t("小时")}}</text>{{car_info.hire_duration_time.minute > 0 ? car_info.hire_duration_time.minute :'' }}<text
  38. v-if="car_info.hire_duration_time.minute>0">{{$t("分")}}</text>
  39. </block>
  40. </text>
  41. </text>
  42. <text style="font-size: 24rpx;opacity: 0.5;">{{$t("请及时续费或归还车辆")}}</text>
  43. </view>
  44. <view @click="routerLink('/pages/order/order')" class="renew-btn">{{$t("去续费")}}</view>
  45. </view>
  46. <view class="car-img-view" >
  47. <view v-if="!car_info.sold_time" class="flex-row flex-between" style="align-items: center;">
  48. <text class="quantity flex-row">{{car_info.soc}} <text
  49. style="font-size: 28rpx;font-weight: 500;">%</text></text>
  50. <view @tap.stop="tapReturnCar" class="return-car-btn flex-row">
  51. <image style="width: 46rpx;height: 46rpx;" src="https://qiniu.bms16.com/FtyG7Gq2QBaVVrZmTnmZFzXhE5nN" mode=""></image>
  52. <view style="margin-left: 12rpx;">{{$t("我要还车")}}</view>
  53. </view>
  54. </view>
  55. <view class="quantity-view flex-row">
  56. <u-line-progress style="width: 100rpx;" active-color="#2ADA62" height="10"
  57. :show-percent="false" :percent="car_info.soc"></u-line-progress>
  58. <view class="quantity-text flex-row">
  59. <view style="font-weight:400;font-size: 22rpx;width: 44rpx;">{{$t("续航")}}</view>
  60. <view style="font-size: 36rpx;">{{formatDistance(car_info.remain_mail) }}<text style="font-size: 30rpx;">{{car_info.remain_mail ? car_info.remain_mail>1000?'km':'m' :'km'}}</text></view>
  61. </view>
  62. </view>
  63. <!-- <img :src="car_info.model_images||'https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX'" style="width: 100%;height: 526rpx;" alt=""> -->
  64. <!-- <img :src="'https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX'"
  65. style="width: 100%;height: 526rpx;" alt=""> -->
  66. <view class="custom-swiper-view">
  67. <u-swiper @click="toMoreInfoPage" v-if="car_image.length!=0" :list="car_image" :autoplay="false" mode="none"
  68. :height="480" bgColor="transparent" class="custom-swiper">
  69. </u-swiper>
  70. <image @click="toMoreInfoPage" v-else style="width: 100%;height: 480rpx;" src="https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX" mode="">
  71. </image>
  72. </view>
  73. <view class="flex-row align-center update-time-view">
  74. <text style="margin-right: 10rpx;">{{car_info.online==1&&car_info.acc_state==1?$t("车辆已开机"): $t("车辆已关机")}} </text>
  75. <text v-if="car_info.heart_time != 0" style="margin-right: 10rpx;">{{$t("更新于")}} {{tools.formatTime( car_info.heart_time|| '')}}</text>
  76. <img v-if="isConnectBlueth" src="https://qiniu.bms16.com/FsL6XWGoIhfsVB7jRg6EGFVsuaTZ"
  77. :style="{width: '24rpx',height: '32rpx'}" alt="">
  78. </view>
  79. </view>
  80. <Control :contrilList="contrilList" @toBluetooth="inductiveUnlockHandle" @loadCarDetail="loadCarDetail"/>
  81. <view :class="['flex-row', 'flex-between', 'map-card-view',car_info.exchange_package_info && car_info.exchange_package_info.activity_time?'height_362':'height_260']">
  82. <MapCard :car_info="car_info" :height="!!(car_info.exchange_package_info && car_info.exchange_package_info.activity_time)"/>
  83. <view class="card-right">
  84. <view class="card-bg" @tap="navTravelingTrack">
  85. <view class="flex-row flex-between card-top-title">
  86. <view class="flex-row align-center">
  87. <img style="width: 36rpx;height: 36rpx;"
  88. src="https://qiniu.bms16.com/FkrcMCV__HraZ0W0NBNdEZPIlwss" alt="">
  89. <text class="margin_l_8">{{isTrackOrAll?$t("最近骑行"):$t("总里程")}}</text>
  90. </view>
  91. <view @tap.stop="isTrackOrAll=!isTrackOrAll"><img
  92. style="width: 24rpx;height: 20rpx;"
  93. src="https://qiniu.bms16.com/FltPK-o7KGS3dQ2pfQHXGSxOdzaN" alt=""></view>
  94. </view>
  95. <view class="card-top-text">{{car_info.current_mail}}<text class="font_24">km</text>
  96. </view>
  97. </view>
  98. <view v-if="car_info.exchange_package_info && car_info.exchange_package_info.activity_time" class="card-bg">
  99. <view class="flex-row card-top-title">
  100. <img style="width: 36rpx;height: 36rpx;"
  101. src="https://qiniu.bms16.com/FtalApKa3STyruaBxxRB4O9hHXyE" alt="">
  102. <text class="margin_l_8">{{$t("换电套餐")}}</text>
  103. </view>
  104. <view v-if="car_info.package_type == 1" class="card-top-text">
  105. {{calculateRemainingDays(car_info.exchange_package_info.expire_time)}} <text
  106. class="font_24">{{$t("天")}}</text>
  107. </view>
  108. <view v-if="car_info.package_type == 2" class=" card-top-text">{{item.last_num}} <text
  109. class="font_24">{{$t("次")}}</text></view>
  110. <view v-if="car_info.package_type == 3" class=" card-top-text">
  111. {{item.total_day}}{{$t("天")}}/{{item.last_num}} <text
  112. class="font_24">{{$t("次")}}</text>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- <custom-switch :defaultPosition="'right'" :width="'400rpx'"
  118. :height="'96rpx'" v-model="switchValue" :fetchData="loadData"></custom-switch> -->
  119. <view class="config-view">
  120. <view @tap="navToPage" class="flex-row config-car-view">
  121. <view class="margin_r_20"><img class="icon_style_64"
  122. src="https://qiniu.bms16.com/Ftzyvs5whxDdMFksYChHaWKVb0Uk" alt=""></view>
  123. <view class="flex-row config-text-view" @tap="inductiveUnlockHandle">
  124. <view class="flex-row font_w_600">{{$t("感应解锁")}}</view>
  125. <view class="flex-row tip-text-config">{{isBluethConnect?$t("蓝牙配对成功"):$t("请先连接蓝牙")}}
  126. </view>
  127. </view>
  128. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm"
  129. alt="">
  130. </view>
  131. <view @tap="navToPage" data-url="/pages/userManagement/userManagement"
  132. class="flex-row config-car-view">
  133. <view class="margin_r_20"><img class="icon_style_64"
  134. src="https://qiniu.bms16.com/FhKkijkN__9UzhYNgamBFSggIlYo" alt=""></view>
  135. <view class="flex-row config-text-view">
  136. <view class="flex-row font_w_600">{{$t("用车人管理")}}</view>
  137. <view class="flex-row tip-text-config">{{car_info.share_num + $t("个家庭账号")}}</view>
  138. </view>
  139. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm"
  140. alt="">
  141. </view>
  142. <view @click="srcFn(`/pages/deviceInfo/deviceInfo`)" class="flex-row config-car-view">
  143. <view class="margin_r_20"><img class="icon_style_64"
  144. src="https://qiniu.bms16.com/FsAg6mHEBJfbtpgIHBrDdNiPo1iH" alt=""></view>
  145. <view class="flex-row config-text-view">
  146. <view class="flex-row font_w_600">{{$t("设备信息")}}</view>
  147. <view class="flex-row tip-text-config">{{$t("软件版本") + (car_info.firmware||'')}}</view>
  148. </view>
  149. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm"
  150. alt="">
  151. </view>
  152. </view>
  153. <view style="height: 264rpx;"></view>
  154. </view>
  155. </block>
  156. <block v-else>
  157. <UnleasedPages :model_list="model_list" :img_list="img_list" />
  158. </block>
  159. <BluetoothUnlockAuth ref="bluetoothUnlockAuth" />
  160. <CustomTabbar @changCar='changCar' curt-tab="home" />
  161. <AndroidUnlockAuth :authStepList="authStepList" :value="isShowPermission" @closePermission="closePermission"
  162. v-if="isShowPermission && (platform === 'android')" />
  163. <IosUnlockAuth :authStepList="authStepList" :value="isShowPermission" @closePermission="closePermission"
  164. v-else-if="isShowPermission && (platform === 'ios')" />
  165. </view>
  166. <returnCar :isShowReturnCar="isShowReturnCar" typePage="index" @closeShowReturnCarBtn="()=>isShowReturnCar=false"
  167. @navStoreBtn="navStoreBtn" @immediatelyReturnBtn="immediatelyReturnBtn" />
  168. </view>
  169. </template>
  170. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  171. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  172. <script>
  173. var config = require('@/common/config.js');
  174. var config_gyq = require('@/common/config_gyq.js');
  175. var common = require('@/common/common.js');
  176. var http = require('@/common/http.js');
  177. var request = require('@/common/request.js');
  178. var storage = require('@/common/storage.js');
  179. import Control from './components/control/control'
  180. import MapCard from './components/mapCard/mapCard'
  181. import UnleasedPages from './components/unleasedPages/unleasedPages'
  182. import CustomTabbar from '@/component/customTabbar/index';
  183. import BluetoothUnlockAuth from '../bluetoothUnlock/bluetoothUnlockAuth.vue'
  184. import AndroidUnlockAuth from './components/AndroidUnlockAuth.vue'
  185. import IosUnlockAuth from './components/IosUnlockAuth.vue'
  186. import ReturnCar from '@/component/returnCar/returnCar';
  187. import {
  188. getFunctionTag,
  189. } from '@/common/storage.js';
  190. import permision from "@/js_sdk/wa-permission/permission.js"
  191. let bluetooth = require('@/common/bluetooth.js');
  192. export default {
  193. watch: {
  194. 'car_info.sar_sn'(newValue, oldValue) {
  195. }
  196. },
  197. data() {
  198. return {
  199. orderInfo:{},
  200. time:null,
  201. isModel: false,
  202. isConnected: false,
  203. statusBarHeight: 0,
  204. newsList: {},
  205. img_list: [],
  206. isLogin: false,
  207. isOverdueShow: true,
  208. contrilList: [],
  209. isTrackOrAll: true,
  210. model_list: [],
  211. car_list: [], //用户车辆列表
  212. car_sn: '', //当前车辆编号
  213. isHideInduction: true,
  214. car_info: {
  215. exchange_package_info: {
  216. activity_time: 0
  217. }
  218. },
  219. platform: 'android', //手机型号
  220. isShowPermission: false, //是否打开权限弹窗
  221. statusBarHeight: 0,
  222. isBluethConnect: false, //当前是否蓝牙连接或者配对
  223. isOpenAllPermission: false, //所有蓝牙配对所需权限是否已开启
  224. isShowReturnCar:false,
  225. overdueData:{},
  226. car_image:[],
  227. isConnectBlueth:false
  228. };
  229. },
  230. computed: {},
  231. components: {
  232. Control,
  233. MapCard,
  234. CustomTabbar,
  235. UnleasedPages,
  236. BluetoothUnlockAuth,
  237. AndroidUnlockAuth,
  238. IosUnlockAuth,
  239. ReturnCar
  240. },
  241. /**
  242. * 生命周期函数--监听页面加载
  243. */
  244. onLoad: function(options) {
  245. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
  246. let _this = this
  247. // #ifdef APP
  248. uni.getNetworkType({
  249. success: (res) => {
  250. if (res.networkType == 'none') {
  251. this.isConnected = false;
  252. } else {
  253. this.isConnected = true;
  254. }
  255. }
  256. });
  257. uni.onNetworkStatusChange((res) => {
  258. _this.isConnected = res.isConnected
  259. if (res.isConnected) {
  260. _this.init()
  261. }
  262. });
  263. // #endif
  264. // #ifndef APP
  265. this.isConnected = true
  266. _this.init()
  267. // #endif
  268. if('car_sn' in this.car_info){
  269. this.bluetoothClose()
  270. bluetooth.initBluetooth()
  271. }
  272. },
  273. /**
  274. * 生命周期函数--监听页面显示
  275. */
  276. onShow: function() {
  277. // #ifdef APP
  278. uni.getNetworkType({
  279. success: (res) => {
  280. if (res.networkType != 'none') {
  281. this.init()
  282. }
  283. }
  284. });
  285. // #endif
  286. // #ifndef APP
  287. this.init()
  288. // #endif
  289. },
  290. onHide(){
  291. this.clearIntervalTimer()
  292. },
  293. // 分享给好友
  294. onShareAppMessage: function(res) { //发送给朋友
  295. return {
  296. title: this.appConfig.app_name,
  297. path: 'pages/index/index',
  298. }
  299. },
  300. onUnload() {
  301. this.clearIntervalTimer()
  302. },
  303. methods: {
  304. clearIntervalTimer() {
  305. if (this.time == null) return
  306. clearInterval(this.time)
  307. this.time = null
  308. },
  309. init() {
  310. this.loadModelList()
  311. this.contrilList = getFunctionTag().activeTag
  312. const user_token = storage.getUserToken()
  313. this.car_info = uni.getStorageSync('car_info') || {};
  314. const app = getApp();
  315. this.isBluethConnect = app.globalData.nearLockCheck
  316. if (!user_token) return
  317. this.newsNumFn()
  318. this.isLogin = true
  319. this.loadUserCarList()
  320. // if(!this.time){
  321. // this.time = setInterval(()=>{
  322. // this.loadUserCarList()
  323. // },5000)
  324. // }
  325. // #ifdef APP
  326. //蓝牙配对所需权限 运行小程序需要隐藏
  327. // const permissionArr = permision.requestAndroidPermissions(this.platform)
  328. // console.log(permissionArr, 'permissionArr');
  329. // this.setData({
  330. // authStepList: permissionArr
  331. // })
  332. // permissionArr.map(item => {
  333. // if (!item.state) this.isOpenAllPermission = true
  334. // })
  335. // #endif
  336. // if (!this.car_info.car_sn) {
  337. // } else {
  338. // this.loadCarDetail(this.car_info.car_sn)
  339. // }
  340. },
  341. retry() {
  342. },
  343. async newsNumFn() {
  344. let {
  345. data
  346. } = await request.postApi(config_gyq.API_FLK_MESSAGE_UNREAD_COUNT, {})
  347. if (data.code == 200) {
  348. this.newsList = data.data
  349. }
  350. },
  351. changCar(e) {
  352. this.car_info = e
  353. },
  354. routerLink(url) {
  355. uni.navigateTo({
  356. url
  357. })
  358. },
  359. loadIsLogin() {
  360. uni.navigateTo({
  361. url: '/pages/loginRegister/login',
  362. })
  363. },
  364. toMoreInfoPage() {
  365. uni.navigateTo({
  366. url: '/pages/moreInfo/moreInfo',
  367. });
  368. },
  369. navTravelingTrack() {
  370. uni.navigateTo({
  371. url: '/pages/travelingTrack/travelingTrack?longitude=' + this.longitude + '&latitude=' + this
  372. .latitude,
  373. success: function(res) {},
  374. fail: function(res) {},
  375. complete: function(res) {}
  376. });
  377. },
  378. inductiveUnlockHandle() {
  379. uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  380. // console.log(!this.isOpenAllPermission,this.isBluethConnect,'this.isBluethConnect');
  381. // if(this.isBluethConnect){
  382. // uni.navigateTo({ url: '/pages/bluetoothUnlock/unlockSet' })
  383. // }else{
  384. // if(!this.isOpenAllPermission){
  385. // common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
  386. // uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  387. // }else{
  388. // this.setData({
  389. // isShowPermission:true,
  390. // })
  391. // }
  392. // }
  393. },
  394. closePermission() {
  395. this.setData({
  396. isShowPermission: false
  397. })
  398. },
  399. showInduction() {
  400. this.isHideInduction = true
  401. },
  402. loadModelList() {
  403. if (this.isModel) {
  404. return
  405. }
  406. this.isModel = true
  407. const me = this
  408. http.postApi(config.API_RECOMMEND_CAR_MODEL_LIST, {}, (resp) => {
  409. if (resp.data.code === 200) {
  410. const list = resp.data.data
  411. const img_list = resp.data.data.map(item => item.image)
  412. me.setData({
  413. model_list: list,
  414. img_list: img_list
  415. })
  416. } else {
  417. common.simpleToast(resp.data.msg);
  418. }
  419. })
  420. },
  421. srcFn(url) {
  422. uni.navigateTo({
  423. url: url
  424. });
  425. },
  426. navToPage(e) {
  427. const me = this
  428. const url = e.currentTarget.dataset.url;
  429. if (!url) {
  430. return;
  431. }
  432. uni.navigateTo({
  433. url: url
  434. });
  435. },
  436. loadUserCarList() {
  437. const me = this
  438. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  439. if (resp.data.code === 200) {
  440. const list = resp.data.data.list
  441. let isCar = false
  442. let itemCar = {}
  443. for (let i = 0; i < list.length; i++) {
  444. let item = list[i];
  445. if (item.car_sn == this.car_info.car_sn) {
  446. isCar = true
  447. itemCar = item
  448. }
  449. }
  450. if (!isCar) {
  451. if (list.length > 0) {
  452. uni.removeStorageSync('car_info')
  453. me.setData({
  454. car_list: list,
  455. car_sn: list[0].car_sn || '',
  456. })
  457. me.loadCarDetail(list[0].car_sn)
  458. } else {
  459. uni.removeStorageSync('car_info')
  460. this.car_info = {}
  461. }
  462. } else {
  463. me.loadCarDetail(itemCar.car_sn)
  464. }
  465. } else {
  466. common.simpleToast(resp.data.msg);
  467. }
  468. })
  469. },
  470. loadCarDetail(car_sn) {
  471. const me = this
  472. http.postApi(config.API_FLK_CAR_DETAIL, {
  473. car_sn
  474. }, (resp) => {
  475. uni.hideLoading();
  476. if (resp.data.code === 200) {
  477. resp.data.data.car_sn = car_sn
  478. const _car_image=resp.data.data.model_images?resp.data.data.model_images.split(','):[]
  479. me.setData({
  480. car_info: resp.data.data,
  481. car_image:_car_image
  482. })
  483. uni.setStorageSync('car_info', this.car_info);
  484. const app=getApp()
  485. //车辆离线连接蓝牙
  486. console.log('me.car_info.online',me.car_info.online);
  487. if(me.car_info.online==1){
  488. me.loadBluetooth()
  489. }
  490. // this.isConnectBlueth=app.globalData.connectionState[this.car_info.car_sn]
  491. //判断逾期
  492. if (!resp.data.data.sold_time) return
  493. let time = Math.ceil(resp.data.data.hire_end_time - Math.floor(new Date()) / 1000) / 60
  494. if (time > 0) {
  495. this.isOverdueShow = true
  496. this.car_info.hire_end_time = common.getTimeToDay(time)
  497. } else {
  498. this.isOverdueShow = false
  499. }
  500. console.log('this.time',this.time);
  501. } else {
  502. // common.simpleToast(resp.data.msg);
  503. }
  504. })
  505. },
  506. navSwitchCar() {
  507. const me = this
  508. //如果租/购多个车辆的话可以切换当前车辆
  509. uni.navigateTo({
  510. url: `/pages/carList/carList?list=${encodeURIComponent(JSON.stringify(me.car_list))}&car_sn=${me.car_sn}`,
  511. })
  512. },
  513. formatDistance(distanceMeters) {
  514. console.log(distanceMeters,'distanceMeters');
  515. // 判断距离是否超过1000米
  516. // let distanceMeters=Number(_distanceMeters)
  517. if (distanceMeters >= 1000) {
  518. // 如果超过1000米,则转换为千米并返回
  519. return (distanceMeters / 1000).toFixed(1);
  520. } else {
  521. // 否则直接返回米
  522. try {
  523. return distanceMeters;
  524. } catch (error) {
  525. return 0;
  526. }
  527. }
  528. },
  529. navStoreBtn() {
  530. const {
  531. latitude,
  532. longitude,
  533. address,
  534. model_name
  535. } = this.car_info
  536. uni.openLocation({
  537. latitude: latitude - 0,
  538. longitude: longitude - 0,
  539. scale: 15,
  540. name: model_name,
  541. address: address,
  542. success: function(res) {}
  543. });
  544. },
  545. tapReturnCar() {
  546. this.overdueMoneyFn(this.car_info.car_sn)
  547. this.setData({
  548. isShowReturnCar: true
  549. })
  550. },
  551. //逾期费用计算
  552. async overdueMoneyFn(car_sn) {
  553. let {
  554. data
  555. } = await request.postApi(config_gyq.API_FLK_CAR_OVERDUE_MONEY, {
  556. car_sn
  557. })
  558. if (data.code == 200) {
  559. this.overdueData = data.data
  560. } else {
  561. common.simpleToast(data.msg)
  562. }
  563. },
  564. immediatelyReturnBtn() {
  565. const {
  566. car_sn,
  567. model_id
  568. } = this.car_info
  569. //提交还车图片
  570. uni.navigateTo({
  571. url: `/pages/activation/activation?isReturnCar=${true}&model_id=${model_id}&car_sn=${car_sn}&isOverdue=${this.isOverdueShow}&overdueMoney=${this.overdueData.money}&overdueTime=${this.overdueData.time}&type=index`
  572. });
  573. },
  574. bluetoothClose: function() {
  575. bluetooth.closeBluetoothAdapter();
  576. bluetooth.closeDevice(
  577. this.car_sn,
  578. () => {
  579. console.log(this.$t('关闭蓝牙连接'));
  580. // this.setData({
  581. // bt_loading: false
  582. // });
  583. },
  584. () => {}
  585. );
  586. bluetooth.offCharacteristicStateChange(this.car_info.car_sn, 'index');
  587. bluetooth.offConnectionStateChange(this.car_info.car_sn, 'index');
  588. },
  589. loadBluetooth() {
  590. const me = this;
  591. const third_device_type = this.car_info.third_device_type
  592. var device = {
  593. mac_id: this.car_info.car_sn,
  594. btid: this.car_info.car_sn,
  595. btkey: this.car_info.car_sn,
  596. bt_type: third_device_type,
  597. device_type: third_device_type,
  598. };
  599. const app=getApp()
  600. // app.globalData.connectionState={}
  601. //bluetooth.acceptDevice(device) 是否是蓝牙类型列表里面的
  602. if (bluetooth.acceptDevice(device)) {
  603. // 打开蓝牙连接
  604. bluetooth.openBluetoothAdapter((res) => {
  605. // common.loading()
  606. bluetooth.connectDevice(device, () => {
  607. //监听蓝牙设备连接状态变化事件
  608. bluetooth.onConnectionStateChange(device.mac_id, 'index', (res) => {
  609. console.log('蓝牙连接状态',res.connected);
  610. if (!res.connected) {
  611. // 蓝牙未连接
  612. // common.simpleToast('蓝牙连接断开',2000)
  613. me.isConnectBlueth=false
  614. } else {
  615. // common.simpleToast('蓝牙连接成功',2000)
  616. // 蓝牙已连接
  617. me.isConnectBlueth=true
  618. }
  619. });
  620. },
  621. (res) => {
  622. console.log('观察周围是否有其他骑手连接,请等待对方完成 或 微信是否开启了蓝牙权限',res,res.errCode);
  623. // var showContent = ""
  624. // if (res && ("errCode" in res)) {
  625. // if (res.errCode == 9000001) {
  626. // var showContent = "观察周围是否有其他骑手连接,请等待对方完成 或 微信是否开启了蓝牙权限!!"
  627. // } else {
  628. // var showContent = "连接失败,请尝试重新连接44444"+res.errCode
  629. // }
  630. // } else {
  631. // var showContent = "连接失败,请尝试重新连接55555"
  632. // }
  633. // uni.showModal({
  634. // title: this.$t('提示'),
  635. // confirmText: this.$t('重新连接'),
  636. // content: showContent,
  637. // success: function(res) {
  638. // if (res.confirm) {
  639. // setTimeout(()=>{
  640. // me.loadBluetooth();
  641. // },100)
  642. // } else {}
  643. // }
  644. // });
  645. },
  646. (res) => {
  647. // console.log('蓝牙未打开或请在右上角设置授权小程序使用蓝牙66666');
  648. uni.hideLoading();
  649. // uni.showModal({
  650. // title: this.$t('提示'),
  651. // confirmText: this.$t('我知道了'),
  652. // content: '蓝牙未打开或请在右上角设置授权小程序使用蓝牙66666',
  653. // success: function(res) {
  654. // if (res.confirm) {
  655. // me.loadBluetooth();
  656. // } else {}
  657. // }
  658. // });
  659. }
  660. );
  661. }, );
  662. } else {
  663. //蓝牙连接未成功
  664. // uni.hideLoading();
  665. // uni.showModal({
  666. // confirmText: this.$t('我知道了'),
  667. // content: this.$t('当前机柜未找到符合的蓝牙类型'),
  668. // showCancel: false,
  669. // title: this.$t('提示'),
  670. // complete: (res) => {}
  671. // });
  672. }
  673. },
  674. }
  675. };
  676. </script>
  677. <style lang="scss" scoped>
  678. @import './index.css';
  679. .header_view {
  680. position: fixed;
  681. top: 0;
  682. left: 0;
  683. width: 100%;
  684. background-color: #c4cad6;
  685. z-index: 999; /* 确保在最上层 */
  686. }
  687. .fillClass {}
  688. .news {
  689. position: relative;
  690. margin-right: 20rpx;
  691. .num {
  692. position: absolute;
  693. right: -6rpx;
  694. top: -6rpx;
  695. min-width: 28rpx;
  696. height: 28rpx;
  697. font-size: 18rpx;
  698. display: flex;
  699. align-items: center;
  700. justify-content: center;
  701. color: #fff;
  702. line-height: 1;
  703. background-color: #FA2918;
  704. border-radius: 50%;
  705. z-index: 99;
  706. }
  707. }
  708. </style>