tanyanfei 2 vuotta sitten
vanhempi
commit
6bf4033c1e

+ 2 - 2
app.json

@@ -1,6 +1,6 @@
 {
 "pages": [
-  
+ 
   "pages/index/index",
   "pages/rank/rank",
   "pages/upload/upload",
@@ -13,7 +13,7 @@
   "pages/stock/stock",
     "pages/apply/apply",
     
-    
+    "pages/login/user",
     
     
     

+ 1 - 1
pages/day/day.wxml

@@ -1,6 +1,6 @@
 <scroll-view scroll-y='{{true}}' bindscrolltolower='next'>
   <view class="stock" wx:for='{{list}}'>
-  <navigator hover-class="none" url="../record/record?id={{item.id}}" >
+  <navigator hover-class="none" url='../today/today?id={{item.match_id}}&record_id={{item.id}}&player_id={{player_id}}' >
     <view class="info">
       <view>{{item.stock_date}}(今日收益 <text  class="{{item.today_income[0]=='-' ?'down':'up'}}">{{item.today_income}}</text>)</view>
     </view>

+ 1 - 1
pages/homepage/homepage.js

@@ -109,7 +109,7 @@ Page({
         player_id: res.data.data.today_record.player_id,
         followers:res.data.data.followers,
         fans:res.data.data.fans,
-        id: res.data.data.match.id,
+        // id: res.data.data.match.id,
         ec: {
           onInit: initChart
         },

+ 1 - 1
pages/homepage/homepage.wxml

@@ -100,7 +100,7 @@
   <view class="title">每日持股
   </view>
   <view  class="stock" wx:for='{{stockList}}' wx:if="{{index<3}}">
-    <navigator hover-class="none">
+    <navigator hover-class="none" url='../today/today?id={{item.match_id}}&record_id={{item.id}}&player_id={{player_id}}'>
       <view class="info">
         <view class="date">{{item.stock_date}}(今日收益 <text  class="{{item.today_income[0]=='-' ?'down':'up'}}">{{item.today_income}}</text>)</view>
       </view>

+ 2 - 2
pages/index/index.js

@@ -302,8 +302,8 @@ Page({
     //判断是否报名
     $api.getAuthinfo().then(res=>{
       if(res.data.data.phone == null || res.data.data.phone==''){
-        wx.switchTab({
-          url: '../user/user',
+        wx.navigateTo({
+          url: '../login/user',
         })
       }
     

+ 324 - 0
pages/login/user.js

@@ -0,0 +1,324 @@
+// pages/user/user.js
+const app = getApp()
+var host = app.globalData.host;
+const $api = require('../../utils/api.js').API;
+var logindata={}
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    usercode: '',
+    phone:'',
+    phcode:'',
+    openid: '',
+    info: {},
+    userinfo:{},
+    todayinfo:{},
+    todayMoney:'',
+    status:0,
+    text:'获取验证码'
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    
+  },
+  zx(){
+    wx.navigateTo({
+      url: '../message/message',
+    })
+  },
+  getcode(){
+    if(this.data.phone.length>=11){
+      $api.sendcode({phone:this.data.phone}).then(res=>{
+        this.countdown()
+      })
+    }else{
+      wx.showToast({
+        icon: 'none',
+        title: '请输入正确的手机号',
+      })
+    }
+    
+  },
+  countdown(){
+    var count=60,_this=this;
+    var timer=setInterval(c,1000)
+    function c(){
+      if(count>0){
+        count--;
+        _this.setData({
+          text:count+"s重新发送"
+        })
+      }else{
+        _this.setData({
+          text:'获取验证码'
+        })
+        clearInterval(timer)
+      }
+    }
+    
+    
+    
+  },
+  getUserData() {
+    $api.getAuthinfo().then(res=>{
+      wx.setNavigationBarTitle({
+        title: '',
+      })
+      if(res.data.data.phone == null || res.data.data.phone==''){
+        return
+      }
+      if(res.data.data.role==0){
+        wx.navigateTo({
+          url: '../apply/apply',
+        })
+      }else{
+        this.setData({
+          usercode: res.data.data.usercode,
+          userinfo: res.data.data,
+          status:3
+        })
+      }
+    })
+    .catch(err=>{
+      this.setData({
+        userinfo: {},
+        status:0
+      })
+    })
+  },
+
+  getTodayData() {
+    $api.getMineLatest().then(res=>{
+      this.setData({
+        todayinfo: res.data.data,
+        todayMoney:((res.data.data.today_fund - res.data.data.yesterday_fund)*10000).toFixed(2)
+      })
+    })
+    .catch(err=>{
+      this.setData({
+        todayinfo: {},
+        status:0
+      })
+    })
+  },
+
+  inputchange(e) {
+    this.setData({
+      phone: e.detail.value
+    })
+  },
+  codechange(e) {
+    this.setData({
+      phcode: e.detail.value
+    })
+  },
+  logout() {
+    wx.removeStorage({
+      key: 'userInfo'
+    })
+    wx.setNavigationBarTitle({
+      title: '登录',
+    })
+    this.setData({
+      userinfo: {},
+      usercode: ''
+    })
+  },
+  /**登陆 */
+  login: function () {
+    var _this=this;
+    // if (!this.data.usercode) {
+    //   wx.showToast({
+    //     icon: 'none',
+    //     title: '请输入用户代码',
+    //   })
+    //   return;
+    // }
+    wx.getUserProfile({
+      desc: '用于完善会员资料',
+      success: res=> {
+        //获取基本信息
+        var data = {
+          nickName: res.userInfo.nickName,
+          avatarUrl: res.userInfo.avatarUrl,
+          usercode: this.data.usercode
+        }
+        wx.showLoading({
+          title: '正在登陆',
+        })
+        wx.login({
+          success(res) {
+            //获取code
+            $api.getOpenid({ code: res.code})
+            .then(res => {
+              //获取openid
+              if (res.data.code != 0) {
+                wx.showToast({
+                  icon: 'none',
+                  title: res.data.message,
+                })
+                wx.hideLoading();
+                return;
+              }
+              data.openid = res.data.data.openid;
+              logindata=data
+              $api.login(data)
+              .then(res=>{
+                //登录成功
+                _this.setData({
+                  status:res.data.data.status
+                })
+                wx.hideLoading();
+                wx.setNavigationBarTitle({
+                  title: '',
+                })
+                if (res.data.code != 0) {
+                  wx.showToast({
+                    icon: 'none',
+                    title: res.data.message,
+                  })
+                  return;
+                }
+                wx.setStorage({
+                  key: 'userInfo',
+                  data: res.data.data,
+                })
+                if(res.data.data.status == 3){
+                  wx.switchTab({
+                    url: '../index/index',
+                  })
+                }
+                
+              })
+              .catch(err=>{
+                wx.hideLoading();
+              })
+            })
+            .catch(err => {
+              //请求失败
+              wx.hideLoading();
+            })
+        
+          }
+        })
+      }
+    })
+
+  },
+  login1(){
+    logindata.phone=this.data.phone
+    logindata.phcode=this.data.phcode
+    if (logindata.phone.length<11){
+      wx.showToast({
+        icon: 'none',
+        title: '请输入正确的手机号',
+      })
+      return
+    }
+    if (!logindata.phcode) {
+      wx.showToast({
+        icon: 'none',
+        title: '请输入验证码',
+      })
+      return
+    }
+
+    $api.login(logindata).then(res=>{
+      if(res.data.code == 0){
+  
+        wx.switchTab({
+          url: '../user/user',
+        })
+      } 
+    })
+  },
+  login2(){
+    if (this.data.phone.length<11) {
+      wx.showToast({
+        icon: 'none',
+        title: '请输入正确的手机号',
+      })
+      return
+    }
+    if (!this.data.phcode) {
+      wx.showToast({
+        icon: 'none',
+        title: '请输入验证码',
+      })
+      return
+    }
+    $api.bindphone({phone:this.data.phone,phcode:this.data.phcode}).then(res=>{
+      if(res.data.code == 0){
+          wx.switchTab({
+            url: '../user/user',
+          })
+      }
+    })
+  },
+  onCustomerService(){
+    wx.openCustomerServiceChat({
+      extInfo: {url: 'https://work.weixin.qq.com/kfid/kfcc1bd2a8bddad1dfb'},
+      corpId: 'wwc4de479c81db4706',
+      success(res) {}
+    })
+  },
+ 
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+
+
+})

+ 3 - 0
pages/login/user.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "登录"
+}

+ 42 - 0
pages/login/user.wxml

@@ -0,0 +1,42 @@
+
+<!-- 未登录 -->
+<view class="no_login" wx:if='{{status == 0}}'>
+    <view class="title">欢迎来到湖南顽主杯实盘大赛</view>
+    <view class='avatar'>
+            <image src="../../images/logo.png"></image>
+    </view>
+    <view class="login">
+        <!-- <input bindinput='inputchange' placeholder="请输入您的代码" value="{{usercode}}"></input> -->
+        <button bindtap="login">登录</button>
+      </view>
+      <!-- <button class="contactus" open-type="contact">咨询</button> -->
+</view>
+<view class="no_login" wx:if='{{status == 1}}'>
+    <view class="title">欢迎来到湖南顽主杯实盘大赛</view>
+    <view class='avatar'>
+          <image src="../../images/logo.png"></image>
+    </view>
+    <view class="login">
+        <view><input type="number" placeholder-style="color:#999" bindinput='inputchange' placeholder="请输入手机号"></input></view>
+        <view class="yzm">
+          <input type="number" placeholder-style="color:#999" bindinput='codechange' placeholder="请输入验证码"></input>
+          <view bindtap="getcode" wx:if="{{text=='获取验证码'}}">{{text}}</view>
+          <view class="disabled" wx:else>{{text}}</view>
+        </view>
+        <button bindtap="login1">登录</button>
+      </view>
+</view>
+<view class="no_login" wx:if='{{status == 2}}'>
+    <view class="title" style="margin-bottom: 50rpx;">为了账号安全,请先绑定手机号</view>
+    <view class="login">
+        <view><input type="number" placeholder-style="color:#999" bindinput='inputchange' placeholder="请输入手机号"></input></view>
+        <view class="yzm">
+          <input type="number" placeholder-style="color:#999" bindinput='codechange' placeholder="请输入验证码"></input>
+          <view bindtap="getcode" wx:if="{{text=='获取验证码'}}">{{text}}</view>
+          <view class="disabled" wx:else>{{text}}</view>
+        </view>
+        <button bindtap="login2">绑定</button>
+      </view>
+</view>
+
+

+ 225 - 0
pages/login/user.wxss

@@ -0,0 +1,225 @@
+/* pages/user/user.wxss */
+page{
+  background: #F4F6F8;
+  /* position: fixed; */
+}
+
+.avatar{
+  width: 120rpx;
+  height: 120rpx;
+  border-radius: 100%;
+  overflow: hidden;
+  margin-right: 30rpx;
+}
+.name{
+  font-size: 40rpx;
+  font-weight: 500;
+  padding-top: 15rpx;
+}
+.name view{
+  font-size: 32rpx;
+  color: #FFF;
+  font-weight: bold;
+  margin-bottom: 12rpx;
+}
+.name text{
+  font-size: 28rpx;
+  color: #FFF;
+  font-weight: 400;
+}
+.info{
+  position: relative;
+  background: #D94B24;
+  display: flex;
+  padding: 30rpx;
+}
+.mine{
+  border: 1px solid #fff;
+  color: #fff;
+  font-size: 28rpx;
+  border-radius: 8rpx;
+  padding:0 8rpx;
+  line-height: 48rpx;
+  position: absolute;
+  right: 30rpx;
+  height: 48rpx;
+  top: 0;
+  bottom: 0;
+  margin: auto;
+}
+.item{
+  line-height: 108rpx;
+  font-size: 32rpx;
+  border-bottom: 1px solid #F5F5F5;
+  position: relative;
+}
+.logout{
+  margin-top:15rpx;
+  background:#fff;
+  border:none;
+  padding: 0 30rpx;
+}
+.item image{
+  width: 32rpx;
+  float: right;
+  margin-top: 38rpx;
+}
+
+
+.login input{
+  width: 100%;
+  height: 88rpx;
+  text-align: left;
+  /* background: #F4F6F8; */
+  font-size: 30rpx;
+  border-radius: 8rpx;
+  padding: 0 24rpx;
+  border: 1px solid #E0E0E0;
+  box-sizing: border-box;
+}
+.login button:not([size='mini']){
+  background: #D94B24;
+  color: #fff;
+  width: 100%;
+  margin-top: 48rpx;
+  height: 88rpx;
+  line-height: 88rpx;
+  padding: 0;
+  font-size: 32rpx;
+  border-radius: 8rpx;
+}
+.no_login{
+  height: 100vh;
+  background: #fff;
+  text-align: center;
+  padding: 30% 70rpx 0;
+}
+.no_login .avatar{
+  width: 160rpx;
+  height: 160rpx;
+  margin: 50rpx auto 100rpx;
+}
+.title{
+  font-size: 32rpx;
+}
+
+.today{
+  margin: 30rpx 30rpx 0;
+  background: #fff;
+  border-radius: 8rpx;
+  box-shadow: 0 0 10px 0px rgba(51, 51, 51, 0.1);
+  overflow: hidden;
+}
+.today navigator{
+  padding: 24rpx;
+}
+.today .money{
+  margin: 0rpx 0rpx 30rpx;
+  font-size: 48rpx;
+}
+.today .date{
+  margin: 15rpx 0rpx;
+  font-size: 28rpx;
+}
+.date>text{
+  color: rgba(156, 156, 156, 1);
+  font-size: 28rpx;
+  display: inline-block;
+  width: 49%;
+}
+.date text text{
+  color: rgba(51, 51, 51, 1);
+  font-weight: 400;
+  margin-left: 45rpx;
+  font-size: 28rpx;
+}
+.today .money .todaydown{
+  font-size: 28rpx;
+  /* margin-left: 20rpx !important; */
+  color: #07B20B !important;
+}
+
+.today .money .todayup{
+  font-size: 32rpx;
+  /* margin-left: 20rpx !important; */
+  color: #E90001 !important;
+}
+
+
+
+.contactus{
+  background: none;
+  width: 100% !important;
+  text-align:center;
+  position: absolute;
+  height: 100%;
+  top: 0;
+  left: 0;
+}
+.up,.down{
+  font-size: 40rpx;
+  font-weight: bold;
+}
+.date .up,.date .down{
+  font-size: 28rpx;
+  font-weight: 400;
+  margin-left: 20rpx !important; 
+}
+.today_text{
+  display: block;
+  font-size: 28rpx;
+  color: rgba(156, 156, 156, 1);
+}
+.msg{
+  background: rgba(247, 247, 247, 1);
+  display: flex;
+  border-top: 1px solid rgba(171, 171, 171, 0.2);
+}
+.msg view{
+  width: 50%;
+  text-align: center;
+  font-size: 28rpx;
+  line-height: 100rpx; 
+}
+.msg view:first-child{
+  border-right: 1px solid rgba(171, 171, 171, 0.2);
+}
+.msg image{
+  width: 32rpx;
+  position: relative;
+  top: 5rpx;
+  left: -10rpx;
+}
+.list{
+  margin:30rpx;
+  border-radius: 8rpx;
+  box-shadow: 0 0 10px 0px rgba(51, 51, 51, 0.1);
+  overflow: hidden;
+}
+.no_login .avatar image{
+  width: 160rpx;
+  height: 160rpx;
+}
+.yzm{
+  margin-top: 30rpx;
+  display: flex;
+  justify-content: space-between;
+}
+.yzm input{
+  width: 65%;
+}
+.yzm view{
+  width: 30%;
+  height: 88rpx;
+  color: #D94B24;
+  line-height: 88rpx;
+  border: 1px solid #D94B24;
+  border-radius: 8rpx;
+  font-size: 30rpx;
+}
+.yzm .disabled{
+  color: #999;
+  border-color: #999;
+}
+
+

+ 1 - 1
pages/today/today.js

@@ -119,7 +119,7 @@ Page({
         player_id: res.data.data.today_record.player_id,
         followers:res.data.data.followers,
         fans:res.data.data.fans,
-        record_id: res.data.data.today_record.id,
+        // record_id: res.data.data.today_record.id,
         ec: {
           onInit: initChart
         },

+ 1 - 1
pages/user/user.json

@@ -1,3 +1,3 @@
 {
-  "navigationBarTitleText": "登录"
+  "navigationBarTitleText": "我的"
 }

+ 1 - 42
pages/user/user.wxml

@@ -1,4 +1,4 @@
-<view class="bg" wx:if='{{status == 3}}'>
+<view class="bg">
       <view class="info">
         <view class='avatar'>
             <image style="width:100%;height:100%;"  src="{{userinfo.avatar}}"></image>
@@ -59,45 +59,4 @@
 
   
 </view>
-<!-- 未登录 -->
-<view class="no_login" wx:if='{{status == 0}}'>
-    <view class="title">欢迎来到湖南顽主杯实盘大赛</view>
-    <view class='avatar'>
-            <open-data type="userAvatarUrl">
-            </open-data>
-    </view>
-    <view class="login">
-        <!-- <input bindinput='inputchange' placeholder="请输入您的代码" value="{{usercode}}"></input> -->
-        <button bindtap="login">登录</button>
-      </view>
-      <!-- <button class="contactus" open-type="contact">咨询</button> -->
-</view>
-<view class="no_login" wx:if='{{status == 1}}'>
-    <view class="title">欢迎来到湖南顽主杯实盘大赛</view>
-    <view class='avatar'>
-          <image src="../../images/logo.png"></image>
-    </view>
-    <view class="login">
-        <view><input type="number" placeholder-style="color:#999" bindinput='inputchange' placeholder="请输入手机号"></input></view>
-        <view class="yzm">
-          <input type="number" placeholder-style="color:#999" bindinput='codechange' placeholder="请输入验证码"></input>
-          <view bindtap="getcode" wx:if="{{text=='获取验证码'}}">{{text}}</view>
-          <view class="disabled" wx:else>{{text}}</view>
-        </view>
-        <button bindtap="login1">登录</button>
-      </view>
-</view>
-<view class="no_login" wx:if='{{status == 2}}'>
-    <view class="title" style="margin-bottom: 50rpx;">为了账号安全,请先绑定手机号</view>
-    <view class="login">
-        <view><input type="number" placeholder-style="color:#999" bindinput='inputchange' placeholder="请输入手机号"></input></view>
-        <view class="yzm">
-          <input type="number" placeholder-style="color:#999" bindinput='codechange' placeholder="请输入验证码"></input>
-          <view bindtap="getcode" wx:if="{{text=='获取验证码'}}">{{text}}</view>
-          <view class="disabled" wx:else>{{text}}</view>
-        </view>
-        <button bindtap="login2">绑定</button>
-      </view>
-</view>
-
 

+ 54 - 54
project.config.json

@@ -1,56 +1,56 @@
 {
-  "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-  "packOptions": {
-    "ignore": [],
-    "include": []
-  },
-  "setting": {
-    "urlCheck": true,
-    "es6": true,
-    "enhance": true,
-    "postcss": true,
-    "preloadBackgroundData": false,
-    "minified": true,
-    "newFeature": true,
-    "coverView": true,
-    "nodeModules": false,
-    "autoAudits": false,
-    "showShadowRootInWxmlPanel": true,
-    "scopeDataCheck": false,
-    "uglifyFileName": false,
-    "checkInvalidKey": true,
-    "checkSiteMap": true,
-    "uploadWithSourceMap": true,
-    "compileHotReLoad": false,
-    "lazyloadPlaceholderEnable": false,
-    "useMultiFrameRuntime": true,
-    "useApiHook": true,
-    "useApiHostProcess": true,
-    "babelSetting": {
-      "ignore": [],
-      "disablePlugins": [],
-      "outputPath": ""
-    },
-    "enableEngineNative": false,
-    "useIsolateContext": false,
-    "userConfirmedBundleSwitch": false,
-    "packNpmManually": false,
-    "packNpmRelationList": [],
-    "minifyWXSS": true,
-    "disableUseStrict": false,
-    "minifyWXML": true,
-    "showES6CompileOption": false,
-    "useCompilerPlugins": false
-  },
-  "compileType": "miniprogram",
-  "libVersion": "2.15.0",
-  "appid": "wxb299e10e65157301",
-  "projectname": "newwzb_xcx",
-  "simulatorType": "wechat",
-  "simulatorPluginLibVersion": {},
-  "editorSetting": {
-    "tabIndent": "insertSpaces",
-    "tabSize": 2
-  },
-  "condition": {}
+	"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+	"packOptions": {
+		"ignore": [],
+		"include": []
+	},
+	"setting": {
+		"urlCheck": true,
+		"es6": true,
+		"enhance": true,
+		"postcss": true,
+		"preloadBackgroundData": false,
+		"minified": true,
+		"newFeature": true,
+		"coverView": true,
+		"nodeModules": false,
+		"autoAudits": false,
+		"showShadowRootInWxmlPanel": true,
+		"scopeDataCheck": false,
+		"uglifyFileName": false,
+		"checkInvalidKey": true,
+		"checkSiteMap": true,
+		"uploadWithSourceMap": true,
+		"compileHotReLoad": false,
+		"lazyloadPlaceholderEnable": false,
+		"useMultiFrameRuntime": true,
+		"useApiHook": true,
+		"useApiHostProcess": true,
+		"babelSetting": {
+			"ignore": [],
+			"disablePlugins": [],
+			"outputPath": ""
+		},
+		"enableEngineNative": false,
+		"useIsolateContext": false,
+		"userConfirmedBundleSwitch": false,
+		"packNpmManually": false,
+		"packNpmRelationList": [],
+		"minifyWXSS": true,
+		"disableUseStrict": false,
+		"minifyWXML": true,
+		"showES6CompileOption": false,
+		"useCompilerPlugins": false
+	},
+	"compileType": "miniprogram",
+	"libVersion": "2.15.0",
+	"appid": "wxb299e10e65157301",
+	"projectname": "newwzb_xcx",
+	"simulatorType": "wechat",
+	"simulatorPluginLibVersion": {},
+	"editorSetting": {
+		"tabIndent": "insertSpaces",
+		"tabSize": 2
+	},
+	"condition": {}
 }

+ 2 - 2
utils/api.js

@@ -36,8 +36,8 @@ function request(method, url, data) {
             } else if (res.data.code == 403) {
               //未登录
               reject(403)
-              wx.switchTab({
-                url: '../user/user',
+              wx.navigateTo({
+                url: '../login/user',
               })
             }else{
               wx.hideNavigationBarLoading()