index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <view>
  3. <top-box :token="token" :userinfo="userinfo"></top-box>
  4. <view class="main-box">
  5. <view class="carinfo">
  6. <view class="norecord" v-if="noData">{{noData}}</view>
  7. <uni-swiper-dot :info="datalist" :current="current" field="content" mode="default"
  8. :dots-styles="dotsStyles">
  9. <swiper class="swiper-box" @change="change">
  10. <swiper-item v-for="(item ,index) in datalist" :key="index">
  11. <view class="swiper-item">
  12. <view class="plate">
  13. <view>车牌号</view>
  14. <view>
  15. <image src="../../static/icon1.png"></image>
  16. </view>
  17. <view>电池AI云管理监控中</view>
  18. </view>
  19. <view class="plate-number">
  20. <view>{{item.plate || '暂无信息'}}</view>
  21. <view>
  22. <image src="../../static/icon2.png"></image>
  23. </view>
  24. </view>
  25. <view class="battery-soc">
  26. <view>电池SOC</view>
  27. <view>
  28. <view class="strip">
  29. <!-- 第二层进度条的颜色 -->
  30. <view class="blue" :style="'width:'+item.soc+'%'">
  31. <!-- (进度条显示的图片 样式:根据父元素进行相对定位 ,本身绝对定位 ) -->
  32. <text class="protext" :style="'left:'+item.soc+'%'"></text>
  33. <view class="pronumber" :style="'left:'+(item.soc-6)+'%'">
  34. {{item.soc || 0}}%
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="battery-info">
  41. <view>
  42. <view>{{item.drivingMileage || 0}}km</view>
  43. <view>已行驶里程</view>
  44. </view>
  45. <view>
  46. <view>{{item.current || 0}}km</view>
  47. <view>预计剩余里程</view>
  48. </view>
  49. <view>
  50. <view>{{item.voltage || 0}}V</view>
  51. <view>电压</view>
  52. </view>
  53. <view>
  54. <view>{{item.drivingMileage || 0}}A</view>
  55. <view>电流</view>
  56. </view>
  57. </view>
  58. </view>
  59. </swiper-item>
  60. </swiper>
  61. </uni-swiper-dot>
  62. </view>
  63. <view class="change-title">
  64. <view>
  65. <image src="../../static/icon3.png"></image>
  66. </view>
  67. <view>换电站信息</view>
  68. </view>
  69. <view class="change-box">
  70. <view class="title">三江新区沙坪换电站</view>
  71. <view class="tags">
  72. <view>常去地点</view>
  73. <view>24小时营业</view>
  74. </view>
  75. <view class="piclist">
  76. <view>
  77. <image src="../../static/pic.jpg"></image>
  78. </view>
  79. <view>
  80. <image src="../../static/pic.jpg"></image>
  81. </view>
  82. </view>
  83. <view class="address">
  84. <view>876m · 四川省宜宾市三江新区沙坪镇沙溪街道89号</view>
  85. <view @click="jumptest">
  86. <image src="../../static/icon4.png"></image>
  87. <view>电话</view>
  88. </view>
  89. <view @click="jumpmaps">
  90. <image src="../../static/icon5.png"></image>
  91. <view>路线</view>
  92. </view>
  93. </view>
  94. <view class="battery-num">
  95. <view>可换电池</view>
  96. <view>8</view>
  97. </view>
  98. </view>
  99. </view>
  100. <tab-bar></tab-bar>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. isAuthShow: false,
  108. token: null,
  109. userinfo: null,
  110. latitude: 29.632675, //纬度参数
  111. longitude: 106.569374, //经度参数
  112. datalist: [],
  113. current: 0,
  114. dotsStyles: {
  115. backgroundColor: 'rgba(88, 190, 107,0.6)',
  116. selectedBackgroundColor: 'rgba(88, 190, 107,0.9)',
  117. },
  118. params: {
  119. lat: undefined,
  120. lng: undefined,
  121. page: 1,
  122. pageSize: 1,
  123. orderByWays: 'desc'
  124. },
  125. noData:null,
  126. }
  127. },
  128. onShow() {
  129. this.$store.dispatch("usersToken").then(() => {
  130. //微信用户第二次登录
  131. this.isAuthShow = false;
  132. this.token = this.$store.getters.getToken;
  133. this.userinfo = this.$store.getters.getUser;
  134. }).catch(() => {
  135. //微信用户首次登录
  136. this.isAuthShow = true;
  137. });
  138. },
  139. onLoad() {
  140. this.mapSelect()
  141. },
  142. mounted() {
  143. this.getHomePage()
  144. },
  145. onReachBottom(){
  146. },
  147. methods: {
  148. jumptest(){
  149. uni.navigateTo({
  150. url:'/pages/scan/index'
  151. })
  152. },
  153. //获取车辆信息
  154. getHomePage() {
  155. this.$http.homepage(this.params).then(res => {
  156. console.log(res)
  157. if(res.code === 0){
  158. if(res.data.vehDataVoList.length==0){
  159. this.noData='暂无记录'
  160. }else{
  161. this.datalist = res.data.vehDataVoList
  162. }
  163. }else{
  164. this.noData='暂无记录'
  165. this.$utils.msg(res.msg)
  166. }
  167. })
  168. },
  169. change(e) {
  170. this.current = e.detail.current;
  171. },
  172. //打开地图导航
  173. jumpmaps() {
  174. if (this.latitude && this.longitude) {
  175. uni.openLocation({
  176. latitude: 29.632675,
  177. longitude: 106.569374,
  178. name: '渝北区风暴之眼电竞酒店(机场路南)',
  179. address: '重庆市重庆市渝北区汇流路1号'
  180. })
  181. } else {
  182. this.$utils.msg("未获取到您的位置信息");
  183. }
  184. },
  185. //获取用户经纬度
  186. mapSelect() {
  187. const that = this
  188. uni.getLocation({
  189. type: 'gcj02',
  190. isHighAccuracy: true,
  191. success: function(res) {
  192. that.latitude = res.latitude
  193. that.longitude = res.longitude
  194. console.log(res, 'getLocation')
  195. },
  196. fail: () => {
  197. this.getMapLocation()
  198. },
  199. })
  200. },
  201. //提示用户打开位置信息
  202. getMapLocation() {
  203. uni.getSetting({
  204. success: (res) => {
  205. var status = res.authSetting
  206. if (!status['scope.userLocation']) {
  207. // 如果授权信息中没有地理位置的授权,则需要弹窗提示用户需要授权地理信息
  208. uni.showModal({
  209. title: '是否授权当前位置',
  210. content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
  211. success: (tip) => {
  212. if (tip.confirm) {
  213. // 如果用户同意授权地理信息,则打开授权设置页面,判断用户的操作
  214. uni.openSetting({
  215. success: (data) => {
  216. // 如果用户授权了地理信息在,则提示授权成功
  217. if (data.authSetting[
  218. 'scope.userLocation'] ===
  219. true) {
  220. uni.showToast({
  221. title: '授权成功',
  222. icon: 'success',
  223. duration: 1000,
  224. })
  225. // 授权成功后,然后再次chooseLocation获取信息
  226. this.mapSelect()
  227. } else {
  228. uni.showToast({
  229. title: '授权失败',
  230. icon: 'none',
  231. duration: 1000,
  232. })
  233. }
  234. },
  235. })
  236. }
  237. },
  238. })
  239. }
  240. if (status['scope.userLocation'] === true && this.latitude === null && this
  241. .longitude === null) {
  242. uni.showToast({
  243. title: '请开启您手机的位置信息!',
  244. icon: 'none',
  245. duration: 5000,
  246. })
  247. }
  248. },
  249. fail: (res) => {
  250. uni.showToast({
  251. title: '调用授权窗口失败',
  252. icon: 'none',
  253. duration: 1000,
  254. })
  255. },
  256. })
  257. },
  258. //扫码进入换电信息页面
  259. toscan() {
  260. uni.switchTab({
  261. url: '/pages/scan/index'
  262. })
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .authorization {
  269. width: 640rpx;
  270. height: 840rpx;
  271. background-color: #fff;
  272. border-radius: 20rpx;
  273. }
  274. .main-box {
  275. padding: 0 30rpx;
  276. .carinfo {
  277. width: 100%;
  278. height: 350rpx;
  279. }
  280. .norecord{
  281. text-align: center;
  282. color: #86909c;
  283. position: relative;
  284. top: 40%;
  285. }
  286. .swiper-box {
  287. height: 380rpx;
  288. .swiper-item {
  289. width: 690rpx;
  290. height: 350rpx;
  291. padding: 32rpx;
  292. box-sizing: border-box;
  293. background-image: url('https://xcx.xnymzx.com/zkstation/car-bg.png');
  294. background-size: 100% 100%;
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: space-between;
  298. .plate {
  299. display: flex;
  300. justify-content: space-between;
  301. view:first-child {
  302. flex: 1;
  303. }
  304. image {
  305. width: 24rpx;
  306. height: 24rpx;
  307. vertical-align: middle;
  308. }
  309. view:last-child {
  310. width: 280rpx;
  311. text-align: right;
  312. color: #6cc57d;
  313. font-size: 30rpx;
  314. }
  315. }
  316. .plate-number {
  317. display: flex;
  318. image {
  319. width: 26rpx;
  320. height: 26rpx;
  321. vertical-align: middle;
  322. }
  323. view:first-child {
  324. font-weight: 600;
  325. font-size: 32rpx;
  326. padding-right: 15rpx;
  327. }
  328. }
  329. .battery-soc {
  330. display: flex;
  331. view:first-child {
  332. width: 138rpx;
  333. }
  334. view:last-child {
  335. flex: 1;
  336. .strip {
  337. /* 父元素相对定位 */
  338. position: relative;
  339. width: 480rpx;
  340. height: 18rpx;
  341. background-color: #fff;
  342. top: 10rpx;
  343. }
  344. .blue {
  345. height: 18rpx;
  346. background-color: #ff7d00;
  347. font-size: 28rpx;
  348. }
  349. .protext {
  350. width: 2rpx;
  351. height: 32rpx;
  352. background: #86909c;
  353. /* 子元素绝对定位 */
  354. position: absolute;
  355. /* 定位方向:属性值 */
  356. top: -9rpx
  357. }
  358. .pronumber {
  359. font-size: 26rpx;
  360. font-weight: bold;
  361. position: absolute;
  362. /* 定位方向:属性值 */
  363. top: 30rpx;
  364. }
  365. }
  366. }
  367. .battery-info {
  368. display: flex;
  369. justify-content: space-between;
  370. text-align: center;
  371. line-height: 36rpx;
  372. view>view:first-child {
  373. font-weight: bold;
  374. }
  375. view>view:last-child {
  376. color: #939da7;
  377. font-size: 26rpx;
  378. margin-top: 8rpx;
  379. }
  380. }
  381. }
  382. }
  383. .change-title {
  384. width: 100%;
  385. padding: 0 20rpx;
  386. box-sizing: border-box;
  387. display: flex;
  388. margin: 30rpx 0;
  389. image {
  390. width: 9rpx;
  391. height: 39rpx;
  392. }
  393. view:first-child {
  394. padding-right: 12rpx;
  395. }
  396. view:last-child {
  397. font-weight: bold;
  398. font-size: 32rpx;
  399. line-height: 32rpx;
  400. }
  401. }
  402. .change-box {
  403. width: 690rpx;
  404. box-sizing: border-box;
  405. border-radius: 25rpx;
  406. background-color: #fff;
  407. padding: 20rpx 30rpx;
  408. display: flex;
  409. flex-direction: column;
  410. overflow: hidden;
  411. .title {
  412. font-weight: bold;
  413. color: #110d2e;
  414. font-size: 34rpx;
  415. }
  416. .tags {
  417. display: flex;
  418. view {
  419. background: #f5f5f5;
  420. color: #979797;
  421. font-size: 24rpx;
  422. padding: 8rpx 15rpx;
  423. margin: 15rpx 12rpx 15rpx 0rpx;
  424. border-radius: 5rpx;
  425. }
  426. }
  427. .piclist {
  428. display: flex;
  429. justify-content: space-between;
  430. margin: 18rpx 0rpx;
  431. width: 630rpx;
  432. overflow: hidden;
  433. // view{
  434. // margin-right: 15rpx;
  435. // }
  436. image {
  437. width: 298rpx;
  438. height: 189rpx;
  439. box-sizing: border-box;
  440. border-radius: 15rpx;
  441. }
  442. }
  443. .address {
  444. display: flex;
  445. justify-content: space-between;
  446. text-align: center;
  447. color: #86909c;
  448. font-size: 24rpx;
  449. view:first-child {
  450. width: 445rpx;
  451. text-align: left;
  452. font-size: 28rpx;
  453. color: #333333;
  454. line-height: 40rpx;
  455. }
  456. image {
  457. width: 44rpx;
  458. height: 44rpx;
  459. }
  460. }
  461. .battery-num {
  462. color: #86909c;
  463. font-size: 30rpx;
  464. margin-top: 12rpx;
  465. display: flex;
  466. line-height: 36rpx;
  467. view:last-child {
  468. color: #000000;
  469. font-weight: 600;
  470. margin-left: 15rpx;
  471. font-size: 36rpx;
  472. }
  473. }
  474. }
  475. }
  476. </style>