index.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. <template>
  2. <view class="page">
  3. <map id="map" :longitude='longitude' :latitude='latitude' :scale='scale' @markertap="marker" @tap="controltap"
  4. @regionchange="regionchange" :show-location="location" :markers="markers" :polyline="polygons" style="height: 100vh;"
  5. @labeltap='marker' @callouttap='marker'>
  6. <cover-view class="backTop"></cover-view>
  7. <cover-view class="topRight" @click.stop="search"></cover-view>
  8. <cover-view class="areaTop" @click="select">{{option[areaIndex].text}}</cover-view>
  9. <cover-image src="/static/img/search.png" style="width: 40upx;height: 40upx;" class="search"></cover-image>
  10. <cover-image src="http://resource.weilaibike.com/bike_yunwei/location.png" @click="posi" class="location"></cover-image>
  11. <cover-image src="http://resource.weilaibike.com/bike_yunwei/ref.png" @click="load" class="load"></cover-image>
  12. <cover-view class="sweepCode" @click="scanCode" :style="{lineHeight:lineHeight+'upx'}">扫描二维码</cover-view>
  13. <cover-view class="beijing" v-if="infoShow"></cover-view>
  14. <cover-view class="code" v-if="infoShow">{{bikeDetail.bike_no}}</cover-view>
  15. <cover-view class="dianliang" v-if="infoShow">剩余电量:{{bikeDetail.battery_power}}%</cover-view>
  16. <cover-view class="xiangqing" v-if="infoShow" @click="detail" :style="{lineHeight:lineHeight+'upx'}">详情</cover-view>
  17. <cover-image src="/static/img/xunling.png" style="width: 48upx;height: 48upx;" class="xunling" v-if="infoShow"
  18. @click="xunling"></cover-image>
  19. <cover-view class="kaisuo" v-if="infoShow" @click="diankai" :style="{lineHeight:lineHeight+'upx'}">开电池锁</cover-view>
  20. <cover-view class="status" v-if="infoShow">{{bikeDetail.tab_name}}</cover-view>
  21. <cover-view class="lastPosi" v-if="infoShow">最后定位时间:{{bikeDetail.last_time}}</cover-view>
  22. <cover-view class="dianl" @click="dianl" :style="{lineHeight:lineHeight+'upx'}">{{allArr[dianIndex]}}</cover-view>
  23. <cover-view class="zhuangtai" @click="zhuangtai" :style="{lineHeight:lineHeight+'upx'}">{{arrState[arrIndex]}}</cover-view>
  24. <cover-view class="shiyong" @click="shiyong" :style="{lineHeight:lineHeight+'upx'}">{{arrDay[arrDayIndex]}}</cover-view>
  25. </map>
  26. </view>
  27. </template>
  28. <script>
  29. var app = getApp();
  30. import {
  31. BluetoothManager,
  32. BtErrorCode,
  33. CMD
  34. } from '../../static/js/bluWKM.js';
  35. import {
  36. preUrl,
  37. } from "../../static/js/config.js";
  38. import {
  39. MapUtil
  40. } from "../../static/js/MapUtil.js";
  41. import {
  42. getLocation,
  43. } from '../../static/js/util.js';
  44. import {
  45. baseRequest
  46. } from "../../static/js/loadToastUtil.js";
  47. const bluM = new BluetoothManager;
  48. let baseUtil, mapUtil = null,
  49. homeUtil = null,
  50. oriMarkerList = [],
  51. currentStationId = '',
  52. centerLongitude = '',
  53. centerlatitude = '',
  54. currentScale = '',
  55. currentNor = '',
  56. currentSou = '';
  57. export default {
  58. data() {
  59. return {
  60. curVal1: "", //下标
  61. location: true,
  62. mapTOP: 0, //地图据顶部高度
  63. bike_no: '', //车牌号
  64. mess: "", //父组件向子组件穿的值
  65. markers: [], //显示单车、停车的P
  66. markers1:[{
  67. // id:0,
  68. latitude: 34.78289468414873,//经度
  69. longitude: 113.7859707019119,//纬度
  70. iconPath: '/static/img/cluMarkerIcon.png',//显示的图标
  71.    rotate:0, // 旋转度数
  72.    width:20, //宽
  73.    height:20, //高
  74.    title:'你在哪了',//标注点名
  75.    alpha:0.5, //透明
  76. callout:{
  77. content:'花园宝宝',
  78. color:'#FFFFFF',
  79. fontSize:14,
  80. borderRadius:2,
  81. bgColor:'#00c16f',
  82. display:'ALWAYS'
  83. },
  84. label:{
  85. content:'河南商丘',
  86. color:'#FFFFFF',
  87. fontSize:14,
  88. borderRadius:2,
  89. bgColor:'#00c16f',
  90. display:'ALWAYS'
  91. }
  92. },],
  93. polygons: [], //区域
  94. longitude: '',
  95. latitude: '',
  96. allArea: [],
  97. area: 0,
  98. show: false, //车子详情的布尔值
  99. id: '', //停车区域的ID
  100. polygons1: [], //可骑行区域 先用这个变量代表
  101. box_no: '', //中控编号
  102. bikeDetail: [],
  103. bikeId: '',
  104. areaID: '',
  105. low_power: '',
  106. state: '',
  107. use_state: '',
  108. parkAreaShow: false, //还车点是否显示
  109. noParkAreaShow: true, //禁停区是否显示
  110. areas: [],
  111. parking: [],
  112. parking_points: [],
  113. no_parking: [],
  114. no_parking_points: [],
  115. infoShow: false,
  116. allEle: [{
  117. text: '全部电量',
  118. value: 0,
  119. areaID: ''
  120. },
  121. {
  122. text: '70%以下',
  123. value: 1,
  124. areaID: '70'
  125. },
  126. {
  127. text: '60%以下',
  128. value: 2,
  129. areaID: '60'
  130. },
  131. {
  132. text: '50%以下',
  133. value: 3,
  134. areaID: '50'
  135. },
  136. {
  137. text: '30%以下',
  138. value: 4,
  139. areaID: '30'
  140. },
  141. {
  142. text: '20%以下',
  143. value: 5,
  144. areaID: '20'
  145. },
  146. ],
  147. allArr: ['全部电量', '70%以下', '60%以下', '50%以下', '30%以下', '20%以下'],
  148. allStatus: [{
  149. text: '全部状态',
  150. value: 0,
  151. areaID: ''
  152. }],
  153. arrDay: ['使用状态', '1天未使用', '3天未使用', '7天未使用'],
  154. arrDayIndex: 0,
  155. allDay: [{
  156. text: '使用状态',
  157. value: 0
  158. },
  159. {
  160. text: '1天未使用',
  161. value: 1
  162. },
  163. {
  164. text: '3天未使用',
  165. value: 2
  166. },
  167. {
  168. text: '7天未使用',
  169. value: 3
  170. }
  171. ],
  172. dianIndex: 0,
  173. arrState: ['全部状态'],
  174. arrIndex: 0,
  175. option: [{
  176. areaID: '',
  177. text: '全部区域',
  178. value: -1,
  179. }],
  180. areaIndex: 0,
  181. lineHeight: '',
  182. allState: '',
  183. statusBarHeight: app.systemInfo.statusBarHeight,
  184. lang: app.systemInfo.lang,
  185. dataType: 'map',
  186. mapData: [],
  187. scrollHeight: app.systemInfo.screenHeight - app.systemInfo.statusBarHeight - 45 - 55 - 91,
  188. searchType: 0, //0 初始状态 1 搜索半径 2 用户筛选
  189. currentRadius: '5 km',
  190. scale: 13,
  191. searchItem: {},
  192. stationInfo: {},
  193. }
  194. },
  195. onShow() {
  196. // console.log("z这是数据235676677898899")
  197. var that = this;
  198. setTimeout(function() {
  199. this.mess = uni.getStorageSync('allArea')
  200. this.curVal1 = uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0
  201. }, 2000)
  202. },
  203. methods: {
  204. controltap: function(e) {
  205. let that = this;
  206. currentStationId = '';
  207. oriMarkerList.forEach(item => {
  208. item.isSelect = false
  209. });
  210. that.infoShow = false;
  211. that.markers = mapUtil.getFortMatMarkerList(currentNor, currentSou, currentScale, oriMarkerList)
  212. },
  213. regionchange: function(e) {
  214. let that = this;
  215. console.log('缩放了')
  216. console.log(e)
  217. if (e.type === "regionchange") {
  218. // that.setData({markers:''})
  219. that.mapCtx.getCenterLocation({
  220. success: function(res) {
  221. console.log(res)
  222. centerLongitude = res.longitude;
  223. centerlatitude = res.latitude;
  224. uni.setStorageSync('centerLongitude', centerLongitude);
  225. uni.setStorageSync('centerlatitude', centerlatitude);
  226. that.mapCtx.getScale({
  227. success: res => {
  228. let scale = res.scale;
  229. console.log(scale)
  230. that.mapCtx.getRegion({
  231. success: res => {
  232. currentNor = res.northeast;
  233. currentSou = res.southwest;
  234. if (scale <= 10) {
  235. that.markers = mapUtil.getFortMatMarkerList(res.northeast, res.southwest, scale, oriMarkerList)
  236. console.log(that.markers)
  237. return;
  238. }
  239. currentScale = scale;
  240. console.log(mapUtil)
  241. if (mapUtil == null) {
  242. mapUtil = new MapUtil(res.northeast, res.southwest, scale);
  243. that.loadMapData(markers => {
  244. markers.forEach(item => {
  245. item.isSelect = item.id == currentStationId;
  246. });
  247. oriMarkerList = markers;
  248. that.markers = mapUtil.getFortMatMarkerList(res.northeast, res.southwest, scale, oriMarkerList)
  249. console.log(that.markers)
  250. });
  251. return;
  252. }
  253. if (mapUtil.checkRefresh(res.northeast, res.southwest)) {
  254. that.loadMapData(markers => {
  255. markers.forEach(item => {
  256. item.isSelect = item.id == currentStationId;
  257. });
  258. oriMarkerList = markers;
  259. that.markers = mapUtil.getFortMatMarkerList(res.northeast, res.southwest, scale, oriMarkerList)
  260. console.log(that.markers)
  261. });
  262. mapUtil.setInitData(res.northeast, res.southwest, scale);
  263. } else {
  264. oriMarkerList.forEach(item => {
  265. item.isSelect = item.id == currentStationId;
  266. });
  267. that.markers = mapUtil.getFortMatMarkerList(res.northeast, res.southwest, scale, oriMarkerList)
  268. console.log(that.markers)
  269. }
  270. }
  271. })
  272. // console.log(that.markers)
  273. }
  274. })
  275. }
  276. })
  277. }
  278. },
  279. loadMapData: function(callBack1) {
  280. var that = this;
  281. var areaId = that.areaID;
  282. //     console.log(areaId)
  283. var low_power = that.low_power;
  284. var state = that.state;
  285. var use_state = that.use_state;
  286. let time = parseInt(use_state / 1000)
  287. if (time === 0) {
  288. time = ''
  289. }
  290. var data = {
  291. 'put_area_id': areaId,
  292. 'battery_power': low_power,
  293. 'all_states': state,
  294. 'last_use_bike_end_time': time
  295. };
  296. // console.log(baseUtil)
  297. baseUtil(data, res => {
  298. // console.log(res)
  299. callBack1(res);
  300. })
  301. },
  302. initMapData: function() {
  303. let that = this;
  304. that.markers = ''
  305. that.loadMapData(markers => {
  306. // console.log(markers)
  307. markers.forEach(item => {
  308. item.isSelect = item.id == currentStationId;
  309. });
  310. oriMarkerList = markers;
  311. that.markers = mapUtil.getFortMatMarkerList(currentNor, currentSou, currentScale, oriMarkerList)
  312. console.log(that.markers)
  313. });
  314. },
  315. getBike_info: function(bikeId) {
  316. console.log(bikeId)
  317. uni.showLoading({
  318. title: '加载中...',
  319. })
  320. app.request('bike/getBikeInfo?bike_no=' + bikeId, '', 'GET').then(res => {
  321. uni.hideLoading();
  322. console.log(res, '获取车辆信息')
  323. if (res.data.bike_info == '') {
  324. this.infoShow = false;
  325. uni.showToast({
  326. title: '暂无该车辆信息~',
  327. })
  328. } else {
  329. console.log(res.data, '车辆信息')
  330. this.bikeDetail = res.data.bike_info;
  331. this.infoShow = true;
  332. }
  333. })
  334. },
  335. dianl: function() {
  336. var that = this;
  337. uni.showActionSheet({
  338. itemList: that.allArr,
  339. success: function(res) {
  340. this.markers = [];
  341. console.log(res, "pppppp")
  342. that.dianIndex = res.tapIndex;
  343. that.low_power = that.allEle[res.tapIndex].areaID
  344. console.log(that.low_power, "iiiiii")
  345. that.initMapData()
  346. },
  347. fail: function(res) {}
  348. })
  349. },
  350. zhuangtai: function() {
  351. var that = this;
  352. console.log(that.arrState, "iiiiiiiiiii")
  353. uni.showActionSheet({
  354. itemList: that.arrState,
  355. success: function(res) {
  356. that.markers = [];
  357. console.log(res)
  358. that.arrIndex = res.tapIndex;
  359. that.state = that.allState[res.tapIndex].areaID
  360. that.initMapData()
  361. },
  362. fail: function(res) {}
  363. })
  364. },
  365. select: function() {
  366. // console.log('11111')
  367. var that = this;
  368. var arr = []
  369. console.log(that.option)
  370. for (let i = 0; i < that.option.length; i++) {
  371. arr = arr.concat(that.option[i].text)
  372. }
  373. console.log(arr)
  374. uni.showActionSheet({
  375. itemList: arr,
  376. success: function(res) {
  377. console.log(res)
  378. that.markers = [];
  379. let index = res.tapIndex
  380. that.areaIndex = index;
  381. that.areaID = that.option[index].areaID;
  382. that.curVal = res.tapIndex
  383. that.initMapData(1)
  384. that.initData(1)
  385. },
  386. fail: function(res) {}
  387. })
  388. },
  389. shiyong: function() {
  390. var that = this;
  391. uni.showActionSheet({
  392. itemList: that.arrDay,
  393. success: function(res) {
  394. console.log(res)
  395. this.markers = [];
  396. that.arrDayIndex = res.tapIndex;
  397. // console.log(that.allArr[res.tapIndex])
  398. var time = new Date().getTime();
  399. if (res.tapIndex == 0) {
  400. time = "";
  401. } else if (res.tapIndex == 1) {
  402. time = time - 86400000 * 1;
  403. } else if (res.tapIndex == 2) {
  404. time = time - 86400000 * 3;
  405. } else if (res.tapIndex == 3) {
  406. time = time - 86400000 * 7;
  407. }
  408. that.use_state = time;
  409. that.initMapData()
  410. },
  411. fail: function(res) {}
  412. })
  413. },
  414. search: function() {
  415. console.log('11')
  416. uni.navigateTo({
  417. url: './bikeTest',
  418. success() {
  419. },
  420. fail(err) {
  421. console.log(err)
  422. }
  423. })
  424. },
  425. detail: function() {
  426. this.infoShow = false;
  427. uni.navigateTo({
  428. url: './bike_detail?bike_no=' + this.bikeId
  429. })
  430. },
  431. maptap: function(e) {
  432. // console.log(e)
  433. this.infoShow = false;
  434. },
  435. diankai: function() {
  436. var that = this;
  437. bluM.connectDeivece(that.bikeDetail.box_no, CMD.batteryUnlock);
  438. app.request('bike/openBatteryLock?bike_id=' + that.bikeDetail.id, '', 'GET').then(res => {
  439. if (res.statusCode == 200) {
  440. uni.showToast({
  441. title: '开电池锁成功',
  442. icon: 'none'
  443. })
  444. }
  445. })
  446. },
  447. xunling: function() {
  448. var that = this;
  449. bluM.connectDeivece(that.bikeDetail.box_no, CMD.bell)
  450. app.request('bike/bikeBell?bike_id=' + that.bikeDetail.id, '', 'GET').then(res => {
  451. if (res.statusCode == 200) {
  452. uni.showToast({
  453. title: '响铃成功',
  454. icon: 'none'
  455. })
  456. }
  457. })
  458. },
  459. async initData(isLoad = false) {
  460. var that = this;
  461. this.markers = [];
  462. uni.showLoading({
  463. title: '加载中...',
  464. })
  465. await app.request('getAreas?put_area_id=' + that.areaID, '', 'GET').then(res => {
  466. uni.hideLoading();
  467. // console.log(res, 'quyu');
  468. let data = res.data
  469. that.ridding_area = data.ridding_area;
  470. that.no_parking = data.no_parking_area;
  471. that.no_parking_points = data.no_parking_points;
  472. that.parking = data.parking_area;
  473. that.parking_points = data.parking_points;
  474. if (isLoad) {
  475. this.showArea(1)
  476. if (this.noParkAreaShow) this.showNoParking(0)
  477. if (this.parkAreaShow) this.showParking(0)
  478. }
  479. })
  480. },
  481. showArea: function(type = 0) {
  482. if (type) {
  483. var ridding_area = this.ridding_area;
  484. this.polygons = ridding_area;
  485. } else {
  486. this.polygons = this.polygons.concat(this.ridding_area);
  487. }
  488. },
  489. clear: function(type = 0) {
  490. if (type === 0) {
  491. let polygons = this.polygons.filter((polygons) => {
  492. if (polygons.id.slice(0, 1) === 'A') {
  493. return false
  494. }
  495. return true
  496. })
  497. this.polygons = polygons;
  498. }
  499. if (type === 1) {
  500. let polygons = this.polygons.filter((polygons) => {
  501. if (polygons.id.slice(0, 1) !== 'P') {
  502. return true
  503. }
  504. return false
  505. })
  506. let markers = this.markers.filter((polygons) => {
  507. if (polygons.id.slice(0, 1) !== 'p') {
  508. return true
  509. }
  510. return false
  511. })
  512. this.polygons = polygons;
  513. this.markers = markers;
  514. }
  515. if (type === 2) {
  516. let polygons = this.polygons.filter((polygons) => {
  517. if (polygons.id.slice(0, 1) !== 'N') {
  518. return true
  519. }
  520. return false
  521. })
  522. let markers = this.markers.filter((polygons) => {
  523. if (polygons.id.slice(0, 1) !== 'n') {
  524. return true
  525. }
  526. return false
  527. })
  528. this.polygons = polygons;
  529. this.markers = markers;
  530. }
  531. },
  532. //显示还车点 0:追加停车点 1:只显示停车点 2:删除停车点
  533. showParking: function(type = 0) {
  534. if (type === 0) {
  535. this.polygons = this.polygons.concat(this.parking);
  536. // this.markers = this.markers.concat(this.parking_points);
  537. }
  538. if (type === 1) {
  539. this.polygons = this.parking;
  540. // this.markers = this.markers;
  541. }
  542. if (type === 2) {
  543. this.clear(1)
  544. }
  545. },
  546. showNoParking: function(type = 0) {
  547. if (type === 0) {
  548. this.polygons = this.polygons.concat(this.no_parking);
  549. // this.markers = this.markers.concat(this.no_parking_points);
  550. }
  551. if (type === 1) {
  552. this.polygons = this.no_parking;
  553. // this.markers = this.no_parking_points;
  554. }
  555. if (type === 2) {
  556. this.clear(2)
  557. }
  558. },
  559. scanCode: function() {
  560. var that = this;
  561. console.log('scanCode')
  562. uni.scanCode({
  563. success: function(res) {
  564. let index = res.result.lastIndexOf("\=");
  565. var code = res.result.substring(index + 1, res.result.length);
  566. that.bikeId = code;
  567. console.log(that.bikeId)
  568. that.getBike_info(code)
  569. },
  570. fail: function() {
  571. uni.showToast({
  572. title: '扫码失败请重试',
  573. icon: 'none'
  574. })
  575. }
  576. })
  577. },
  578. getBikes: function(clear = 0) {
  579. uni.showLoading({
  580. title: '加载中...',
  581. })
  582. var that = this;
  583. var areaId = that.areaID;
  584. var low_power = that.low_power;
  585. var state = that.state;
  586. var use_state = that.use_state;
  587. let time = parseInt(use_state / 1000);
  588. // this.markers = '';
  589. if (time === 0) {
  590. time = ''
  591. }
  592. var data = {
  593. put_area_id: areaId,
  594. battery_power: low_power,
  595. all_states: state,
  596. last_use_bike_end_time: time
  597. };
  598. app.request('getBikes', data, 'POST').then(res => {
  599. uni.hideLoading();
  600. // console.log(res, 'bikes')
  601. var markers = that.markers
  602. if (clear) {
  603. markers = that.markers.filter((marker) => {
  604. if (marker.id.slice(0, 1) === 'B') {
  605. return false
  606. }
  607. return true
  608. })
  609. }
  610. that.markers = markers.concat(res.data);
  611. })
  612. },
  613. load: function() {
  614. var that = this;
  615. uni.showLoading({
  616. title: '刷新中...',
  617. })
  618. console.log('load')
  619. this.markers = [];
  620. if (this.noParkAreaShow) {
  621. this.showNoParking(0);
  622. } else {
  623. this.showNoParking(2);
  624. }
  625. if (this.parkAreaShow) {
  626. this.showParking(0)
  627. } else {
  628. this.showParking(2)
  629. }
  630. that.initMapData()
  631. setTimeout(function() {
  632. uni.getLocation({
  633. type: 'gcj02',
  634. success: (res) => {
  635. console.log(res, '定位信息')
  636. that.longitude = res.longitude;
  637. that.latitude = res.latitude;
  638. that.markers.unshift({
  639. // "id": "B10010010006",
  640. "iconPath": "/static/img/bike_yunwei/111.jpg",
  641. "typer": "lixian",
  642. "width": 38,
  643. "height": 38,
  644. "zIndex": 1101,
  645. longitude: res.longitude,
  646. latitude: res.latitude,
  647. })
  648. uni.hideLoading();
  649. // console.log(that.markers, "当前位置")
  650. },
  651. fail: function(err) {
  652. uni.hideLoading();
  653. console.log(err)
  654. }
  655. })
  656. }, 500)
  657. },
  658. posi: function() {
  659. // console.log(this.markers)
  660. // this.markers.splice(0, 1)
  661. // console.log(this.markers)
  662. uni.showLoading({
  663. title: '定位中...',
  664. mask: true
  665. })
  666. console.log('posi')
  667. //点击定位
  668. var that = this;
  669. uni.getLocation({
  670. type: 'gcj02',
  671. success: (res) => {
  672. console.log(res, '定位信息')
  673. that.longitude = res.longitude;
  674. that.latitude = res.latitude;
  675. // that.markers.unshift({
  676. // // "id": "B10010010006",
  677. // "iconPath": "/static/img/bike_yunwei/111.jpg",
  678. // "typer": "lixian",
  679. // "width": 38,
  680. // "height": 38,
  681. // "zIndex": 1101,
  682. // longitude: res.longitude,
  683. // latitude: res.latitude,
  684. // })
  685. uni.hideLoading();
  686. },
  687. fail: function(err) {
  688. uni.hideLoading();
  689. console.log(err)
  690. }
  691. })
  692. },
  693. marker: function(e) {
  694. console.log(e)
  695. // return;
  696. var that = this;
  697. // let type = markerId.slice(0, 1)
  698. //车辆索引
  699. // if (type === 'B') {
  700. // }
  701. var id = e.detail.markerId;
  702. // id = id.substring(1, id.length);
  703. // that.bikeId = id;
  704. // that.getBike_info(id)
  705. for (let i = 0; i < that.markers.length; i++) {
  706. let item = that.markers[i];
  707. item.setCheckStatus(id == item.id && item.callout == undefined && item.label == undefined);
  708. if (id == item.id) {
  709. if (item.callout == undefined && item.label == undefined) {
  710. if (currentStationId == id) {
  711. return;
  712. }
  713. that.getBike_info(id.slice(1))
  714. that.bikeId = id.slice(1);
  715. } else {
  716. that.latitude = item.latitude;
  717. that.longitude = item.longitude;
  718. that.scale = currentScale + 1
  719. }
  720. }
  721. }
  722. that.markers = that.markers
  723. },
  724. parkShow1: function() {
  725. this.parkAreaShow = !this.parkAreaShow;
  726. console.log('parkshow1')
  727. if (this.parkAreaShow) {
  728. this.showParking(0)
  729. } else {
  730. this.showParking(2)
  731. }
  732. },
  733. forbidShow: function() {
  734. this.noParkAreaShow = !this.noParkAreaShow
  735. if (this.noParkAreaShow) {
  736. this.showNoParking(0);
  737. } else {
  738. this.showNoParking(2);
  739. }
  740. },
  741. },
  742. mounted() {
  743. // this.allData()
  744. // if (uni.getStorageSync('curVal')) {
  745. // // let active = this.swiperTabIdx;
  746. // // let areaId = uni.getStorageSync('curId');
  747. // console.log("这是初始加载数据")
  748. // this.allData()
  749. // // console.log(this.bike,"这是车辆数据")
  750. // } else {
  751. // // console.log(this.list)
  752. // // this.areaID = this.list[0].areaID;
  753. // // console.log(this.areaID, '12345678')
  754. // this.allData()
  755. // }
  756. },
  757. // 获取车辆信息
  758. onLoad(options) {
  759. // console.log(app.request())
  760. var that = this;
  761. setTimeout(function() {
  762. var arr = uni.getStorageSync('allArea');
  763. console.log(arr, "ooooooo")
  764. that.option = that.option.concat(arr);
  765. }, 500)
  766. app.request('index', '', 'GET').then(res => {
  767. console.log(res.data, 'index')
  768. var data = res.data;
  769. var arr2 = []
  770. for (var i = 0; i < data.wx_bikeStates.length; i++) {
  771. data.wx_bikeStates[i].value = i + 1
  772. console.log(data.wx_bikeStates[i].text, "lllll")
  773. arr2.push(data.wx_bikeStates[i].text)
  774. // console.log(arr2, "kkkkkk")
  775. }
  776. var arr1 = [{
  777. areaID: '',
  778. value: 0,
  779. text: '全部状态'
  780. }]
  781. var allState = arr1.concat(data.wx_bikeStates);
  782. console.log(allState, "pppppp")
  783. var zhuangtai = data.bike_states;
  784. let arr = Object.values(zhuangtai)
  785. setTimeout(function() {
  786. that.allState = allState;
  787. that.arrState = that.arrState.concat(arr2);
  788. <<<<<<< HEAD
  789. }, 500)
  790. })
  791. that.getBikes();
  792. console.log(that.arrState, "车辆位置")
  793. switch (uni.getSystemInfoSync().platform) {
  794. case 'android':
  795. console.log('客户端是Android')
  796. that.lineHeight = '75'
  797. break;
  798. case 'ios':
  799. console.log('客户端是iOS')
  800. that.lineHeight = '80'
  801. break;
  802. }
  803. that.posi(); //获取当前位置
  804. that.mapCtx = uni.createMapContext('map');
  805. this.initData(1)
  806. console.log(that.mapCtx)
  807. // that.posi(); //获取当前位置
  808. // console.log(baseRequest)
  809. baseUtil = baseRequest;
  810. // console.log(baseUtil)
  811. // console.log(getLocation)
  812. getLocation(baseUtil, (lat, lng) => {
  813. that.latitude = lat;
  814. that.longitude = lng;
  815. })
  816. that.initMapData()
  817. }
  818. }
  819. </script>
  820. <style>
  821. @import url('/static/base.css');
  822. </style>
  823. <style>
  824. page {
  825. width: 100%;
  826. height: 100%;
  827. }
  828. uni-page-body {
  829. width: 100%;
  830. height: 100%;
  831. }
  832. .page {
  833. width: 100%;
  834. height: 100%;
  835. display: flex;
  836. flex-direction: column;
  837. align-items: center;
  838. overflow-y: hidden;
  839. position: relative;
  840. }
  841. .search {
  842. position: absolute;
  843. top: 60upx;
  844. right: 40upx;
  845. z-index: 9999;
  846. }
  847. .areaTop {
  848. position: absolute;
  849. top: 60upx;
  850. left: 30upx;
  851. z-index: 9999;
  852. height: 50upx;
  853. line-height: 30upx;
  854. /* padding: 10upx; */
  855. color: black;
  856. font-size: 30upx;
  857. width: 200upx;
  858. }
  859. .backTop {
  860. width: 100%;
  861. position: absolute;
  862. top: 0upx;
  863. left: 0upx;
  864. z-index: 999;
  865. background: #F5F8FE;
  866. height: 120upx;
  867. }
  868. .topRight {
  869. width: 200upx;
  870. position: absolute;
  871. top: 0upx;
  872. right: 0upx;
  873. z-index: 99999;
  874. height: 100upx;
  875. }
  876. map {
  877. position: absolute;
  878. bottom: 0;
  879. width: 100%;
  880. /* height:80%; */
  881. margin-top: 20%;
  882. }
  883. .dianl {
  884. position: absolute;
  885. width: 250upx;
  886. height: 80upx;
  887. text-align: center;
  888. font-size: 28upx;
  889. top: 120upx;
  890. left: 0upx;
  891. background: white;
  892. }
  893. .zhuangtai {
  894. position: absolute;
  895. width: 250upx;
  896. height: 80upx;
  897. text-align: center;
  898. font-size: 28upx;
  899. top: 120upx;
  900. left: 250upx;
  901. background: white;
  902. box-sizing: border-box;
  903. border-left: 2upx solid red;
  904. border-right: 2upx solid red;
  905. }
  906. .shiyong {
  907. position: absolute;
  908. width: 250upx;
  909. height: 80upx;
  910. text-align: center;
  911. font-size: 28upx;
  912. top: 120upx;
  913. right: 0upx;
  914. background: white;
  915. }
  916. .location {
  917. width: 72upx;
  918. height: 72upx;
  919. position: absolute;
  920. bottom: 5%;
  921. left: 50upx;
  922. }
  923. .load {
  924. width: 72upx;
  925. height: 72upx;
  926. position: absolute;
  927. bottom: 5%;
  928. right: 50upx;
  929. }
  930. .sweepCode {
  931. width: 300upx;
  932. height: 90upx;
  933. border-radius: 50upx;
  934. background: #1AEAC9;
  935. font-size: 32upx;
  936. color: white;
  937. text-align: center;
  938. line-height: 80upx;
  939. position: absolute;
  940. bottom: 5%;
  941. left: 57%;
  942. margin-left: -200upx;
  943. }
  944. .beijing {
  945. position: absolute;
  946. width: 700upx;
  947. height: 280upx;
  948. top: 210upx;
  949. left: 50%;
  950. margin-left: -350upx;
  951. background: white;
  952. z-index: 10;
  953. border-radius: 20upx;
  954. }
  955. .code {
  956. position: absolute;
  957. z-index: 20;
  958. color: black;
  959. font-weight: bold;
  960. font-size: 32upx;
  961. top: 230upx;
  962. left: 50upx;
  963. width: 200upx;
  964. }
  965. .dianliang {
  966. position: absolute;
  967. z-index: 20;
  968. color: #E34B6E;
  969. font-size: 32upx;
  970. top: 230upx;
  971. left: 260upx;
  972. }
  973. .xiangqing {
  974. position: absolute;
  975. z-index: 20;
  976. color: #E34B6E;
  977. font-size: 32upx;
  978. top: 370upx;
  979. left: 50upx;
  980. width: 200upx;
  981. height: 80upx;
  982. text-align: center;
  983. line-height: 80upx;
  984. border: #212121 2upx solid;
  985. border-radius: 50upx;
  986. }
  987. .kaisuo {
  988. position: absolute;
  989. z-index: 20;
  990. color: white;
  991. font-size: 32upx;
  992. top: 370upx;
  993. right: 50upx;
  994. width: 200upx;
  995. height: 80upx;
  996. text-align: center;
  997. background: #FF5F5D;
  998. border-radius: 50upx;
  999. }
  1000. .status {
  1001. position: absolute;
  1002. z-index: 20;
  1003. color: #E34B6E;
  1004. font-size: 32upx;
  1005. top: 230upx;
  1006. right: 60upx;
  1007. }
  1008. .xunling {
  1009. position: absolute;
  1010. z-index: 20;
  1011. top: 390upx;
  1012. right: 280upx;
  1013. }
  1014. .lastPosi {
  1015. position: absolute;
  1016. z-index: 20;
  1017. color: #858585;
  1018. font-size: 28upx;
  1019. top: 300upx;
  1020. left: 50upx;
  1021. }
  1022. =======
  1023. },500)
  1024. })
  1025. that.getBikes();
  1026. console.log(that.arrState, "车辆位置")
  1027. switch (uni.getSystemInfoSync().platform) {
  1028. case 'android':
  1029. console.log('客户端是Android')
  1030. that.lineHeight = '75'
  1031. break;
  1032. case 'ios':
  1033. console.log('客户端是iOS')
  1034. that.lineHeight = '80'
  1035. break;
  1036. }
  1037. that.posi(); //获取当前位置
  1038. this.initData(1)
  1039. }
  1040. }
  1041. </script>
  1042. <style>
  1043. @import url('/static/base.css');
  1044. </style>
  1045. <style>
  1046. page {
  1047. width: 100%;
  1048. height: 100%;
  1049. }
  1050. uni-page-body {
  1051. width: 100%;
  1052. height: 100%;
  1053. }
  1054. .page {
  1055. width: 100%;
  1056. height: 100%;
  1057. display: flex;
  1058. flex-direction: column;
  1059. align-items: center;
  1060. overflow-y: hidden;
  1061. position: relative;
  1062. }
  1063. .search {
  1064. position: absolute;
  1065. top: 40upx;
  1066. right: 40upx;
  1067. z-index: 9999;
  1068. }
  1069. .areaTop {
  1070. position: absolute;
  1071. top: 60upx;
  1072. left: 30upx;
  1073. z-index: 9999;
  1074. height: 50upx;
  1075. line-height: 30upx;
  1076. /* padding: 10upx; */
  1077. color: black;
  1078. font-size: 30upx;
  1079. width: 200upx;
  1080. }
  1081. .backTop {
  1082. width: 100%;
  1083. position: absolute;
  1084. top: 0upx;
  1085. left: 0upx;
  1086. z-index: 999;
  1087. background: #F5F8FE;
  1088. height: 120upx;
  1089. }
  1090. .topRight {
  1091. width: 200upx;
  1092. position: absolute;
  1093. top: 0upx;
  1094. right: 0upx;
  1095. z-index: 99999;
  1096. height: 100upx;
  1097. }
  1098. map {
  1099. position: absolute;
  1100. bottom: 0;
  1101. width: 100%;
  1102. /* height:80%; */
  1103. margin-top: 20%;
  1104. }
  1105. .dianl {
  1106. position: absolute;
  1107. width: 250upx;
  1108. height: 80upx;
  1109. text-align: center;
  1110. font-size: 28upx;
  1111. top: 120upx;
  1112. left: 0upx;
  1113. background: white;
  1114. }
  1115. .zhuangtai {
  1116. position: absolute;
  1117. width: 250upx;
  1118. height: 80upx;
  1119. text-align: center;
  1120. font-size: 28upx;
  1121. top: 120upx;
  1122. left: 250upx;
  1123. background: white;
  1124. box-sizing: border-box;
  1125. border-left: 2upx solid red;
  1126. border-right: 2upx solid red;
  1127. }
  1128. .shiyong {
  1129. position: absolute;
  1130. width: 250upx;
  1131. height: 80upx;
  1132. text-align: center;
  1133. font-size: 28upx;
  1134. top: 120upx;
  1135. right: 0upx;
  1136. background: white;
  1137. }
  1138. .location {
  1139. width: 72upx;
  1140. height: 72upx;
  1141. position: absolute;
  1142. bottom: 5%;
  1143. left: 50upx;
  1144. }
  1145. .load {
  1146. width: 72upx;
  1147. height: 72upx;
  1148. position: absolute;
  1149. bottom: 5%;
  1150. right: 50upx;
  1151. }
  1152. .sweepCode {
  1153. width: 300upx;
  1154. height: 90upx;
  1155. border-radius: 50upx;
  1156. background: #1AEAC9;
  1157. font-size: 32upx;
  1158. color: white;
  1159. text-align: center;
  1160. line-height: 80upx;
  1161. position: absolute;
  1162. bottom: 5%;
  1163. left: 57%;
  1164. margin-left: -200upx;
  1165. }
  1166. .beijing {
  1167. position: absolute;
  1168. width: 700upx;
  1169. height: 280upx;
  1170. top: 210upx;
  1171. left: 50%;
  1172. margin-left: -350upx;
  1173. background: white;
  1174. z-index: 10;
  1175. border-radius: 20upx;
  1176. }
  1177. .code {
  1178. position: absolute;
  1179. z-index: 20;
  1180. color: black;
  1181. font-weight: bold;
  1182. font-size: 32upx;
  1183. top: 230upx;
  1184. left: 50upx;
  1185. width: 200upx;
  1186. }
  1187. .dianliang {
  1188. position: absolute;
  1189. z-index: 20;
  1190. color: #E34B6E;
  1191. font-size: 32upx;
  1192. top: 230upx;
  1193. left: 260upx;
  1194. }
  1195. .xiangqing {
  1196. position: absolute;
  1197. z-index: 20;
  1198. color: #E34B6E;
  1199. font-size: 32upx;
  1200. top: 370upx;
  1201. left: 50upx;
  1202. width: 200upx;
  1203. height: 80upx;
  1204. text-align: center;
  1205. line-height: 80upx;
  1206. border: #212121 2upx solid;
  1207. border-radius: 50upx;
  1208. }
  1209. .kaisuo {
  1210. position: absolute;
  1211. z-index: 20;
  1212. color: white;
  1213. font-size: 32upx;
  1214. top: 370upx;
  1215. right: 50upx;
  1216. width: 200upx;
  1217. height: 80upx;
  1218. text-align: center;
  1219. background: #FF5F5D;
  1220. border-radius: 50upx;
  1221. }
  1222. .status {
  1223. position: absolute;
  1224. z-index: 20;
  1225. color: #E34B6E;
  1226. font-size: 32upx;
  1227. top: 230upx;
  1228. right: 60upx;
  1229. }
  1230. .xunling {
  1231. position: absolute;
  1232. z-index: 20;
  1233. top: 390upx;
  1234. right: 280upx;
  1235. }
  1236. .lastPosi {
  1237. position: absolute;
  1238. z-index: 20;
  1239. color: #858585;
  1240. font-size: 28upx;
  1241. top: 300upx;
  1242. left: 50upx;
  1243. }
  1244. >>>>>>> b5b7e5b494eb95cb74e074d52b1baeff3f73835b
  1245. </style>