oneFloorList.vue 3.74 KB
<template>
	<view>
		 <headerComp :leftImgSrc="leftSrc" @leftClick="backClick" :title="titleStr"></headerComp>
		<searchBox @handleEvent="searchFun"></searchBox>
		 <view class="list">
			 <view class="listItem" @tap="itemFun(item)" v-for="item in list">
				 <text>{{item.name}}</text>
			 </view>
		 </view>
		<!-- <uni-list>
			<uni-list-item :title="this.$t('index').allStore" @click="selectStore(id)"></uni-list-item>
			<uni-list-item :title="item.name" @click="selectStore(item.id,item.name)" v-for="item in list"></uni-list-item>
		</uni-list> -->
	</view>
</template>

<script>
	import headerComp from '../../components/header'
	import searchBox from '../../components/search'
	
	export default{
		data(){
			return{
				aa:"aa",
				leftSrc:'../../static/header/backArrow.png',
				titleStr:this.$t('index').storeSelect,
				id:'',
				atoken:'',
				list:[],
				allList:[],
				accountName:'',
				url:'',
				selectSrc:'../../static/list/select.png',
				unSelectSrc:'../../static/list/unselect.png',
				selectIdArr:[],
				selectNameArr:[],
				type:''
			}
		},
		onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数
// 			this.atoken=option.atoken;
// 			this.id=option.accountId;
			this.url=option.url;
			this.type=option.type;
			uni.getStorage({
				key:'accountName',
				success:(res)=>{
					this.accountName=res.data;
				}
			})
			uni.getStorage({
				key:'accountId',
				success:(res)=>{
					this.id=res.data;
				}
			})
			uni.getStorage({
				key:'atoken',
				success:(res)=>{
					this.atoken=res.data;
				}
			})
			this.getListData();
		},
		computed: {
			i18n(){
				return this.$t('index')
			}
		},
		components:{
			headerComp,searchBox
		},
		methods: {
			searchFun(val){
				this.list=[];
				this.allList.forEach(item=>{
					if(item.name.indexOf(val)!=-1){
						this.list.push(item)
					}
				})
			},
			itemFun(item){
				this.selectIdArr=[];
				this.selectNameArr=[]
				this.selectNameArr.push(item.name)
				this.selectIdArr.push(item.id)
				this.confirmFun();
			},
			confirmFun(){
				uni.removeStorage({
					key: 'selectStoreNameArr',
					success: function (res) {
						console.log('success');
					}
				});
				uni.setStorage({
					key:'selectFloorIdArr',
					data:JSON.stringify(this.selectIdArr)
				})
				uni.setStorage({
					key:'selectFloorNameArr',
					data:JSON.stringify(this.selectNameArr)
				})
				uni.reLaunch({
					url:this.url+'?type='+this.type,
				})
			},
			getListData(){
				uni.getStorage({
					key:'accountList',
					success:(res)=>{
						this.allList=JSON.parse(res.data);
						this.list=JSON.parse(res.data);
					}
				})
				
				var mallid='';
				uni.getStorage({
					key:"selectAccountIdArr",
					success: (res) => {
						mallid=JSON.parse(res.data)[0];
					}
				})
				uni.request({
					url:window.url+'/floors',
					data:{
						accountId: this.id,
						mallId:mallid,
						status: 1,
						_t:Date.parse(new Date())/1000
					},
					header: {
						'Authorization': this.atoken //自定义请求头信息
					},
					method:'GET',
					success:(res) =>{
						this.allList=JSON.parse(JSON.stringify(res.data.data));
						this.allList.unshift({
							name:'全部',
							id:'all'
						})
						this.list=JSON.parse(JSON.stringify(res.data.data));
						this.list.unshift({
							name:'全部',
							id:'all'
						})
					}
				})
			},
			backClick() {
				uni.navigateBack({
					delta:1
				})
			}
		},
	}
</script>

<style>
	.listItem{
		border-bottom: 1px solid #979797;
		height: 72.46upx;
		line-height: 72.46upx;
		font-size: 23.55upx;
		background: #FFFFFF;
		position: relative;
	}
	.listItem>image{
		width: 28.98upx;
		height: 28.98upx;
		position: absolute;
		top:23.55upx;
		left: 25.36upx;
	}
	.listItem text{
		margin-left: 77.89upx;
	}
</style>