zjh 5 سال پیش
والد
کامیت
42af1c2be7
2فایلهای تغییر یافته به همراه37 افزوده شده و 14 حذف شده
  1. 36 13
      pages/item/item.js
  2. 1 1
      pages/item/item.wxml

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