tanyanfei 1 rok temu
rodzic
commit
6fdc945a9d

+ 1 - 0
app.json

@@ -10,6 +10,7 @@
     "pages/black/black",
     "pages/myfollow/myfollow",
     "pages/todayExp/todayExp",
+    "pages/nrcomments/nrcomments",
     "pages/user/user",
     "pages/choice/choice",
     "pages/hotuser/hotuser",

+ 1 - 1
pages/index/index.wxml

@@ -10,7 +10,7 @@
   </view> -->
 
 <view class="list-top">
-    <navigator url="../stock/stock?type=1">
+    <navigator url="../stock/stock?type=1&stock_date={{date}}">
       <image mode="widthFix" src="../../xiao/rmgp@2x.png"></image>
       热门股票
     </navigator>

+ 99 - 0
pages/nrcomments/nrcomments.js

@@ -0,0 +1,99 @@
+// pages/hotuser/hotuser.js
+const $api = require('../../utils/api.js').API;
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    list:[],
+    total:0,
+    page:1,
+    date:''
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    $api.getDate().then(res=>{
+      this.setData({
+        date:res.data.data
+      })
+      this.getData()
+    })
+    
+  },
+
+  getData:function(){
+    wx.showNavigationBarLoading()
+    var list = this.data.list
+    $api.getNbcomments({date:this.data.date,page:this.data.page,page_size:20}).then(res=>{
+      wx.hideNavigationBarLoading()
+      res.data.data.list.forEach(item => {
+        list.push(item)
+      })
+      this.setData({
+        list: list,
+        total: res.data.data.total
+      })
+    })
+  },
+  next: function () {
+    if (this.data.list.length < this.data.total) {
+      const page = this.data.page + 1
+      this.setData({
+        page: page
+      })
+      this.getData()
+    }
+  },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
pages/nrcomments/nrcomments.json

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

+ 14 - 0
pages/nrcomments/nrcomments.wxml

@@ -0,0 +1,14 @@
+<wxs module="filters" src="../../utils/toFixed.wxs" />
+<scroll-view  scroll-y='{{true}}'  bindscrolltolower='next'>
+  <view class="list"  wx:for="{{list}}">
+    <image style="width: 100%;" mode="withFix" src="{{item.img}}"></image>
+    <view class="stock_name">{{item.stock_name}} 
+      <text>{{item.stock_code}}</text>
+    </view>
+    <view class="desc">{{item.content}}</view>
+    <view class="nr">{{filters.getDate(item.ctime)}}</view>
+  </view>
+  <block wx:if='{{total >= 20}}'>
+        <view class='loading' wx:if='{{list.length < total}}'>上拉加载更多...</view>
+  </block>
+</scroll-view>

+ 29 - 0
pages/nrcomments/nrcomments.wxss

@@ -0,0 +1,29 @@
+/* pages/nrcomments/nrcomments.wxss */
+scroll-view{
+  height: 100vh;
+}
+.list{
+  padding: 20rpx;
+  margin-bottom: 20rpx;
+}
+.nr{
+  font-size: 26rpx;
+  text-align: right;
+  color: #333;
+}
+.desc{
+  font-size: 28rpx;
+  line-height: 40rpx;
+  margin: 30rpx 0;
+}
+.stock_name{
+  /* line-height: 100rpx; */
+  font-size: 32rpx;
+  margin-top: 20rpx;
+  font-weight: 500;
+}
+.stock_name text{
+  font-weight: 400;
+  font-size: 28rpx;
+  padding: 5rpx 10rpx;
+}

+ 53 - 23
pages/stock/stock.js

