index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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="orderInfo.hire_duration_time">
  35. {{orderInfo.hire_duration_time.day > 0 ? orderInfo.hire_duration_time.day :'' }}<text
  36. v-if="orderInfo.hire_duration_time.day>0">{{$t("日")}}</text>{{orderInfo.hire_duration_time.hour > 0 ? orderInfo.hire_duration_time.hour :'' }}<text
  37. v-if="orderInfo.hire_duration_time.hour>0">{{$t("小时")}}</text>{{orderInfo.hire_duration_time.minute > 0 ? orderInfo.hire_duration_time.minute :'' }}<text
  38. v-if="orderInfo.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. data() {
  194. return {
  195. time:null,
  196. isModel: false,
  197. isConnected: false,
  198. statusBarHeight: 0,
  199. newsList: {},
  200. img_list: [],
  201. isLogin: false,
  202. isOverdueShow: true,
  203. contrilList: [],
  204. isTrackOrAll: true,
  205. model_list: [],
  206. car_list: [], //用户车辆列表
  207. car_sn: '', //当前车辆编号
  208. isHideInduction: true,
  209. car_info: {
  210. exchange_package_info: {
  211. activity_time: 0
  212. }
  213. },
  214. platform: 'android', //手机型号
  215. isShowPermission: false, //是否打开权限弹窗
  216. statusBarHeight: 0,
  217. isBluethConnect: false, //当前是否蓝牙连接或者配对
  218. isOpenAllPermission: false, //所有蓝牙配对所需权限是否已开启
  219. isShowReturnCar:false,
  220. overdueData:{},
  221. car_image:[],
  222. isConnectBlueth:false
  223. };
  224. },
  225. computed: {},
  226. components: {
  227. Control,
  228. MapCard,
  229. CustomTabbar,
  230. UnleasedPages,
  231. BluetoothUnlockAuth,
  232. AndroidUnlockAuth,
  233. IosUnlockAuth,
  234. ReturnCar
  235. },
  236. /**
  237. * 生命周期函数--监听页面加载
  238. */
  239. onLoad: function(options) {
  240. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
  241. let _this = this
  242. // #ifdef APP
  243. uni.getNetworkType({
  244. success: (res) => {
  245. if (res.networkType == 'none') {
  246. this.isConnected = false;
  247. } else {
  248. this.isConnected = true;
  249. }
  250. }
  251. });
  252. uni.onNetworkStatusChange((res) => {
  253. _this.isConnected = res.isConnected
  254. if (res.isConnected) {
  255. _this.init()
  256. }
  257. });
  258. // #endif
  259. // #ifndef APP
  260. this.isConnected = true
  261. _this.init()
  262. // #endif
  263. if('car_sn' in this.car_info){
  264. this.bluetoothClose()
  265. bluetooth.initBluetooth()
  266. }
  267. },
  268. /**
  269. * 生命周期函数--监听页面显示
  270. */
  271. onShow: function() {
  272. // #ifdef APP
  273. uni.getNetworkType({
  274. success: (res) => {
  275. if (res.networkType != 'none') {
  276. this.init()
  277. }
  278. }
  279. });
  280. // #endif
  281. // #ifndef APP
  282. this.init()
  283. // #endif
  284. },
  285. // 分享给好友
  286. onShareAppMessage: function(res) { //发送给朋友
  287. return {
  288. title: this.appConfig.app_name,
  289. path: 'pages/index/index',
  290. }
  291. },
  292. onUnload() {
  293. this.clearIntervalTimer()
  294. },
  295. methods: {
  296. clearIntervalTimer() {
  297. if (this.time == null) return
  298. clearInterval(this.time)
  299. this.time = null
  300. },
  301. init() {
  302. this.loadModelList()
  303. this.contrilList = getFunctionTag().activeTag
  304. const user_token = storage.getUserToken()
  305. this.car_info = uni.getStorageSync('car_info') || {};
  306. const app = getApp();
  307. this.isBluethConnect = app.globalData.nearLockCheck
  308. if (!user_token) return
  309. this.newsNumFn()
  310. this.isLogin = true
  311. this.loadUserCarList()
  312. // #ifdef APP
  313. //蓝牙配对所需权限 运行小程序需要隐藏
  314. // const permissionArr = permision.requestAndroidPermissions(this.platform)
  315. // console.log(permissionArr, 'permissionArr');
  316. // this.setData({
  317. // authStepList: permissionArr
  318. // })
  319. // permissionArr.map(item => {
  320. // if (!item.state) this.isOpenAllPermission = true
  321. // })
  322. // #endif
  323. // if (!this.car_info.car_sn) {
  324. // } else {
  325. // this.loadCarDetail(this.car_info.car_sn)
  326. // }
  327. },
  328. retry() {
  329. },
  330. async newsNumFn() {
  331. let {
  332. data
  333. } = await request.postApi(config_gyq.API_FLK_MESSAGE_UNREAD_COUNT, {})
  334. if (data.code == 200) {
  335. this.newsList = data.data
  336. }
  337. },
  338. changCar(e) {
  339. this.car_info = e
  340. },
  341. routerLink(url) {
  342. uni.navigateTo({
  343. url
  344. })
  345. },
  346. loadIsLogin() {
  347. uni.navigateTo({
  348. url: '/pages/loginRegister/login',
  349. })
  350. },
  351. toMoreInfoPage() {
  352. uni.navigateTo({
  353. url: '/pages/moreInfo/moreInfo',
  354. });
  355. },
  356. navTravelingTrack() {
  357. uni.navigateTo({
  358. url: '/pages/travelingTrack/travelingTrack?longitude=' + this.longitude + '&latitude=' + this
  359. .latitude,
  360. success: function(res) {},
  361. fail: function(res) {},
  362. complete: function(res) {}
  363. });
  364. },
  365. inductiveUnlockHandle() {
  366. uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  367. // console.log(!this.isOpenAllPermission,this.isBluethConnect,'this.isBluethConnect');
  368. // if(this.isBluethConnect){
  369. // uni.navigateTo({ url: '/pages/bluetoothUnlock/unlockSet' })
  370. // }else{
  371. // if(!this.isOpenAllPermission){
  372. // common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
  373. // uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  374. // }else{
  375. // this.setData({
  376. // isShowPermission:true,
  377. // })
  378. // }
  379. // }
  380. },
  381. closePermission() {
  382. this.setData({
  383. isShowPermission: false
  384. })
  385. },
  386. showInduction() {
  387. this.isHideInduction = true
  388. },
  389. loadModelList() {
  390. if (this.isModel) {
  391. return
  392. }
  393. this.isModel = true
  394. const me = this
  395. http.postApi(config.API_RECOMMEND_CAR_MODEL_LIST, {}, (resp) => {
  396. if (resp.data.code === 200) {
  397. const list = resp.data.data
  398. const img_list = resp.data.data.map(item => item.image)
  399. me.setData({
  400. model_list: list,
  401. img_list: img_list
  402. })
  403. } else {
  404. common.simpleToast(resp.data.msg);
  405. }
  406. })
  407. },
  408. srcFn(url) {
  409. uni.navigateTo({
  410. url: url
  411. });
  412. },
  413. navToPage(e) {
  414. const me = this
  415. const url = e.currentTarget.dataset.url;
  416. if (!url) {
  417. return;
  418. }
  419. uni.navigateTo({
  420. url: url
  421. });
  422. },
  423. loadUserCarList() {
  424. const me = this
  425. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  426. if (resp.data.code === 200) {
  427. const list = resp.data.data.list
  428. let isCar = false
  429. let itemCar = {}
  430. for (let i = 0; i < list.length; i++) {
  431. let item = list[i];
  432. if (item.car_sn == this.car_info.car_sn) {
  433. isCar = true
  434. itemCar = item
  435. }
  436. }
  437. if (!isCar) {
  438. if (list.length > 0) {
  439. uni.removeStorageSync('car_info')
  440. me.setData({
  441. car_list: list,
  442. car_sn: list[0].car_sn || '',
  443. })
  444. me.loadCarDetail(list[0].car_sn)
  445. } else {
  446. uni.removeStorageSync('car_info')
  447. this.car_info = {}
  448. }
  449. } else {
  450. me.loadCarDetail(itemCar.car_sn)
  451. }
  452. } else {
  453. common.simpleToast(resp.data.msg);
  454. }
  455. })
  456. },
  457. loadCarDetail(car_sn) {
  458. const me = this
  459. http.postApi(config.API_FLK_CAR_DETAIL, {
  460. car_sn
  461. }, (resp) => {
  462. uni.hideLoading();
  463. if (resp.data.code === 200) {
  464. resp.data.data.car_sn = car_sn
  465. const _car_image=resp.data.data.model_images?resp.data.data.model_images.split(','):[]
  466. me.setData({
  467. car_info: resp.data.data,
  468. car_image:_car_image
  469. })
  470. uni.setStorageSync('car_info', this.car_info);
  471. const app=getApp()
  472. //车辆离线连接蓝牙
  473. console.log('me.car_info.online',me.car_info.online);
  474. if(me.car_info.online==1){
  475. me.loadBluetooth()
  476. }
  477. // this.isConnectBlueth=app.globalData.connectionState[this.car_info.car_sn]
  478. //判断逾期
  479. if (!resp.data.data.sold_time) return
  480. let time = Math.ceil(resp.data.data.hire_end_time - Math.floor(new Date()) / 1000) / 60
  481. if (time > 0) {
  482. this.isOverdueShow = true
  483. this.car_info.hire_end_time = common.getTimeToDay(time)
  484. } else {
  485. this.isOverdueShow = false
  486. }
  487. console.log('this.time',this.time);
  488. if(!this.time){
  489. console.log(1111);
  490. this.time = setInterval(()=>{
  491. this.loadCarDetail(car_sn)
  492. },5000)
  493. }
  494. } else {
  495. // common.simpleToast(resp.data.msg);
  496. }
  497. })
  498. },
  499. navSwitchCar() {
  500. const me = this
  501. //如果租/购多个车辆的话可以切换当前车辆
  502. uni.navigateTo({
  503. url: `/pages/carList/carList?list=${encodeURIComponent(JSON.stringify(me.car_list))}&car_sn=${me.car_sn}`,
  504. })
  505. },
  506. formatDistance(distanceMeters) {
  507. console.log(distanceMeters,'distanceMeters');
  508. // 判断距离是否超过1000米
  509. // let distanceMeters=Number(_distanceMeters)
  510. if (distanceMeters >= 1000) {
  511. // 如果超过1000米,则转换为千米并返回
  512. return (distanceMeters / 1000).toFixed(1);
  513. } else {
  514. // 否则直接返回米
  515. try {
  516. return distanceMeters;
  517. } catch (error) {
  518. return 0;
  519. }
  520. }
  521. },
  522. navStoreBtn() {
  523. const {
  524. latitude,
  525. longitude,
  526. address,
  527. model_name
  528. } = this.car_info
  529. uni.openLocation({
  530. latitude: latitude - 0,
  531. longitude: longitude - 0,
  532. scale: 15,
  533. name: model_name,
  534. address: address,
  535. success: function(res) {}
  536. });
  537. },
  538. tapReturnCar() {
  539. this.overdueMoneyFn(this.car_info.car_sn)
  540. this.setData({
  541. isShowReturnCar: true
  542. })
  543. },
  544. //逾期费用计算
  545. async overdueMoneyFn(car_sn) {
  546. let {
  547. data
  548. } = await request.postApi(config_gyq.API_FLK_CAR_OVERDUE_MONEY, {
  549. car_sn
  550. })
  551. if (data.code == 200) {
  552. this.overdueData = data.data
  553. } else {
  554. common.simpleToast(data.msg)
  555. }
  556. },
  557. immediatelyReturnBtn() {
  558. const {
  559. car_sn,
  560. model_id
  561. } = this.car_info
  562. //提交还车图片
  563. uni.navigateTo({
  564. 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`
  565. });
  566. },
  567. bluetoothClose: function() {
  568. bluetooth.closeBluetoothAdapter();
  569. bluetooth.closeDevice(
  570. this.car_sn,
  571. () => {
  572. console.log(this.$t('关闭蓝牙连接'));
  573. // this.setData({
  574. // bt_loading: false
  575. // });
  576. },
  577. () => {}
  578. );
  579. bluetooth.offCharacteristicStateChange(this.car_info.car_sn, 'index');
  580. bluetooth.offConnectionStateChange(this.car_info.car_sn, 'index');
  581. },
  582. loadBluetooth() {
  583. const me = this;
  584. const third_device_type = this.car_info.third_device_type
  585. var device = {
  586. mac_id: this.car_info.car_sn,
  587. btid: this.car_info.car_sn,
  588. btkey: this.car_info.car_sn,
  589. bt_type: third_device_type,
  590. device_type: third_device_type,
  591. };
  592. const app=getApp()
  593. // app.globalData.connectionState={}
  594. //bluetooth.acceptDevice(device) 是否是蓝牙类型列表里面的
  595. if (bluetooth.acceptDevice(device)) {
  596. // 打开蓝牙连接
  597. bluetooth.openBluetoothAdapter((res) => {
  598. // common.loading()
  599. bluetooth.connectDevice(device, () => {
  600. //监听蓝牙设备连接状态变化事件
  601. bluetooth.onConnectionStateChange(device.mac_id, 'index', (res) => {
  602. console.log('蓝牙连接状态',res.connected);
  603. if (!res.connected) {
  604. // 蓝牙未连接
  605. // common.simpleToast('蓝牙连接断开',2000)
  606. me.isConnectBlueth=false
  607. } else {
  608. // common.simpleToast('蓝牙连接成功',2000)
  609. // 蓝牙已连接
  610. me.isConnectBlueth=true
  611. }
  612. });
  613. },
  614. (res) => {
  615. console.log('观察周围是否有其他骑手连接,请等待对方完成 或 微信是否开启了蓝牙权限',res,res.errCode);
  616. // var showContent = ""
  617. // if (res && ("errCode" in res)) {
  618. // if (res.errCode == 9000001) {
  619. // var showContent = "观察周围是否有其他骑手连接,请等待对方完成 或 微信是否开启了蓝牙权限!!"
  620. // } else {
  621. // var showContent = "连接失败,请尝试重新连接44444"+res.errCode
  622. // }
  623. // } else {
  624. // var showContent = "连接失败,请尝试重新连接55555"
  625. // }
  626. // uni.showModal({
  627. // title: this.$t('提示'),
  628. // confirmText: this.$t('重新连接'),
  629. // content: showContent,
  630. // success: function(res) {
  631. // if (res.confirm) {
  632. // setTimeout(()=>{
  633. // me.loadBluetooth();
  634. // },100)
  635. // } else {}
  636. // }
  637. // });
  638. },
  639. (res) => {
  640. // console.log('蓝牙未打开或请在右上角设置授权小程序使用蓝牙66666');
  641. uni.hideLoading();
  642. // uni.showModal({
  643. // title: this.$t('提示'),
  644. // confirmText: this.$t('我知道了'),
  645. // content: '蓝牙未打开或请在右上角设置授权小程序使用蓝牙66666',
  646. // success: function(res) {
  647. // if (res.confirm) {
  648. // me.loadBluetooth();
  649. // } else {}
  650. // }
  651. // });
  652. }
  653. );
  654. }, );
  655. } else {
  656. //蓝牙连接未成功
  657. // uni.hideLoading();
  658. // uni.showModal({
  659. // confirmText: this.$t('我知道了'),
  660. // content: this.$t('当前机柜未找到符合的蓝牙类型'),
  661. // showCancel: false,
  662. // title: this.$t('提示'),
  663. // complete: (res) => {}
  664. // });
  665. }
  666. },
  667. }
  668. };
  669. </script>
  670. <style lang="scss" scoped>
  671. @import './index.css';
  672. .header_view {
  673. position: fixed;
  674. top: 0;
  675. left: 0;
  676. width: 100%;
  677. background-color: #c4cad6;
  678. z-index: 999; /* 确保在最上层 */
  679. }
  680. .fillClass {}
  681. .news {
  682. position: relative;
  683. margin-right: 20rpx;
  684. .num {
  685. position: absolute;
  686. right: -6rpx;
  687. top: -6rpx;
  688. min-width: 28rpx;
  689. height: 28rpx;
  690. font-size: 18rpx;
  691. display: flex;
  692. align-items: center;
  693. justify-content: center;
  694. color: #fff;
  695. line-height: 1;
  696. background-color: #FA2918;
  697. border-radius: 50%;
  698. z-index: 99;
  699. }
  700. }
  701. </style>