index.vue 8.8 KB

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