Просмотр исходного кода

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
网点列表修改

1004749546@qq.com 4 лет назад
Родитель
Сommit
a24453b1ca
1 измененных файлов с 34 добавлено и 29 удалено
  1. 34 29
      pages/store/storeList.vue

+ 34 - 29
pages/store/storeList.vue

@@ -25,6 +25,10 @@
 					<u-image width="110rpx" height="110rpx" :border-radius="10" :src="getStoreStatus(item)"></u-image>
 				</view>
 			</view>
+			<u-empty :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
+			<view style="padding: 20upx;">
+				<u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
+			</view>
 		</scroll-view>
 	</view>
 </template>
@@ -37,6 +41,8 @@
 		},
 		data() {
 			return {
+				noDataText: '暂无数据',
+				status: 'loadmore',
 				storeList: [{
 						id: 1,
 						icon: '',
@@ -70,7 +76,8 @@
 					lng: '0'
 				},
 				pageNo: 1,
-				pageSize: 10
+				pageSize: 10,
+				total: 0
 			}
 		},
 		onShow() {
@@ -99,9 +106,7 @@
 		computed: {},
 		methods: {
 			getStoresList() {
-				uni.showLoading({
-					title: '正在加载...'
-				})
+				this.status = "loading"
 				let lat = this.currentPosition.lat
 				let lng = this.currentPosition.lng
 				getStoresList({
@@ -111,36 +116,31 @@
 					lng: lng
 				}).then(res => {
 					console.log(res)
+					uni.hideLoading()
 					if (res.status == 200) {
 						let list = res.data.list
-						if (list && list.length) {
-							list.map(item => {
-								if (item.addrDetail.indexOf("省") > 0 && item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") >
-									0) {
-									item.addrDetail = item.addrDetail
+						list.map(item => {
+							if (item.addrDetail.indexOf("省") > 0 && item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") >
+								0) {
+								item.addrDetail = item.addrDetail
+							} else {
+								if (item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") > 0) {
+									item.addrDetail = item.addrProvinceName + item.addrDetail
+								} else if (item.addrDetail.indexOf("区") > 0) {
+									item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
 								} else {
-									if (item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") > 0) {
-										item.addrDetail = item.addrProvinceName + item.addrDetail
-									} else if (item.addrDetail.indexOf("区") > 0) {
-										item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
-									} else {
-										item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
-									}
+									item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
 								}
-								item.distance = item.distance ? Math.round(item.distance / 1000) : ''
-								item.star = getStarNum(item.level)
-							})
-							this.storeList = this.storeList.concat(list)
-						} else {
-							if (this.pageNo != 1) {
-								uni.showToast({
-									title: '已经是最后一页'
-								})
-								this.isLastPage = true
 							}
-						}
+							item.distance = item.distance ? Math.round(item.distance / 1000) : ''
+						})
+						this.storeList = this.storeList.concat(list)
+						this.total = res.data.count || 0
+					} else {
+						this.storeList = []
+						this.total = 0
+						this.noDataText = res.message
 					}
-					uni.hideLoading()
 				})
 			},
 			// 获取网点营业状态
@@ -167,7 +167,12 @@
 			},
 			// 到达底部
 			reachBottom() {
-
+				if(this.storeList.length < this.total){
+					this.pageNo += 1
+					this.getStoresList()
+				}else{
+					this.status = "nomore"
+				}
 			}
 
 		}