Browse Source

tag、概念详情跳转

xiangbo 7 months ago
parent
commit
e5dcb5718d

+ 4 - 1
app.json

@@ -3,7 +3,9 @@
     "pages/index/index",
     "pages/miniClass/miniClass",
     "pages/mine/mine",
-    "pages/newsDetail/newsDetail"
+    "pages/newsDetail/newsDetail",
+    "pages/search/search",
+    "pages/conceptPage/conceptPage"
   ],
   "window": {
     "backgroundTextStyle": "light",
@@ -12,6 +14,7 @@
     "navigationBarTextStyle": "black"
   },
   "tabBar": {
+    "selectedColor": "#000000",
     "list": [
       {
         "pagePath": "pages/index/index",

+ 6 - 1
components/AttentionPannel/AttentionPannel.js

@@ -26,6 +26,11 @@ Component({
       this.setData({
         isAttention: !this.data.isAttention
       })
+    },
+    conceptItemClick(e) {
+      const index = e.currentTarget.dataset.index
+      console.log(index)
+      this.triggerEvent('conceptItemClick', index)
     }
   }
-})
+})

+ 1 - 1
components/AttentionPannel/AttentionPannel.wxml

@@ -1,4 +1,4 @@
-<view class="container">
+<view class="container" bindtap="conceptItemClick" data-index="{{attentionItem.plate_id}}">
 	<image class="attention-image" src="{{attentionItem.image}}"></image>
 	<view class="attention-name">{{attentionItem.plate_name}}</view>
 	<view class="attention-number">{{attentionItem.plate_count}}关注</view>

+ 30 - 0
components/ConceptPannel/ConceptPannel.js

@@ -0,0 +1,30 @@
+// components/ConceptPannel/ConceptPannel.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    list: {
+      type: Object,
+      value: {}
+    }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    list: []
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    handleGoDetial(e){
+      const index = e.currentTarget.dataset.index
+      console.log(index)
+      this.triggerEvent('conceptItemClick', index)
+    }
+  }
+})

+ 4 - 0
components/ConceptPannel/ConceptPannel.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 10 - 0
components/ConceptPannel/ConceptPannel.wxml

@@ -0,0 +1,10 @@
+<view class="container" bindtap="handleGoDetial" data-index="{{list.msg_id}}">
+	<view class="concept-pannel-title">
+		<view class="concept-pannel-fast" wx:if="{{list.is_a_message=='1'}}">快讯</view>
+		{{list.title}}
+	</view>
+	<view class="concept-pannel-content">
+	{{list.content}}
+	</view>
+  <view class="concept-pannel-time">{{list.showtime}}</view>
+</view>

+ 73 - 0
components/ConceptPannel/ConceptPannel.wxss

@@ -0,0 +1,73 @@
+.container {
+  margin: 0 28rpx;
+  border-bottom: 1px solid #E0E0E0;
+}
+
+.concept-pannel-fast {
+  display: inline-block;
+  font-family: PingFangSC-Regular;
+  font-size: 24rpx;
+  color: #4da9ff;
+  letter-spacing: 0;
+  text-align: justify;
+  line-height: 24rpx;
+  background: #edf6ff;
+  border: 1px solid #4da9ff;
+  border-radius: 2px;
+  padding: 1px;
+}
+
+.concept-pannel-title {
+  font-family: PingFangSC-Medium;
+  font-size: 32rpx;
+  color: #212121;
+  letter-spacing: 0;
+  font-weight: bolder;
+  margin-top: 30rpx;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 2;
+}
+
+.concept-pannel-content {
+  font-family: PingFangSC-Regular;
+  font-size: 28rpx;
+  color: #808c98;
+  letter-spacing: 0;
+  margin-top: 14rpx;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 3;
+}
+
+.concept-pannel-time {
+  font-family: PingFangSC-Regular;
+  font-size: 26rpx;
+  color: #a0adba;
+  letter-spacing: 0;
+  margin: 20rpx 0 30rpx 0;
+}
+
+/* .concept-pannel-content {
+  font-size: 28rpx;
+  margin-bottom: 20rpx;
+  color: #808C98;
+  max-height: 120rpx;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 3;
+} */
+
+.concept-pannel-content-show {
+  font-size: 28rpx;
+  color: #808C98;
+  max-height: 100%;
+  margin-bottom: 20rpx;
+  /* transition: all 3s linear; */
+}

