網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
效果圖:
<template>
<view class="user">
<view class="list">
<view class="title">地址列表</view>
<view class="title-label">
<view>名稱(chēng)</view>
<view>距離(由近到遠(yuǎn)排序)</view>
</view>
<view class="item" v-for="(item,index) in sortingList" :key="index">
<view class="item-top">
<view class="item-top-left">{{item.placeName}}</view>
<view class="item-top-right">
<view>{{item.designCapacity}}km</view>
<view class="view-btn" @click="toNavigation(item.longitude,item.latitude,item.placeName,item.temporaryAddress)">
<image src="../../static/img/view-btn.png"></image>
</view>
</view>
</view>
<view class="item-bottom">地址:{{item.temporaryAddress}}</view>
</view>
<!-- 到底了~ -->
<view class="loadall" v-if="sortingList.length > 10 && loadAll">已加載全部數(shù)據(jù)</view>
<!-- 空 -->
<view class="empty" v-if="!sortingList.length">
<view class="empty-text">暫無(wú)數(shù)據(jù)</view>
</view>
</view>
</view>
</template>
<script>
var http = require("../../utils/http.js");
var config = require("../../utils/config.js");
export default {
data() {
return {
sortingList: [],//地址列表
longitude: '', // 經(jīng)度(當(dāng)前用戶(hù)位置)
latitude: '',// 緯度(當(dāng)前用戶(hù)位置)
loadAll: false ,// 已加載全部
current: 1,
total:0,//總數(shù)量
pageSize:10,//每頁(yè)查詢(xún)數(shù)量
}
},
components: {},
props: {},
computed:{},
/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
*/
onLoad: function (options) {
this.getCurrentLocation()
},
/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示
*/
onShow: function () {
this.current = 1
this.sortingList = []
this.getSortingList(1)
},
/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏
*/
onHide: function () {},
/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載
*/
onUnload: function () {},
/**
* 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶(hù)下拉動(dòng)作
*/
onPullDownRefresh: function () {},
/**
* 頁(yè)面上拉觸底事件的處理函數(shù)
*/
onReachBottom: function () {
if (this.current < this.total/this.pageSize) {
this.current ++;
this.getSortingList(1)
} else {
this.loadAll = true
}
},
methods: {
//通過(guò)自帶的方法獲取到當(dāng)前的經(jīng)緯度
getCurrentLocation() {
let that = this
uni.getLocation({
type: 'wgs84',
success: function(res) {
console.log("當(dāng)前位置信息:",res)
that.longitude = res.longitude; // 經(jīng)度
that.latitude = res.latitude;// 緯度
},
fail: function(error) {
uni.showToast({
title: '無(wú)法獲取位置信息!無(wú)法使用位置功能',
icon: 'none',
})
}
});
},
// 獲取地址列表
getSortingList: function(current) {
uni.showLoading();
var params = {
url: "/xxx/xxx",
method: "GET",
data: {
pageNum: this.current,
pageSize: 10,
longitude: this.longitude, // 經(jīng)度
latitude: this.latitude // 緯度
},
callBack: res => {
uni.hideLoading()
this.sortingList = this.sortingList.concat(res.rows);
this.total = res.total;
}
};
http.request(params);
},
//導(dǎo)航--傳終點(diǎn)的坐標(biāo)即可
toNavigation: function(endLongitude,endLatitude,placeName,temporaryAddress) {
console.log("返回的坐標(biāo):",endLongitude,endLatitude)
uni.openLocation({
longitude: parseFloat(endLongitude),
latitude: parseFloat(endLatitude),
scale: 28, // 縮放比例TODO
name:placeName,//地點(diǎn)名稱(chēng)
address:temporaryAddress,//地點(diǎn)詳細(xì)地址
success: function (res) {
console.log('success:',res);
}
});
},
}
}
</script>
<style>
page {
background: #f4f4f4;
}
.list{
margin-top: 32rpx;
}
.title{
font-size: 34rpx;
color: #333333;
text-align: center;
}
.title-label{
margin-top: 27rpx;
margin-bottom: 24rpx;
display: flex;
justify-content: space-between;
font-size: 30rpx;
color: #666666;
padding-left: 22rpx;
padding-right: 22rpx;
}
.item{
width:100%;
padding: 17rpx 22rpx 28rpx 22rpx;
background: #FFFFFF;
margin-bottom: 28rpx;
box-sizing:border-box;
}
.item-top{
height: 56rpx;
line-height: 56rpx;
margin-bottom: 27rpx;
font-size: 30rpx;
color: #333333;
display: flex;
justify-content: space-between;
}
.item-top-right{
display: flex;
justify-content: space-between;
height: 56rpx;
line-height: 56rpx;
}
.item-bottom{
font-size: 30rpx;
color: #666;
}
.view-btn{
width: 200rpx;
height: 58rpx;
border-radius: 60rpx;
margin-left: 10rpx;
}
.view-btn image{
width:100%;
height:100%;
}
.empty-text {
font-size: 28rpx;
text-align: center;
color: #999;
line-height: 2em;
}
.loadall{
font-size: 28rpx;
text-align: center;
color: #999;
line-height: 2em;
margin-bottom: 20rpx;
}
</style>
原文鏈接:https://blog.csdn.net/maoge_666/article/details/131580694
- 上一篇:沒(méi)有了
- 下一篇:沒(méi)有了
相關(guān)推薦
- 2022-04-26 jQuery實(shí)現(xiàn)鎖定頁(yè)面元素(表格列)_jquery
- 2022-07-15 QT中QByteArray與char、int、float之間的互相轉(zhuǎn)化_C 語(yǔ)言
- 2023-12-21 npm install 報(bào)錯(cuò)(npm ERR! errno: -4048, npm ERR! c
- 2022-05-17 【go】解決“dial tcp 142.251.42.241:443: connect: conne
- 2022-06-02 python套接字socket通信_(tái)python
- 2022-11-25 Django使用裝飾器限制對(duì)視圖的訪(fǎng)問(wèn)及實(shí)現(xiàn)原理_python
- 2023-10-12 v-if和v-for的優(yōu)先級(jí)以及二者同時(shí)使用的情況
- 2022-04-15 python機(jī)器學(xué)習(xí)MATLAB最小二乘法的兩種解讀_python
- 欄目分類(lèi)
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支