From 45359a419890ae5fc89b7bfa10ef81e134a44e21 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Tue, 17 Sep 2024 20:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 43 ++++++++++++++++++++++++------------------- pages/purse/purse.vue | 5 +++-- utils/oss-upload/oss/index.js | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/config.js b/config.js index b5be8ab..721ac43 100644 --- a/config.js +++ b/config.js @@ -15,39 +15,44 @@ const config = { baseUrl : 'http://h5.xzaiyp.top/uav-api', }, 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 = { mapKey : '', + fileType : 'service', 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 : { // //桶的地址 // region: 'oss-cn-guangzhou', // //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: // accessKey: LTAI5tMan18fjJPUtr3Aim2W // secretKey: lhALqqgYijc115wY8c1KfTYkbSnq5I diff --git a/pages/purse/purse.vue b/pages/purse/purse.vue index 988f7df..28c9d4a 100644 --- a/pages/purse/purse.vue +++ b/pages/purse/purse.vue @@ -114,9 +114,10 @@ uploadImage(){ let self = this + this.$Oss.ossUploadImage({ success(res) { - self.form.image = res + self.form.image = JSON.parse(res.data).message } }) }, @@ -167,7 +168,7 @@ uni.navigateTo({ url: '/pages/center/center' }) - },500) + },800) this.cleanForm() this.getUserInfo() //刷新用户信息(更新用户余额) diff --git a/utils/oss-upload/oss/index.js b/utils/oss-upload/oss/index.js index 024eb80..ae18ea4 100644 --- a/utils/oss-upload/oss/index.js +++ b/utils/oss-upload/oss/index.js @@ -8,6 +8,8 @@ import { } from '@/utils/oss-upload/oss/web.js' import ossConfig from '@/config.js' +import axios from '../../axios.js' + /** * 生成一个随机的Key */ @@ -89,10 +91,45 @@ export function ossUploadImage({ fail //失败时的回调 }) { const sizeType = [compressed ? 'compressed' : 'original'] + uni.chooseImage({ count: 1, sizeType, 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 return uploadFileToOSS(res.tempFiles[0]).then(success).catch(fail) // #endif