index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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. <text class="quantity-text flex-row">
  47. <text style="font-weight:400;font-size: 22rpx;">{{$t("续航")}}</text>
  48. <text style="font-size: 36rpx;">{{car_info.endurance}}</text><text
  49. style="font-size: 30rpx;">km</text>
  50. </text>
  51. </view>
  52. <!-- <img :src="car_info.model_images||'https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX'" style="width: 100%;height: 526rpx;" alt=""> -->
  53. <img :src="'https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX'"
  54. style="width: 100%;height: 526rpx;" alt="">
  55. <view class="flex-row align-center update-time-view">
  56. <text style="margin-right: 10rpx;">{{$t("车辆已关机")}} </text>
  57. <text style="margin-right: 10rpx;">{{$t("更新于")}} {{car_info.heart_time|| ''}}11-25 23:05 </text>
  58. <img src="https://qiniu.bms16.com/FsL6XWGoIhfsVB7jRg6EGFVsuaTZ"
  59. style="width: 24rpx;height: 32rpx;" alt="">
  60. </view>
  61. </view>
  62. <Control :contrilList="contrilList" />
  63. <view v-if="car_info.exchange_package_info && car_info.exchange_package_info.activity_time"
  64. class="flex-row flex-between map-card-view">
  65. <MapCard :car_info="car_info" />
  66. <view class="card-right">
  67. <view class="card-bg" @tap="navTravelingTrack">
  68. <view class="flex-row flex-between card-top-title">
  69. <view class="flex-row align-center">
  70. <img style="width: 36rpx;height: 36rpx;"
  71. src="https://qiniu.bms16.com/FkrcMCV__HraZ0W0NBNdEZPIlwss" alt="">
  72. <text class="margin_l_8">{{isTrackOrAll?'最近骑行':'总里程'}}</text>
  73. </view>
  74. <view @tap.stop="isTrackOrAll=!isTrackOrAll"><img style="width: 24rpx;height: 20rpx;"
  75. src="https://qiniu.bms16.com/FltPK-o7KGS3dQ2pfQHXGSxOdzaN" alt=""></view>
  76. </view>
  77. <view class="card-top-text">{{car_info.current_mail}}<text class="font_24">km</text></view>
  78. </view>
  79. <view class="card-bg">
  80. <view class="flex-row card-top-title">
  81. <img style="width: 36rpx;height: 36rpx;"
  82. src="https://qiniu.bms16.com/FtalApKa3STyruaBxxRB4O9hHXyE" alt="">
  83. <text class="margin_l_8">{{$t("换电套餐")}}</text>
  84. </view>
  85. <view v-if="car_info.package_type == 1" class=" card-top-text">
  86. {{calculateRemainingDays(car_info.exchange_package_info.expire_time)}} <text
  87. class="font_24">{{$t("天")}}</text>
  88. </view>
  89. <view v-if="car_info.package_type == 2" class=" card-top-text">{{item.last_num}} <text
  90. class="font_24">{{$t("次")}}</text></view>
  91. <view v-if="car_info.package_type == 3" class=" card-top-text">
  92. {{item.total_day}}{{$t("天")}}/{{item.last_num}} <text class="font_24">{{$t("次")}}</text>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="config-view">
  98. <view @tap="navToPage" class="flex-row config-car-view">
  99. <view class="margin_r_20"><img class="icon_style_64"
  100. src="https://qiniu.bms16.com/Ftzyvs5whxDdMFksYChHaWKVb0Uk" alt=""></view>
  101. <view class="flex-row config-text-view" @tap="inductiveUnlockHandle">
  102. <view class="flex-row font_w_600">{{$t("感应解锁")}}</view>
  103. <view class="flex-row tip-text-config">{{$t("请先连接蓝牙")}}</view>
  104. </view>
  105. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm" alt="">
  106. </view>
  107. <view @tap="navToPage" data-url="/pages/userManagement/userManagement"
  108. class="flex-row config-car-view">
  109. <view class="margin_r_20"><img class="icon_style_64"
  110. src="https://qiniu.bms16.com/FhKkijkN__9UzhYNgamBFSggIlYo" alt=""></view>
  111. <view class="flex-row config-text-view">
  112. <view class="flex-row font_w_600">{{$t("用车人管理")}}</view>
  113. <view class="flex-row tip-text-config">{{car_info.share_num + $t("个家庭账号")}}</view>
  114. </view>
  115. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm" alt="">
  116. </view>
  117. <view @click="srcFn(`/pages/deviceInfo/deviceInfo`)" class="flex-row config-car-view">
  118. <view class="margin_r_20"><img class="icon_style_64"
  119. src="https://qiniu.bms16.com/FsAg6mHEBJfbtpgIHBrDdNiPo1iH" alt=""></view>
  120. <view class="flex-row config-text-view">
  121. <view class="flex-row font_w_600">{{$t("设备信息")}}</view>
  122. <view class="flex-row tip-text-config">{{$t("软件版本") + (car_info.firmware||'')}}</view>
  123. </view>
  124. <img class="icon_style_28" src="https://qiniu.bms16.com/FqnbZ2iKHmzCGJA8XD30sf5g_CAm" alt="">
  125. </view>
  126. </view>
  127. <view style="height: 264rpx;"></view>
  128. </view>
  129. </block>
  130. <block v-else>
  131. <UnleasedPages :model_list="model_list" :img_list="img_list" />
  132. </block>
  133. <BluetoothUnlockAuth ref="bluetoothUnlockAuth" />
  134. <CustomTabbar @changCar='changCar' curt-tab="home"/>
  135. <AndroidUnlockAuth :value="isShowPermission" @closePermission="closePermission" v-if="isShowPermission && (platform === 'android')" />
  136. <IosUnlockAuth :value="isShowPermission" @closePermission="closePermission" v-else-if="isShowPermission && (platform === 'ios')" />
  137. </view>
  138. </template>
  139. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  140. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  141. <script>
  142. var app = getApp();
  143. var config = require('@/common/config.js');
  144. var config_gyq = require('@/common/config_gyq.js');
  145. var common = require('@/common/common.js');
  146. var http = require('@/common/http.js');
  147. var request = require('@/common/request.js');
  148. var storage = require('@/common/storage.js');
  149. import Control from './components/control/control'
  150. import MapCard from './components/mapCard/mapCard'
  151. import UnleasedPages from './components/unleasedPages/unleasedPages'
  152. import CustomTabbar from '@/component/customTabbar/index';
  153. import BluetoothUnlockAuth from '../bluetoothUnlock/bluetoothUnlockAuth.vue'
  154. import AndroidUnlockAuth from './components/AndroidUnlockAuth.vue'
  155. import IosUnlockAuth from './components/IosUnlockAuth.vue'
  156. import {
  157. getFunctionTag,
  158. } from '@/common/storage.js';
  159. import permision from "@/js_sdk/wa-permission/permission.js"
  160. var bluetooth = require('@/common/bluetooth.js');
  161. export default {
  162. data() {
  163. return {
  164. statusBarHeight:0,
  165. newsList: {},
  166. img_list: [],
  167. isLogin: false,
  168. isOverdueShow: false,
  169. contrilList: [],
  170. isTrackOrAll: true,
  171. model_list: [],
  172. car_list: [], //用户车辆列表
  173. car_sn: '', //当前车辆编号
  174. isHideInduction: true,
  175. car_info: {
  176. exchange_package_info: {
  177. activity_time: 0
  178. }
  179. },
  180. platform:'android',//手机型号
  181. isShowPermission:false,//是否打开权限弹窗
  182. statusBarHeight:0,
  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. console.log(getFunctionTag().activeTag)
  232. this.contrilList = getFunctionTag().activeTag
  233. const user_token = storage.getUserToken()
  234. this.car_info = uni.getStorageSync('car_info') || {};
  235. if (!user_token) {
  236. this.isLogin = false
  237. //this.loadIsLogin()
  238. return
  239. }
  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.showModal({
  285. title: '提示',
  286. content: '您还未登录,请先登录',
  287. showCancel: true,
  288. cancelText: '取消',
  289. confirmText: '确定',
  290. success: function(res) {
  291. if (res.confirm) {
  292. uni.navigateTo({
  293. url: '/pages/loginRegister/login',
  294. })
  295. }
  296. },
  297. fail: function(res) {},
  298. complete: function(res) {},
  299. })
  300. },
  301. connectBluetooth() {
  302. var device = {
  303. mac_id: "900000997",
  304. btid: "900000997",
  305. btkey: "900000997",
  306. bt_type: "ZXCar",
  307. device_type: "ZXCar"
  308. };
  309. },
  310. toMoreInfoPage() {
  311. uni.navigateTo({
  312. url: '/pages/moreInfo/moreInfo',
  313. });
  314. },
  315. navTravelingTrack() {
  316. uni.navigateTo({
  317. url: '/pages/travelingTrack/travelingTrack?longitude=' + this.longitude + '&latitude=' + this
  318. .latitude,
  319. success: function(res) {},
  320. fail: function(res) {},
  321. complete: function(res) {}
  322. });
  323. },
  324. inductiveUnlockHandle() {
  325. const permissionArr=permision.requestAndroidPermissions(this.platform)
  326. app.globalData.permissionArr=permissionArr
  327. // let isOpenAllPermission=false
  328. // app.globalData.permissionArr.map(item=>{
  329. // if(!item.state) isOpenAllPermission=true
  330. // })
  331. // this.isShowPermission=true
  332. this.setData({
  333. isShowPermission:true
  334. })
  335. // this.$refs.bluetoothUnlockAuth.open();
  336. // console.log(this.isOpenAllPermission,'this.isOpenAllPermission');
  337. // if(!isOpenAllPermission){
  338. // common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
  339. // uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  340. // }else{
  341. // this.$refs.bluetoothUnlockAuth.open();
  342. // }
  343. },
  344. closePermission(){
  345. this.setData({
  346. isShowPermission:false
  347. })
  348. },
  349. showInduction() {
  350. this.isHideInduction = true
  351. },
  352. loadModelList() {
  353. const me = this
  354. http.postApi(config.API_RECOMMEND_CAR_MODEL_LIST, {}, (resp) => {
  355. if (resp.data.code === 200) {
  356. const list = resp.data.data
  357. console.log(resp.data.data)
  358. const img_list = resp.data.data.map(item => item.image)
  359. me.setData({
  360. model_list: list,
  361. img_list: img_list
  362. })
  363. } else {
  364. common.simpleToast(resp.data.msg);
  365. }
  366. })
  367. },
  368. srcFn(url) {
  369. uni.navigateTo({
  370. url: url
  371. });
  372. },
  373. navToPage(e) {
  374. const me = this
  375. const url = e.currentTarget.dataset.url;
  376. if (!url) {
  377. return;
  378. }
  379. uni.navigateTo({
  380. url: url
  381. });
  382. // if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
  383. // uni.navigateTo({
  384. // url: url
  385. // });
  386. // } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
  387. // uni.showModal({
  388. // title: '身份认证提示',
  389. // content: '尚未完成身份认证,是否进行身份认证?',
  390. // cancelText: '取消',
  391. // confirmText: '确定',
  392. // success: function(res) {
  393. // if (res.confirm) {
  394. // me.loadFaceToken()
  395. // }
  396. // },
  397. // fail: function(res) {},
  398. // complete: function(res) {},
  399. // })
  400. // } else {
  401. // uni.showModal({
  402. // title: '提示',
  403. // content: '您还未登录,请先登录',
  404. // showCancel: true,
  405. // cancelText: '取消',
  406. // confirmText: '确定',
  407. // success: function(res) {
  408. // if (res.confirm) {
  409. // //#ifdef MP-ALIPAY
  410. // uni.navigateTo({
  411. // url: '/pages/phoneLogin/phoneLogin',
  412. // })
  413. // //#endif
  414. // //#ifdef MP-WEIXIN
  415. // uni.navigateTo({
  416. // url: '/pages/login/login',
  417. // })
  418. // //#endif
  419. // }
  420. // },
  421. // fail: function(res) {},
  422. // complete: function(res) {},
  423. // })
  424. // }
  425. },
  426. loadUserCarList() {
  427. const me = this
  428. common.loading()
  429. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  430. uni.hideLoading();
  431. if (resp.data.code === 200) {
  432. const list = resp.data.data.list
  433. if (list.length > 0) {
  434. me.setData({
  435. car_list: list,
  436. car_sn: list[0].car_sn || '',
  437. })
  438. me.loadCarDetail(list[0].car_sn)
  439. }
  440. } else {
  441. common.simpleToast(resp.data.msg);
  442. }
  443. })
  444. },
  445. loadCarDetail(car_sn) {
  446. const me = this
  447. common.loading()
  448. http.postApi(config.API_FLK_CAR_DETAIL, {
  449. car_sn
  450. }, (resp) => {
  451. uni.hideLoading();
  452. if (resp.data.code === 200) {
  453. resp.data.data.car_sn = car_sn
  454. me.setData({
  455. car_info: resp.data.data,
  456. })
  457. uni.setStorageSync('car_info', this.car_info);
  458. //判断逾期
  459. if(!resp.data.data.sold_time) return
  460. let time = Math.ceil(resp.data.data.hire_end_time - Math.floor(new Date()) / 1000) / 60
  461. if (time > 0) {
  462. this.isOverdueShow = true
  463. this.car_info.hire_end_time = common.getTimeToDay(time)
  464. } else {
  465. this.isOverdueShow = false
  466. }
  467. } else {
  468. common.simpleToast(resp.data.msg);
  469. }
  470. })
  471. },
  472. navSwitchCar() {
  473. const me = this
  474. //如果租/购多个车辆的话可以切换当前车辆
  475. uni.navigateTo({
  476. url: `/pages/carList/carList?list=${encodeURIComponent(JSON.stringify(me.car_list))}&car_sn=${me.car_sn}`,
  477. })
  478. },
  479. formatDistance(distanceMeters) {
  480. // 判断距离是否超过1000米
  481. // let distanceMeters=Number(_distanceMeters)
  482. if (distanceMeters >= 1000) {
  483. // 如果超过1000米,则转换为千米并返回
  484. return (distanceMeters / 1000).toFixed(1);
  485. } else {
  486. // 否则直接返回米
  487. return distanceMeters.toFixed(0);
  488. }
  489. }
  490. }
  491. };
  492. </script>
  493. <style lang="scss" scoped>
  494. @import './index.css';
  495. .news {
  496. position: relative;
  497. .num {
  498. position: absolute;
  499. right: -6rpx;
  500. top: -6rpx;
  501. min-width: 28rpx;
  502. height: 28rpx;
  503. font-size: 18rpx;
  504. display: flex;
  505. align-items: center;
  506. justify-content: center;
  507. color: #fff;
  508. line-height: 1;
  509. background-color: #FA2918;
  510. border-radius: 50%;
  511. }
  512. }
  513. </style>