<template>
	<view class="main">
		<!--搜索-->
		<view class="search">
			<view class="usearch">
				<u-search placeholder="请输入职位名称" bgColor="white" :showAction="false"></u-search>
			</view>
			<view class="address">
				<text class="icon">&#xe62e;</text>
				<text>南宁市</text>
			</view>
		</view>
		<!--轮播图-->
		<view class="banner">
			<u-swiper circular :radius="5" :indicator="true" keyName="pic" :list="bannerList" :height="160" class="uni-swiper" @click="click"></u-swiper>
		</view>
		<!--菜单-->
		<view class="menu">
			<view class="cd" @click="go('/pages/job/map')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #03a9f4">&#xe647;</view>
						<view class="title">地图找工</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/job/list?type=0')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #4581fb">&#xe9d9;</view>
						<view class="title">全职</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/job/list?type=1')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ff5722">&#xe62a;</view>
						<view class="title">兼职</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/index/index')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #03a9f4">&#xe725;</view>
						<view class="title">结算广场</view>
					</view>
				</view>
			</view>
		</view>
		<!--找工作-->
		<!-- 		<view class="tab">
			<u-tabs :inactiveStyle="{ fontSize: '15px' }" :activeStyle="{ color: '#3c9cff', fontSize: '17px' }" :list="tab" :current="current" @click="click"></u-tabs>
		</view> -->
		<view class="jobs" v-if="current == 0"></view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			ip: this.http.ip,
			current: 0,
			tab: [{ name: '最新工作' }, { name: '身边工作' }, { name: '现结工作' }],
			user: {},
			bannerList: [],
			noticeList: []
		};
	},
	onShow() {},
	onLoad() {
		this.initData();
	},
	methods: {
		initData() {
			//首页数据
			this.http.request({
				url: '/app/home/index',
				success: (res) => {
					this.contract = res.data.data.contract;
					this.bannerList = res.data.data.bannerList;
					res.data.data.noticeList.forEach((item) => {
						this.noticeList.push(item.title);
					});
				}
			});
			//初始化所有地区
			this.http.request({
				url: '/app/common/column/city/all',
				success: (res) => {
					uni.setStorageSync('city_all', res.data.data);
				}
			});
			//授权获取位置
			uni.authorize({
				scope: 'scope.userLocation',
				success: (s) => {
					uni.getLocation({
						type: 'wgs84',
						success: (res) => {
							uni.setStorageSync('location', res);
						}
					});
				},
				fail(res) {
					uni.showModal({ title: '提示', content: '定位失败,请检查是否允许定位', showCancel: false });
				}
			});
		},
		click(e) {
			this.current = e.index;
		},
		go(url) {
			uni.navigateTo({ url: url });
		}
	}
};
</script>

<style lang="scss">
@import './index.scss';
</style>
