index.vue 18 KB

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