tanyanfei преди 4 години
родител
ревизия
4142ef7115

+ 2 - 2
pages/gameDetail/gameDetail.wxml

@@ -4,7 +4,7 @@
     <!-- <view><text>参赛名</text>{{datas.match.start_time}}</view> -->
     <!-- <view><text>参赛名</text>{{datas.match.start_time}}</view> -->
     <view><text>参赛组</text>{{datas.match.groups}}</view>
     <view><text>参赛组</text>{{datas.match.groups}}</view>
 </view>
 </view>
-<view class="part info">
+<view class="part info" wx:if='{{datas.today_record}}'>
     <view> <text>{{datas.today_record.rank}}</text>排名  </view>
     <view> <text>{{datas.today_record.rank}}</text>排名  </view>
     <view> <text style="color:#FF5151;">{{datas.today_record.today_income}}</text>盈亏  </view>
     <view> <text style="color:#FF5151;">{{datas.today_record.today_income}}</text>盈亏  </view>
     <view> <text>{{datas.today_record.init_fund}}</text>初始资产(万)  </view>
     <view> <text>{{datas.today_record.init_fund}}</text>初始资产(万)  </view>
@@ -12,7 +12,7 @@
 </view>
 </view>
 
 
 <view class="part">
 <view class="part">
-  <view class="container">
+  <view class="container" wx:if='{{datas.records.length>0}}'>
       <ec-canvas id="mychart-dom-line" canvas-id="mychart-line" ec="{{ ec }}">
       <ec-canvas id="mychart-dom-line" canvas-id="mychart-line" ec="{{ ec }}">
       </ec-canvas>
       </ec-canvas>
   </view>
   </view>

+ 17 - 15
pages/index/index.js

