mallList.vue 2.54 KB
<template>
	<view>
		 <headerComp :leftImgSrc="leftSrc" @leftClick="backClick" :title="titleStr"></headerComp>
		<!-- <div class="searchBox">
			 <mSearch @search="search($event,0)" backgroundColor="#0069FF" :mode="2" :show=false></mSearch>
		 </div> -->
		 <uni-list>
			<uni-list-item :title="this.$t('index').allStore" @tap="selectStore(id,'all')"></uni-list-item>
			<uni-list-item :title="item.name" @tap="selectStore(item.id,item.name)" v-for="item in list"></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'
	// import mSearch from '@/components/mehaotian-search/mehaotian-search'
	
	export default{
		data(){
			return{
				aa:"aa",
				leftSrc:'../../static/header/backArrow.png',
				titleStr:this.$t('index').storeSelect,
				id:'',
				atoken:'',
				list:[],
				accountName:'',
				url:''
			}
		},
		onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数
// 			this.atoken=option.atoken;
// 			this.id=option.accountId;
			this.url=option.url;
			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,uniList,uniListItem
		},
		methods: {
			search(e, val) {
				console.log(e);
			},
			selectStore(id,name){
				uni.setStorage({
					key:'orgIds',
					data:id
				})
				if(id==this.id&&name=='all'){
					uni.setStorage({
						key:'type',
						data:'account'
					})
					uni.setStorage({
						key:'orgName',
						data:this.accountName
					})
				}else{
					uni.setStorage({
						key:'type',
						data:'mall'
					})
					uni.setStorage({
						key:'orgName',
						data:name
					})
				}
				uni.reLaunch({
					url:this.url,
				})
			},
			getListData(){
				uni.request({
					url:window.url+'/malls',
					data:{
						accountId:this.id,
						_t:Date.parse(new Date())/1000
					},
					header: {
						'Authorization': this.atoken //自定义请求头信息
					},
					method:'GET',
					success:(res) =>{
						this.list=res.data.data;
					}
				})
			},
			backClick() {
				uni.navigateBack({
					delta:1
				})
			}
		},
	}
</script>

<style>
</style>