zzp hace 2 años
padre
commit
22c59bae97
Se han modificado 2 ficheros con 41 adiciones y 14 borrados
  1. 2 2
      config/api.js
  2. 39 12
      pagesMain/venueMore.vue

+ 2 - 2
config/api.js

@@ -5,8 +5,8 @@
 // const API_BASE = 'http://192.168.1.109/newApi'
 // const API_BASE = 'http://192.168.1.117:8089'
 // const API_BASE = 'http://192.168.1.145/newApi'
-const API_BASE = 'http://192.168.1.117:8089'
-// const API_BASE = 'http://192.168.1.145/newApi'
+// const API_BASE = 'http://192.168.1.117:8089'
+const API_BASE = 'http://192.168.1.145/newApi'
 
 module.exports = {
 	//  微信授权登录

+ 39 - 12
pagesMain/venueMore.vue

@@ -1,5 +1,8 @@
 <template>
 	<view class="content">
+		<view class="filter-box">
+			<u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
+		</view>
 		<view class="venue-box">
 			<u-card :head-border-bottom="false" :foot-border-top="false" title-size="32" padding="0" margin="10px" v-for="(item, index) in venueList"
 			 :key="index" class="venue-card" @click="goToVenueDetail(item)">
@@ -34,6 +37,7 @@
 	export default {
 		data() {
 			return {
+				filterText: '',
 				venueList: []
 			}
 		},
@@ -43,25 +47,42 @@
 			])
 		},
 		onLoad() {
-			// 附件场馆
-			NET.request(API.getVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
-				this.venueList = res.data
-			}).catch(error => {
-				this.$refs.uTips.show({
-					title: error.message,
-					type: 'warning',
-				})
-				setTimeout(() => {
-					uni.navigateBack()
-				},1000)
-			})
+			this.getAllVenue()
 		},
 		methods: {
+			//  获取全部场馆
+			getAllVenue() {
+				// 附件场馆
+				NET.request(API.getVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
+					this.venueList = res.data
+				}).catch(error => {
+					this.$refs.uTips.show({
+						title: error.message,
+						type: 'warning',
+					})
+					setTimeout(() => {
+						uni.navigateBack()
+					},1000)
+				})
+			},
 			//  跳转场馆详情
 			goToVenueDetail(item) {
 				uni.navigateTo({
 					url: '/pagesMain/venueDetail?id=' + item.id
 				});
+			},
+			setFilterText() {
+				if(this.filterText) {
+					let arr = []
+					this.venueList.forEach(item => {
+						if(item.name.indexOf(this.filterText) >= 0) {
+							arr.push(item)
+						}
+					})
+					this.venueList = arr
+				} else {
+					this.getAllVenue()
+				}
 			}
 		}
 	}
@@ -74,6 +95,12 @@
 		width: 100%;
 		float: left;
 		
+		.filter-box {
+			height: 48px;
+			padding: 10px 15px;
+			background-color: #FFFFFF;
+		}
+		
 		.venue-box {
 			width: 100vw;
 			float: left;