@@ -16,16 +16,18 @@ Page({
     text:'我要解读',
     comment:'',
     list:[],
+    page1:1,
+    total1:0,
     myList:[],
-    searchList:[]
+    searchList:[],
+    nbComments:[],
+    todaynb:0
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    // options.type=1
-    options.stock_date='2023-07-21'
     this.setData({
       type:options.type,
       stock_date:options.stock_date
@@ -37,7 +39,13 @@ Page({
       })
     })
     if (options.id){
-      this.setData({id:options.id})
+      //详情
+      this.setData({
+        id:options.id,
+        list:[],
+        page1:1,
+        total1:0
+      })
       this.getComment()
       this.getMylist()
       $api.getAuthinfo().then(res=>{
@@ -45,30 +53,52 @@ Page({
           role: res.data.data.role
         })
       })
-      if(options.type == 2){
-        $api.getSellStock({ id: options.id, stock_date: this.data.stock_date }).then(res => {
-          this.setData({
-            info: res.data.data
-          })
-          wx.setNavigationBarTitle({
-            title: res.data.data.name,
-          })
+      $api.getStock({ id: options.id, stock_date: this.data.stock_date }).then(res => {
+        this.setData({
+          info: res.data.data
         })
-      }else{
-        $api.getStock({ id: options.id, stock_date: this.data.stock_date }).then(res => {
-          this.setData({
-            info: res.data.data
-          })
-          wx.setNavigationBarTitle({
-            title: res.data.data.name,
-          })
+        wx.setNavigationBarTitle({
+          title: res.data.data.name,
         })
-      }
+      })
+      $api.getStockNbcomments({stock_id:options.id,date:this.data.stock_date}).then(res=>{
+        this.setData({
+          nbComments:res.data.data.list
+        })
+      })
+      this.getPlarer()
     }else{
       this.getData()
-      
+      $api.getNbcomments({date:this.data.stock_date}).then(res=>{
+        this.setData({
+          todaynb:res.data.data.total
+        })
+      })
     } 
   },
+  //获取今日持仓
+  getPlarer(){
+    var list = this.data.list
+    $api.getStockPlayer({ id: this.data.id, stock_date: this.data.stock_date,page:this.data.page1 }).then(res=>{
+      wx.hideNavigationBarLoading()
+      res.data.data.list.forEach(item => {
+        list.push(item)
+      })
+      this.setData({
+        list: list,
+        total1: res.data.data.total
+      })
+    })
+  },
+  next1: function () {
+    if (this.data.cur==1 && this.data.list.length < this.data.total1) {
+      const page = this.data.page1 + 1
+      this.setData({
+        page1: page
+      })
+      this.getPlarer()
+    }
+  },
   bindDateChange(e){
     this.setData({
       stock_date:e.detail.value,
@@ -230,7 +260,7 @@ Page({
         }
         
       })
-    
+      
     
   },
 

+ 23 - 27
pages/stock/stock.wxml

@@ -1,27 +1,21 @@
 <wxs module="filters" src="../../utils/toFixed.wxs" />
-
-
-
-
-
-
-
-
-
-
 <view wx:if="{{type==1}}">
   <view wx:if='{{id}}' class="detail">
     <view class="stock_name">{{info.name}} 
     <text>{{info.code}}</text>
     </view>
-    <image wx:if='{{info.img}}' mode="withFix" src="{{info.img}}"></image>
-    <view wx:if='{{info.desc}}' class="desc">{{info.desc}}</view>
+    <block wx:if='{{info.last_nb_comments}}'>
+      <image mode="withFix" src="{{info.last_nb_comments.img}}"></image>
+      <view class="desc">{{info.last_nb_comments.content}}</view>
+      <view class="nr">@牛人点评 {{filters.getDate(info.last_nb_comments.ctime)}}</view>
+    </block>
     <view class="tab">
         <view bindtap="tab"   data-id='1' class="{{cur==1?'act':''}}">今日持仓<text></text></view>
         <view bindtap="tab" data-id='0' class="{{cur==0?'act':''}}">我要解读<text></text></view>
+        <view bindtap="tab" data-id='2' class="{{cur==2?'act':''}}">牛人点评<text></text></view>
     </view>
-    <scroll-view bindtap="blur"  scroll-y='{{true}}' style="height:calc(100vh - 380rpx);background: #fff;padding: 30rpx;">
-      <view class="content" wx:if='{{cur==0}}'>
+    <view bindtap="blur" style="background: #fff;padding: 30rpx 30rpx 180rpx;">
+        <view class="content" wx:if='{{cur==0}}'>
           <view class="_list" wx:for="{{comment_list}}">
             <navigator url="../homepage/homepage?user_id={{item.user_id}}"><image src="{{item.user_avatar}}" ></image></navigator>
               <view class="msg">
@@ -40,8 +34,8 @@
               </view>
           </view>
         </view>
-        <view wx:if='{{cur==1}}'>
-          <navigator hover-class="none" class="player" wx:for='{{info.list}}' url="../today/today?id={{item.match_id}}&user_id={{item.user_id}}">
+        <scroll-view wx:if='{{cur==1}}' bindscrolltolower='next1' scroll-y='{{true}}' style="height:calc(100vh - 90rpx);">
+            <navigator hover-class="none" class="player" wx:for='{{list}}' url="../today/today?id={{item.match_id}}&user_id={{item.user_id}}">
               <view class="name">{{item.username}}  <text>{{item.badge}}</text> 
               </view> 
               <view class="info">
@@ -57,18 +51,19 @@
                               <view wx:else>空仓</view>
               </view>
             </navigator>
-        </view>
+            <block wx:if='{{total1 >= 20}}'>
+                <view class='loading' wx:if='{{list.length < total1}}'>加载更多...</view>
+            </block>
+        </scroll-view>
         <view wx:if='{{cur==2}}'>
-          <navigator hover-class="none"  class="_list" wx:for="{{myList}}" url="../homepage/homepage?id={{item.match_id}}&user_id={{item.user_id}}">
-            <image src="{{item.user_avatar}}" ></image>
-              <view class="msg">
-                  <text class="_name" style="line-height:60rpx;">{{item.user_name}}</text>
-              </view>
-          </navigator>
+          <view wx:for="{{nbComments}}" style="margin-bottom: 20rpx;">
+            <image style="width: 100%;" mode="withFix" src="{{item.img}}"></image>
+            <view class="desc">{{item.content}}</view>
+            <view class="nr">{{filters.getDate(item.ctime)}}</view>
+          </view>
         </view>
-    </scroll-view>
-
-    <view class="post">
+    </view>
+    <view  class="post">
         <input value="{{comment}}" confirm-type='send' bindconfirm='sendmsg' placeholder-style="color:#999" maxlength="500" bindinput="inputchange1" focus='{{focus}}' type="text" placeholder="{{text}}"/>
         <!-- <button bindtap="sendmsg">提交</button> -->
     </view>
@@ -87,7 +82,8 @@
       </view>
     </view>
     <scroll-view  scroll-y='{{true}}' bindscrolltolower='next' style="background: #fff;padding:0 30rpx;">
-        <navigator hover-class="none" class="list" url="../stock/stock?id={{item.id}}&&date={{stock_date}}&type=1" wx:for='{{list}}'>
+        <navigator wx:if='{{todaynb>0}}' url="../nrcomments/nrcomments" class="nbcomment">今日牛人点评</navigator>
+        <navigator hover-class="none" class="list" url="../stock/stock?id={{item.id}}&&stock_date={{stock_date}}&type=1" wx:for='{{list}}'>
           <image wx:if="{{index<3}}" class="number" mode="widthFix" src="../../xiao/{{index+1}}.png"></image>
           <text wx:else class="number">{{index+1}}</text>
           <view class="stock-name">

+ 16 - 3
pages/stock/stock.wxss

@@ -1,7 +1,7 @@
 /* pages/stock/stock.wxss */
 page{
   /* padding: 30rpx; */
-  background-color: #F7F7F7;
+  background-color: #fff;
 }
 .top_bg {
   position: relative;
@@ -20,6 +20,13 @@ page{
   font-size: 46rpx;
   font-weight: 600;
 }
+.nbcomment{
+  text-align: center;
+  padding: 20rpx 0;
+  text-decoration: underline;
+  color: red;
+  font-size: 32rpx;
+}
 .search-img{
   width: 40rpx;
   position: absolute;
@@ -55,9 +62,15 @@ page{
 image.number{
   margin-top: 10rpx;
 }
+.nr{
+  padding: 0 30rpx;
+  font-size: 26rpx;
+  text-align: right;
+  color: #333;
+}
 .desc{
-  font-size: 30rpx;
-  line-height: 48rpx;
+  font-size: 28rpx;
+  line-height: 40rpx;
   margin: 30rpx 0;
   padding: 0 30rpx;
 }

+ 4 - 1
utils/api.js

@@ -137,7 +137,8 @@ const API = {
   getRecord: (data) => request(GET, `/api/wx/player/record`, data),
   getCurrecord: (data) => request(GET, `/api/wx/player/currecord`, data),
   getArticle: (data) => request(GET, `/api/wx/article`, data),
-  getStock: (data) => request(GET, `/api/wx/v2/stock`, data),
+  getStock: (data) => request(GET, `/api/wx/v3/stock`, data),
+  getStockPlayer: (data) => request(GET, `/api/wx/v3/stock/players/list`, data),
   searchStock: (data) => request(GET, `/api/wx/stock/search`, data),
   getNotoice: (data) => request(GET, `/api/wx/v2/notices/list`, data),
   getDate: (data) => request(GET, `/api/wx/v2/default/date`, data),
@@ -169,6 +170,8 @@ const API = {
   getBlacklist: (data) => request(GET, `/api/wx/v3/user/black/list`, data),
   cancelBlack: (data) => request(DELETE, `/api/wx/v3/user/black`, data),
   blackUser: (data) => request(POST, `/api/wx/v3/user/black`, data),
+  getNbcomments: (data) => request(GET, `/api/wx/v3/stock/nbcomments/list`, data),
+  getStockNbcomments: (data) => request(GET, `/api/wx/v3/stock/comments/list`, data),
   
 }; 
 module.exports = {

+ 5 - 1
utils/toFixed.wxs

@@ -1,4 +1,7 @@
 var filters = {
+  getDate: function (value) {
+    return value.split(' ')[0]
+  },
   toFix2: function (value) {
     return parseFloat(value).toFixed(2)//此处2为保留两位小数
   },
@@ -20,5 +23,6 @@ var filters = {
 module.exports = {
   toFix2: filters.toFix2,
   defaultImg:filters.defaultImg,
-  getColor:filters.getColor
+  getColor:filters.getColor,
+  getDate:filters.getDate
 }