<template>
	<view class="swiper">
		<u-swiper :list="swiper_list" keyName="image" height="300rpx" radius="12rpx" @change="e => swiper_current = e.current" @click="swiperclick">
			<view slot="indicator" class="indicator">
				<view class="indicator__dot" v-for="(item, index) in swiper_list" :key="index"
					:class="[index === swiper_current && 'indicator__dot--active']">
				</view>
			</view>
		</u-swiper>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	export default {
		props: {
			type: {
				typeof: String,
				default: ''
			}
		},
		data() {
			return {
				swiper_list: [],
				swiper_current: 0,
			}
		},
		mounted() {
			this.getlist()
		},
		onLoad() {
			
		},
		onShow() {
			
		},
		onPullDownRefresh() {
			
		},
		onReachBottom() {
			
		},
		methods: {
			getlist() {
				var _this = this
				$api.req({
					url: 'banner',
					method: 'GET',
					data: {
						type: this.type,
						limit: 5
					}
				}, function(res) {
					if(res.code == 10000) {
						_this.swiper_list = res.data
					}
				})
			},
			swiperclick(e) {
				var data = this.swiper_list[e]
				if(data.is_jump == 1) {
					if(data.jump_type == 'external') {
						window.location.href = data.jump_url
					} else {
						uni.navigateTo({
							url: data.jump_url
						})
					}
				}
			},
		}
	}
</script>

<style lang="scss">

</style>
