objList.vue 2.63 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:'选择对象',
				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;
			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.setStorage({
					key:'objId',
					data:JSON.stringify(this.selectIdArr)
				})
				uni.setStorage({
					key:'objName',
					data:JSON.stringify(this.selectNameArr)
				})
				uni.reLaunch({
					url:this.url+'?type='+this.type,
				})
			},
			getListData(){
				this.allList=[{
					name:"单对象",
					id:"one"
				},{
					name:"多对象",
					id:"more"
				}];
				this.list=[{
					name:"单对象",
					id:"one"
				},{
					name:"多对象",
					id:"more"
				}];
			},
			backClick() {
				uni.navigateBack({
					delta:1
				})
			}
		},
	}
</script>

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