+ 10 - 1
components/NewsPannel/NewsPannel.js

@@ -26,7 +26,6 @@ Component({
       console.log('A股快讯内容被点击')
       console.log(e.currentTarget.dataset.index)
       let list = this.data.lists
-      // let isShow = true
       list[e.currentTarget.dataset.index].isShow = !list[
         e.currentTarget.dataset.index
       ].isShow
@@ -41,6 +40,16 @@ Component({
       wx.previewImage({
         urls: [url]
       })
+    },
+    handleTagClick(e) {
+      console.log('A股快讯tag被点击', e.currentTarget.dataset)
+      // console.log(list[index])
+      // console.log(lists)
+      wx.navigateTo({
+        url:
+          '../../pages/conceptPage/conceptPage?index=' +
+          e.currentTarget.dataset.index
+      })
     }
   }
 })

+ 1 - 2
components/NewsPannel/NewsPannel.wxml

@@ -8,9 +8,8 @@
 			<image class="info-a-all-profitable" src="../../images/profitable.png" wx:if="{{item.impact=='利好'}}"></image>
 			{{item.title}}
 			<view class="info-a-all-tag-container">
-				<view class="info-a-all-tag" wx:for="{{item.tags}}">#{{item}}</view>
+				<view class="info-a-all-tag" wx:for-item="items" wx:for-index="indexs" data-index="{{lists[index].tagIndex[indexs]}}" wx:for="{{item.tags}}" bindtap="handleTagClick">#{{items}}</view>
 			</view>
-
 		</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}}

+ 103 - 0
pages/conceptPage/conceptPage.js

@@ -0,0 +1,103 @@
+// pages/conceptPage/conceptPage.js
+import http from '../../service/conceptReq'
+Page({
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    index: '',
+    list: [
+      // {
+      //   image:
+      //     'http://cdtest.hx168.com.cn:25158/file/zhapp/appWeb/custfile/hxinfo/2019/010.jpg',
+      //   three_increase_stocks: '603043.SS;002847.SZ;002946.SZ',
+      //   impact: '',
+      //   title:
+      //     '好想你:今年上半年实现净利润22.56亿元,同比增长1680.02%。报告期内,公司完成重大资产出售事项,将所持有的杭州郝姆斯食品有限公司100%股权出售给百事饮料(香港)有限公司 ',
+      //   stocks: '好 想 你,002582.SZ',
+      //   content: ' ',
+      //   is_a_message: '1',
+      //   is_focus: '0',
+      //   showtime: '2020-08-04 20:20:54.0',
+      //   plate_id: '33200722',
+      //   plate_name: '食品',
+      //   rn: '1',
+      //   msg_id: '733820',
+      //   plate_count: '12'
+      // }
+    ]
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    wx.showLoading({
+      title: '加载中'
+    })
+    console.log(options)
+    this.setData({
+      index: options.index
+    })
+    http.getConcept(options.index, res => {
+      console.log(res)
+      this.setData({
+        list: this.data.list.concat(res)
+      })
+      wx.hideLoading()
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {},
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {},
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {},
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {},
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {},
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    wx.showLoading({
+      title: '加载中'
+    })
+    http.getConcept(this.data.index, res => {
+      console.log(res)
+      this.setData({
+        list: this.data.list.concat(res)
+      })
+      wx.hideLoading()
+    })
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {},
+  handleGoDetail: function (e) {
+    const index = e.detail
+    console.log('华西概念题材详情被点击')
+    wx.navigateTo({
+      url: '../newsDetail/newsDetail?infocode=' + index + '&i_info_type=5'
+    })
+  }
+})

+ 5 - 0
pages/conceptPage/conceptPage.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "ConceptPannel":"../../components/ConceptPannel/ConceptPannel"
+  }
+}

+ 16 - 0
pages/conceptPage/conceptPage.wxml

