index.vue 17 KB

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