index.vue 15 KB

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