@@ -0,0 +1,16 @@
+<view class="concept-detail-container">
+	<view class="concept-detail-head">
+		<view class="concept-head-img-container">
+			<image class="concept-head-img" src="{{list[0].image}}"></image>
+		</view>
+		<view class="concept-head-title">#{{list[0].plate_name}}</view>
+		<view class="concept-head-number">{{list[0].plate_count}}关注</view>
+		<view class="concept-head-btn">关注</view>
+	</view>
+
+	<view class="concept-detail-content-container">
+		<view class="concept-detail-content">
+			<ConceptPannel wx:for="{{list}}" list="{{item}}" bindconceptItemClick="handleGoDetail" />
+		</view>
+	</view>
+</view>

+ 56 - 0
pages/conceptPage/conceptPage.wxss

@@ -0,0 +1,56 @@
+.concept-detail-head {
+  /* border: 1px solid black; */
+  position: relative;
+  height: 250rpx;
+}
+.concept-head-img-container {
+  /* border: 1px solid black; */
+  border-radius: 5px;
+  width: 694rpx;
+  height: 230rpx;
+  margin: 20rpx auto 20rpx auto;
+  overflow: hidden;
+}
+
+.concept-head-img {
+  width: 100%;
+}
+.concept-head-title {
+  position: absolute;
+  top: 50rpx;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  font-family: PingFangSC-Medium;
+  font-size: 36rpx;
+  color: #ffffff;
+  letter-spacing: 0;
+  text-align: center;
+}
+
+.concept-head-number {
+  position: absolute;
+  top: 100rpx;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  font-family: PingFangSC-Regular;
+  font-size: 26rpx;
+  color: #ffffff;
+  letter-spacing: 0;
+  line-height: 42rpx;
+}
+
+.concept-head-btn {
+  background-color: red;
+  position: absolute;
+  left: 50%;
+  bottom: 20rpx;
+  transform: translate(-50%, -50%);
+  font-size: 28rpx;
+  color: #ffffff;
+  width: 116rpx;
+  height: 58rpx;
+  line-height: 58rpx;
+  text-align: center;
+  border-radius: 15px;
+}
+

+ 19 - 6
pages/index/index.js

