index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <view>
  3. <block v-if="isLogin && car_info.car_sn">
  4. <view class="container-view">
  5. <navBar type="index" />
  6. <view class="flex-row flex-between align-center padding_about_40">
  7. <view class="car-name-view" @tap="navSwitchCar">
  8. <text style="margin-right: 10rpx;">{{car_info.car_name}}</text>
  9. <img src="https://qiniu.bms16.com/FoSXDpVGvbdmwbX3CMUBvR7X4IzI"
  10. style="width: 14rpx;height: 14rpx;" alt="">
  11. </view>
  12. <view @click="routerLink('/pages/message/index')" class="news">
  13. <view v-if="(newsList.plate_count + newsList.device_count) > 0" class="num">{{newsList.plate_count + newsList.device_count}}</view>
  14. <image src="https://qiniu.bms16.com/FtlfBtBE5-TeTI5EdrciX_u8u_Sx"
  15. style="width: 48rpx;height: 48rpx;" mode=""></image>
  16. </view>
  17. </view>
  18. <view v-if="isOverdueShow" class="overdue-view flex-row flex-between">
  19. <view class="overdue-view-text flex-row">
  20. <text class="overdue-text-left">您已逾期
  21. <text class="overdue-num">
  22. <block v-if="orderInfo.hire_duration_time">
  23. {{orderInfo.hire_duration_time.day > 0 ? orderInfo.hire_duration_time.day :'' }}<text
  24. v-if="orderInfo.hire_duration_time.day>0">日</text>{{orderInfo.hire_duration_time.hour > 0 ? orderInfo.hire_duration_time.hour :'' }}<text
  25. v-if="orderInfo.hire_duration_time.hour>0">小时</text>{{orderInfo.hire_duration_time.minute > 0 ? orderInfo.hire_duration_time.minute :'' }}<text
  26. v-if="orderInfo.hire_duration_time.minute>0">分</text>
  27. </block>
  28. </text>
  29. </text>
  30. <text style="font-size: 24rpx;opacity: 0.5;">请及时续费或归还车辆</text>
  31. </view>
  32. <view @click="routerLink('/pages/order/order')" class="renew-btn">去续费</view>
  33. </view>
  34. <view class="car-img-view" @tap="toMoreInfoPage">
  35. <view class="quantity-view flex-row">
  36. <text class="quantity flex-row">{{car_info.soc}} <text
  37. style="font-size: 28rpx;font-weight: 500;">%</text></text>
  38. <u-line-progress style="width: 100rpx;" active-color="#2ADA62" height="10" :show-percent="false"
  39. :percent="car_info.soc"></u-line-progress>
  40. <view class="quantity-text flex-row">
  41. <view style="font-weight:400;font-size: 22rpx;width: 44rpx;">{{$t("续航")}}</view>
  42. <view style="font-size: 36rpx;">{{formatDistance(car_info.endurance) }}<text style="font-size: 30rpx;">{{car_info.endurance>1000?'km':'m'}}</text></view>
  43. </view>
  44. </view>
  45. <!-- <img :src="car_info.model_images||'https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX'" style="width: 100%;height: 526rpx;" alt=""> -->
  46. <img :src="'https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX'"
  47. style="width: 100%;height: 526rpx;" alt="">
  48. <view class="flex-row align-center update-time-view">
  49. <text style="margin-right: 10rpx;">{{$t("车辆已关机")}} </text>
  50. <text v-if="car_info.heart_time != 0" style="margin-right: 10rpx;">{{$t("更新于")}} {{car_info.heart_time|| ''}}</text>
  51. <img :src="'https://qiniu.bms16.com/'+(isBluethConnect?'Fk3f9H_o-1Wq2xXx7I_xo7bxK1xJ':'FsL6XWGoIhfsVB7jRg6EGFVsuaTZ')"
  52. :style="{width: (isBluethConnect?32:24)+'rpx',height: '32rpx'}" alt="">
  53. </view>
  54. </view>
  55. <Control :contrilList="contrilList" />
  56. <view v-if="car_info.exchange_package_info && car_info.exchange_package_info.activity_time"
  57. class="flex-row flex-between map-card-view">
  58. <MapCard :car_info="car_info" />
  59. <view class="card-right">
  60. <view class="card-bg" @tap="navTravelingTrack">
  61. <view class="flex-row flex-between card-top-title">
  62. <view class="flex-row align-center">
  63. <img style="width: 36rpx;height: 36rpx;"
  64. src="https://qiniu.bms16.com/FkrcMCV__HraZ0W0NBNdEZPIlwss" alt="">
  65. <text class="margin_l_8">{{isTrackOrAll?'最近骑行':'总里程'}}</text>
  66. </view>
  67. <view @tap.stop="isTrackOrAll=!isTrackOrAll"><img style="width: 24rpx;height: 20rpx;"
  68. src="https://qiniu.bms16.com/FltPK-o7KGS3dQ2pfQHXGSxOdzaN" alt=""></view>
  69. </view>
  70. <view class="card-top-text">{{car_info.current_mail}}<text class="font_24">km</text></view>
  71. </view>
  72. <view class="card-bg">
  73. <view class="flex-row card-top-title">
  74. <img style="width: 36rpx;height: 36rpx;"
  75. src="https://qiniu.bms16.com/FtalApKa3STyruaBxxRB4O9hHXyE" alt="">
  76. <text class="margin_l_8">{{$t("换电套餐")}}</text>
  77. </view>
  78. <view v-if="car_info.package_type == 1" class=" card-top-text">
  79. {{calculateRemainingDays(car_info.exchange_package_info.expire_time)}} <text
  80. class="font_24">{{$t("天")}}</text>
  81. </view>
  82. <view v-if="car_info.package_type == 2" class=" card-top-text">{{item.last_num}} <text
  83. class="font_24">{{$t("次")}}</text></view>
  84. <view v-if="car_info.package_type == 3" class=" card-top-text">
  85. {{item.total_day}}{{$t("天")}}/{{item.last_num}} <text class="font_24">{{$t("次")}}</text>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="config-view">
  91. <view @tap="navToPage" class="flex-row config-car-view">
  92. <view class="margin_r_20"><img class="icon_style_64"
  93. src="https://qiniu.bms16.com/Ftzyvs5whxDdMFksYChHaWKVb0Uk" alt=""></view>
  94. <view class="flex-row config-text-view" @tap="inductiveUnlockHandle">
  95. <view class="flex-row font_w_600">{{$t("感应解锁")}}</view>
  96. <view class="flex-row tip-text-config">{{isBluethConnect?$t("蓝牙配对成功"):$t("请先连接蓝牙")}}</view>
  97. </view>
  98. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm" alt="">
  99. </view>
  100. <view @tap="navToPage" data-url="/pages/userManagement/userManagement"
  101. class="flex-row config-car-view">
  102. <view class="margin_r_20"><img class="icon_style_64"
  103. src="https://qiniu.bms16.com/FhKkijkN__9UzhYNgamBFSggIlYo" alt=""></view>
  104. <view class="flex-row config-text-view">
  105. <view class="flex-row font_w_600">{{$t("用车人管理")}}</view>
  106. <view class="flex-row tip-text-config">{{car_info.share_num + $t("个家庭账号")}}</view>
  107. </view>
  108. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm" alt="">
  109. </view>
  110. <view @click="srcFn(`/pages/deviceInfo/deviceInfo`)" class="flex-row config-car-view">
  111. <view class="margin_r_20"><img class="icon_style_64"
  112. src="https://qiniu.bms16.com/FsAg6mHEBJfbtpgIHBrDdNiPo1iH" alt=""></view>
  113. <view class="flex-row config-text-view">
  114. <view class="flex-row font_w_600">{{$t("设备信息")}}</view>
  115. <view class="flex-row tip-text-config">{{$t("软件版本") + (car_info.firmware||'')}}</view>
  116. </view>
  117. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm" alt="">
  118. </view>
  119. </view>
  120. <view style="height: 264rpx;"></view>
  121. </view>
  122. </block>
  123. <block v-else>
  124. <UnleasedPages :model_list="model_list" :img_list="img_list" />
  125. </block>
  126. <BluetoothUnlockAuth ref="bluetoothUnlockAuth" />
  127. <CustomTabbar @changCar='changCar' curt-tab="home"/>
  128. <AndroidUnlockAuth :authStepList="authStepList" :value="isShowPermission" @closePermission="closePermission" v-if="isShowPermission && (platform === 'android')" />
  129. <IosUnlockAuth :authStepList="authStepList" :value="isShowPermission" @closePermission="closePermission" v-else-if="isShowPermission && (platform === 'ios')" />
  130. </view>
  131. </template>
  132. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  133. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  134. <script>
  135. var app = getApp();
  136. var config = require('@/common/config.js');
  137. var config_gyq = require('@/common/config_gyq.js');
  138. var common = require('@/common/common.js');
  139. var http = require('@/common/http.js');
  140. var request = require('@/common/request.js');
  141. var storage = require('@/common/storage.js');
  142. import Control from './components/control/control'
  143. import MapCard from './components/mapCard/mapCard'
  144. import UnleasedPages from './components/unleasedPages/unleasedPages'
  145. import CustomTabbar from '@/component/customTabbar/index';
  146. import BluetoothUnlockAuth from '../bluetoothUnlock/bluetoothUnlockAuth.vue'
  147. import AndroidUnlockAuth from './components/AndroidUnlockAuth.vue'
  148. import IosUnlockAuth from './components/IosUnlockAuth.vue'
  149. import {
  150. getFunctionTag,
  151. } from '@/common/storage.js';
  152. import permision from "@/js_sdk/wa-permission/permission.js"
  153. var bluetooth = require('@/common/bluetooth.js');
  154. export default {
  155. data() {
  156. return {
  157. newsList: {},
  158. img_list: [],
  159. isLogin: false,
  160. isOverdueShow: false,
  161. contrilList: [],
  162. isTrackOrAll: true,
  163. model_list: [],
  164. car_list: [], //用户车辆列表
  165. car_sn: '', //当前车辆编号
  166. isHideInduction: true,
  167. car_info: {
  168. exchange_package_info: {
  169. activity_time: 0
  170. }
  171. },
  172. platform:'android',//手机型号
  173. isShowPermission:false,//是否打开权限弹窗
  174. statusBarHeight:0,
  175. isBluethConnect:false, //当前是否蓝牙连接或者配对
  176. };
  177. },
  178. computed: {},
  179. components: {
  180. Control,
  181. MapCard,
  182. CustomTabbar,
  183. UnleasedPages,
  184. BluetoothUnlockAuth,
  185. AndroidUnlockAuth,
  186. IosUnlockAuth
  187. },
  188. /**
  189. * 生命周期函数--监听页面加载
  190. */
  191. onLoad: function(options) {
  192. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
  193. this.locationFn()
  194. this.loadModelList()
  195. const user_token = storage.getUserToken()
  196. if (!user_token) {
  197. this.loadIsLogin()
  198. return
  199. }
  200. },
  201. /**
  202. * 生命周期函数--监听页面显示
  203. */
  204. onShow: function() {
  205. // const permissionArr=permision.requestAndroidPermissions()
  206. // app.globalData.permissionArr=permissionArr
  207. // permision.gotoAppPermissionSetting()
  208. // let status = checkBatteryOptimizationStatus();
  209. // if (!permissionArr) {
  210. // uni.showModal({
  211. // title: "电池优化提示",
  212. // content: "您的设备开启了电池优化,可能会影响应用后台运行,请在设置中关闭。",
  213. // showCancel: true,
  214. // cancelText: "忽略",
  215. // confirmText: "去设置",
  216. // success(res) {
  217. // if (res.confirm) {
  218. // permision.gotoAppPermissionSetting(); // 跳转到电池优化设置
  219. // }
  220. // }
  221. // });
  222. // }
  223. // app.globalData.permissionArr=permissionArr
  224. console.log(getFunctionTag().activeTag)
  225. this.contrilList = getFunctionTag().activeTag
  226. const user_token = storage.getUserToken()
  227. this.car_info = uni.getStorageSync('car_info') || {};
  228. if (!user_token) {
  229. this.isLogin = false
  230. //this.loadIsLogin()
  231. return
  232. }
  233. console.log(app.globalData.connectionState[this.car_sn],'app.globalData.connectionState[this.car_sn]');
  234. this.isBluethConnect=app.globalData.connectionState[this.car_sn] && app.globalData.connectionState[this.car_sn].connected
  235. this.newsNumFn()
  236. this.isLogin = true
  237. if (!this.car_info.car_sn) {
  238. this.loadUserCarList()
  239. } else {
  240. this.loadCarDetail(this.car_info.car_sn)
  241. }
  242. },
  243. // 分享给好友
  244. onShareAppMessage: function(res) { //发送给朋友
  245. return {
  246. title: this.appConfig.app_name,
  247. path: 'pages/index/index',
  248. }
  249. },
  250. methods: {
  251. async newsNumFn() {
  252. let {
  253. data
  254. } = await request.postApi(config_gyq.API_FLK_MESSAGE_UNREAD_COUNT, {})
  255. if (data.code == 200) {
  256. this.newsList = data.data
  257. }
  258. },
  259. locationFn() {
  260. uni.getLocation({
  261. success(res) {
  262. let myLocation = {
  263. latitude: res.latitude,
  264. longitude: res.longitude,
  265. }
  266. storage.setUserCurrentLocation(myLocation)
  267. }
  268. })
  269. },
  270. changCar(e) {
  271. this.car_info = e
  272. },
  273. routerLink(url) {
  274. uni.navigateTo({
  275. url
  276. })
  277. },
  278. loadIsLogin() {
  279. uni.showModal({
  280. title: '提示',
  281. content: '您还未登录,请先登录',
  282. showCancel: true,
  283. cancelText: '取消',
  284. confirmText: '确定',
  285. success: function(res) {
  286. if (res.confirm) {
  287. uni.navigateTo({
  288. url: '/pages/loginRegister/login',
  289. })
  290. }
  291. },
  292. fail: function(res) {},
  293. complete: function(res) {},
  294. })
  295. },
  296. toMoreInfoPage() {
  297. uni.navigateTo({
  298. url: '/pages/moreInfo/moreInfo',
  299. });
  300. },
  301. navTravelingTrack() {
  302. uni.navigateTo({
  303. url: '/pages/travelingTrack/travelingTrack?longitude=' + this.longitude + '&latitude=' + this
  304. .latitude,
  305. success: function(res) {},
  306. fail: function(res) {},
  307. complete: function(res) {}
  308. });
  309. },
  310. inductiveUnlockHandle() {
  311. if(this.isBluethConnect){
  312. uni.navigateTo({ url: '/pages/bluetoothUnlock/unlockSet' })
  313. }else{
  314. const permissionArr=permision.requestAndroidPermissions(this.platform)
  315. console.log(permissionArr,'permissionArr');
  316. this.setData({
  317. authStepList:permissionArr
  318. })
  319. let isOpenAllPermission=false
  320. permissionArr.map(item=>{
  321. if(!item.state) isOpenAllPermission=true
  322. })
  323. if(!isOpenAllPermission){
  324. common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
  325. uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  326. }else{
  327. this.setData({
  328. isShowPermission:true,
  329. })
  330. }
  331. }
  332. },
  333. closePermission(){
  334. this.setData({
  335. isShowPermission:false
  336. })
  337. },
  338. showInduction() {
  339. this.isHideInduction = true
  340. },
  341. loadModelList() {
  342. const me = this
  343. http.postApi(config.API_RECOMMEND_CAR_MODEL_LIST, {}, (resp) => {
  344. if (resp.data.code === 200) {
  345. const list = resp.data.data
  346. const img_list = resp.data.data.map(item => item.image)
  347. me.setData({
  348. model_list: list,
  349. img_list: img_list
  350. })
  351. } else {
  352. common.simpleToast(resp.data.msg);
  353. }
  354. })
  355. },
  356. srcFn(url) {
  357. uni.navigateTo({
  358. url: url
  359. });
  360. },
  361. navToPage(e) {
  362. const me = this
  363. const url = e.currentTarget.dataset.url;
  364. if (!url) {
  365. return;
  366. }
  367. uni.navigateTo({
  368. url: url
  369. });
  370. // if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
  371. // uni.navigateTo({
  372. // url: url
  373. // });
  374. // } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
  375. // uni.showModal({
  376. // title: '身份认证提示',
  377. // content: '尚未完成身份认证,是否进行身份认证?',
  378. // cancelText: '取消',
  379. // confirmText: '确定',
  380. // success: function(res) {
  381. // if (res.confirm) {
  382. // me.loadFaceToken()
  383. // }
  384. // },
  385. // fail: function(res) {},
  386. // complete: function(res) {},
  387. // })
  388. // } else {
  389. // uni.showModal({
  390. // title: '提示',
  391. // content: '您还未登录,请先登录',
  392. // showCancel: true,
  393. // cancelText: '取消',
  394. // confirmText: '确定',
  395. // success: function(res) {
  396. // if (res.confirm) {
  397. // //#ifdef MP-ALIPAY
  398. // uni.navigateTo({
  399. // url: '/pages/phoneLogin/phoneLogin',
  400. // })
  401. // //#endif
  402. // //#ifdef MP-WEIXIN
  403. // uni.navigateTo({
  404. // url: '/pages/login/login',
  405. // })
  406. // //#endif
  407. // }
  408. // },
  409. // fail: function(res) {},
  410. // complete: function(res) {},
  411. // })
  412. // }
  413. },
  414. loadUserCarList() {
  415. const me = this
  416. common.loading()
  417. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  418. uni.hideLoading();
  419. if (resp.data.code === 200) {
  420. const list = resp.data.data.list
  421. if (list.length > 0) {
  422. me.setData({
  423. car_list: list,
  424. car_sn: list[0].car_sn || '',
  425. })
  426. me.loadCarDetail(list[0].car_sn)
  427. }
  428. } else {
  429. common.simpleToast(resp.data.msg);
  430. }
  431. })
  432. },
  433. loadCarDetail(car_sn) {
  434. const me = this
  435. common.loading()
  436. http.postApi(config.API_FLK_CAR_DETAIL, {
  437. car_sn
  438. }, (resp) => {
  439. uni.hideLoading();
  440. if (resp.data.code === 200) {
  441. resp.data.data.car_sn = car_sn
  442. me.setData({
  443. car_info: resp.data.data,
  444. })
  445. uni.setStorageSync('car_info', this.car_info);
  446. //判断逾期
  447. if(!resp.data.data.sold_time) return
  448. let time = Math.ceil(resp.data.data.hire_end_time - Math.floor(new Date()) / 1000) / 60
  449. if (time > 0) {
  450. this.isOverdueShow = true
  451. this.car_info.hire_end_time = common.getTimeToDay(time)
  452. } else {
  453. this.isOverdueShow = false
  454. }
  455. } else {
  456. common.simpleToast(resp.data.msg);
  457. }
  458. })
  459. },
  460. navSwitchCar() {
  461. const me = this
  462. //如果租/购多个车辆的话可以切换当前车辆
  463. uni.navigateTo({
  464. url: `/pages/carList/carList?list=${encodeURIComponent(JSON.stringify(me.car_list))}&car_sn=${me.car_sn}`,
  465. })
  466. },
  467. formatDistance(distanceMeters) {
  468. // 判断距离是否超过1000米
  469. // let distanceMeters=Number(_distanceMeters)
  470. if (distanceMeters >= 1000) {
  471. // 如果超过1000米,则转换为千米并返回
  472. return (distanceMeters / 1000).toFixed(1);
  473. } else {
  474. // 否则直接返回米
  475. return distanceMeters.toFixed(0);
  476. }
  477. }
  478. }
  479. };
  480. </script>
  481. <style lang="scss" scoped>
  482. @import './index.css';
  483. .news {
  484. position: relative;
  485. .num {
  486. position: absolute;
  487. right: -6rpx;
  488. top: -6rpx;
  489. min-width: 28rpx;
  490. height: 28rpx;
  491. font-size: 18rpx;
  492. display: flex;
  493. align-items: center;
  494. justify-content: center;
  495. color: #fff;
  496. line-height: 1;
  497. background-color: #FA2918;
  498. border-radius: 50%;
  499. }
  500. }
  501. </style>