<template>
	<view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				getstationCode:null,
			}
		},
		onShow() {
			let stationCode = this.getstationCode
			if(stationCode){
				this.getstationCode = null
				this.getPamars(stationCode)
			}else{
				console.log("redirect home")
				uni.reLaunch({
					url:'/pages/index/index'
				})
			}
		},
		onLoad(options) {
			console.log("options",options)
			if(options.stationCode){
				this.getstationCode=options.stationCode
			}
			if((decodeURIComponent(options.q)).split("=")[1]){
				this.getstationCode = (decodeURIComponent(options.q)).split("=")[1]
			}
		},
		methods: {
			getPamars(stationCode){
				if(this.$storage.getJson("token")){
					this.$http.getStationExchange({
						stationCode: stationCode
					}).then(res => {
						if (res.code === 0 && res.data) {
							uni.navigateTo({
								url: '/pages/powerExchange/index?stationCode=' +stationCode + '&exchangeNo=' + res.data
							})
						} else {
							uni.navigateTo({
								url: '/pages/public/404?error=' + res.msg
							})
						}
					})
				}else{
					uni.navigateTo({
						url: '/pages/public/login?topage='+stationCode,
					});
				}
			}
		}
	}
</script>

<style>

</style>
