index.vue 16 KB

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