index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <view class="jpmain body">
  3. <componentLogin ref="refLogin" :check="0"
  4. @findByOpenId="findByOpenId"></componentLogin>
  5. <view class="Area Area1" v-if="pointAuthorize">
  6. <view class="top">
  7. <view class="name">附近地锁</view>
  8. <view class="value" @click="getUserLocation()">
  9. <img class="img" src="@/assets/img/homepage/riLine-restart-line.svg" alt="">
  10. 重新定位
  11. </view>
  12. </view>
  13. <view class="list">
  14. <view class="line" v-for="(item,i) in nearList"
  15. @click="gotoInfo(item)">
  16. <view class="itembody">
  17. <view class="itemhead">
  18. <img class="img" src="@/assets/img/index.png" alt="">
  19. </view>
  20. <view class="item" >
  21. <view class="name">
  22. {{item.name}}
  23. <span class="tag" v-if="item.userPreferred"> <u-icon name="star-fill" color="#FFAE00" size="24"></u-icon> 常用 </span>
  24. </view>
  25. <view class="item2" >
  26. <span class="span" :class="' status status'+item.status">{{item.status=='1'?'在线':'离线'}}</span><span class="span">|</span>
  27. <span class="span" :class="' lockStatus lockStatus'+item.lockStatus">{{item.lockStatusN}}</span>
  28. <template v-if="item.buildMode">
  29. <span class="span">|</span>
  30. <span class="span buildMode1" v-if="item.buildMode==1" >用户自建</span>
  31. <span class="span buildMode2" v-if="item.buildMode==2" >平台运营</span>
  32. </template>
  33. <span class="span">|</span>
  34. <view class="span spanEnd" >{{item.parkingName}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="value">小于50米
  39. <u-icon name="arrow-right" color="#CCCCCC"></u-icon>
  40. </view>
  41. </view>
  42. </view>
  43. <u-empty text="50米内没有地锁" mode="list" margin-top="80" v-if="!nearList.length">
  44. <view slot="bottom">
  45. <view class="value-slot" @click="getUserLocation()">
  46. <img class="img" src="@/assets/img/homepage/riLine-restart-line.svg" alt="">
  47. 重新定位
  48. </view>
  49. </view>
  50. </u-empty>
  51. </view>
  52. <view class="Area Area2" v-if="otherList.length">
  53. <view class="top">
  54. <view class="name">全部地锁</view>
  55. </view>
  56. <view class="list">
  57. <view class="line" v-for="(item,i) in otherList" :key="i"
  58. @click="gotoInfo(item)">
  59. <view class="itembody">
  60. <view class="itemhead">
  61. <img class="img" src="@/assets/img/index.png" alt="">
  62. </view>
  63. <view class="item" >
  64. <view class="name">
  65. {{item.name}}
  66. <span class="tag" v-if="item.userPreferred" > <u-icon name="star-fill" color="#FFAE00" size="24"></u-icon> 常用 </span>
  67. </view>
  68. <view class="item2" >
  69. <span class="span" :class="' status status'+item.status">{{item.status=='1'?'在线':'离线'}}</span><span class="span">|</span>
  70. <span class="span" :class="' lockStatus lockStatus'+item.lockStatus">{{item.lockStatusN}}</span>
  71. <template v-if="item.buildMode">
  72. <span class="span">|</span>
  73. <span class="span buildMode1" v-if="item.buildMode==1" >用户自建</span>
  74. <span class="span buildMode2" v-if="item.buildMode==2" >平台运营</span>
  75. </template>
  76. <span class="span">|</span>
  77. <view class="span spanEnd" >{{item.parkingName}}</view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="value" v-if="item.distance" >{{distanceN(item.distance)}}<u-icon name="arrow-right" color="#CCCCCC"></u-icon></view>
  82. <view class="value" v-else ><u-icon name="arrow-right" color="#CCCCCC"></u-icon></view>
  83. </view>
  84. </view>
  85. </view>
  86. <u-tabbar v-model="current" :list="tabbarList"
  87. mid-button-size="112" :mid-button="true"
  88. @input="gotoinput"
  89. inactive-color="#ADB8C2" active-color="#5098FF">
  90. </u-tabbar>
  91. </view>
  92. </template>
  93. <script>
  94. import * as API from '@/apis/pagejs/pagesIndex.js'
  95. import componentLogin from '@/components/componentLogin.vue';
  96. import tabbar from '@/pages/business/as-components/Tabbar.vue';
  97. export default {
  98. components: {
  99. componentLogin,tabbar,
  100. },
  101. data() {
  102. return {
  103. current: 0,
  104. pointAuthorize:true,
  105. latitude: 30.337053,
  106. longitude: 112.240222,
  107. allList: [],
  108. isReady:true,
  109. point: false, //是否获取了定位
  110. tabbarList: [{
  111. iconPath:require("@/assets/img/tabBar/index1.png") ,
  112. selectedIconPath: require( "@/assets/img/tabBar/index1-HL.png"),
  113. text: '附近 ',
  114. pagePath2: "/pages/business/index",
  115. },
  116. {
  117. iconPath: require("@/assets/img/tabBar/parking_icon.png"),
  118. selectedIconPath: require("@/assets/img/tabBar/parking_icon.png"),
  119. text: '',
  120. pagePath2: "/pages/business/main",
  121. midButton: true,
  122. },
  123. {
  124. iconPath: require("@/assets/img/tabBar/center.png"),
  125. selectedIconPath: require("@/assets/img/tabBar/center-HL.png"),
  126. text: '我的',
  127. pagePath2: "/pages/business/center",
  128. }
  129. ],
  130. }
  131. },
  132. onLoad() {
  133. this.userInfo = this.jphelp.getPersonInfo()
  134. },
  135. onReady() {
  136. this.$refs.refLogin.findByOpenId()
  137. //this.getParkingList()
  138. },
  139. onShow() {
  140. if(this.isReady){
  141. if(this.point){
  142. // #ifdef MP-WEIXIN
  143. this.getUserLocation()
  144. // #endif
  145. }else{
  146. this.getParkingList()
  147. }
  148. }
  149. },
  150. computed: {
  151. otherList() {
  152. var sz = []
  153. for (var i in this.allList) {
  154. var item = this.allList[i]
  155. if (this.point) {
  156. if (item.distance > 1) {
  157. sz.push(item)
  158. }
  159. } else {
  160. sz.push(item)
  161. }
  162. }
  163. return sz
  164. },
  165. nearList() {
  166. var sz = []
  167. for (var i in this.allList) {
  168. var item = this.allList[i]
  169. if (this.point) {
  170. if (item.distance < 1) {
  171. sz.push(item)
  172. }
  173. } else {
  174. }
  175. }
  176. return sz
  177. }
  178. },
  179. methods: {
  180. gotoinput(i){
  181. var item=this.tabbarList[i]
  182. if(!item.pagePath){
  183. uni.reLaunch({
  184. url:item.pagePath2
  185. })
  186. }
  187. },
  188. gotoInfo(item){
  189. var url='pages/business/lockInfo?from=1&id='+item.id;
  190. if (this.point) {
  191. url+=`&point=1&longitude=${this.longitude}&latitude=${this.latitude}`
  192. }
  193. url+="&d="+new Date().getTime()
  194. this.gotoUrl(url)
  195. },
  196. getParkingList() {
  197. uni.showLoading({
  198. title: "加载中",
  199. mask: true,
  200. })
  201. var obj = {
  202. pageIndex: 1,
  203. pageSize: 999,
  204. radius: 999999999,
  205. }
  206. if (this.point) {
  207. obj.longitude = this.longitude
  208. obj.latitude = this.latitude
  209. }
  210. API.floorList(obj).then((res) => {
  211. this.allList = res.data.data
  212. console.log(this.nearList)
  213. uni.hideLoading();
  214. }).catch(error => {
  215. uni.hideLoading();
  216. uni.showToast({
  217. title: error,
  218. icon: "none"
  219. })
  220. })
  221. },
  222. findByOpenId(res) {
  223. this.isReady=true
  224. // #ifdef MP-WEIXIN
  225. this.getUserLocation()
  226. // #endif
  227. this.getParkingList()
  228. },
  229. getUserLocation() {
  230. var _this=this
  231. uni.authorize({
  232. scope: 'scope.userLocation',
  233. success() {
  234. uni.getLocation({
  235. type: 'gcj02',
  236. altitude:true,
  237. isHighAccuracy:true,
  238. success: function(res) {
  239. console.log('当前位置的经度:' + res.longitude);
  240. console.log('当前位置的纬度:' + res.latitude);
  241. _this.point=true
  242. _this.longitude=res.longitude
  243. _this.latitude=res.latitude
  244. _this.getParkingList()
  245. }
  246. });
  247. }
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style scoped lang="scss">
  254. .body {
  255. padding: 32rpx;
  256. padding-top:40rpx;
  257. }
  258. .value-slot {
  259. color: rgba(22, 119, 255, 1);
  260. font-size: 24rpx;
  261. display: flex;
  262. align-items: center;
  263. .img {
  264. width: 28rpx;
  265. height: 28rpx;
  266. }
  267. }
  268. .Area {
  269. .img {
  270. margin: 0 8rpx;
  271. }
  272. margin-bottom: 32rpx;
  273. .top {
  274. margin-bottom: 8rpx;
  275. display: flex;
  276. justify-content: space-between;
  277. .name {
  278. color: rgba(51, 51, 51, 1);
  279. font-size: 32rpx;
  280. font-weight: bold;
  281. }
  282. .value {
  283. color: rgba(22, 119, 255, 1);
  284. font-size: 24rpx;
  285. display: flex;
  286. align-items: center;
  287. .img {
  288. width: 28rpx;
  289. height: 28rpx;
  290. }
  291. }
  292. }
  293. .list {
  294. .line{
  295. display: flex;
  296. align-items: center;
  297. justify-content: space-between;
  298. .itemhead{
  299. display: flex;
  300. .img {
  301. width: 48rpx;
  302. height: 48rpx;
  303. }
  304. }
  305. .itembody{
  306. padding: 16rpx 0;
  307. display: flex;
  308. align-items: center;
  309. }
  310. .item {
  311. display: flex;
  312. flex-direction: column;
  313. padding-left: 16rpx;
  314. .name {
  315. color: rgba(51, 51, 51, 1);
  316. font-size: 32rpx;
  317. display: flex;
  318. align-items: center;
  319. //padding-bottom: 8rpx;
  320. .tag{
  321. font-size: 24rpx;
  322. color: rgba(255,174,0,1);
  323. border: 1px solid rgba(255,174,0,1);
  324. padding: 1px 8rpx;
  325. border-radius: 4px;
  326. margin-left: 8rpx;
  327. }
  328. }
  329. }
  330. .value {
  331. color: rgba(119, 119, 119, 1);
  332. white-space: pre;
  333. font-size: 24rpx;
  334. }
  335. .item2{
  336. display: flex;
  337. white-space: pre;
  338. color: rgba(119, 119, 119, 1);
  339. font-size: 24rpx;
  340. .span{
  341. margin-right: 12rpx;
  342. }
  343. .spanEnd{
  344. overflow: hidden;
  345. text-overflow: ellipsis;
  346. white-space: nowrap;
  347. width: 180rpx;
  348. }
  349. .status1{
  350. color: #4CAF50;
  351. }
  352. .lockStatus{
  353. color: #4CAF50;
  354. }
  355. .lockStatus1{
  356. color: #4CAF50;
  357. }
  358. .lockStatus2{
  359. color: #ff9800;
  360. }
  361. .lockStatus0{
  362. color: red;
  363. }
  364. .lockStatus4{
  365. color: red;
  366. }
  367. }
  368. }
  369. }
  370. }
  371. .Area2 {
  372. margin-top: 40rpx;
  373. .list {
  374. .line {
  375. border-bottom: 1px solid rgba(232, 232, 232, 1);
  376. ;
  377. }
  378. }
  379. }
  380. .buildMode{
  381. font-size: 24rpx;
  382. border: 1px solid #bbbbbb;
  383. border-radius: 4px;
  384. color: #1677ff;
  385. padding: 2rpx 8rpx;
  386. margin:0 8rpx;
  387. }
  388. .buildMode1{
  389. color: #1677ff;
  390. //border: 1px solid #1677ff;
  391. }
  392. .buildMode2{
  393. color:#4CAF50;
  394. //border: 1px solid #4CAF50;
  395. }
  396. </style>