优化代码

This commit is contained in:
java110 2021-05-29 19:38:42 +08:00
parent ef9a364da5
commit bf6254b74e

View File

@ -86,6 +86,7 @@
<script> <script>
const context = require("../../context/Java110Context.js"); const context = require("../../context/Java110Context.js");
import * as TanslateImage from '../../utils/translate-image.js';
const constant = context.constant; const constant = context.constant;
const factory = context.factory; const factory = context.factory;
export default { export default {
@ -115,7 +116,7 @@
var _that = this; var _that = this;
wx.chooseImage({ wx.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: function(res) { success: function(res) {
// console.log(res) // console.log(res)
@ -127,11 +128,20 @@
}); });
var tempFilePaths = res.tempFilePaths var tempFilePaths = res.tempFilePaths
console.log('头像地址', tempFilePaths); console.log('头像地址', tempFilePaths);
//#ifdef H5
TanslateImage.translate(tempFilePaths, (_baseInfo) => {
_that.headerImg = _baseInfo;
_that._uploadOwnerHeaderImg();
wx.hideLoading()
})
//#endif
//#ifdef MP-WEIXIN
factory.base64.urlTobase64(tempFilePaths[0]).then(function(_baseInfo) { factory.base64.urlTobase64(tempFilePaths[0]).then(function(_baseInfo) {
_that.headerImg = _baseInfo; _that.headerImg = _baseInfo;
_that._uploadOwnerHeaderImg(); _that._uploadOwnerHeaderImg();
wx.hideLoading() wx.hideLoading()
}); });
//#endif
} }
}) })
}, },