index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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;">{{car_info.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 :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 @tap="navToPage" 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. </view>
  97. </template>
  98. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  99. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  100. <script>
  101. var app = getApp();
  102. var config = require('@/common/config.js');
  103. var common = require('@/common/common.js');
  104. var http = require('@/common/http.js');
  105. var storage = require('@/common/storage.js');
  106. import Control from './components/control/control'
  107. import MapCard from './components/mapCard/mapCard'
  108. import UnleasedPages from './components/unleasedPages/unleasedPages'
  109. import CustomTabbar from '@/component/customTabbar/index';
  110. import BluetoothUnlockAuth from '../bluetoothUnlock/bluetoothUnlockAuth.vue'
  111. import {
  112. getFunctionTag,
  113. } from '@/common/storage.js';
  114. import permision from "@/js_sdk/wa-permission/permission.js"
  115. export default {
  116. data() {
  117. return {
  118. contrilList:[],
  119. carLocation: [{
  120. id: 1345,
  121. latitude: 23.099994,
  122. longitude: 113.324004,
  123. iconPath: 'https://qiniu.bms16.com/FjzP68_NSPJbde_JraN5dJRnyqqJ',
  124. width: 60,
  125. height: 60,
  126. customCallout: {
  127. display: 'ALWAYS', // 'BYCLICK':点击显示; 'ALWAYS':常显
  128. },
  129. }], // 标记点
  130. carAddress:'普宁升记炒饭肠粉百...',
  131. isTrackOrAll:true,
  132. model_list:[],
  133. car_list:[],//用户车辆列表
  134. car_sn:'',//当前车辆编号
  135. isHideInduction:true,
  136. car_info:{
  137. exchange_package_info:{
  138. activity_time:0
  139. }
  140. }
  141. };
  142. },
  143. computed: {},
  144. components: {
  145. Control,
  146. MapCard,
  147. CustomTabbar,
  148. UnleasedPages,
  149. BluetoothUnlockAuth
  150. },
  151. /**
  152. * 生命周期函数--监听页面加载
  153. */
  154. onLoad: function(options) {
  155. const user_token = storage.getUserToken()
  156. if (!user_token) {
  157. this.loadIsLogin()
  158. return
  159. }
  160. this.loadModelList()
  161. },
  162. /**
  163. * 生命周期函数--监听页面显示
  164. */
  165. onShow: function() {
  166. // const permissionArr=permision.requestAndroidPermissions()
  167. // app.globalData.permissionArr=permissionArr
  168. // permision.gotoAppPermissionSetting()
  169. // let status = checkBatteryOptimizationStatus();
  170. // if (!permissionArr) {
  171. // uni.showModal({
  172. // title: "电池优化提示",
  173. // content: "您的设备开启了电池优化,可能会影响应用后台运行,请在设置中关闭。",
  174. // showCancel: true,
  175. // cancelText: "忽略",
  176. // confirmText: "去设置",
  177. // success(res) {
  178. // if (res.confirm) {
  179. // permision.gotoAppPermissionSetting(); // 跳转到电池优化设置
  180. // }
  181. // }
  182. // });
  183. // }
  184. // app.globalData.permissionArr=permissionArr
  185. console.log(33333333)
  186. console.log(getFunctionTag().activeTag)
  187. this.contrilList = getFunctionTag().activeTag
  188. const user_token = storage.getUserToken()
  189. console.log(user_token)
  190. if (!user_token) {
  191. this.loadIsLogin()
  192. return
  193. }
  194. this.loadUserCarList()
  195. },
  196. // 分享给好友
  197. onShareAppMessage: function(res) { //发送给朋友
  198. return {
  199. title: this.appConfig.app_name,
  200. path: 'pages/index/index',
  201. }
  202. },
  203. methods: {
  204. loadIsLogin(){
  205. uni.showModal({
  206. title: '提示',
  207. content: '您还未登录,请先登录',
  208. showCancel: true,
  209. cancelText: '取消',
  210. confirmText: '确定',
  211. success: function(res) {
  212. if (res.confirm) {
  213. uni.navigateTo({
  214. url: '/pages/loginRegister/login',
  215. })
  216. }
  217. },
  218. fail: function(res) {},
  219. complete: function(res) {},
  220. })
  221. },
  222. connectBluetooth(){
  223. var device = {
  224. mac_id: "900000997",
  225. btid: "900000997",
  226. btkey: "900000997",
  227. bt_type: "ZXCar",
  228. device_type: "ZXCar"
  229. };
  230. },
  231. navTravelingTrack(){
  232. uni.navigateTo({
  233. url: '/pages/travelingTrack/travelingTrack?longitude=' + this.longitude +'&latitude=' + this.latitude,
  234. success: function(res) {},
  235. fail: function(res) {},
  236. complete: function(res) {}
  237. });
  238. },
  239. inductiveUnlockHandle() {
  240. this.isHideInduction=false
  241. let isOpenAllPermission=false
  242. app.globalData.permissionArr.map(item=>{
  243. if(!item.state) isOpenAllPermission=true
  244. })
  245. // console.log(this.isOpenAllPermission,'this.isOpenAllPermission');
  246. if(!isOpenAllPermission){
  247. common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
  248. uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  249. }else{
  250. this.$refs.bluetoothUnlockAuth.open();
  251. }
  252. },
  253. showInduction(){
  254. this.isHideInduction=true
  255. },
  256. loadModelList() {
  257. const me = this
  258. http.postApi(config.API_RECOMMEND_CAR_MODEL_LIST, {}, (resp) => {
  259. if (resp.data.code === 200) {
  260. const list=resp.data.data
  261. const img_list=resp.data.data.map(item=>item.image)
  262. me.setData({
  263. model_list:list,
  264. img_list:img_list
  265. })
  266. } else {
  267. common.simpleToast(resp.data.msg);
  268. }
  269. })
  270. },
  271. srcFn(url){
  272. uni.navigateTo({
  273. url: url
  274. });
  275. },
  276. navToPage(e) {
  277. const me = this
  278. const url = e.currentTarget.dataset.url;
  279. if (!url) {
  280. return;
  281. }
  282. uni.navigateTo({
  283. url: url
  284. });
  285. // if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
  286. // uni.navigateTo({
  287. // url: url
  288. // });
  289. // } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
  290. // uni.showModal({
  291. // title: '身份认证提示',
  292. // content: '尚未完成身份认证,是否进行身份认证?',
  293. // cancelText: '取消',
  294. // confirmText: '确定',
  295. // success: function(res) {
  296. // if (res.confirm) {
  297. // me.loadFaceToken()
  298. // }
  299. // },
  300. // fail: function(res) {},
  301. // complete: function(res) {},
  302. // })
  303. // } else {
  304. // uni.showModal({
  305. // title: '提示',
  306. // content: '您还未登录,请先登录',
  307. // showCancel: true,
  308. // cancelText: '取消',
  309. // confirmText: '确定',
  310. // success: function(res) {
  311. // if (res.confirm) {
  312. // //#ifdef MP-ALIPAY
  313. // uni.navigateTo({
  314. // url: '/pages/phoneLogin/phoneLogin',
  315. // })
  316. // //#endif
  317. // //#ifdef MP-WEIXIN
  318. // uni.navigateTo({
  319. // url: '/pages/login/login',
  320. // })
  321. // //#endif
  322. // }
  323. // },
  324. // fail: function(res) {},
  325. // complete: function(res) {},
  326. // })
  327. // }
  328. },
  329. loadUserCarList(){
  330. const me = this
  331. common.loading()
  332. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  333. uni.hideLoading();
  334. if (resp.data.code === 200) {
  335. const list=resp.data.data.list
  336. if(list.length > 0){
  337. me.setData({
  338. car_list:list,
  339. car_sn:list[0].car_sn||'',
  340. })
  341. me.loadCarDetail(list[0].car_sn)
  342. }
  343. } else {
  344. common.simpleToast(resp.data.msg);
  345. }
  346. })
  347. },
  348. loadCarDetail(car_sn){
  349. const me = this
  350. common.loading()
  351. http.postApi(config.API_FLK_CAR_DETAIL, {car_sn}, (resp) => {
  352. uni.hideLoading();
  353. if (resp.data.code === 200) {
  354. resp.data.data.car_sn = car_sn
  355. me.setData({
  356. car_info:resp.data.data,
  357. })
  358. uni.setStorageSync('car_info', this.car_info);
  359. } else {
  360. common.simpleToast(resp.data.msg);
  361. }
  362. })
  363. },
  364. navSwitchCar(){
  365. const me=this
  366. //如果租/购多个车辆的话可以切换当前车辆
  367. uni.navigateTo({
  368. url: `/pages/carList/carList?list=${encodeURIComponent(JSON.stringify(me.car_list))}&car_sn=${me.car_sn}`,
  369. })
  370. }
  371. }
  372. };
  373. </script>
  374. <style>
  375. @import './index.css';
  376. </style>