index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view class="main" :style="{height:Authorize?'auto':'100vh'}">
  3. <top-box :userinfo="userinfo" :days="days" keys="1"></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="indexes"
  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-3)+'%'">
  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. <mescroll-body
  70. ref="mescrollRef"
  71. @init="mescrollInit"
  72. @down="downCallback"
  73. @up="upCallback"
  74. :up="upOption"
  75. :height="(screenHeight-200)+'rpx'"
  76. >
  77. <view class="change-box" v-for="(item,index) in stationDataVoList" :key="item.stationInfo.id">
  78. <view class="title">{{item.stationInfo.stationName}}</view>
  79. <view class="tags">
  80. <view v-if="item.stationInfo.frequentPlace">常去地点</view>
  81. <view>{{item.stationInfo.businessHours}}</view>
  82. </view>
  83. <view class="piclist">
  84. <view v-for="(img,index) in item.urlList" :key="index">
  85. <image :src="img"></image>
  86. </view>
  87. </view>
  88. <view class="address">
  89. <view v-if="item.stationInfo.distance">{{item.stationInfo.distance >= 1000 ? (item.stationInfo.distance/1000).toFixed(1)+'km' : item.stationInfo.distance+'m'}} · {{item.stationInfo.address}}</view>
  90. <view v-else>{{item.stationInfo.stationName || ''}}</view>
  91. <view @click="makePhone(item.stationInfo.phoneNum)">
  92. <image src="../../static/icon4.png"></image>
  93. <view>电话</view>
  94. </view>
  95. <view @click="jumpmaps(item.stationInfo.lat,item.stationInfo.lng,item.stationInfo.address,item.stationInfo.name)">
  96. <image src="../../static/icon5.png"></image>
  97. <view>路线</view>
  98. </view>
  99. </view>
  100. <view class="battery-num">
  101. <view>可换电池</view>
  102. <view>{{item.batteryNum}}</view>
  103. </view>
  104. </view>
  105. </mescroll-body>
  106. <view class="grace-loading" @click="resetPosition" v-if="noposition">{{noposition}}</view>
  107. </view>
  108. <tab-bar></tab-bar>
  109. </view>
  110. </template>
  111. <script>
  112. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  113. export default {
  114. mixins: [MescrollMixin],
  115. data() {
  116. return {
  117. token: null,
  118. userinfo: null,
  119. // latitude: 29.632675, //纬度参数
  120. // longitude: 106.569374, //经度参数
  121. datalist: [],
  122. current: 0,
  123. dotsStyles: {
  124. backgroundColor: 'rgba(88, 190, 107,0.6)',
  125. selectedBackgroundColor: 'rgba(88, 190, 107,0.9)',
  126. },
  127. params: {
  128. lat: null,
  129. lng: null,
  130. page: 1,
  131. pageSize: 10,
  132. orderByWays: 'desc'
  133. },
  134. noData: null,
  135. stationDataVoList: [],
  136. isLoadAll: false,
  137. totalPages: 0, // 总页数
  138. upOption:{
  139. page:{
  140. size:10,
  141. num:0,
  142. },
  143. noMoreSize:2,
  144. empty:'暂无相关数据'
  145. },
  146. noposition:null,
  147. days:0,
  148. Authorize:false,
  149. }
  150. },
  151. onShow() {
  152. this.$store.dispatch("usersStatus").then(()=>{
  153. //微信用户第二次登录
  154. this.token=this.$store.state.users.token
  155. this.userinfo=this.$store.state.users
  156. this.getHomeCar()
  157. this.getUserDays()
  158. this.reloadList()
  159. this.noData=null
  160. }).catch(()=>{
  161. //微信用户首次登录
  162. this.noData='请先登录'
  163. });
  164. },
  165. onLoad() {
  166. let systemInfoSync = uni.getSystemInfoSync();
  167. this.screenHeight = systemInfoSync.screenHeight - 300;
  168. },
  169. mounted() {
  170. this.mapSelect()
  171. },
  172. methods: {
  173. //重新获取定位
  174. resetPosition(){
  175. this.mapSelect()
  176. },
  177. //获取加入天数
  178. getUserDays(){
  179. this.$http.getDays().then(res=>{
  180. if(res.code === 0){
  181. this.days=res.data
  182. }else{
  183. this.$utils.msg(res.msg);
  184. }
  185. })
  186. },
  187. //拨打电话
  188. makePhone(num) {
  189. uni.makePhoneCall({
  190. phoneNumber: num.toString(), //电话号码
  191. })
  192. },
  193. reloadList(){
  194. this.canReset && this.mescroll.resetUpScroll()
  195. this.canReset && this.mescroll.scrollTo(0,0)
  196. this.canReset = true
  197. },
  198. //获取换电站信息
  199. upCallback(page) {
  200. console.log("--------------------upCallback")
  201. if(this.Authorize==true){
  202. this.params.page=page.num
  203. this.params.pageSize=page.size
  204. console.log("params:",this.params)
  205. this.$http.homeStation(this.params).then(res => {
  206. <<<<<<< HEAD
  207. console.log("res",res)
  208. console.log("data:",res.data)
  209. =======
  210. console.log(res.data)
  211. >>>>>>> 51bdfa93462721aa88aa8ca3ec36637e2e332f19
  212. uni.hideLoading();
  213. if (res.code === 0) {
  214. this.totalPages = res.data.total
  215. if(page.num == 1) this.stationDataVoList = []
  216. this.stationDataVoList=this.stationDataVoList.concat(res.data.list)
  217. this.mescroll.endBySize(res.data.list.length, res.data.total);
  218. } else {
  219. this.$utils.msg(res.msg)
  220. this.mescroll.endErr();
  221. }
  222. })
  223. }else{
  224. console.log("Authorize","false")
  225. this.mescroll.endErr();
  226. }
  227. },
  228. //获取车辆信息
  229. getHomeCar() {
  230. let params={
  231. page: 1,
  232. pageSize: 10,
  233. orderByWays: 'desc'
  234. }
  235. this.$http.homeCar(params).then(res => {
  236. if (res.code === 0) {
  237. if (res.data.length == 0) {
  238. this.noData = '暂无记录'
  239. } else {
  240. this.datalist = res.data
  241. }
  242. } else {
  243. this.$utils.msg(res.msg)
  244. }
  245. })
  246. },
  247. change(e) {
  248. this.current = e.detail.current;
  249. },
  250. //打开地图导航
  251. jumpmaps(lat,lng,address,name) {
  252. if (lat && lng && address && name) {
  253. uni.openLocation({
  254. latitude:lat,
  255. longitude:lng,
  256. name: name,
  257. address: address
  258. })
  259. } else {
  260. this.$utils.msg("位置信息丢失");
  261. }
  262. },
  263. //获取用户经纬度
  264. mapSelect() {
  265. uni.showLoading({
  266. title: '加载中'
  267. });
  268. const that = this
  269. uni.getLocation({
  270. type: 'gcj02',
  271. isHighAccuracy: true,
  272. success: function(res) {
  273. that.params.lat = res.latitude
  274. that.params.lng = res.longitude
  275. that.Authorize=true
  276. that.noposition=null
  277. that.mescroll.resetUpScroll()
  278. console.log(res, 'getLocation')
  279. that.$utils.msg("-------------"+res.latitude+","+res.longitude)
  280. },
  281. fail: () => {
  282. uni.hideLoading();
  283. that.noposition='定位失败'
  284. that.getMapLocation()
  285. that.$utils.msg("定位失败")
  286. },
  287. })
  288. },
  289. //提示用户打开位置信息
  290. getMapLocation() {
  291. uni.getSetting({
  292. success: (res) => {
  293. var status = res.authSetting
  294. if (!status['scope.userLocation']) {
  295. // 如果授权信息中没有地理位置的授权,则需要弹窗提示用户需要授权地理信息
  296. uni.showModal({
  297. title: '是否授权当前位置',
  298. content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
  299. success: (tip) => {
  300. if (tip.confirm) {
  301. // 如果用户同意授权地理信息,则打开授权设置页面,判断用户的操作
  302. uni.openSetting({
  303. success: (data) => {
  304. // 如果用户授权了地理信息在,则提示授权成功
  305. if (data.authSetting['scope.userLocation'] ===true) {
  306. uni.showToast({
  307. title: '授权成功',
  308. icon: 'success',
  309. duration: 1000,
  310. })
  311. // 授权成功后,然后再次chooseLocation获取信息
  312. this.mapSelect()
  313. } else {
  314. uni.hideLoading();
  315. this.noposition='授权失败'
  316. this.Authorize=false
  317. }
  318. },
  319. })
  320. }else{
  321. uni.hideLoading();
  322. this.noposition='授权失败'
  323. this.Authorize=false
  324. }
  325. },
  326. })
  327. }
  328. if (status['scope.userLocation'] === true && this.params.lat === null && this.params.lng === null) {
  329. uni.showToast({
  330. title: '请开启您手机的位置信息!',
  331. icon: 'none',
  332. duration: 5000,
  333. })
  334. }
  335. },
  336. fail: (res) => {
  337. uni.showToast({
  338. title: '调用授权窗口失败',
  339. icon: 'none',
  340. duration: 1000,
  341. })
  342. },
  343. })
  344. },
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. .main{
  350. background: linear-gradient(180deg, #FFFFFF 0%, #F2F3F5 100%);
  351. }
  352. .authorization {
  353. width: 640rpx;
  354. height: 840rpx;
  355. background-color: #fff;
  356. border-radius: 20rpx;
  357. }
  358. .grace-loading{
  359. position: relative;
  360. text-align: center;
  361. padding-top: 100rpx;
  362. height: 300rpx;
  363. color: #979797;
  364. }
  365. .main-box {
  366. padding: 0 30rpx;
  367. // background: linear-gradient(180deg, #FFFFFF 0%, #F2F3F5 100%);
  368. .carinfo {
  369. width: 100%;
  370. height: 350rpx;
  371. }
  372. .norecord {
  373. text-align: center;
  374. color: #86909c;
  375. position: relative;
  376. top: 40%;
  377. }
  378. .swiper-box {
  379. height: 380rpx;
  380. .swiper-item {
  381. width: 690rpx;
  382. height: 350rpx;
  383. padding: 32rpx;
  384. box-sizing: border-box;
  385. background-image: url('https://rl-zk-image.oss-cn-hangzhou.aliyuncs.com/image/car-bg.png');
  386. background-size: 100% 100%;
  387. display: flex;
  388. flex-direction: column;
  389. justify-content: space-between;
  390. .plate {
  391. display: flex;
  392. justify-content: space-between;
  393. view:first-child {
  394. flex: 1;
  395. }
  396. image {
  397. width: 24rpx;
  398. height: 24rpx;
  399. vertical-align: middle;
  400. }
  401. view:last-child {
  402. width: 280rpx;
  403. text-align: left;
  404. padding-left: 10rpx;
  405. color: #6cc57d;
  406. font-size: 30rpx;
  407. padding-top: 2rpx;
  408. }
  409. }
  410. .plate-number {
  411. display: flex;
  412. image {
  413. width: 26rpx;
  414. height: 26rpx;
  415. vertical-align: middle;
  416. }
  417. view:first-child {
  418. font-weight: 600;
  419. font-size: 36rpx;
  420. padding-right: 15rpx;
  421. }
  422. }
  423. .battery-soc {
  424. display: flex;
  425. margin-bottom: 22rpx;
  426. view:first-child {
  427. width: 105rpx;
  428. font-size: 22rpx;
  429. }
  430. view:last-child {
  431. flex: 1;
  432. .strip {
  433. /* 父元素相对定位 */
  434. position: relative;
  435. width: 525rpx;
  436. height: 18rpx;
  437. background-color: #fff;
  438. top: 10rpx;
  439. }
  440. .blue {
  441. height: 18rpx;
  442. background-color: #ff7d00;
  443. font-size: 28rpx;
  444. }
  445. .protext {
  446. width: 2rpx;
  447. height: 32rpx;
  448. background: #86909c;
  449. /* 子元素绝对定位 */
  450. position: absolute;
  451. /* 定位方向:属性值 */
  452. top: -9rpx
  453. }
  454. .pronumber {
  455. font-size: 26rpx;
  456. font-weight: bold;
  457. position: absolute;
  458. /* 定位方向:属性值 */
  459. top: 30rpx;
  460. }
  461. }
  462. }
  463. .battery-info {
  464. display: flex;
  465. justify-content: space-between;
  466. text-align: center;
  467. line-height: 36rpx;
  468. view>view:first-child {
  469. font-weight: bold;
  470. }
  471. view>view:last-child {
  472. color: #939da7;
  473. font-size: 26rpx;
  474. }
  475. }
  476. }
  477. }
  478. .change-title {
  479. width: 100%;
  480. padding: 0 20rpx;
  481. box-sizing: border-box;
  482. display: flex;
  483. margin-bottom: 24rpx;
  484. margin-top: 44rpx;
  485. image {
  486. width: 9rpx;
  487. height: 39rpx;
  488. }
  489. view:first-child {
  490. padding-right: 12rpx;
  491. }
  492. view:last-child {
  493. font-weight: bold;
  494. font-size: 32rpx;
  495. line-height: 32rpx;
  496. }
  497. }
  498. .change-box:last-child{
  499. margin-bottom: 140rpx !important;
  500. }
  501. .change-box {
  502. width: 690rpx;
  503. box-sizing: border-box;
  504. border-radius: 25rpx;
  505. box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(226,226,226,0.25);
  506. background-color: #fff;
  507. padding: 20rpx 30rpx;
  508. display: flex;
  509. flex-direction: column;
  510. overflow: hidden;
  511. margin-bottom: 30rpx;
  512. .title {
  513. font-weight: bold;
  514. color: #110d2e;
  515. font-size: 34rpx;
  516. }
  517. .tags {
  518. display: flex;
  519. :first-child{
  520. background: rgba(88,190,107,0.1);
  521. color: #58BE6B;
  522. }
  523. view {
  524. background: #f5f5f5;
  525. color: #979797;
  526. font-size: 24rpx;
  527. padding: 8rpx 15rpx;
  528. margin: 15rpx 12rpx 15rpx 0rpx;
  529. border-radius: 5rpx;
  530. }
  531. }
  532. .piclist {
  533. display: flex;
  534. justify-content: space-between;
  535. margin: 18rpx 0rpx;
  536. width: 630rpx;
  537. overflow: hidden;
  538. // view{
  539. // margin-right: 15rpx;
  540. // }
  541. image {
  542. width: 298rpx;
  543. height: 189rpx;
  544. box-sizing: border-box;
  545. border-radius: 15rpx;
  546. }
  547. }
  548. .address {
  549. display: flex;
  550. justify-content: space-between;
  551. text-align: center;
  552. color: #86909c;
  553. font-size: 24rpx;
  554. view:first-child {
  555. width: 445rpx;
  556. text-align: left;
  557. font-size: 28rpx;
  558. color: #333333;
  559. line-height: 40rpx;
  560. }
  561. image {
  562. width: 44rpx;
  563. height: 44rpx;
  564. }
  565. }
  566. .battery-num {
  567. color: #86909c;
  568. font-size: 30rpx;
  569. margin-top: 12rpx;
  570. display: flex;
  571. line-height: 36rpx;
  572. view:last-child {
  573. color: #000000;
  574. font-weight: 600;
  575. margin-left: 15rpx;
  576. font-size: 36rpx;
  577. }
  578. }
  579. }
  580. }
  581. </style>