eventList.vue 3.62 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:'',
				showList:{},
				mallId:''
			}
		},
		onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数
// 			this.atoken=option.atoken;
 			this.id=option.accountId;
			uni.getStorage({
				key:"selectAccountIdArr",
				success: (res) => {
					this.mallid=JSON.parse(res.data)[0];
				}
			})
			if(!this.mallId){
				this.mallId=option.mallId;
			}
			this.url=option.url;
			this.type=option.type;
			uni.getStorage({
				key:'showList',
				success:(res)=>{
					this.showList=JSON.parse(res.data)
				}
			})
			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.setStorage({
					key:'eventIdArr',
					data:JSON.stringify(this.selectIdArr)
				})
				uni.setStorage({
					key:'eventNameArr',
					data:JSON.stringify(this.selectNameArr)
				})
				uni.reLaunch({
					url:this.url+'?type='+this.type,
				})
			},
			getListData(){
				var year=''
				
				uni.getStorage({
					key:"selectDate",
					success: (res) => {
						year=res.data.split(',')[0];
					}
				})
				uni.request({
					url:window.url+'/events/getEvent',
					data:{
						accountId:this.id,
						mallId:this.mallId,
						year:year,
						_t:Date.parse(new Date())/1000
					},
					header: {
						'Authorization': this.atoken //自定义请求头信息
					},
					method:'GET',
					success:(res) =>{
						this.allList=JSON.parse(JSON.stringify(res.data.data));
						this.list=JSON.parse(JSON.stringify(res.data.data));
					}
				})
			},
			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>