|
@@ -83,6 +83,7 @@ Component({
|
|
itemList: ['拍照'],
|
|
itemList: ['拍照'],
|
|
success: chooseResult => {
|
|
success: chooseResult => {
|
|
console.log('showActionSheet',this.data.pictures.length)
|
|
console.log('showActionSheet',this.data.pictures.length)
|
|
|
|
+ console.log('chooseResult.tapIndex1',chooseResult.tapIndex)
|
|
if (this.data.pictures.length >= MAX_PICTURE) {
|
|
if (this.data.pictures.length >= MAX_PICTURE) {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '一次最多只能选择6张',
|
|
title: '一次最多只能选择6张',
|
|
@@ -91,23 +92,28 @@ Component({
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ console.log('chooseResult.tapIndex2',chooseResult.tapIndex)
|
|
that.setData({
|
|
that.setData({
|
|
gridLoading: true
|
|
gridLoading: true
|
|
})
|
|
})
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ console.log('chooseResult.tapIndex3',chooseResult.tapIndex)
|
|
switch (chooseResult.tapIndex) {
|
|
switch (chooseResult.tapIndex) {
|
|
case 0:
|
|
case 0:
|
|
- wx.chooseImage({
|
|
|
|
|
|
+ wx.chooseMedia({
|
|
sourceType: ['camera'],
|
|
sourceType: ['camera'],
|
|
sizeType: ['original'],
|
|
sizeType: ['original'],
|
|
|
|
+ mediaType: ['image'],
|
|
|
|
+ camera: 'back',
|
|
|
|
+ fail: e => {
|
|
|
|
+ console.log('chooseMedia:fail:' + e.errMsg)
|
|
|
|
+ },
|
|
success: res => {
|
|
success: res => {
|
|
console.log(res);
|
|
console.log(res);
|
|
var pictures = that.data.pictures
|
|
var pictures = that.data.pictures
|
|
|
|
|
|
res.tempFiles.forEach(function (item, idx) {
|
|
res.tempFiles.forEach(function (item, idx) {
|
|
console.log(idx, item)
|
|
console.log(idx, item)
|
|
- item['suffix'] = item.path.substring(item.path.lastIndexOf(".") + 1, item.path.length)
|
|
|
|
|
|
+ item['suffix'] = item.tempFilePath.substring(item.tempFilePath.lastIndexOf(".") + 1, item.tempFilePath.length)
|
|
item['err'] = SUFFIX.indexOf(item['suffix'].toLowerCase()) > -1 ? '' : '图片格式错误'
|
|
item['err'] = SUFFIX.indexOf(item['suffix'].toLowerCase()) > -1 ? '' : '图片格式错误'
|
|
if (item['err'] == '') {
|
|
if (item['err'] == '') {
|
|
item['err'] = item.size > 1024 * 1024 * 10 ? '图片超过10M' : ''
|
|
item['err'] = item.size > 1024 * 1024 * 10 ? '图片超过10M' : ''
|
|
@@ -116,6 +122,7 @@ Component({
|
|
})
|
|
})
|
|
console.log(res.tempFiles)
|
|
console.log(res.tempFiles)
|
|
Array.prototype.push.apply(pictures, res.tempFiles);
|
|
Array.prototype.push.apply(pictures, res.tempFiles);
|
|
|
|
+ console.log('pictures::' + pictures)
|
|
that.setData({
|
|
that.setData({
|
|
pictures: pictures,
|
|
pictures: pictures,
|
|
})
|
|
})
|
|
@@ -128,10 +135,12 @@ Component({
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
- wx.chooseImage({
|
|
|
|
|
|
+ wx.chooseMedia({
|
|
count: MAX_PICTURE - that.data.pictures.length,
|
|
count: MAX_PICTURE - that.data.pictures.length,
|
|
sizeType: ['original'],
|
|
sizeType: ['original'],
|
|
sourceType: ['album'],
|
|
sourceType: ['album'],
|
|
|
|
+ mediaType: ['image'],
|
|
|
|
+ camera: 'back',
|
|
success: res => {
|
|
success: res => {
|
|
console.log(res);
|
|
console.log(res);
|
|
var pictures = that.data.pictures
|
|
var pictures = that.data.pictures
|
|
@@ -140,7 +149,7 @@ Component({
|
|
res.tempFiles.forEach(function (item, idx) {
|
|
res.tempFiles.forEach(function (item, idx) {
|
|
console.log(idx, item)
|
|
console.log(idx, item)
|
|
if (that.data.pictures.length + idx + 1 <= MAX_PICTURE) {
|
|
if (that.data.pictures.length + idx + 1 <= MAX_PICTURE) {
|
|
- item['suffix'] = item.path.substring(item.path.lastIndexOf(".") + 1, item.path.length)
|
|
|
|
|
|
+ item['suffix'] = item.tempFilePath.substring(item.tempFilePath.lastIndexOf(".") + 1, item.tempFilePath.length)
|
|
item['err'] = SUFFIX.indexOf(item['suffix'].toLowerCase()) > -1 ? '' : '图片格式错误'
|
|
item['err'] = SUFFIX.indexOf(item['suffix'].toLowerCase()) > -1 ? '' : '图片格式错误'
|
|
if (item['err'] == '') {
|
|
if (item['err'] == '') {
|
|
item['err'] = item.size > 1024 * 1024 * 10 ? '图片超过10M' : ''
|
|
item['err'] = item.size > 1024 * 1024 * 10 ? '图片超过10M' : ''
|
|
@@ -446,7 +455,7 @@ Component({
|
|
const that = this
|
|
const that = this
|
|
if (retry > 0) {
|
|
if (retry > 0) {
|
|
wx.compressImage({
|
|
wx.compressImage({
|
|
- src: img.path,
|
|
|
|
|
|
+ src: img.tempFilePath,
|
|
quality: 80,
|
|
quality: 80,
|
|
success: function(cf) {
|
|
success: function(cf) {
|
|
console.log('uploadImage:compressImage:success',cf)
|
|
console.log('uploadImage:compressImage:success',cf)
|