index.vue 17 KB

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