|
@@ -173,23 +173,32 @@ Page({
|
|
|
var today_stock_img = this.data.today_stock_img;
|
|
var today_stock_img = this.data.today_stock_img;
|
|
|
wx.chooseImage({
|
|
wx.chooseImage({
|
|
|
success: res=> {
|
|
success: res=> {
|
|
|
- const tempFilePaths = res.tempFilePaths
|
|
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ const tempFilePaths = res.tempFiles
|
|
|
for (let i = 0; i < tempFilePaths.length;i++){
|
|
for (let i = 0; i < tempFilePaths.length;i++){
|
|
|
- wx.uploadFile({
|
|
|
|
|
- url: host + '/api/wx/uploadfile',
|
|
|
|
|
- filePath: tempFilePaths[i],
|
|
|
|
|
- name: 'file',
|
|
|
|
|
- header: {
|
|
|
|
|
- 'Authorization': this.data.userInfo.token
|
|
|
|
|
- },
|
|
|
|
|
- success: res => {
|
|
|
|
|
- const data = JSON.parse(res.data)
|
|
|
|
|
- today_stock_img.push(data.data.url)
|
|
|
|
|
- this.setData({
|
|
|
|
|
- today_stock_img: today_stock_img
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if(tempFilePaths[i].size > 1024){
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ title: '图片大小不能超过1M'
|
|
|
|
|
+ })
|
|
|
|
|
+ }else{
|
|
|
|
|
+ wx.uploadFile({
|
|
|
|
|
+ url: host + '/api/wx/uploadfile',
|
|
|
|
|
+ filePath: tempFilePaths[i].path,
|
|
|
|
|
+ name: 'file',
|
|
|
|
|
+ header: {
|
|
|
|
|
+ 'Authorization': this.data.userInfo.token
|
|
|
|
|
+ },
|
|
|
|
|
+ success: res => {
|
|
|
|
|
+ const data = JSON.parse(res.data)
|
|
|
|
|
+ today_stock_img.push(data.data.url)
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ today_stock_img: today_stock_img
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|