tanyanfei 3 年 前
コミット
5d8e686663
2 ファイル変更74 行追加69 行削除
  1. 73 68
      pages/upload/upload.js
  2. 1 1
      pages/upload/upload.wxml

+ 73 - 68
pages/upload/upload.js

@@ -54,7 +54,8 @@ Page({
     })
     $api.getAuthinfo().then(res=>{
       this.setData({
-        role: res.data.data.role
+        role: res.data.data.role,
+        need_fill: res.data.data.need_fill,
       })
     })
   },
@@ -211,79 +212,78 @@ Page({
     })
   },
   post(){
-    $api.getAuthinfo().then(res => {
+    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({
-        need_fill: res.data.data.need_fill,
+        disable: true
       })
-      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: '正在提交',
+      $api.updateRecord(parm).then(res => {
+        wx.hideLoading()
+        wx.showToast({
+          title: '提交成功',
         })
         this.setData({
-          disable: true
+          freshen: true,
         })
-        $api.updateRecord(parm).then(res => {
-          wx.hideLoading()
-          wx.showToast({
-            title: '提交成功',
-          })
+        setTimeout(() => {
           this.setData({
-            freshen: true,
+            stock: [{ label: '', name: '', code: '', fund: '' }],
+            stockList: [],
+            today_stock_img: [],
+            value: [-1],
+            is_markt: 0,
+            today_fund: '',
+            disable: false
           })
-          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)
-        })
-      }
-    })
+          wx.switchTab({
+            url: '../index/index',
+          })
+        }, 200)
+      })
+    }else{
+      this.setData({
+        show:1
+      })
+    }
 
     
   },
@@ -304,7 +304,12 @@ Page({
       wx.showToast({
         title: '提交成功',
       })
-      this.getUserData()
+      this.setData({
+        show: 0,
+        need_fill:0,
+        init_fund:''
+      })
+      // this.getUserData()
     })
 
   },

+ 1 - 1
pages/upload/upload.wxml

@@ -61,7 +61,7 @@
 </form>
 
 
-<view class="modal" wx:if='{{need_fill}}'>
+<view class="modal" wx:if='{{show}}'>
   <view class="fund_modal">
     <view>请先输入初始资金</view>
     <input type='digit' bindinput="fundchange"></input>