Browse Source

修改bug

master
前端-胡立永 8 months ago
parent
commit
45359a4198
3 changed files with 64 additions and 21 deletions
  1. +24
    -19
      config.js
  2. +3
    -2
      pages/purse/purse.vue
  3. +37
    -0
      utils/oss-upload/oss/index.js

+ 24
- 19
config.js View File

@ -15,39 +15,44 @@ const config = {
baseUrl : 'http://h5.xzaiyp.top/uav-api', baseUrl : 'http://h5.xzaiyp.top/uav-api',
}, },
prod : { prod : {
baseUrl : 'https://uav-api.xzaiyp.top/uav-api',
}
// baseUrl : 'https://uav-api.xzaiyp.top/uav-api',
baseUrl : 'https://api.olxbookbub.top/uav-oxl-api',//国外服务器
},
} }
// 默认配置 // 默认配置
const defaultConfig = { const defaultConfig = {
mapKey : '', mapKey : '',
fileType : 'service',
aliOss : { aliOss : {
url : 'https://tennis-oss.xzaiyp.top/',
config : {
//桶的地址
region: 'oss-cn-guangzhou',
//id
accessKeyId:'LTAI5tNycA46YTwm383dRvMV',
//密钥
accessKeySecret:'tAdbYQCmdur6jbZ8hjvgB7T1Z52mIG',
//桶的名字
bucket: 'zhuoqiu-image',
endpoint:'oss-cn-guangzhou.aliyuncs.com',
},
// url : 'https://dianpin-img.xzaiyp.top/',
// url : 'https://tennis-oss.xzaiyp.top/',
// config : { // config : {
// //桶的地址 // //桶的地址
// region: 'oss-cn-guangzhou', // region: 'oss-cn-guangzhou',
// //id // //id
// accessKeyId:'LTAI5tMan18fjJPUtr3Aim2W',
// accessKeyId:'LTAI5tNycA46YTwm383dRvMV',
// //密钥 // //密钥
// accessKeySecret:'lhALqqgYijc115wY8c1KfTYkbSnq5I',
// accessKeySecret:'tAdbYQCmdur6jbZ8hjvgB7T1Z52mIG',
// //桶的名字 // //桶的名字
// bucket: 'mangoimageapplet',
// endpoint:'oss-cn-shenzhen.aliyuncs.com',
// bucket: 'zhuoqiu-image',
// endpoint:'oss-cn-guangzhou.aliyuncs.com',
// }, // },
//
url : 'https://shop996image.oss-ap-southeast-5.aliyuncs.com',
config : {
//桶的地址
region: 'oss-ap-southeast-5.aliyuncs.com',
//id
accessKeyId:'LTAI5tHmEEmaoEArocKKpccd',
//密钥
accessKeySecret:'GeVPNHZnnEwQyvtIbHrZgEKtWzaCxx',
//桶的名字
bucket: 'shop996image',
endpoint:'oss-cn-shenzhen.aliyuncs.com',
},//oss-cn-hangzhou.aliyuncs.com
// oss: // oss:
// accessKey: LTAI5tMan18fjJPUtr3Aim2W // accessKey: LTAI5tMan18fjJPUtr3Aim2W
// secretKey: lhALqqgYijc115wY8c1KfTYkbSnq5I // secretKey: lhALqqgYijc115wY8c1KfTYkbSnq5I


+ 3
- 2
pages/purse/purse.vue View File

@ -114,9 +114,10 @@
uploadImage(){ uploadImage(){
let self = this let self = this
this.$Oss.ossUploadImage({ this.$Oss.ossUploadImage({
success(res) { success(res) {
self.form.image = res
self.form.image = JSON.parse(res.data).message
} }
}) })
}, },
@ -167,7 +168,7 @@
uni.navigateTo({ uni.navigateTo({
url: '/pages/center/center' url: '/pages/center/center'
}) })
},500)
},800)
this.cleanForm() this.cleanForm()
this.getUserInfo() //() this.getUserInfo() //()


+ 37
- 0
utils/oss-upload/oss/index.js View File

@ -8,6 +8,8 @@ import {
} from '@/utils/oss-upload/oss/web.js' } from '@/utils/oss-upload/oss/web.js'
import ossConfig from '@/config.js' import ossConfig from '@/config.js'
import axios from '../../axios.js'
/** /**
* 生成一个随机的Key * 生成一个随机的Key
*/ */
@ -89,10 +91,45 @@ export function ossUploadImage({
fail //失败时的回调 fail //失败时的回调
}) { }) {
const sizeType = [compressed ? 'compressed' : 'original'] const sizeType = [compressed ? 'compressed' : 'original']
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType, sizeType,
success(res) { success(res) {
console.log(res);
if(ossConfig.fileType == 'service'){
uni.showLoading()
return uni.uploadFile({
url : ossConfig.baseUrl + '/sys/common/upload',
// filePath : res.tempFilePaths,
file : res.tempFiles[0],
// file : res.tempFiles[0],
fileType : 'image',
success(e){
uni.hideLoading()
success(e)
},
fail(e){
uni.hideLoading()
fail(e)
}
})
// const file = res.tempFiles[0]
// let formData = new FormData()
// formData.append('files', file)
// return axios({
// url: ossConfig.baseUrl + '/sys/common/upload',
// method: 'POST',
// headers: {
// 'Content-Type': 'multipart/form-data'
// },
// data: formData
// }).then(success).catch(fail)
}
// #ifdef H5 // #ifdef H5
return uploadFileToOSS(res.tempFiles[0]).then(success).catch(fail) return uploadFileToOSS(res.tempFiles[0]).then(success).catch(fail)
// #endif // #endif


Loading…
Cancel
Save