123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <template>
- <view class="main">
- <!--搜索-->
- <view class="search">
- <view class="usearch">
- <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search')"></u-search>
- </view>
- <view class="address omit" @click="go('/pages/job/position/city')">
- <text class="icon"></text>
- <text>{{ param.cityName || '南宁市' }}</text>
- </view>
- </view>
- <!--轮播图-->
- <view class="banner">
- <u-swiper circular :radius="5" :indicator="true" keyName="pic" :list="bannerList" :height="160" class="uni-swiper" @click="bannerClick"></u-swiper>
- </view>
- <view class="tab">
- <u-tabs :scrollable="false" :lineHeight="5" :inactiveStyle="{ fontSize: '17px' }" :activeStyle="{ color: '#3c9cff', fontSize: '17px' }" :list="tab" @click="tabClick"></u-tabs>
- </view>
- <!--职位列表-->
- <view class="list">
- <jobIndex :list="list" v-if="list.length > 0 && param.recommend == 1"></jobIndex>
- <job :list="list" v-if="list.length > 0 && param.recommend == ''"></job>
- <u-empty v-if="list.length === 0" text="该城市暂无工作"></u-empty>
- <button class="btn" v-if="list.length == 8" @click="go('/pages/job/list?type=' + param.type + '¤t=' + param.current)">
- <text>查看更多</text>
- <text class="icon"></text>
- </button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- tab: [
- { name: '推荐工作', orderBy: 'id', type: 0, recommend: 1, current: 1 },
- { name: '身边工作', orderBy: 'distance', type: 0, recommend: '', current: 2 },
- { name: '现结工作', orderBy: 'id', type: 1, recommend: 1, current: 1 }
- ],
- list: [],
- param: { pageNum: 1, pageSize: 8, type: 0, recommend: 1, current: 1 },
- bannerList: []
- };
- },
- onLoad() {
- this.getData();
- this.initData();
- uni.$on('select_city', (res) => {
- this.param.cityName = res.title;
- this.param.regionId = res.id;
- this.getData();
- });
- },
- methods: {
- initData() {
- //轮播图
- this.http.request({
- url: '/app/home/banner/0',
- success: (res) => {
- this.bannerList = res.data.data;
- }
- });
- //初始化所有地区
- if(!uni.getStorageSync('city_all')){
- this.http.request({
- url: '/app/common/column/city/all',
- success: (res) => {
- uni.setStorageSync('city_all', res.data.data);
- }
- });
- }
- // #ifdef MP-WEIXIN
- //授权获取位置
- uni.authorize({
- scope: 'scope.userLocation',
- success: (s) => {
- uni.getLocation({
- type: 'wgs84',
- success: (res) => {
- uni.setStorageSync('location', res);
- this.param.latitude = res.latitude;
- this.param.longitude = res.longitude;
- this.getData();
- }
- });
- },
- fail(res) {
- uni.showModal({ title: '提示', content: '定位失败,请检查是否允许定位', showCancel: false });
- }
- });
- // #endif
- },
- getData() {
- this.http.request({
- url: '/app/position/list',
- data: this.param,
- success: (res) => {
- this.list = res.data.rows;
- }
- });
- },
- tabClick(e) {
- this.param.orderBy = e.orderBy;
- this.param.type = e.type;
- this.param.recommend = e.recommend;
- this.param.current = e.current;
- this.getData();
- },
- //点击轮播图
- bannerClick(index) {
- let item = this.bannerList[index];
- if (item.contentType == '新闻资讯') {
- uni.navigateTo({ url: '/pages/news/detail?id=' + item.contentId });
- }
- if (item.contentType == '通知公告') {
- uni.navigateTo({ url: '/pages/notice/detail?id=' + item.contentId });
- }
- if (item.contentType == '工作职位') {
- uni.navigateTo({ url: '/pages/job/detail?id=' + item.contentId });
- }
- },
- go(url) {
- uni.navigateTo({ url: url });
- }
- }
- };
- </script>
- <style lang="scss">
- .banner {
- margin-top: 15px;
- box-shadow: $box-shadow;
- }
- .tab {
- background-color: white;
- margin-top: 10px;
- border-radius: 5px;
- box-shadow: $box-shadow;
- }
- .list {
- padding-top: 10px;
- }
- .btn {
- width: 60%;
- margin-top: 10px;
- }
- </style>
|