@@ -9,8 +9,7 @@ Page({
     isHotShow: false,
     hotShowImg: '../../images/hotShow.png',
     hotHiddenImg: '../../images/hotHidden.png',
-    navs: [
-      {
+    navs: [{
         id: 0,
         name: 'A股快讯',
         isActive: true
@@ -26,8 +25,7 @@ Page({
         isActive: false
       }
     ],
-    scrolls: [
-      {
+    scrolls: [{
         id: 0,
         name: '全部',
         isActive: true
@@ -354,7 +352,7 @@ Page({
     const index = e.detail
     console.log(index)
     wx.navigateTo({
-      url: '../newsDetail/newsDetail?infocode=' + index
+      url: '../newsDetail/newsDetail?infocode=' + index + '&i_info_type=4'
     })
   },
 
@@ -363,5 +361,20 @@ Page({
     this.setData({
       isHotShow: !this.data.isHotShow
     })
+  },
+  // 概念题材-热门关注每一项被点击处理函数
+  handleConceptItemClick(e) {
+    console.log(e.detail)
+    const index = e.detail
+    wx.navigateTo({
+      url: '../conceptPage/conceptPage?index=' + index
+    })
+  },
+
+  // 概念题材的搜索框被点击后跳转H5
+  handleToSearch: function () {
+    wx.navigateTo({
+      url: '../search/search'
+    })
   }
-})
+})

+ 3 - 3
pages/index/index.wxml

@@ -39,7 +39,7 @@
 	</block>
 	<block wx:elif="{{navs[2].isActive}}">
 		<view class="info-concept-container">
-			<view class="info-concept-search-container">
+			<view class="info-concept-search-container" bindtap="handleToSearch">
 				<view class="info-concept-icon"></view>
 				<view class="info-concept-search">搜索感兴趣的题材</view>
 			</view>
@@ -47,7 +47,7 @@
 				<view class="info-concept-title">热门关注推荐</view>
 				<view wx:if="{{!isHotShow}}" class="{{!isHotShow?'info-concept-hot-content':'info-concept-hot-content-active'}}">
 					<view class="info-concept-hot-item" wx:for="{{noPlateList}}">
-						<AttentionPannel attentionItem="{{item}}" />
+						<AttentionPannel attentionItem="{{item}}" bindconceptItemClick="handleConceptItemClick" />
 					</view>
 				</view>
 
@@ -55,7 +55,7 @@
 					<scroll-view class="info-concept-hot-scroll" scroll-y="true">
 						<view class="info-concept-hot-scroll-container">
 							<view class="info-concept-hot-item" wx:for="{{noPlateList}}">
-								<AttentionPannel attentionItem="{{item}}" />
+								<AttentionPannel attentionItem="{{item}}" bindconceptItemClick="handleConceptItemClick" />
 							</view>
 						</view>
 					</scroll-view>

+ 6 - 1
pages/newsDetail/newsDetail.js

@@ -11,14 +11,19 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    wx.showLoading({
+      title: '加载中'
+    })
     console.log(options)
     this.setData({
       url:
         'https://fw.hx168.com.cn/zhapp/appWeb/api/servlet/InformationServlet?i_infocode=' +
         options.infocode +
-        '&i_info_type=4' +
+        '&i_info_type=' +
+        options.i_info_type +
         '&hiddendownload=1'
     })
+    wx.hideLoading()
     console.log(this.data.url)
   },
 

+ 66 - 0
pages/search/search.js

@@ -0,0 +1,66 @@
+// pages/search/search.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 3 - 0
pages/search/search.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 3 - 0
pages/search/search.wxml

@@ -0,0 +1,3 @@
+<view class="container">
+  <web-view src="https://m.hx168.com.cn/category/tjkc.html?channel=hcapp"></web-view>
+</view>

+ 1 - 0
pages/search/search.wxss

@@ -0,0 +1 @@
+/* pages/search/search.wxss */

+ 11 - 4
project.config.json

@@ -27,7 +27,7 @@
 			"outputPath": ""
 		},
 		"useIsolateContext": true,
-		"useCompilerModule": true,
+		"useCompilerModule": false,
 		"userConfirmedUseCompilerModuleSwitch": false
 	},
 	"compileType": "miniprogram",
@@ -50,11 +50,11 @@
 			"current": -1,
 			"list": []
 		},
-		"game": {
+		"plugin": {
 			"current": -1,
 			"list": []
 		},
-		"plugin": {
+		"game": {
 			"current": -1,
 			"list": []
 		},
@@ -64,7 +64,14 @@
 		},
 		"miniprogram": {
 			"current": -1,
-			"list": []
+			"list": [
+				{
+					"id": -1,
+					"name": "概念题材详情页",
+					"pathName": "pages/conceptPage/conceptPage",
+					"scene": null
+				}
+			]
 		}
 	}
 }

+ 29 - 0
service/conceptReq.js

@@ -0,0 +1,29 @@
+const HTTP = require('../utils/http')
+
+const http = new HTTP.HTTP()
+let conceptPage = 1
+
+let getConcept = function (index, callback) {
+  let params = {
+    funcNo: '3052066',
+    i_plate_id: index,
+    i_eno: '150030045146',
+    i_page: conceptPage,
+    i_perpage: '20'
+  }
+  http.request('GET', params, res => {
+    let result = res.data.results
+    console.log(result)
+    if (result) {
+      result.forEach((v, i) => {
+        v.showtime = v.showtime.substring(5, 16)
+      })
+    }
+    conceptPage = conceptPage + 1
+    callback(result)
+  })
+}
+
+module.exports = {
+  getConcept: getConcept
+}

+ 42 - 16
service/indexReq.js

@@ -37,16 +37,22 @@ let getAll = function (callback) {
     let result = res.data.results
     // 循环遍历结果数组,可以在请求拿到结果时进行,然后追加,此处可判断是否等于全局日期变量
     result.forEach((v, i) => {
+      console.log(v)
       // 处理返回的标签列表,即概念题材
       let tags = []
+      let tagIndex = []
       if (v.plateids) {
         v.plateids = v.plateids.split(';')
         v.plateids.forEach((v, i) => {
-          v = v.substring(9)
-          console.log(v)
-          tags = tags.concat(v)
+          let tagSplit = v.split(',')
+          console.log(tagSplit)
+          if (tags.length < 2) {
+            tags = tags.concat(tagSplit[1])
+            tagIndex = tagIndex.concat(tagSplit[0])
+          }
         })
         v.tags = tags
+        v.tagIndex = tagIndex
       }
       // 处理返回的大时间
       const newDate = v.showtime.substring(0, 10)
@@ -93,14 +99,19 @@ let getBigNews = function (callback) {
     result.forEach((v, i) => {
       // 处理返回的标签列表,即概念题材
       let tags = []
+      let tagIndex = []
       if (v.plateids) {
         v.plateids = v.plateids.split(';')
         v.plateids.forEach((v, i) => {
-          v = v.substring(9)
-          console.log(v)
-          tags = tags.concat(v)
+          let tagSplit = v.split(',')
+          console.log(tagSplit)
+          if (tags.length < 2) {
+            tags = tags.concat(tagSplit[1])
+            tagIndex = tagIndex.concat(tagSplit[0])
+          }
         })
         v.tags = tags
+        v.tagIndex = tagIndex
       }
       const newDate = v.showtime.substring(0, 10)
       if (newDate !== bigDate) {
@@ -146,14 +157,19 @@ let getChanges = function (callback) {
     result.forEach((v, i) => {
       // 处理返回的标签列表,即概念题材
       let tags = []
+      let tagIndex = []
       if (v.plateids) {
         v.plateids = v.plateids.split(';')
         v.plateids.forEach((v, i) => {
-          v = v.substring(9)
-          console.log(v)
-          tags = tags.concat(v)
+          let tagSplit = v.split(',')
+          console.log(tagSplit)
+          if (tags.length < 2) {
+            tags = tags.concat(tagSplit[1])
+            tagIndex = tagIndex.concat(tagSplit[0])
+          }
         })
         v.tags = tags
+        v.tagIndex = tagIndex
       }
       const newDate = v.showtime.substring(0, 10)
       if (newDate !== changeDate) {
@@ -199,14 +215,19 @@ let getGoodNews = function (callback) {
     result.forEach((v, i) => {
       // 处理返回的标签列表,即概念题材
       let tags = []
+      let tagIndex = []
       if (v.plateids) {
         v.plateids = v.plateids.split(';')
         v.plateids.forEach((v, i) => {
-          v = v.substring(9)
-          console.log(v)
-          tags = tags.concat(v)
+          let tagSplit = v.split(',')
+          console.log(tagSplit)
+          if (tags.length < 2) {
+            tags = tags.concat(tagSplit[1])
+            tagIndex = tagIndex.concat(tagSplit[0])
+          }
         })
         v.tags = tags
+        v.tagIndex = tagIndex
       }
       const newDate = v.showtime.substring(0, 10)
       if (newDate !== goodDate) {
@@ -253,14 +274,19 @@ let getNotice = function (callback) {
     result.forEach((v, i) => {
       // 处理返回的标签列表,即概念题材
       let tags = []
+      let tagIndex = []
       if (v.plateids) {
         v.plateids = v.plateids.split(';')
         v.plateids.forEach((v, i) => {
-          v = v.substring(9)
-          console.log(v)
-          tags = tags.concat(v)
+          let tagSplit = v.split(',')
+          console.log(tagSplit)
+          if (tags.length < 2) {
+            tags = tags.concat(tagSplit[1])
+            tagIndex = tagIndex.concat(tagSplit[0])
+          }
         })
         v.tags = tags
+        v.tagIndex = tagIndex
       }
       const newDate = v.showtime.substring(0, 10)
       if (newDate !== noticeDate) {
@@ -335,4 +361,4 @@ module.exports = {
   getImportantNews: getImportantNews,
   getNoPlatelist: getNoPlatelist,
   getNotice: getNotice
-}
+}