floorList.vue 3.24 KB
<template>
	<view>
		 <headerComp :leftImgSrc="leftSrc" @leftClick="backClick" :title="titleStr"></headerComp>
		 <view class="hearSwich">
			 <span class="swichButton" :class="{active:selectFloor}" @tap="tapFloor" v-if="permissionsFun('floor')">楼层</span>
			 <span class="swichButton" :class="{active:selectZone}" @tap="tapZone" v-if="permissionsFun('shop')">{{i18n.area}}</span>
		 </view>
		 <uni-list v-show="selectFloor"  v-if="permissionsFun('floor')">
			<uni-list-item :title="item.name" @tap="selectItem(item.id,item.name)" v-for="item in floorList"></uni-list-item>
		</uni-list>
		<uni-list v-show="selectZone"  v-if="permissionsFun('shop')">
			<uni-list-item :title="item.name" @tap="selectItem(item.id,item.name)" v-for="item in zoneList"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import headerComp from '../../components/header'
	import uniList from '@/components/list/uni-list/uni-list.vue'
	import uniListItem from '@/components/list/uni-list-item/uni-list-item.vue'
	
	export default{
		data(){
			return{
				leftSrc:'../../static/header/backArrow.png',
				titleStr:this.$t("index").areaSelect,
				accountId:'',
				atoken:'',
				mallId:'',
				floorList:[],
				zoneList:[],
				selectFloor:true,
				selectZone:false
			}
		},
		onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数
			this.atoken=option.atoken;
			this.accountId=option.accountId;
			this.mallId=option.mallId;
			this.getListData();
		},
		computed: {
			i18n() {
				return this.$t("index")
			}
		},
		components:{
			headerComp,uniList,uniListItem
		},
		methods: {
			tapFloor(){
				this.selectFloor=true;
				this.selectZone=false;
			},
			tapZone(){
				this.selectFloor=false;
				this.selectZone=true;
			},
			selectItem(id,name){
				uni.setStorage({
					key:'orgIds',
					data:id
				})
				uni.setStorage({
					key:'orgName',
					data:name
				})
				if(this.selectFloor){
					uni.setStorage({
						key:'type',
						data:'floor'
					})
				}else{
					uni.setStorage({
						key:'type',
						data:'zone'
					})
				}
				uni.reLaunch({
					url:'../index/index',
				})
			},
			getListData(){
				uni.request({
					url:window.url+'/floors',
					data:{
						accountId:this.accountId,
						mallId:this.mallId,
						_t:Date.parse(new Date())/1000
					},
					header: {
						'app-code':'mobile',
						'Authorization': this.atoken //自定义请求头信息
					},
					method:'GET',
					success:(res) =>{
						this.floorList=res.data.data;
					}
				})
				uni.request({
					url:window.url+'/zones',
					data:{
						accountId:this.accountId,
						mallId:this.mallId,
						_t:Date.parse(new Date())/1000
					},
					header: {
						'app-code':'mobile',
						'Authorization': this.atoken //自定义请求头信息
					},
					method:'GET',
					success:(res) =>{
						this.zoneList=res.data.data;
					}
				})
			},
			backClick() {
				uni.navigateBack({
					delta:1
				})
			}
		},
	}
</script>

<style>
	.hearSwich{
		width: 100%;
		display: flex;
		flex-direction:row;
		border: 1px solid #0069FF;
		border-radius: 10.86upx;
		font-size:21.73upx;
		margin-top: 7.24upx;
	}
	.swichButton{
		flex: 1;
		text-align: center;
		padding: 7.24upx 0;
	}
	.active{
		background: #0069FF;
		color: #FFFFFF;
	}
</style>