123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- <template>
- <view class="content">
- <view class="content_top">
- <u-navbar leftText="" height="44px" :bgColor="bgColor" :placeholder="true">
- <view class="navbar_left hflex acenter" slot="left">
- <image src="../../../static/images/index/logo.png" style="width: 160rpx;height: 60rpx;"></image>
- <view class="dian" v-if="city != '全国'"></view>
- <view class="hflex acenter" v-if="city && city != '全国'">
- <image :src="weather.icon" style="width: 32rpx;height: 32rpx;margin-right: 8rpx;"></image>
- <view class="text_style1">{{weather.min}}°~{{weather.max}}°</view>
- </view>
- </view>
- </u-navbar>
- <view class="search hflex acenter" :class="scrollHeight > 0 ? 'bg_white' : ''">
- <view class="hflex acenter" @click="changeCity">
- <view class="city">{{city ? city : '全国'}}</view>
- <u-icon name="arrow-down-fill" color="#000" size="10"></u-icon>
- </view>
- <u-search v-model="serach_value" borderColor="#506dff" placeholder="搜索关键词" shape="round" :showAction="false"
- @click="focus" disabled bgColor="#fff">
- </u-search>
- </view>
- </view>
-
- <view class="swiper">
- <u-swiper :indicator="true" indicatorActiveColor="#506dff" :list="bannerList" radius="20rpx" @click="toBanner" keyName="img" height="170"></u-swiper>
- </view>
- <view class="notice hflex acenter jbetween">
- <!-- <view class="notice_left">公告</view> -->
- <u-notice-bar :text="notice_text" direction="column" icon="公告" color="#7a7b7c" bgColor="#f3f7ff" @click="toNot"></u-notice-bar>
- <view class="hflex acenter" @click="toNotlist">
- <view class="text1">更多</view>
- <u-icon name="arrow-right" color="#bebebf" size="14"></u-icon>
- </view>
- </view>
- <view class="boxs hflex acenter jbetween">
- <image :src="class_img1" mode="widthFix" style="width: 336rpx;" @click="toDetail(1)"></image>
- <image :src="class_img2" mode="widthFix" style="width: 336rpx;" @click="toDetail(2)"></image>
- </view>
- <view class="boxs hflex acenter jbetween">
- <image :src="class_img3" mode="widthFix" style="width: 220rpx;" @click="toDetail(3)"></image>
- <image :src="class_img4" mode="widthFix" style="width: 220rpx;" @click="toDetail(4)"></image>
- <image :src="class_img5" mode="widthFix" style="width: 220rpx;" @click="toDetail(5)"></image>
- </view>
- <view class="boxs fixed" :style="'top:' + height + 'px'">
- <u-tabs :list="tabs" @click="changeTaaba" :scrollable = "true"
- :activeStyle="{
- fontSize: '30rpx',
- color: '#000',
- }" :inactiveStyle="{
- fontSize: '30rpx',
- color: '#888888'
- }"></u-tabs>
- </view>
- <view class="boxs" style="margin: 0;" v-if="pageList.length > 0">
- <news-module :pageList="pageList" @toDetail="toNews"></news-module>
- </view>
- <!-- <view class="boxs" v-else>
- <u-empty icon="https://ship.shipcc.cn/common/zhan.png" text="暂时没有数据哦">
- </view> -->
- </view>
- </template>
- <script>
- import $api, { closeLoading } from '@/static/js/api.js'
- var that = ''
- const app = getApp().globalData
- export default {
- data() {
- return {
- title: 'Hello',
- weather: {
- icon: '/static/icons/100.svg',
- min: 0,
- max: 10
- },
- city: '',
- location: '',
- serach_value: '',
- bannerList: [
- ],
- notice_text: [
- ],
- noticeList: [],
- class_img1: 'https://cn-shanghai-aliyun-cloudauth-1196126035163283.oss-cn-shanghai.aliyuncs.com/class_img1.png',
- class_img2: 'https://cn-shanghai-aliyun-cloudauth-1196126035163283.oss-cn-shanghai.aliyuncs.com/class_img2.png',
- class_img3: 'https://cn-shanghai-aliyun-cloudauth-1196126035163283.oss-cn-shanghai.aliyuncs.com/class_img3.png',
- class_img4: 'https://cn-shanghai-aliyun-cloudauth-1196126035163283.oss-cn-shanghai.aliyuncs.com/class_img4.png',
- class_img5: 'https://cn-shanghai-aliyun-cloudauth-1196126035163283.oss-cn-shanghai.aliyuncs.com/class_img5.png',
- tabs: [],
- pageList: [
- ],
- bgColor: 'rgb(255,255,255,0)',
- exad: '',
- page: 1,
- total: 1,
- cid: '',
- scrollHeight: 0,
- height: 0
- }
- },
- onLoad() {
- that = this
- let res = uni.getSystemInfoSync()
- that.height = res.statusBarHeight + 92
- console.log('getSystemInfoSync',res);
- // this.getCity()
- // that.getCate()
- // that.getBanner()
- // that.HXlogin()
- },
- onShow() {
- that.exad = []
- that.getCity()
- that.getCate()
- that.getNotice()
- that.getBanner()
- },
- onPullDownRefresh() {
- that.getNotice()
- },
- watch: {
- city(newVal, oldVal) {
- console.log('城市数据发生改变');
- that.getCity()
- }
- },
- onPageScroll(e) {
- that.scrollHeight = e.scrollTop
- if(e.scrollTop != 0) {
- that.bgColor = "#fff"
- } else {
- that.bgColor = 'rgba(255,255,255,0)'
- }
- },
- methods: {
- getBanner() {
- $api.req({
- url: '/data/api.Data/getSlider',
- data: {
- keys: 'home_banner'
- }
- }, function(res) {
- if(res.code == 1) {
- that.bannerList = res.data
- }
- })
- },
- getNotice() {
- $api.req({
- url: '/data/api.Notice/index',
- data: {
- page: 1,
- limit: 10
- }
- }, function(res) {
- if(res.code == 1) {
- that.noticeList = res.data.data
- for(var i=0;i<that.noticeList.length;i++) {
- that.notice_text.push(that.noticeList[i].title)
- }
- // uni.stopPullDownRefresh();
- }
- uni.stopPullDownRefresh();
- })
- },
- // 获取当前位置
- getCity() {
- that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '全国'
- console.log(that.city);
- if(!that.city) {
- // that.city = '全国'
- return new Promise((resolve, reject) => {
- app.getLoca().then(res=> {
- console.log('getLoaction',res);
- that.city = res[0].regeocodeData.addressComponent.city
- uni.setStorageSync('city',that.city)
- uni.setStorageSync('locationCity',that.city)
- })
- })
- }
- that.getWeather()
- },
- changeCity() {
- $api.jump('/page_index/pages/index/changeCity')
- },
- // 获取当前城市天气
- getWeather() {
- if(that.city == '全国') {
- return
- }
- uni.request({
- url: 'https://geoapi.qweather.com/v2/city/lookup',
- data: {
- key: '682de67f4b8d4a5e97bc63ed722ae3cf',
- location:that.city
- },
- header:{
- 'content-type': 'application/x-www-form-urlencoded',
- },
- success(res) {
- uni.request({
- url: "https://devapi.qweather.com/v7/weather/7d",
- data: {
- location: res.data.location[0].id,
- key: '682de67f4b8d4a5e97bc63ed722ae3cf'
- },
- header:{
- 'content-type': 'application/x-www-form-urlencoded',
- },
- success(res2) {
- that.weather = {
- icon: '/static/icons/' + res2.data.daily[0].iconDay + '.svg',
- min: res2.data.daily[0].tempMin,
- max: res2.data.daily[0].tempMax
- }
- }
- })
- }
- })
- /* $api.req({
- url: '/data/api.Weather/area',
- data: {
- name: that.city
- }
- }, function(res) {
- that.weather = {
- icon: '/static/icons/' + res.data.daily[0].iconDay + '.svg',
- min: res.data.daily[0].tempMin,
- max: res.data.daily[0].tempMax
- }
- }) */
- },
- // 点击天气
- toWeather() {
- // $api.jump('/page_index/pages/index/weather')
- },
- // 轮播图跳转
- toBanner(e) {
- var url = that.bannerList[e].url
- if(url == '#') {
- return
- }
- $api.jump('/pages/user/web_view?src=' + encodeURIComponent(url))
- },
- // 点击输入框
- focus() {
- $api.jump('/page_index/pages/index/search')
- },
- toNot(index) {
- $api.jump('/page_index/pages/index/noticeDetail?id=' + that.noticeList[index].id)
- },
- // 公告列表
- toNotlist() {
- $api.jump('/page_index/pages/index/noticeList')
- },
- toDetail(index) {
-
- var url = ''
- switch(index) {
- case 1:
- url = '/page_index/pages/demand/demand';
- break;
- case 2:
- url = '/page_index/pages/purchase/purchase';
- break;
- case 3:
- url = '/page_index/pages/repair/repair';
- break;
- case 4:
- url = '/page_index/pages/bidding/bidding';
- break;
- case 5:
- url = '/page_index/pages/resources/resources';
- break;
- }
-
- $api.jump(url)
- },
- // 切换tabs
- changeTaaba(e) {
-
- that.page = 1
- that.cid = e.id
- // that.pageList = []
- that.exad = []
- that.getList(that.cid)
- },
- getCate() {
- $api.req({
- url: '/data/api.Xw/category'
- }, function(res) {
- if(res.code == 1) {
- that.tabs = res.data
- that.cid = that.tabs[0].id
- that.getList(that.cid)
- }
- })
- },
- getList(cid) {
- $api.req({
- url: '/data/api.Xw/index',
- data: {
- page: that.page,
- cid: cid,
- keyword: that.serach_value,
- exad: that.exad
- }
- }, function(res) {
- if(res.code == 1) {
- for(var i=0;i<res.data.data.length;i++) {
- if(res.data.data[i].images == "") {
- that.$set(res.data.data[i],'has_img',true)
- }else {
- res.data.data[i].images = res.data.data[i].images.split('|')
- }
- if(res.data.data[i].ctype == 2) {
- that.exad += res.data.data[i].id+ ','
- }
- }
- if(that.page == 1) {
- that.pageList = res.data.data
- } else {
- that.pageList = that.pageList.concat(res.data.data)
- }
- that.total = res.data.total
- // that.exad = res.data.exad.join(',')
-
- }
- })
- },
- toNews(index) {
- if(that.pageList[index].ctype == 1) {
- $api.jump('/page_index/pages/index/newDetail?id=' + that.pageList[index].id)
- } else if(that.pageList[index].ctype == 2){
- $api.jump('/page_index/pages/index/ggDetail?id=' + that.pageList[index].id)
- }
- },
- onReachBottom() {
- if (Number(that.page) * 15 >= Number(that.total)) {
- $api.info("没有更多了")
- } else {
- that.page++
- that.getList(that.cid)
- }
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content::v-deep {
- // padding: 0 30rpx;
- background: #fff;
- .content_top {
- position: relative;
- background: url('../../../static/images/index/bg.png') no-repeat;
- background-size: 100%;
- box-sizing: border-box;
- padding: 0 30rpx 120rpx;
- .navbar_left {
-
- .dian {
- width: 8rpx;
- height: 8rpx;
- background: #232323;
- border-radius: 50%;
- margin: 0 6rpx 0 12rpx;
- }
- }
- .search {
- position: fixed;
- width: 691rpx;
- box-sizing: border-box;
- z-index: 999;
- padding: 20rpx 0;
- /* margin-top: 36rpx; */
- .city {
- color: #222222;
- font-size: 32rpx;
- margin-right: 16rpx;
- }
- .u-input {
- border: solid 1rpx #526eff;
- background: #fff;
- height: 76rpx;
- margin-left: 16rpx;
- padding: 0 24rpx !important;
- }
- }
- }
- .swiper {
-
- width: 690rpx;
- // box-sizing: border-box;
- // padding: 0 30rpx;
- height: 170px;
- margin: 0rpx auto 20rpx;
- border-radius: 20rpx;
- .u-swiper__wrapper__item__wrapper {
- height: 170px;
- }
- }
- .notice {
- width: 690rpx;
- box-sizing: border-box;
- padding: 15rpx 30rpx 15rpx 0;
- background-color: #f3f7ff;
- margin: 0 30rpx 0;
- border-radius: 20rpx;
-
- .u-notice-bar {
- // background-color: #f3f7ff !important;
- //
- .u-icon__icon {
- font-size: 32rpx;
- // padding-left: 24rpx;
- color: #506dff !important;
- padding-right: 20rpx;
- border-right: 3rpx solid #f1f1f1;
- }
- }
-
- .notice_left {
-
- }
- }
- // .class_img {
- // width: 100%;
- // box-sizing: border-box;
- // padding: 0 30rpx;
-
- // }
- .boxs {
- width: 100%;
- box-sizing: border-box;
- padding: 0 30rpx;
- margin: 24rpx 0 0;
- }
- .fixed {
- background-color: #fff;
- position: sticky;
- top: 256rpx;
- z-index: 99;
- }
- .bg_white {
- background-color: #fff !important;
- }
- .text1 {
- font-size: 25rpx;
- color: #8f8f90;
- }
- }
- </style>
|