Browse Source

关注详情信息,id是默认的

xuxh 5 years ago
parent
commit
1976894625
5 changed files with 66 additions and 85 deletions
  1. 6 0
      api/request.js
  2. 2 1
      api/urls.js
  3. 30 30
      pages/attention/attention.js
  4. 4 3
      pages/attention/attention.wxml
  5. 24 51
      pages/attention/attention.wxss

+ 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;
+ }