tanyanfei 3 years ago
parent
commit
0c837eb885
6 changed files with 134 additions and 121 deletions
  1. 87 57
      pages/upload/upload.js
  2. 11 1
      pages/upload/upload.wxml
  3. 35 0
      pages/upload/upload.wxss
  4. 1 21
      pages/user/user.js
  5. 0 8
      pages/user/user.wxml
  6. 0 34
      pages/user/user.wxss

+ 87 - 57
pages/upload/upload.js

@@ -211,72 +211,102 @@ Page({
     })
   },
   post(){
-    var parm={
-      stock_date: this.data.stock_date,
-      today_stock:this.data.stock,
-      is_markt: this.data.is_markt,
-      today_stock_img: this.data.today_stock_img,
-      today_fund: Number(this.data.today_fund),
-      experience: this.data.experience
-    }
-    if (!parm.today_fund){
-      wx.showToast({
-        icon: 'none',
-        title: '请输入今日净资产'
+    $api.getAuthinfo().then(res => {
+      this.setData({
+        need_fill: res.data.data.need_fill,
       })
-      return
-    }
-    if (!parm.is_markt){
-      // for (let i = 0; i < parm.today_stock.length;i++){
-      //   if (!parm.today_stock[i].name || !parm.today_stock[i].fund) {
-      //     wx.showToast({
-      //       icon: 'none',
-      //       title: '请选择股票并输入资金额'
-      //     })
-      //     return;
-      //     break;
-      //   }
-      // }
-      
-    }else{
-      parm.today_stock = []
-    }
-    if (parm.today_stock_img.length<=0) {
+      if (!this.data.need_fill){
+        var parm = {
+          stock_date: this.data.stock_date,
+          today_stock: this.data.stock,
+          is_markt: this.data.is_markt,
+          today_stock_img: this.data.today_stock_img,
+          today_fund: Number(this.data.today_fund),
+          experience: this.data.experience
+        }
+        if (!parm.today_fund) {
+          wx.showToast({
+            icon: 'none',
+            title: '请输入今日净资产'
+          })
+          return
+        }
+        if (!parm.is_markt) {
+          // for (let i = 0; i < parm.today_stock.length;i++){
+          //   if (!parm.today_stock[i].name || !parm.today_stock[i].fund) {
+          //     wx.showToast({
+          //       icon: 'none',
+          //       title: '请选择股票并输入资金额'
+          //     })
+          //     return;
+          //     break;
+          //   }
+          // }
+
+        } else {
+          parm.today_stock = []
+        }
+        if (parm.today_stock_img.length <= 0) {
+          wx.showToast({
+            icon: 'none',
+            title: '请上传截图'
+          })
+          return
+        }
+        wx.showLoading({
+          title: '正在提交',
+        })
+        this.setData({
+          disable: true
+        })
+        $api.updateRecord(parm).then(res => {
+          wx.hideLoading()
+          wx.showToast({
+            title: '提交成功',
+          })
+          this.setData({
+            freshen: true,
+          })
+          setTimeout(() => {
+            this.setData({
+              stock: [{ label: '', name: '', code: '', fund: '' }],
+              stockList: [],
+              today_stock_img: [],
+              value: [-1],
+              is_markt: 0,
+              today_fund: '',
+              disable: false
+            })
+            wx.switchTab({
+              url: '../index/index',
+            })
+          }, 200)
+        })
+      }
+    })
+
+    
+  },
+  fundchange(e) {
+    this.setData({
+      init_fund: e.detail.value
+    })
+  },
+  save() {
+    if (!this.data.init_fund) {
       wx.showToast({
         icon: 'none',
-        title: '请上传截图'
+        title: '请输入初始资金',
       })
-      return
+      return;
     }
-    wx.showLoading({
-      title: '正在提交',
-    })
-    this.setData({
-      disable:true
-    })
-    $api.updateRecord(parm).then(res=>{
-      wx.hideLoading()
+    $api.initfund({ init_fund: this.data.init_fund }).then(res => {
       wx.showToast({
         title: '提交成功',
       })
-      this.setData({
-        freshen: true,
-      })
-      setTimeout(() => {
-        this.setData({
-          stock: [{ label: '', name: '', code: '', fund: '' }],
-          stockList: [],
-          today_stock_img: [],
-          value: [-1],
-          is_markt: 0,
-          today_fund: '',
-          disable: false
-        })
-        wx.switchTab({
-          url: '../index/index',
-        })
-      }, 200)
+      this.getUserData()
     })
+
   },
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 11 - 1
pages/upload/upload.wxml

@@ -58,4 +58,14 @@
     
     <!-- <button wx:if='{{!change}}' disable='{{disable}}' bindtap="post">上传</button>
     <button wx:else  bindtap="post" disable='{{disable}}'>修改</button> -->
-</form>
+</form>
+
+
+<view class="modal" wx:if='{{need_fill}}'>
+  <view class="fund_modal">
+    <view>请先输入初始资金</view>
+    <input type='digit' bindinput="fundchange"></input>
+    <text>W</text>
+    <button bindtap="save">确定</button>
+  </view>
+</view>

+ 35 - 0
pages/upload/upload.wxss

@@ -186,4 +186,39 @@ form button:not([size='mini']){
 .stock_list view{
   padding:10rpx;
   color: #666;
+}
+
+.modal{
+  position: fixed;
+  width: 100%;
+  height: 100vh;
+  background: rgba(0,0,0,.5);
+  top: 0;
+  left: 0;
+  z-index: 99;
+}
+.fund_modal{
+  width: 80%;
+  padding: 50rpx;
+  /* height: 20vh; */
+  background: #fff;
+  border-radius: 16rpx;
+  margin: 30vh auto;
+  text-align: center;
+  position: relative;
+}
+.fund_modal view{
+  font-size: 30rpx;
+  
+}
+.fund_modal input{
+  border: 1px solid #ccc;
+  height: 80rpx;
+  border-radius: 8rpx;
+  margin: 20rpx 0;
+}
+.fund_modal text{
+  position: absolute;
+  right: 65rpx;
+  top: 40%;
 }

+ 1 - 21
pages/user/user.js

@@ -237,27 +237,7 @@ Page({
       success(res) {}
     })
   },
-  fundchange(e) {
-    this.setData({
-      init_fund: e.detail.value
-    })
-  },
-  save() {
-    if (!this.data.init_fund) {
-      wx.showToast({
-        icon: 'none',
-        title: '请输入初始资金',
-      })
-      return;
-    }
-    $api.initfund({ init_fund: this.data.init_fund}).then(res=>{
-      wx.showToast({
-        title: '提交成功',
-      })
-      this.getUserData()
-    })
-
-  },
+ 
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 0 - 8
pages/user/user.wxml

@@ -100,11 +100,3 @@
 </view>
 
 
-<view class="modal" wx:if='{{userinfo.need_fill}}'>
-  <view class="fund_modal">
-    <view>请先输入初始资金</view>
-    <input type='digit' bindinput="fundchange"></input>
-    <text>W</text>
-    <button bindtap="save">确定</button>
-  </view>
-</view>

+ 0 - 34
pages/user/user.wxss

@@ -223,37 +223,3 @@ page{
 }
 
 
-.modal{
-  position: fixed;
-  width: 100%;
-  height: 100vh;
-  background: rgba(0,0,0,.5);
-  top: 0;
-  left: 0;
-  z-index: 99;
-}
-.fund_modal{
-  width: 80%;
-  padding: 50rpx;
-  /* height: 20vh; */
-  background: #fff;
-  border-radius: 16rpx;
-  margin: 30vh auto;
-  text-align: center;
-  position: relative;
-}
-.fund_modal view{
-  font-size: 30rpx;
-  
-}
-.fund_modal input{
-  border: 1px solid #ccc;
-  height: 80rpx;
-  border-radius: 8rpx;
-  margin: 20rpx 0;
-}
-.fund_modal text{
-  position: absolute;
-  right: 65rpx;
-  top: 40%;
-}