@@ -3,14 +3,6 @@ import * as echarts from '../../ec-canvas/echarts';
 const app = getApp();
 const app = getApp();
 var host = app.globalData.host;
 var host = app.globalData.host;
 Page({
 Page({
-  onShareAppMessage: function (res) {
-    return {
-      title: 'ECharts 可以在微信小程序中使用啦!',
-      path: '/pages/index/index',
-      success: function () { },
-      fail: function () { }
-    }
-  },
   data: {
   data: {
     ec: {
     ec: {
       onInit: initChart
       onInit: initChart
@@ -24,12 +16,19 @@ Page({
     wx.getStorage({
     wx.getStorage({
       key: 'userInfo',
       key: 'userInfo',
       success: res => {
       success: res => {
-        this.setData({
-          userInfo: res.data
-        })
-        this.getData();
+        if (res.data){
+          this.setData({
+            userInfo: res.data
+          })
+          this.getData();
+        }else{
+          wx.switchTab({
+            url: '../user/user',
+          })
+        }
       },
       },
       fail:error=>{
       fail:error=>{
+        
         //跳转到登陆页面
         //跳转到登陆页面
         wx.switchTab({
         wx.switchTab({
           url: '../user/user',
           url: '../user/user',
@@ -38,9 +37,13 @@ Page({
     })
     })
   },
   },
   onShow(){
   onShow(){
-    console.log(233)
+    
     if (!this.data.userInfo.token) {
     if (!this.data.userInfo.token) {
       this.onLoad()
       this.onLoad()
+    }else{
+      console.log(233)
+      wx.showNavigationBarLoading()
+      this.getData()
     }
     }
   },
   },
   getData(){
   getData(){
@@ -65,13 +68,12 @@ Page({
     })
     })
   },
   },
   onReady() {
   onReady() {
-  }
+  },
 });
 });
 
 
 
 
 /**折线图 */
 /**折线图 */
 function initChart(canvas, width, height, dpr) {
 function initChart(canvas, width, height, dpr) {
-  
   wx.getStorage({
   wx.getStorage({
     key: 'userInfo',
     key: 'userInfo',
     success: res => {
     success: res => {

+ 3 - 1
pages/index/index.wxml

@@ -5,11 +5,13 @@
     <image mode="widthFix" src="../images/bank.png"></image>
     <image mode="widthFix" src="../images/bank.png"></image>
     <view class="rank"> <text>{{datas.cur_rank?datas.cur_rank:''}}</text>当前排名 </view>  
     <view class="rank"> <text>{{datas.cur_rank?datas.cur_rank:''}}</text>当前排名 </view>  
   </view>
   </view>
-  <view class="container">
+  <view class="container"  wx:if='{{datas.records.length>0}}'>
     <ec-canvas id="mychart" canvas-id="mychart-line" ec="{{ ec }}">
     <ec-canvas id="mychart" canvas-id="mychart-line" ec="{{ ec }}">
     </ec-canvas>
     </ec-canvas>
   </view>
   </view>
+  
 </view>
 </view>
+<view style="text-align:center;padding:100px 0;" wx:if='{{datas.records.length==0}}'>暂无数据</view>
 <navigator  class="part part1" wx:for='{{datas.records}}' url="../detail/detail?id={{item.id}}"> 
 <navigator  class="part part1" wx:for='{{datas.records}}' url="../detail/detail?id={{item.id}}"> 
     <view class="item">
     <view class="item">
         <text class="tag">日期</text>{{item.stock_date}}
         <text class="tag">日期</text>{{item.stock_date}}

+ 43 - 1
pages/list/list.js

@@ -1,4 +1,6 @@
 // pages/list/list.js
 // pages/list/list.js
+const app = getApp();
+var host = app.globalData.host;
 Page({
 Page({
 
 
   /**
   /**
@@ -12,7 +14,47 @@ Page({
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
-
+    wx.showNavigationBarLoading()
+    /**获取token */
+    wx.getStorage({
+      key: 'userInfo',
+      success: res => {
+        this.setData({
+          userInfo: res.data
+        })
+        this.getData(options.id);
+      },
+      fail: error => {
+        //跳转到登陆页面
+        wx.switchTab({
+          url: '../user/user',
+        })
+      }
+    })
+  },
+  getData(id) {
+    wx.request({
+      url: host + '/api/wx/group/rank',
+      data: { id: id },
+      header: {
+        'Authorization': this.data.userInfo.token
+      },
+      success: res => {
+        this.setData({
+          datas: res.data.data
+        })
+        wx.setNavigationBarTitle({
+          title: res.data.data.group.name,
+        })
+        wx.hideNavigationBarLoading()
+      },
+      fail: error => {
+        //跳转到登陆页面
+        wx.switchTab({
+          url: '../user/user',
+        })
+      }
+    })
   },
   },
 
 
   /**
   /**

+ 1 - 1
pages/list/list.json

@@ -1,3 +1,3 @@
 {
 {
-  "navigationBarTitleText": "千万组"
+  "navigationBarTitleText": ""
 }
 }

+ 6 - 18
pages/list/list.wxml

@@ -3,24 +3,12 @@
     <text>今日资产</text><text>总盈亏</text>
     <text>今日资产</text><text>总盈亏</text>
 </view>
 </view>
 <view class="list">
 <view class="list">
-    <view class="item">
-        <image mode="widthFix" src="../images/1.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/2.png"></image>
-        <text class="name">北京炒家北京炒家北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/3.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
+    <view class="item" wx:for='{{datas.players}}'>
+        <image wx:if='{{index==0}}' mode="widthFix" src="../images/1.png"></image>
+        <image wx:if='{{index==1}}' mode="widthFix" src="../images/2.png"></image>
+        <image wx:if='{{index==2}}' mode="widthFix" src="../images/3.png"></image>
+        <text class="name">{{item.username}}</text>
+        <text>{{item.fund}}</text>
         <text>899w</text>
         <text>899w</text>
         <text class="red">35.87%</text>
         <text class="red">35.87%</text>
     </view>
     </view>

+ 63 - 6
pages/rank/rank.js

@@ -1,18 +1,77 @@
 // pages/rank/rank.js
 // pages/rank/rank.js
+const app = getApp();
+var host = app.globalData.host;
 Page({
 Page({
 
 
   /**
   /**
    * 页面的初始数据
    * 页面的初始数据
    */
    */
   data: {
   data: {
-
+    datas: {},
+    userInfo: {}
   },
   },
 
 
   /**
   /**
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
-  onLoad: function (options) {
-
+  onLoad() {
+    wx.showNavigationBarLoading()
+    /**获取token */
+    wx.getStorage({
+      key: 'userInfo',
+      success: res => {
+        if (res.data) {
+          this.setData({
+            userInfo: res.data
+          })
+          this.getData();
+        } else {
+          wx.switchTab({
+            url: '../user/user',
+          })
+        }
+      },
+      fail: error => {
+        //跳转到登陆页面
+        wx.switchTab({
+          url: '../user/user',
+        })
+      }
+    })
+  },
+  onShow() {
+
+    if (!this.data.userInfo.token) {
+      this.onLoad()
+    } else {
+      console.log(233)
+      wx.showNavigationBarLoading()
+      this.getData()
+    }
+  },
+  getData() {
+    wx.request({
+      url: host + '/api/wx/group/rank/list',
+      header: {
+        'Authorization': this.data.userInfo.token
+      },
+      success: res => {
+        console.log(res)
+        this.setData({
+          datas: res.data.data
+        })
+        wx.setNavigationBarTitle({
+          title: res.data.data.match.name,
+        })
+        wx.hideNavigationBarLoading()
+      },
+      fail: error => {
+        //跳转到登陆页面
+        wx.switchTab({
+          url: '../user/user',
+        })
+      }
+    })
   },
   },
 
 
   /**
   /**
@@ -25,9 +84,7 @@ Page({
   /**
   /**
    * 生命周期函数--监听页面显示
    * 生命周期函数--监听页面显示
    */
    */
-  onShow: function () {
-
-  },
+  
 
 
   /**
   /**
    * 生命周期函数--监听页面隐藏
    * 生命周期函数--监听页面隐藏

+ 1 - 1
pages/rank/rank.json

@@ -1,3 +1,3 @@
 {
 {
-  "navigationBarTitleText": "第42届湖南顽主杯实盘大赛"
+  "navigationBarTitleText": ""
 }
 }

+ 10 - 81
pages/rank/rank.wxml

@@ -3,93 +3,22 @@
     <text>排名</text><text>选手</text><text>初始资产</text>
     <text>排名</text><text>选手</text><text>初始资产</text>
     <text>今日资产</text><text>总盈亏</text>
     <text>今日资产</text><text>总盈亏</text>
 </view>
 </view>
-<view class="list">
+<view class="list" wx:for="{{datas.groups}}">
     <view class="title">
     <view class="title">
-        千万组
-        <navigator url="../list/list">
+        {{item.name}}
+        <navigator url="../list/list?id={{item.id}}">
           查看更多  <image mode="widthFix" src="../images/right_icon.png"></image>
           查看更多  <image mode="widthFix" src="../images/right_icon.png"></image>
         </navigator>
         </navigator>
     </view> 
     </view> 
-    <view class="item">
-        <image mode="widthFix" src="../images/1.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/2.png"></image>
-        <text class="name">北京炒家北京炒家北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/3.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
+    <view class="item" wx:for='{{item.players}}' 
+    wx:for-index='i' wx:for-item='player'>
+        <image wx:if='{{i==0}}' mode="widthFix" src="../images/1.png"></image>
+        <image wx:if='{{i==1}}' mode="widthFix" src="../images/2.png"></image>
+        <image wx:if='{{i==2}}' mode="widthFix" src="../images/3.png"></image>
+        <text class="name">{{player.username}}</text>
+        <text>{{player.fund}}</text>
         <text>899w</text>
         <text>899w</text>
         <text class="red">35.87%</text>
         <text class="red">35.87%</text>
     </view>
     </view>
 </view>
 </view>
 
 
-<view class="list">
-    <view class="title">
-        百万组
-        <navigator url="../list/list">
-          查看更多  <image mode="widthFix" src="../images/right_icon.png"></image>
-        </navigator>
-    </view> 
-    <view class="item">
-        <image mode="widthFix" src="../images/1.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/2.png"></image>
-        <text class="name">北京炒家北京炒家北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/3.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-</view>
-
-
-<view class="list">
-    <view class="title">
-        十万组
-        <navigator url="../list/list">
-          查看更多  <image mode="widthFix" src="../images/right_icon.png"></image>
-        </navigator>
-    </view> 
-    <view class="item">
-        <image mode="widthFix" src="../images/1.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/2.png"></image>
-        <text class="name">北京炒家北京炒家北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-    <view class="item">
-        <image mode="widthFix" src="../images/3.png"></image>
-        <text class="name">北京炒家</text>
-        <text>1232w</text>
-        <text>899w</text>
-        <text class="red">35.87%</text>
-    </view>
-</view>

+ 10 - 4
pages/upload/upload.js

@@ -32,10 +32,16 @@ Page({
     wx.getStorage({
     wx.getStorage({
       key: 'userInfo',
       key: 'userInfo',
       success: res => {
       success: res => {
-        this.setData({
-          userInfo: res.data
-        })
-        this.getData();
+        if (res.data) {
+          this.setData({
+            userInfo: res.data
+          })
+          this.getData();
+        } else {
+          wx.switchTab({
+            url: '../user/user',
+          })
+        }
       },
       },
       fail:error=>{
       fail:error=>{
         wx.switchTab({
         wx.switchTab({

+ 2 - 2
pages/upload/upload.wxml

@@ -15,7 +15,7 @@
       <text>w</text>
       <text>w</text>
       <view bindtap="add" wx:if='{{index==stock.length-1}}' class="add">添加持股</view>
       <view bindtap="add" wx:if='{{index==stock.length-1}}' class="add">添加持股</view>
       <view   wx:else style="width:28%;">
       <view   wx:else style="width:28%;">
-        <icon bindtap="del" data-id='{{index}}' style="margin-top:20rpx;" class="icon-small" type="cancel" size="23"></icon>
+        <icon bindtap="del" data-id='{{index}}' style="margin-top:20rpx;" class="icon-small" type="cancel" size="25"></icon>
       </view>
       </view>
     </view>
     </view>
     <view class="openmarket">  
     <view class="openmarket">  
@@ -25,7 +25,7 @@
     <view class="label">账户截图</view>
     <view class="label">账户截图</view>
     <view wx:for='{{today_stock_img}}'>
     <view wx:for='{{today_stock_img}}'>
         <image style="width:220rpx;" mode="widthFix" src="{{item}}"></image>
         <image style="width:220rpx;" mode="widthFix" src="{{item}}"></image>
-        <icon bindtap="del1" data-id='{{index}}' class="icon-small" type="cancel" size="23"></icon>
+        <icon bindtap="del1" data-id='{{index}}' class="icon-small" type="cancel" size="25"></icon>
     </view>
     </view>
     <image bindtap="upload" class="upload" mode="widthFix" src="../images/upload.png"></image>
     <image bindtap="upload" class="upload" mode="widthFix" src="../images/upload.png"></image>
     <view class="tips">
     <view class="tips">

+ 1 - 1
pages/upload/upload.wxss

@@ -84,4 +84,4 @@ form button:not([size='mini']){
 }
 }
 .upload{
 .upload{
   width: 220rpx;
   width: 220rpx;
-}
+}

+ 18 - 7
pages/user/user.js

@@ -20,10 +20,12 @@ Page({
       wx.getStorage({
       wx.getStorage({
         key: 'userInfo',
         key: 'userInfo',
         success:res=>{
         success:res=>{
-          this.setData({
-            userInfo:res.data
-          })
-          this.getUserData();
+          if (res.data){
+            this.setData({
+              userInfo: res.data
+            })
+            this.getUserData();
+          }
         }
         }
       })
       })
   },
   },
@@ -89,8 +91,16 @@ Page({
                   data: data,
                   data: data,
                   success(res){
                   success(res){
                       //登陆成功
                       //登陆成功
-                      wx.hideLoading();
-                    console.log(res.data.data)
+                    console.log(res)
+                    wx.hideLoading();
+                    if(res.data.code != 0){
+                      wx.showToast({
+                        icon: 'none',
+                        title: res.data.message,
+                      })
+                      return;
+                    }
+                      
                       _this.setData({
                       _this.setData({
                         userInfo : res.data.data
                         userInfo : res.data.data
                       })
                       })
@@ -99,7 +109,8 @@ Page({
                         data: res.data.data,
                         data: res.data.data,
                       })
                       })
                   },
                   },
-                  fail(){
+                  fail(error){
+                    console.log(error)
                     wx.hideLoading();
                     wx.hideLoading();
                   }
                   }
                 })
                 })

+ 1 - 1
pages/user/user.wxml

@@ -1,5 +1,5 @@
 <view class="bg">
 <view class="bg">
-    <image style="width:100%;" mode="widthFix" src="../images/my_bg.png"></image>
+    <image style="width:100%;height:15vh;" mode="scaleToFill" src="../images/my_bg.png"></image>
       <view class="info">
       <view class="info">
         <view class='avatar'>
         <view class='avatar'>
             <open-data  type="userAvatarUrl"></open-data>
             <open-data  type="userAvatarUrl"></open-data>