index.vue 13 KB

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