Browse Source

数据加载

xiangbo 8 months ago
parent
commit
5b72fdb6f7

+ 6 - 1
components/AttentionPannel/AttentionPannel.js

@@ -13,7 +13,9 @@ Component({
   /**
    * 组件的初始数据
    */
-  data: {},
+  data: {
+    isAttention: false
+  },
 
   /**
    * 组件的方法列表
@@ -21,6 +23,9 @@ Component({
   methods: {
     handleAtentionClick() {
       console.log('关注按钮被点击')
+      this.setData({
+        isAttention: !this.data.isAttention
+      })
     }
   }
 })

+ 2 - 1
components/AttentionPannel/AttentionPannel.wxml

@@ -2,5 +2,6 @@
 	<image class="attention-image" src="{{attentionItem.image}}"></image>
 	<view class="attention-name">{{attentionItem.plate_name}}</view>
 	<view class="attention-number">{{attentionItem.plate_count}}关注</view>
-	<view class="attention-btn" bindtap="handleAtentionClick">关注</view>
+	<view wx:if="{{!isAttention}}" class="attention-btn" bindtap="handleAtentionClick">关注</view>
+	<view wx:else class="attention-btn attention-btn-active" bindtap="handleAtentionClick">已关注</view>
 </view>

+ 8 - 1
components/AttentionPannel/AttentionPannel.wxss

@@ -31,7 +31,7 @@
   color: #74828f;
   letter-spacing: 0;
   line-height: 42rpx;
-  margin:10rpx 0;
+  margin: 10rpx 0;
 }
 
 .attention-btn {
@@ -45,3 +45,10 @@
   border: 1px solid #f04933;
   border-radius: 29px;
 }
+
+.attention-btn-active {
+  width: 110%;
+  transform: translate(-5%, 0);
+  color: #b5b6b6;
+  border: 1px solid #b5b6b6;
+}

+ 1 - 1
components/NewsPannel/NewsPannel.js

@@ -26,7 +26,7 @@ Component({
       console.log('A股快讯内容被点击')
       console.log(e.currentTarget.dataset.index)
       let list = this.data.lists
-      let isShow = true
+      // let isShow = true
       list[e.currentTarget.dataset.index].isShow = !list[
         e.currentTarget.dataset.index
       ].isShow

+ 16 - 13
components/NewsPannel/NewsPannel.wxml

@@ -1,16 +1,19 @@
-<view class="info-a-all-list" wx:for="{{lists}}" wx:key="id">
-	<view class="info-a-all-circle {{item.big_news_flag=='1'?'info-a-all-circle-active':''}}">
-		<text class="info-a-all-clock {{item.big_news_flag=='1'?'info-a-all-clock-active':''}}">{{item.showtime}}</text>
-	</view>
-	<view class="info-a-all-title {{item.big_news_flag=='1'?'info-a-all-clock-active':''}}">
-		<image class="info-a-all-profitable" src="../../images/profitable.png" wx:if="{{item.impact=='利好'}}"></image>
-		{{item.title}}
-	</view>
-	<view class="info-a-all-content-container">
-		<view class="{{item.isShow?'info-a-all-content-show':'info-a-all-content'}} {{item.big_news_flag=='1'?'info-a-all-clock-active':''}}" wx:if="{{item.content==''?false:true}}" data-index="{{index}}" bindtap="handleItemClick" id="{{index}}">{{item.content}}
+<view class="container" wx:for="{{lists}}" wx:key="id">
+	<view class="info-a-all-time" wx:if="{{item.date}}">{{item.date}}</view>
+	<view class="info-a-all-list">
+		<view class="info-a-all-circle {{item.big_news_flag=='1'?'info-a-all-circle-active':''}}">
+			<text class="info-a-all-clock {{item.big_news_flag=='1'?'info-a-all-clock-active':''}}">{{item.showtime}}</text>
 		</view>
-		<image class="info-a-all-image" src="{{item.image}}" wx:if="{{item.image!=''}}" bindtap="handleImageClick" data-image="{{item.image}}"></image>
-	</view>
+		<view class="info-a-all-title {{item.big_news_flag=='1'?'info-a-all-clock-active':''}}">
+			<image class="info-a-all-profitable" src="../../images/profitable.png" wx:if="{{item.impact=='利好'}}"></image>
+			{{item.title}}
+		</view>
+		<view class="info-a-all-content-container">
+			<view class="{{item.isShow?'info-a-all-content-show':'info-a-all-content'}} {{item.big_news_flag=='1'?'info-a-all-clock-active':''}}" wx:if="{{item.content==''?false:true}}" data-index="{{index}}" bindtap="handleItemClick" id="{{index}}">{{item.content}}
+			</view>
+			<image class="info-a-all-image" src="{{item.image}}" wx:if="{{item.image!=''}}" bindtap="handleImageClick" data-image="{{item.image}}"></image>
+		</view>
+
 
-	
+	</view>
 </view>

+ 6 - 0
components/NewsPannel/NewsPannel.wxss

@@ -66,10 +66,16 @@
   font-size: 28rpx;
   color: #808C98;
   max-height: 100%;
+  /* transition: all 3s linear; */
 }
 
 .info-a-all-image {
   height: 288rpx;
   width: 657rpx;
   border-radius: 10rpx;
+}
+.info-a-all-time {
+  font-size: 26rpx;
+  margin: 0 0 20rpx 0rpx;
+  font-weight: bolder;
 }

+ 0 - 0
images/缺省图-无关注@2x.png → images/myNone.png


+ 25 - 1
pages/index/index.js

@@ -22,7 +22,7 @@ Page({
       },
       {
         id: 2,
-        name: '概念材',
+        name: '概念材',
         isActive: false
       }
     ],
@@ -61,6 +61,9 @@ Page({
    */
   onLoad: function (options) {
     // 页面初始化时调用一次A股快讯全部新闻接口
+    wx.showLoading({
+      title: '加载中'
+    })
     http.getAll(res => {
       console.log(res)
       this.setData({
@@ -70,6 +73,7 @@ Page({
         goodList: [],
         news: []
       })
+      wx.hideLoading()
     })
   },
 
@@ -95,6 +99,9 @@ Page({
       case 0:
         switch (scrollIndex) {
           case 0:
+            wx.showLoading({
+              title: '加载中'
+            })
             console.log('全部')
             http.getAll(res => {
               this.setData({
@@ -104,9 +111,13 @@ Page({
                 goodList: [],
                 news: []
               })
+              wx.hideLoading()
             })
             break
           case 1:
+            wx.showLoading({
+              title: '加载中'
+            })
             console.log('大新闻')
             http.getBigNews(res => {
               this.setData({
@@ -116,9 +127,13 @@ Page({
                 goodList: [],
                 news: []
               })
+              wx.hideLoading()
             })
             break
           case 2:
+            wx.showLoading({
+              title: '加载中'
+            })
             console.log('盘中异动')
             http.getChanges(res => {
               this.setData({
@@ -128,9 +143,13 @@ Page({
                 goodList: [],
                 news: []
               })
+              wx.hideLoading()
             })
             break
           case 3:
+            wx.showLoading({
+              title: '加载中'
+            })
             console.log('利好')
             http.getGoodNews(res => {
               this.setData({
@@ -140,11 +159,15 @@ Page({
                 goodList: this.data.goodList.concat(res),
                 news: []
               })
+              wx.hideLoading()
             })
             break
         }
         break
       case 1:
+        wx.showLoading({
+          title: '加载中'
+        })
         console.log('加载要闻')
         http.getImportantNews(res => {
           this.setData({
@@ -154,6 +177,7 @@ Page({
             goodList: [],
             news: this.data.news.concat(res)
           })
+          wx.hideLoading()
         })
         break
       case 2:

+ 13 - 11
pages/index/index.wxml

@@ -8,25 +8,21 @@
 		</view>
 		<block wx:if="{{scrolls[0].isActive}}">
 			<view class="info-a-all-container">
-				<view class="info-a-all-time">2020-04-21 星期二</view>
 				<NewsPannel lists="{{allList}}"></NewsPannel>
 			</view>
 		</block>
 		<block wx:elif="{{scrolls[1].isActive}}">
 			<view class="info-a-all-container">
-				<view class="info-a-all-time">2020-04-21 星期二</view>
 				<NewsPannel lists="{{bigNewsList}}"></NewsPannel>
 			</view>
 		</block>
 		<block wx:elif="{{scrolls[2].isActive}}">
 			<view class="info-a-all-container">
-				<view class="info-a-all-time">2020-04-21 星期二</view>
 				<NewsPannel lists="{{changeList}}"></NewsPannel>
 			</view>
 		</block>
 		<block wx:elif="{{scrolls[3].isActive}}">
 			<view class="info-a-all-container">
-				<view class="info-a-all-time">2020-04-21 星期二</view>
 				<NewsPannel lists="{{goodList}}"></NewsPannel>
 			</view>
 		</block>
@@ -58,15 +54,21 @@
 			</view>
 			<view>
 				<view class="info-concept-title">我的关注</view>
-				<view class="info-concept-subhead">
-					<view class="info-concept-subhead-content">#5G</view>
-					<image class="info-concept-subhead-image" src="../../images/goDetail.png"></image>
-					<image class="info-concept-subhead-icon" src="../../images/hotShow.png"></image>
-				</view>
-				<view class="info-concept-mine-content">
-					<AttentionList />
+				<view class="info-concept-default">
+					<image class="info-concept-default-img" src="../../images/myNone.png"></image>
+					<view class="info-concept-default-text">暂无关注内容</view>
 				</view>
 
+				<view class="info-concept-mine-container" wx:if="{{false}}">
+					<view class="info-concept-subhead">
+						<view class="info-concept-subhead-content">#5G</view>
+						<image class="info-concept-subhead-image" src="../../images/goDetail.png"></image>
+						<image class="info-concept-subhead-icon" src="../../images/hotShow.png"></image>
+					</view>
+					<view class="info-concept-mine-content">
+						<AttentionList />
+					</view>
+				</view>
 			</view>
 		</view>
 	</block>

+ 29 - 11
pages/index/index.wxss

@@ -7,11 +7,6 @@
 .info-a-scroll {
   height: 102rpx;
 }
-.info-a-all-time {
-  font-size: 26rpx;
-  margin: 0 0 20rpx 0rpx;
-  font-weight: bolder;
-}
 
 .info-concept-search-container {
   padding-top: 10rpx;
@@ -59,7 +54,7 @@
   display: flex;
   flex-wrap: wrap;
   justify-content: start;
-  max-height: 252rpx;
+  max-height: 270rpx;
   overflow: hidden;
 }
 .info-concept-hot-content-active {
@@ -99,6 +94,29 @@
   height: 32rpx;
 }
 
+.info-concept-default {
+  width: 500rpx;
+  margin: 0 auto;
+  /* border: 1px solid black; */
+  text-align: center;
+  padding-top: 60rpx;
+}
+
+.info-concept-default-img {
+  width: 188rpx;
+  height: 170rpx;
+  margin: 0 auto;
+  display: block;
+}
+.info-concept-default-text {
+  margin-top: 34rpx;
+  font-family: PingFangSC-Regular;
+  font-size: 28rpx;
+  color: #a0adba;
+  letter-spacing: 0;
+  text-align: center;
+}
+
 .info-concept-subhead {
   width: 750rpx;
   height: 70rpx;
@@ -114,22 +132,22 @@
   justify-content: start;
   align-items: center;
 }
-.info-concept-subhead-content{
+.info-concept-subhead-content {
   position: relative;
 }
-.info-concept-subhead-image{
+.info-concept-subhead-image {
   height: 32rpx;
   width: 32rpx;
 }
-.info-concept-subhead-icon{
+.info-concept-subhead-icon {
   position: absolute;
   right: 28rpx;
   top: 50%;
   height: 32rpx;
   width: 32rpx;
-  transform: translate(-50%,-50%);
+  transform: translate(-50%, -50%);
 }
 
-.info-concept-mine-content{
+.info-concept-mine-content {
   padding-bottom: 20rpx;
 }

+ 1 - 1
project.config.json

@@ -32,7 +32,7 @@
 	},
 	"compileType": "miniprogram",
 	"libVersion": "2.12.0",
-	"appid": "wx1f111dda5743a3d4",
+	"appid": "wx2e3ff21f7654562e",
 	"projectname": "HUAXI",
 	"debugOptions": {
 		"hidedInDevtools": []

+ 82 - 0
service/indexReq.js

@@ -6,6 +6,10 @@ let bigNewsPage = 1
 let changesPage = 1
 let goodNewsPage = 1
 let importantNewsPage = 1
+let allDate = ''
+let bigDate = ''
+let changeDate = ''
+let goodDate = ''
 
 // A股快讯全部请求
 let getAll = function (callback) {
@@ -13,6 +17,7 @@ let getAll = function (callback) {
   changesPage = 1
   goodNewsPage = 1
   importantNewsPage = 1
+  bigDate = ''
   console.log(allPage)
   let params = {
     funcNo: '3052062',
@@ -26,6 +31,21 @@ let getAll = function (callback) {
     let result = res.data.results
     // 循环遍历结果数组,可以在请求拿到结果时进行,然后追加,此处可判断是否等于全局日期变量
     result.forEach((v, i) => {
+      const newDate = v.showtime.substring(0, 10)
+      if (newDate !== allDate) {
+        allDate = newDate
+        let dateObject = new Date(allDate)
+        let week
+        if (dateObject.getDay() == 0) week = allDate + ' 星期日'
+        if (dateObject.getDay() == 1) week = allDate + ' 星期一'
+        if (dateObject.getDay() == 2) week = allDate + ' 星期二'
+        if (dateObject.getDay() == 3) week = allDate + ' 星期三'
+        if (dateObject.getDay() == 4) week = allDate + ' 星期四'
+        if (dateObject.getDay() == 5) week = allDate + ' 星期五'
+        if (dateObject.getDay() == 6) week = allDate + ' 星期六'
+        v.date = week
+        console.log(v.date)
+      }
       v.showtime = v.showtime.substring(11, 16)
     })
     allPage = allPage + 1
@@ -38,6 +58,9 @@ let getBigNews = function (callback) {
   changesPage = 1
   goodNewsPage = 1
   importantNewsPage = 1
+  allDate = ''
+  changeDate = ''
+  goodDate = ''
   let params = {
     funcNo: '3052062',
     i_page: bigNewsPage,
@@ -48,6 +71,21 @@ let getBigNews = function (callback) {
     let result = res.data.results
     // 循环遍历结果数组,可以在请求拿到结果时进行,然后追加,此处可判断是否等于全局日期变量
     result.forEach((v, i) => {
+      const newDate = v.showtime.substring(0, 10)
+      if (newDate !== bigDate) {
+        bigDate = newDate
+        let dateObject = new Date(bigDate)
+        let week
+        if (dateObject.getDay() == 0) week = bigDate + ' 星期日'
+        if (dateObject.getDay() == 1) week = bigDate + ' 星期一'
+        if (dateObject.getDay() == 2) week = bigDate + ' 星期二'
+        if (dateObject.getDay() == 3) week = bigDate + ' 星期三'
+        if (dateObject.getDay() == 4) week = bigDate + ' 星期四'
+        if (dateObject.getDay() == 5) week = bigDate + ' 星期五'
+        if (dateObject.getDay() == 6) week = bigDate + ' 星期六'
+        v.date = week
+        console.log(v.date)
+      }
       v.showtime = v.showtime.substring(11, 16)
     })
     bigNewsPage = bigNewsPage + 1
@@ -60,6 +98,9 @@ let getChanges = function (callback) {
   bigNewsPage = 1
   goodNewsPage = 1
   importantNewsPage = 1
+  allDate = ''
+  bigDate = ''
+  goodDate = ''
   let params = {
     funcNo: '3052062',
     i_page: changesPage,
@@ -70,6 +111,21 @@ let getChanges = function (callback) {
     let result = res.data.results
     // 循环遍历结果数组,可以在请求拿到结果时进行,然后追加,此处可判断是否等于全局日期变量
     result.forEach((v, i) => {
+      const newDate = v.showtime.substring(0, 10)
+      if (newDate !== changeDate) {
+        changeDate = newDate
+        let dateObject = new Date(changeDate)
+        let week
+        if (dateObject.getDay() == 0) week = changeDate + ' 星期日'
+        if (dateObject.getDay() == 1) week = changeDate + ' 星期一'
+        if (dateObject.getDay() == 2) week = changeDate + ' 星期二'
+        if (dateObject.getDay() == 3) week = changeDate + ' 星期三'
+        if (dateObject.getDay() == 4) week = changeDate + ' 星期四'
+        if (dateObject.getDay() == 5) week = changeDate + ' 星期五'
+        if (dateObject.getDay() == 6) week = changeDate + ' 星期六'
+        v.date = week
+        console.log(v.date)
+      }
       v.showtime = v.showtime.substring(11, 16)
     })
     changesPage = changesPage + 1
@@ -82,6 +138,9 @@ let getGoodNews = function (callback) {
   bigNewsPage = 1
   changesPage = 1
   importantNewsPage = 1
+  allDate = ''
+  bigDate = ''
+  changeDate = ''
   let params = {
     funcNo: '3052062',
     i_page: goodNewsPage,
@@ -92,6 +151,21 @@ let getGoodNews = function (callback) {
     let result = res.data.results
     // 循环遍历结果数组,可以在请求拿到结果时进行,然后追加,此处可判断是否等于全局日期变量
     result.forEach((v, i) => {
+      const newDate = v.showtime.substring(0, 10)
+      if (newDate !== goodDate) {
+        goodDate = newDate
+        let dateObject = new Date(goodDate)
+        let week
+        if (dateObject.getDay() == 0) week = goodDate + ' 星期日'
+        if (dateObject.getDay() == 1) week = goodDate + ' 星期一'
+        if (dateObject.getDay() == 2) week = goodDate + ' 星期二'
+        if (dateObject.getDay() == 3) week = goodDate + ' 星期三'
+        if (dateObject.getDay() == 4) week = goodDate + ' 星期四'
+        if (dateObject.getDay() == 5) week = goodDate + ' 星期五'
+        if (dateObject.getDay() == 6) week = goodDate + ' 星期六'
+        v.date = week
+        console.log(v.date)
+      }
       v.showtime = v.showtime.substring(11, 16)
     })
     goodNewsPage = goodNewsPage + 1
@@ -104,6 +178,10 @@ let getImportantNews = function (callback) {
   bigNewsPage = 1
   changesPage = 1
   goodNewsPage = 1
+  allDate = ''
+  bigDate = ''
+  changeDate = ''
+  goodDate = ''
   let params = {
     funcNo: '3052020',
     i_page: importantNewsPage,
@@ -122,6 +200,10 @@ let getImportantNews = function (callback) {
 
 // 获取用户未关注的概念题材列表
 let getNoPlatelist = function (i_eno, callback) {
+  allDate = ''
+  bigDate = ''
+  changeDate = ''
+  goodDate = ''
   let params = {
     funcNo: '3052110',
     i_eno: i_eno