index.vue 9.3 KB

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