Forráskód Böngészése

Merge branch 'master' of ssh://192.168.1.202:8088/lx/shares

lx 5 éve
szülő
commit
25b580664a

+ 6 - 0
api/request.js

@@ -70,6 +70,12 @@ module.exports = {
     return new Promise((resolve,reject) =>{
       resolve(service.get(urls.hotSearch,data))
     })
+  },
+  // 个人关注
+  followList:(data)=>{
+    return new Promise((resolve,reject)=>{
+      resolve(service.post(urls.followList,data))
+    })
   }
 
 }

+ 2 - 1
api/urls.js

@@ -5,6 +5,7 @@ const urls ={
     newsList:host + '/api/news/list',
     detail:host +'/api/news/details',
     search: host + '/api/news/search',
-    hotSearch: host + '/api/news/search/hot'
+    hotSearch: host + '/api/news/search/hot',
+    followList:host +  '/api/follow/list'
 }
 module.exports = urls;

+ 30 - 30
pages/attention/attention.js

@@ -1,4 +1,6 @@
 import * as echarts from '../../ec-canvas/echarts';
+// var Api = require('../../api/urls.js');
+var wxRequest = require('../../api/request.js') 
 
 var app = getApp()
 function initChart(canvas, width, height, dpr, data) {
@@ -48,7 +50,6 @@ function initChart(canvas, width, height, dpr, data) {
 }
 
 Page({
-
   data: {
     // 页面配置  
     winWidth: 0,
@@ -58,35 +59,7 @@ Page({
     ec: {
       onInit: initChart
     },
-    array:[
-      {
-        title:'BK0422',
-        subtitle:"交运物流",
-        Increase:"+1.22",
-        digital:"33",
-        color:'crimson',
-        data:[52,56,355,444],
-        keep:'已关注'
-      },
-      {
-        title:'BK0738',
-        subtitle:"多元金融",
-        Increase:"+1.22",
-        digital:"33",
-        color:'crimson',
-        data:[52,56,355,444],
-        keep:'已关注'
-      },
-      {
-        title:'BK0450',
-        subtitle:"港口水运",
-        Increase:"+1.22",
-        digital:"33",
-        color:'crimson',
-        data:[52,56,355,444,52,56,355,444,52,56,355,444,2],
-        keep:'已关注'
-      }
-    ],
+    array:[],
 
   },
   onLoad: function() {
@@ -100,6 +73,33 @@ Page({
         });
       }
     });
+    // 获取关注的信息
+    var userId={
+      // userId:wx.getStorageSync('openid')
+      userId:'ocVI541TGfnTChi5DlIa7beac2YM'
+    }
+    console.log(userId);
+    this.getFollow(userId);
+
+  },
+  getFollow:function(userId){
+    var that = this;
+    wxRequest.followList(userId).then((res)=>{
+      console.log(res);
+      console.log(res.data.data);     
+      if(res.statusCode==200){
+        that.setData({
+         array:res.data.data
+        })
+         console.log(that.data.array);
+       }else{
+        wx.showToast({
+          title: '125',
+          icon: 'none'
+        })
+      }
+    
+    })
   },
   open: function (e) {
     console.log(e)

+ 4 - 3
pages/attention/attention.wxml

@@ -4,12 +4,13 @@
         <scroll-view scroll-y style="height: 100%;">
           <view wx:for="{{array}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row="{{item}}">
             <view class="swiper-box-left">
-              <view>{{item.title}}</view>
-              <view class="swiper-box-subtitle">{{item.subtitle}}</view>
+              <view>{{item.industryName}}</view>
+              <!-- <view class="swiper-box-subtitle">{{item.subtitle}}</view> -->
             </view>
             <view class="swiper-box-right">
               <view class="swiper-box-button">
-                <button class="mini-btn" type="warn" size="mini">{{item.Increase}}</button>
+                <button class="mini-btn" type="warn" size="mini" wx:if="{{item.industryTag===true}}">+{{item.industryValue}}%</button>
+                <button wx:else class="mini-btn" type="warn" style="background:#07c160;" size="mini">-{{item.industryValue}}%</button>
               </view>
             </view>
           </view>

+ 24 - 51
pages/attention/attention.wxss

@@ -1,24 +1,3 @@
-page {
-  background: #000;
-}  
-.swiper-tab {
-  width: 100%;
-  text-align: center;
-  line-height: 80rpx;
-}
-
-.swiper-tab-list {
-  font-size: 30rpx;
-  display: inline-block;
-  width: 30%;
-  color: #777;
-}
-
-.on {
-  color: #D81E06;
-  border-bottom: 5rpx solid #D81E06;
-}
-
 .swiper-box {
   display: block;
   height: 100%;
@@ -26,34 +5,28 @@ page {
   overflow: hidden;
   color: #fff;
 }
-
-.swiper-box .swiper-box-view {
- display: flex;
- justify-content: space-between;
- align-items: center;
+.swiper-box-view {
+  display: flex;
+  justify-content: space-between ;
+  align-items: center;
   margin: 10rpx;
- border-bottom: 1rpx slategray solid;
-}
-ec-canvas {
-  width: 100%;
-  height: 100%;
-
-  }
-  .swiper-box .swiper-box-view .swiper-box-left .swiper-box-subtitle{
-    color: slategray;
-  }
-  .swiper-box .swiper-box-view .swiper-box-right{
-    display: flex;
-    align-items: center;
-  }
-.swiper-box .swiper-box-view .swiper-box-right .swiper-box-canvas {
-  height: 120rpx;
-  width: 300rpx;
-}
-.swiper-box .swiper-box-view .swiper-box-right .swiper-box-button{
-  text-align: right;
-}
-.swiper-box .swiper-box-view .swiper-box-right .swiper-box-button button{
-  color: #fff;
-  background: #D81E06;
-}
+  border-bottom: 1rpx slategray solid;
+ }
+   .swiper-box-view .swiper-box-left .swiper-box-subtitle{
+     color: slategray;
+   }
+  .swiper-box-view .swiper-box-right{
+     display: flex;
+     align-items: center;
+   }
+  .swiper-box-view .swiper-box-right .swiper-box-canvas {
+   height: 120rpx;
+   width: 300rpx;
+ }
+  .swiper-box-view .swiper-box-right .swiper-box-button{
+   text-align: right;
+ }
+  .swiper-box-view .swiper-box-right .swiper-box-button button{
+   color: #fff;
+   background: #D81E06;
+ }

+ 36 - 13
pages/item/item.js

@@ -22,7 +22,7 @@ function initChart(canvas, width, height, dpr, data) {
     devicePixelRatio: dpr // new
   });
   canvas.setChart(chart);
-   console.log(data)
+
   var option ={
     title: {//标题
       text: '',
@@ -288,7 +288,7 @@ Page({
         winHeight: 0,
         // tab切换 
         currentTab: 0,
-      button:"关注",
+        follow:"关注",
           ec: {
       // onInit: initChart
     },
@@ -365,9 +365,7 @@ Page({
     }else{
       Values=JSON.parse(options.row).industryValue.toFixed(2)+"%"
       colors="#07c160"
-
     }
-    console.log(app.globalData.userInfo)
     this.setData({
    [Name]:JSON.parse(options.row).industryName,
    [plateId]:JSON.parse(options.row).industryId,
@@ -376,32 +374,52 @@ Page({
     })
   that.posthisfind(JSON.parse(options.row).industryId,)
   that.postpredfind(JSON.parse(options.row).industryId,)
-  that.postfollow()
+
   },
   postfollow:function(){
     var that = this;
-     console.log(app.globalData.userInfo)
+
     var data={
       plateId: this.data.object.plateId,
       plateName: this.data.object.Name,
       userId: wx.getStorageSync('openid'),
       userName: app.globalData.userInfo.nickName,
     }
-    console.log(data)
+  
     var postfollow = wxRequest.postRequest(Api.postfollow(),data);
+    postfollow.then((res)=>{
+   
+      if(res.statusCode==200){
+        that.setData({
+          follow:res.data.data==1? "已关注":"关注"
+         })
+        wx.showToast({
+          title: res.data.message,
+          icon: 'success',
+          duration: 2000
+        })
+      }
+      
+    })
   },
     //获取数据
     posthisfind:function(row){
       // console.log(row)
       var that = this;
-      var postbyiid = wxRequest.postRequest(Api.posthisfind(),[row]);
+      var data=[{
+          plateId: row,
+		       userId: wx.getStorageSync('openid')
+        }
+      ]
+      var postbyiid = wxRequest.postRequest(Api.posthisfind(),data);
       postbyiid.then((res)=>{
-        console.log(res)
+       console.log(res)
         // console.log(that.recursion(res.data))
         if(res.statusCode==200){
           that.setData({
            realchartData:that.recursion(res.data.data),
            newsData:res.data.data.news,
+           follow:res.data.data.isFollowed ? "已关注":"关注"
           })
           initChart(real.detail.canvas, real.detail.width, real.detail.height,real.detail.dpr,that.recursion(res.data.data));
         }
@@ -409,21 +427,26 @@ Page({
       })
     },
     echartInit(e) {
-      console.log(e);
+     
       real=e
       // initChart(e.detail.canvas, e.detail.width, e.detail.height,e.detail.dpr,e.target.dataset.record);
    },
    echartInitunder(e){
-    console.log(e);
+
     under=e
     // initChart(e.detail.canvas, e.detail.width, e.detail.height,e.detail.dpr,e.target.dataset.record);
    },
       //获取下周预测数据
       postpredfind:function(row){
         var that = this;
-        var postbyiid = wxRequest.postRequest(Api.postpredfind(),[row]);
+        var data=[ {
+            plateId: row,
+             userId: wx.getStorageSync('openid')
+          }
+        ]
+        var postbyiid = wxRequest.postRequest(Api.postpredfind(),data);
         postbyiid.then((res)=>{
-          console.log(res)
+      
           if(res.statusCode==200){
             that.setData({
               nextchartData:that.recursion(res.data.data),

+ 1 - 1
pages/item/item.wxml

@@ -1,6 +1,6 @@
 <view class="title">
  <view class="title-button">
-  <button type="default" size="mini">{{button}}</button>
+  <button type="default" size="mini" bindtap="postfollow">{{follow}}</button>
  </view>
  <view class="title-name">
    <text class="title-name-Big">{{object.Name}}</text>