123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import {
- mainUrl
- } from '@/http/baseUrl.js';
- export default {
- // 选择图片
- chooseImage(Num) {
-
- var list=[]
- console.log(Num)
- var maxNum=Num
- console.log(maxNum)
- uni.chooseImage({
- count: maxNum,
- success: function(e) {
- for (let i in e.tempFilePaths) {
- if (i >= (maxNum - list.length)) {
- break;
- }
- let fileName = '';
-
- // // #ifdef MP-BAIDU
- // fileName = e.tempFilePaths[i].substr(e.tempFilePaths[i].lastIndexOf('/') + 1);
- // // #endif
- uni.uploadFile({
- url:mainUrl+'/api/File',
- filePath: e.tempFilePaths[i],
- name: 'File',
- fileType: 'image',
- header:{
- "User-Agent":"apifox/1.0.0 (https://www.apifox.cn)"
- },
- formData: {
- File: JSON.stringify(e.tempFilePaths[i]),
- // file_name: fileName,
- },
- success(re) {
- let res=JSON.parse(re.data)
- if (res.code == 200) {
- console.log(res.data.file,2225)
- var list=[]
- list.push(res.data.file)
- console.log(list,899)
-
- } else {
- console.log(55)
- uni.showModal({
- title: '',
- content: res.msg,
- showCancel: false,
- });
- }
- },
- fail(e) {
- if (e && e.msg) {
- uni.showModal({
- title: '错误',
- content: e.msg,
- showCancel: false,
- });
- }
- },
- });
- }
-
- },
- complete: function(e) {
- // 触发事件 tabEvent
- return []
- }
- })
- return list
- }
-
-
- }
|