| | |
| | | |
| | | uni.chooseImage({ |
| | | sourceType: sourceTypeArray[this.sourceTypeIndex], |
| | | sizeType: sizeTypeArray[this.sizeTypeIndex], |
| | | //sizeType: sizeTypeArray[this.sizeTypeIndex], |
| | | sizeType: ['compressed'], // 强制使用压缩模式 |
| | | crop: this.isCrop ? { |
| | | "quality": this.cropPercent, |
| | | "width": this.cropWidth, |
| | |
| | | } : null, |
| | | count: this.qsImage.length + this.count[this.countIndex] > 9 ? 9 - this.qsImage.length : this.count[this.countIndex], |
| | | success: (res) => { |
| | | let url = res.tempFilePaths[0]; |
| | | pathToBase64(url) |
| | | .then(base64 => { |
| | | // 找到最后一个斜杠的位置 |
| | | let lastSlashIndex = url.lastIndexOf("/"); |
| | | // 提取文件名 |
| | | let fileName = url.substring(lastSlashIndex + 1); |
| | | let entity = {}; |
| | | entity.img = base64; |
| | | entity.Picturename = fileName; |
| | | entity.fid = this.fid; |
| | | entity.qsType = 4; |
| | | entity.base64Date = base64.split(',')[1]; |
| | | |
| | | this.qsImage.push(entity); |
| | | }) |
| | | .catch(error => { |
| | | console.error(error) |
| | | }) |
| | | |
| | | pathToBase64(url) |
| | | .then(base64 => { |
| | | // 找到最后一个斜杠的位置 |
| | | let lastSlashIndex = url.lastIndexOf("/"); |
| | | // 提取文件名 |
| | | let fileName = url.substring(lastSlashIndex + 1); |
| | | let entity = {}; |
| | | entity.img = base64; |
| | | entity.Picturename = fileName; |
| | | entity.fid = this.fid; |
| | | entity.qsType = 4; |
| | | entity.base64Date = base64.split(',')[1]; |
| | | |
| | | this.qsImage.push(entity); |
| | | }) |
| | | .catch(error => { |
| | | console.error(error) |
| | | }) |
| | | |
| | | }, |
| | | fail: (err) => { |
| | | console.log("err: ", JSON.stringify(err)); |
| | |
| | | }); |
| | | }, |
| | | previewImage(index) { |
| | | // console.log(this.qsImage.map(s=>s.img)[0]) |
| | | let imagesArry = []; |
| | | base64ToPath(this.qsImage.map(s=>s.img)[index]).then(path => { |
| | | uni.hideLoading(); |
| | | imagesArry[0] = path |
| | | console.log(path); |
| | | uni.previewImage({ |
| | | current: 0, |
| | | urls: imagesArry |
| | | }) |
| | | }) |
| | | |
| | | |
| | | // uni.previewImage({ |
| | | // current: index, // 设置当前显示图片的链接 |
| | | // current: '0', // 设置当前显示图片的链接 |
| | | // urls: this.qsImage.map(s=>s.img), // 需要预览的图片链接列表 |
| | | // loop: false, // 是否开启图片轮播,默认为 false |
| | | // indicator: 'default',// 图片指示器类型,可选值为 "default"、"number"、"pointer",默认为 "default" |
| | | // indicator: 'pointer',// 图片指示器类型,可选值为 "default"、"number"、"pointer",默认为 "default" |
| | | // }); |
| | | }, |
| | | init() { |