index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <view>
  3. <block v-if="isLogin && car_info.car_sn">
  4. <view class="container-view">
  5. <view class="flex-row flex-between align-center padding_about_40">
  6. <view class="car-name-view" @tap="navSwitchCar">
  7. <text style="margin-right: 10rpx;">{{car_info.car_name}}</text>
  8. <img src="https://qiniu.bms16.com/FoSXDpVGvbdmwbX3CMUBvR7X4IzI"
  9. style="width: 14rpx;height: 14rpx;" alt="">
  10. </view>
  11. <view @click="routerLink('/pages/message/index')" class="news">
  12. <view v-if="(newsList.plate_count + newsList.device_count) > 0" class="num">{{newsList.plate_count + newsList.device_count}}</view>
  13. <image src="https://qiniu.bms16.com/FtlfBtBE5-TeTI5EdrciX_u8u_Sx"
  14. style="width: 48rpx;height: 48rpx;" mode=""></image>
  15. </view>
  16. </view>
  17. <view v-if="isOverdueShow" class="overdue-view flex-row flex-between">
  18. <view class="overdue-view-text flex-row">
  19. <text class="overdue-text-left">您已逾期
  20. <text class="overdue-num">
  21. <block v-if="orderInfo.hire_duration_time">
  22. {{orderInfo.hire_duration_time.day > 0 ? orderInfo.hire_duration_time.day :'' }}<text
  23. v-if="orderInfo.hire_duration_time.day>0">日</text>{{orderInfo.hire_duration_time.hour > 0 ? orderInfo.hire_duration_time.hour :'' }}<text
  24. v-if="orderInfo.hire_duration_time.hour>0">小时</text>{{orderInfo.hire_duration_time.minute > 0 ? orderInfo.hire_duration_time.minute :'' }}<text
  25. v-if="orderInfo.hire_duration_time.minute>0">分</text>
  26. </block>
  27. </text>
  28. </text>
  29. <text style="font-size: 24rpx;opacity: 0.5;">请及时续费或归还车辆</text>
  30. </view>
  31. <view @click="routerLink('/pages/order/order')" class="renew-btn">去续费</view>
  32. </view>
  33. <view class="car-img-view" @tap="toMoreInfoPage">
  34. <view class="quantity-view flex-row">
  35. <text class="quantity flex-row">{{car_info.soc}} <text
  36. style="font-size: 28rpx;font-weight: 500;">%</text></text>
  37. <u-line-progress style="width: 100rpx;" active-color="#2ADA62" height="10" :show-percent="false"
  38. :percent="car_info.soc"></u-line-progress>
  39. <text class="quantity-text flex-row">
  40. <text style="font-weight:400;font-size: 22rpx;">{{$t("续航")}}</text>
  41. <text style="font-size: 36rpx;">{{car_info.endurance}}</text><text
  42. style="font-size: 30rpx;">km</text>
  43. </text>
  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 style="margin-right: 10rpx;">{{$t("更新于")}} {{car_info.heart_time|| ''}}11-25 23:05 </text>
  51. <img src="https://qiniu.bms16.com/FsL6XWGoIhfsVB7jRg6EGFVsuaTZ"
  52. style="width: 24rpx;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">{{$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 :value="isShowPermission" @closePermission="closePermission" v-if="isShowPermission && (platform === 'android')" />
  129. <IosUnlockAuth :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. };
  175. },
  176. computed: {},
  177. components: {
  178. Control,
  179. MapCard,
  180. CustomTabbar,
  181. UnleasedPages,
  182. BluetoothUnlockAuth,
  183. AndroidUnlockAuth,
  184. IosUnlockAuth
  185. },
  186. /**
  187. * 生命周期函数--监听页面加载
  188. */
  189. onLoad: function(options) {
  190. this.locationFn()
  191. this.loadModelList()
  192. const user_token = storage.getUserToken()
  193. if (!user_token) {
  194. this.loadIsLogin()
  195. return
  196. }
  197. },
  198. /**
  199. * 生命周期函数--监听页面显示
  200. */
  201. onShow: function() {
  202. // const permissionArr=permision.requestAndroidPermissions()
  203. // app.globalData.permissionArr=permissionArr
  204. // permision.gotoAppPermissionSetting()
  205. // let status = checkBatteryOptimizationStatus();
  206. // if (!permissionArr) {
  207. // uni.showModal({
  208. // title: "电池优化提示",
  209. // content: "您的设备开启了电池优化,可能会影响应用后台运行,请在设置中关闭。",
  210. // showCancel: true,
  211. // cancelText: "忽略",
  212. // confirmText: "去设置",
  213. // success(res) {
  214. // if (res.confirm) {
  215. // permision.gotoAppPermissionSetting(); // 跳转到电池优化设置
  216. // }
  217. // }
  218. // });
  219. // }
  220. // app.globalData.permissionArr=permissionArr
  221. console.log(getFunctionTag().activeTag)
  222. this.contrilList = getFunctionTag().activeTag
  223. const user_token = storage.getUserToken()
  224. this.car_info = uni.getStorageSync('car_info') || {};
  225. if (!user_token) {
  226. this.isLogin = false
  227. //this.loadIsLogin()
  228. return
  229. }
  230. this.newsNumFn()
  231. this.isLogin = true
  232. if (!this.car_info.car_sn) {
  233. this.loadUserCarList()
  234. } else {
  235. this.loadCarDetail(this.car_info.car_sn)
  236. }
  237. },
  238. // 分享给好友
  239. onShareAppMessage: function(res) { //发送给朋友
  240. return {
  241. title: this.appConfig.app_name,
  242. path: 'pages/index/index',
  243. }
  244. },
  245. methods: {
  246. async newsNumFn() {
  247. let {
  248. data
  249. } = await request.postApi(config_gyq.API_FLK_MESSAGE_UNREAD_COUNT, {})
  250. if (data.code == 200) {
  251. this.newsList = data.data
  252. }
  253. },
  254. locationFn() {
  255. uni.getLocation({
  256. success(res) {
  257. let myLocation = {
  258. latitude: res.latitude,
  259. longitude: res.longitude,
  260. }
  261. storage.setUserCurrentLocation(myLocation)
  262. }
  263. })
  264. },
  265. changCar(e) {
  266. this.car_info = e
  267. },
  268. routerLink(url) {
  269. uni.navigateTo({
  270. url
  271. })
  272. },
  273. loadIsLogin() {
  274. uni.showModal({
  275. title: '提示',
  276. content: '您还未登录,请先登录',
  277. showCancel: true,
  278. cancelText: '取消',
  279. confirmText: '确定',
  280. success: function(res) {
  281. if (res.confirm) {
  282. uni.navigateTo({
  283. url: '/pages/loginRegister/login',
  284. })
  285. }
  286. },
  287. fail: function(res) {},
  288. complete: function(res) {},
  289. })
  290. },
  291. connectBluetooth() {
  292. var device = {
  293. mac_id: "900000997",
  294. btid: "900000997",
  295. btkey: "900000997",
  296. bt_type: "ZXCar",
  297. device_type: "ZXCar"
  298. };
  299. },
  300. toMoreInfoPage() {
  301. uni.navigateTo({
  302. url: '/pages/moreInfo/moreInfo',
  303. });
  304. },
  305. navTravelingTrack() {
  306. uni.navigateTo({
  307. url: '/pages/travelingTrack/travelingTrack?longitude=' + this.longitude + '&latitude=' + this
  308. .latitude,
  309. success: function(res) {},
  310. fail: function(res) {},
  311. complete: function(res) {}
  312. });
  313. },
  314. inductiveUnlockHandle() {
  315. const permissionArr=permision.requestAndroidPermissions(this.platform)
  316. app.globalData.permissionArr=permissionArr
  317. // let isOpenAllPermission=false
  318. // app.globalData.permissionArr.map(item=>{
  319. // if(!item.state) isOpenAllPermission=true
  320. // })
  321. // this.isShowPermission=true
  322. this.setData({
  323. isShowPermission:true
  324. })
  325. // this.$refs.bluetoothUnlockAuth.open();
  326. // console.log(this.isOpenAllPermission,'this.isOpenAllPermission');
  327. // if(!isOpenAllPermission){
  328. // common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
  329. // uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  330. // }else{
  331. // this.$refs.bluetoothUnlockAuth.open();
  332. // }
  333. },
  334. closePermission(){
  335. this.setData({
  336. isShowPermission:false
  337. })
  338. },
  339. showInduction() {
  340. this.isHideInduction = true
  341. },
  342. loadModelList() {
  343. const me = this
  344. http.postApi(config.API_RECOMMEND_CAR_MODEL_LIST, {}, (resp) => {
  345. if (resp.data.code === 200) {
  346. const list = resp.data.data
  347. console.log('哈哈哈啊哈')
  348. console.log(resp.data.data)
  349. const img_list = resp.data.data.map(item => item.image)
  350. me.setData({
  351. model_list: list,
  352. img_list: img_list
  353. })
  354. } else {
  355. common.simpleToast(resp.data.msg);
  356. }
  357. })
  358. },
  359. srcFn(url) {
  360. uni.navigateTo({
  361. url: url
  362. });
  363. },
  364. navToPage(e) {
  365. const me = this
  366. const url = e.currentTarget.dataset.url;
  367. if (!url) {
  368. return;
  369. }
  370. uni.navigateTo({
  371. url: url
  372. });
  373. // if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
  374. // uni.navigateTo({
  375. // url: url
  376. // });
  377. // } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
  378. // uni.showModal({
  379. // title: '身份认证提示',
  380. // content: '尚未完成身份认证,是否进行身份认证?',
  381. // cancelText: '取消',
  382. // confirmText: '确定',
  383. // success: function(res) {
  384. // if (res.confirm) {
  385. // me.loadFaceToken()
  386. // }
  387. // },
  388. // fail: function(res) {},
  389. // complete: function(res) {},
  390. // })
  391. // } else {
  392. // uni.showModal({
  393. // title: '提示',
  394. // content: '您还未登录,请先登录',
  395. // showCancel: true,
  396. // cancelText: '取消',
  397. // confirmText: '确定',
  398. // success: function(res) {
  399. // if (res.confirm) {
  400. // //#ifdef MP-ALIPAY
  401. // uni.navigateTo({
  402. // url: '/pages/phoneLogin/phoneLogin',
  403. // })
  404. // //#endif
  405. // //#ifdef MP-WEIXIN
  406. // uni.navigateTo({
  407. // url: '/pages/login/login',
  408. // })
  409. // //#endif
  410. // }
  411. // },
  412. // fail: function(res) {},
  413. // complete: function(res) {},
  414. // })
  415. // }
  416. },
  417. loadUserCarList() {
  418. const me = this
  419. common.loading()
  420. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  421. uni.hideLoading();
  422. if (resp.data.code === 200) {
  423. const list = resp.data.data.list
  424. if (list.length > 0) {
  425. me.setData({
  426. car_list: list,
  427. car_sn: list[0].car_sn || '',
  428. })
  429. me.loadCarDetail(list[0].car_sn)
  430. }
  431. } else {
  432. common.simpleToast(resp.data.msg);
  433. }
  434. })
  435. },
  436. loadCarDetail(car_sn) {
  437. const me = this
  438. common.loading()
  439. http.postApi(config.API_FLK_CAR_DETAIL, {
  440. car_sn
  441. }, (resp) => {
  442. uni.hideLoading();
  443. if (resp.data.code === 200) {
  444. resp.data.data.car_sn = car_sn
  445. me.setData({
  446. car_info: resp.data.data,
  447. })
  448. uni.setStorageSync('car_info', this.car_info);
  449. //判断逾期
  450. if(!resp.data.data.sold_time) return
  451. let time = Math.ceil(resp.data.data.hire_end_time - Math.floor(new Date()) / 1000) / 60
  452. if (time > 0) {
  453. this.isOverdueShow = true
  454. this.car_info.hire_end_time = common.getTimeToDay(time)
  455. } else {
  456. this.isOverdueShow = false
  457. }
  458. } else {
  459. common.simpleToast(resp.data.msg);
  460. }
  461. })
  462. },
  463. navSwitchCar() {
  464. const me = this
  465. //如果租/购多个车辆的话可以切换当前车辆
  466. uni.navigateTo({
  467. url: `/pages/carList/carList?list=${encodeURIComponent(JSON.stringify(me.car_list))}&car_sn=${me.car_sn}`,
  468. })
  469. },
  470. formatDistance(distanceMeters) {
  471. // 判断距离是否超过1000米
  472. // let distanceMeters=Number(_distanceMeters)
  473. if (distanceMeters >= 1000) {
  474. // 如果超过1000米,则转换为千米并返回
  475. return (distanceMeters / 1000).toFixed(1);
  476. } else {
  477. // 否则直接返回米
  478. return distanceMeters.toFixed(0);
  479. }
  480. }
  481. }
  482. };
  483. </script>
  484. <style lang="scss" scoped>
  485. @import './index.css';
  486. .news {
  487. position: relative;
  488. .num {
  489. position: absolute;
  490. right: -6rpx;
  491. top: -6rpx;
  492. min-width: 28rpx;
  493. height: 28rpx;
  494. font-size: 18rpx;
  495. display: flex;
  496. align-items: center;
  497. justify-content: center;
  498. color: #fff;
  499. line-height: 1;
  500. background-color: #FA2918;
  501. border-radius: 50%;
  502. }
  503. }
  504. </style>