|
@@ -20,7 +20,8 @@ Page({
|
|
|
cur:0,
|
|
|
freshen:true,
|
|
|
disable:false,
|
|
|
- id:0
|
|
|
+ id:0,
|
|
|
+ images:[],
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -33,12 +34,18 @@ Page({
|
|
|
this.setData({
|
|
|
disable: false
|
|
|
})
|
|
|
- $api.getAuthinfo().then(res=>{
|
|
|
- this.setData({
|
|
|
- role: res.data.data.role,
|
|
|
- need_fill: res.data.data.need_fill,
|
|
|
- })
|
|
|
+
|
|
|
+ $api.initUser()
|
|
|
+
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'user',
|
|
|
+ complete: res => {
|
|
|
+ this.setData({
|
|
|
+ role: res.data.role,
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
+
|
|
|
$api.getCurrecord().then(res=>{
|
|
|
if (!res.data.data.id){return}
|
|
|
let stock = res.data.data.today_stock
|
|
@@ -87,6 +94,11 @@ Page({
|
|
|
value: value
|
|
|
})
|
|
|
},
|
|
|
+ delToday(e){
|
|
|
+ this.setData({
|
|
|
+ today_fund: '',
|
|
|
+ })
|
|
|
+ },
|
|
|
bindPickerChange(e){
|
|
|
var i=this.data.cur;
|
|
|
var v = e.target.dataset.name
|
|
@@ -181,6 +193,7 @@ Page({
|
|
|
wx.showLoading({
|
|
|
title: '正在上传',
|
|
|
})
|
|
|
+
|
|
|
const tempFilePaths = res.tempFiles
|
|
|
for (let i = 0; i < tempFilePaths.length; i++) {
|
|
|
$api.upload(tempFilePaths[i].path, 'file').then(res => {
|
|
@@ -192,6 +205,9 @@ Page({
|
|
|
today_stock_img: today_stock_img
|
|
|
})
|
|
|
console.log(this.data.today_stock_img,22222222222)
|
|
|
+ if (i==0 && today_stock_img.length == 1){
|
|
|
+ this.loadOcr(tempFilePaths[i].path,res.data.url)
|
|
|
+ }
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: '上传失败',
|
|
@@ -201,11 +217,65 @@ Page({
|
|
|
.catch(err => {
|
|
|
wx.hideLoading()
|
|
|
})
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ loadOcr(path,url){
|
|
|
+ var _this = this
|
|
|
+
|
|
|
+ wx.getImageInfo({
|
|
|
+ src:path,
|
|
|
+ success:function(ires){
|
|
|
+ _this.loadImageOcr(url,ires.width < ires.height ? 'phone':'pc')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ loadImageOcr(img_url,source){
|
|
|
+ var _this = this
|
|
|
+ var param = {
|
|
|
+ img_url:img_url.split('?')[0],
|
|
|
+ source:source,
|
|
|
+ }
|
|
|
+ console.log('img_url',param['img_url'])
|
|
|
+ console.log('source',param['source'])
|
|
|
+ $api.imageOcr(param).then(res => {
|
|
|
+ console.log('ocr',res)
|
|
|
+ if(res.data.code == 0){
|
|
|
+ _this.setData({
|
|
|
+ today_fund:res.data.data.today,
|
|
|
+ stock:res.data.data.list
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ startOcr(e){
|
|
|
+ var index = e.target.dataset.index;
|
|
|
+ var img_url = this.data.today_stock_img[index]
|
|
|
+
|
|
|
+ console.log('startocr',img_url)
|
|
|
+ this.loadImageOcr(img_url,this.data.images[index].width < this.data.images[index].height ? 'phone':'pc')
|
|
|
+ },
|
|
|
+
|
|
|
+ imageLoad: function(e) {
|
|
|
+ var width=e.detail.width; //获取图片真实宽度
|
|
|
+ var height=e.detail.height;
|
|
|
+
|
|
|
+ var image=this.data.images;
|
|
|
+ //将图片的datadata-index作为image对象的key,然后存储图片的宽高值
|
|
|
+ image[e.target.dataset.index]={
|
|
|
+ width:width,
|
|
|
+ height:height,
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ images:image
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
del1(e) {
|
|
|
var i = e.target.dataset.id;
|
|
|
var today_stock_img = this.data.today_stock_img;
|
|
@@ -222,145 +292,112 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
post(){
|
|
|
- if (!this.data.need_fill) {
|
|
|
- var stocks = []
|
|
|
- var slist = this.data.stock
|
|
|
+ var stocks = []
|
|
|
+ var slist = this.data.stock
|
|
|
|
|
|
- for(let i=0;i<slist.length;i++){
|
|
|
- if(slist[i].name.length <= 0){
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if(slist[i].fund > 5000){
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '持仓金额单位为万'
|
|
|
- })
|
|
|
- return;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- stocks.push(slist[i])
|
|
|
+ for(let i=0;i<slist.length;i++){
|
|
|
+ if(slist[i].name.length <= 0){
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- var parm = {
|
|
|
- stock_date: this.data.stock_date,
|
|
|
- today_stock: stocks,
|
|
|
- is_markt: this.data.is_markt,
|
|
|
- today_stock_img: this.data.today_stock_img,
|
|
|
- today_fund: Number(this.data.today_fund),
|
|
|
- id:this.data.id,
|
|
|
- experience: this.data.experience
|
|
|
- }
|
|
|
- if (!parm.today_fund) {
|
|
|
+ if(slist[i].fund > 5000){
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '请输入今日净资产'
|
|
|
+ title: '持仓金额单位为万'
|
|
|
})
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- if (parm.today_fund >= 10000) {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '今日净资产单位为万'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
+ stocks.push(slist[i])
|
|
|
+ }
|
|
|
|
|
|
- // 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 = []
|
|
|
- // }
|
|
|
-
|
|
|
- console.log(parm)
|
|
|
- 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,
|
|
|
- disable: false
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- this.setData({
|
|
|
- stock: [{ label: '', name: '', code: '', fund: '' }],
|
|
|
- stockList: [],
|
|
|
- today_stock_img: [],
|
|
|
- value: [-1],
|
|
|
- is_markt: 0,
|
|
|
- today_fund: ''
|
|
|
-
|
|
|
- })
|
|
|
- wx.switchTab({
|
|
|
- url: '../user/user',
|
|
|
- })
|
|
|
- }, 200)
|
|
|
+ var parm = {
|
|
|
+ stock_date: this.data.stock_date,
|
|
|
+ today_stock: stocks,
|
|
|
+ is_markt: this.data.is_markt,
|
|
|
+ today_stock_img: this.data.today_stock_img,
|
|
|
+ today_fund: Number(this.data.today_fund),
|
|
|
+ id:this.data.id,
|
|
|
+ experience: this.data.experience
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!parm.today_fund) {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '请输入今日净资产'
|
|
|
})
|
|
|
- .catch(
|
|
|
- this.setData({
|
|
|
- disable:false
|
|
|
- })
|
|
|
- )
|
|
|
- }else{
|
|
|
- this.setData({
|
|
|
- show:1
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parm.today_fund >= 10000) {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '今日净资产单位为万'
|
|
|
})
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- },
|
|
|
- fundchange(e) {
|
|
|
- this.setData({
|
|
|
- init_fund: e.detail.value
|
|
|
- })
|
|
|
- },
|
|
|
- save() {
|
|
|
- if (!this.data.init_fund) {
|
|
|
+ // 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 = []
|
|
|
+ // }
|
|
|
+
|
|
|
+ console.log(parm)
|
|
|
+ if (parm.today_stock_img.length <= 0) {
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '请输入初始资金',
|
|
|
+ title: '请上传截图'
|
|
|
})
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
- $api.initfund({ init_fund: this.data.init_fund }).then(res => {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '正在提交',
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ disable: true
|
|
|
+ })
|
|
|
+ $api.updateRecord(parm).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
wx.showToast({
|
|
|
title: '提交成功',
|
|
|
})
|
|
|
this.setData({
|
|
|
- show: 0,
|
|
|
- need_fill:0,
|
|
|
- init_fund:''
|
|
|
+ freshen: true,
|
|
|
+ disable: false
|
|
|
})
|
|
|
- // this.getUserData()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.setData({
|
|
|
+ stock: [{ label: '', name: '', code: '', fund: '' }],
|
|
|
+ stockList: [],
|
|
|
+ today_stock_img: [],
|
|
|
+ value: [-1],
|
|
|
+ is_markt: 0,
|
|
|
+ today_fund: ''
|
|
|
+
|
|
|
+ })
|
|
|
+ wx.switchTab({
|
|
|
+ url: '../user/user',
|
|
|
+ })
|
|
|
+ }, 200)
|
|
|
})
|
|
|
-
|
|
|
+ .catch(
|
|
|
+ this.setData({
|
|
|
+ disable:false
|
|
|
+ })
|
|
|
+ )
|
|
|
},
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|