網站首頁 編程語言 正文
效果圖:
<template>
<view class="user">
<view class="list">
<view class="title">地址列表</view>
<view class="title-label">
<view>名稱</view>
<view>距離(由近到遠排序)</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">已加載全部數據</view>
<!-- 空 -->
<view class="empty" v-if="!sortingList.length">
<view class="empty-text">暫無數據</view>
</view>
</view>
</view>
</template>
<script>
var http = require("../../utils/http.js");
var config = require("../../utils/config.js");
export default {
data() {
return {
sortingList: [],//地址列表
longitude: '', // 經度(當前用戶位置)
latitude: '',// 緯度(當前用戶位置)
loadAll: false ,// 已加載全部
current: 1,
total:0,//總數量
pageSize:10,//每頁查詢數量
}
},
components: {},
props: {},
computed:{},
/**
* 生命周期函數--監聽頁面加載
*/
onLoad: function (options) {
this.getCurrentLocation()
},
/**
* 生命周期函數--監聽頁面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函數--監聽頁面顯示
*/
onShow: function () {
this.current = 1
this.sortingList = []
this.getSortingList(1)
},
/**
* 生命周期函數--監聽頁面隱藏
*/
onHide: function () {},
/**
* 生命周期函數--監聽頁面卸載
*/
onUnload: function () {},
/**
* 頁面相關事件處理函數--監聽用戶下拉動作
*/
onPullDownRefresh: function () {},
/**
* 頁面上拉觸底事件的處理函數
*/
onReachBottom: function () {
if (this.current < this.total/this.pageSize) {
this.current ++;
this.getSortingList(1)
} else {
this.loadAll = true
}
},
methods: {
//通過自帶的方法獲取到當前的經緯度
getCurrentLocation() {
let that = this
uni.getLocation({
type: 'wgs84',
success: function(res) {
console.log("當前位置信息:",res)
that.longitude = res.longitude; // 經度
that.latitude = res.latitude;// 緯度
},
fail: function(error) {
uni.showToast({
title: '無法獲取位置信息!無法使用位置功能',
icon: 'none',
})
}
});
},
// 獲取地址列表
getSortingList: function(current) {
uni.showLoading();
var params = {
url: "/xxx/xxx",
method: "GET",
data: {
pageNum: this.current,
pageSize: 10,
longitude: this.longitude, // 經度
latitude: this.latitude // 緯度
},
callBack: res => {
uni.hideLoading()
this.sortingList = this.sortingList.concat(res.rows);
this.total = res.total;
}
};
http.request(params);
},
//導航--傳終點的坐標即可
toNavigation: function(endLongitude,endLatitude,placeName,temporaryAddress) {
console.log("返回的坐標:",endLongitude,endLatitude)
uni.openLocation({
longitude: parseFloat(endLongitude),
latitude: parseFloat(endLatitude),
scale: 28, // 縮放比例TODO
name:placeName,//地點名稱
address:temporaryAddress,//地點詳細地址
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
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-10-29 python中正則表達式findall的用法實例_python
- 2022-10-10 C++私有繼承與EBO深入分析講解_C 語言
- 2023-07-27 TypeScript類和多態、抽象類、訪問修飾符
- 2022-06-04 為Centos安裝指定版本的Docker_docker
- 2022-07-06 python?pandas遍歷每行并累加進行條件過濾方式_python
- 2022-06-22 Android在Sqlite3中的應用及多線程使用數據庫的建議(實例代碼)_Android
- 2022-07-06 C語言for循環嵌套for循環在實踐題目中應用詳解_C 語言
- 2022-05-01 C#程序調用cmd.exe執行命令_C#教程
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支