mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-06-11 06:07:24 +08:00
在我的页面直接修改上传头像
This commit is contained in:
parent
2e1be8c740
commit
a8c837e95d
@ -3,7 +3,7 @@
|
|||||||
<view class="user-container bg-white my_user">
|
<view class="user-container bg-white my_user">
|
||||||
<view class="userinfo" :style="{background: 'url('+topImg+') no-repeat center center'}" >
|
<view class="userinfo" :style="{background: 'url('+topImg+') no-repeat center center'}" >
|
||||||
<view class="wait" v-if="login">
|
<view class="wait" v-if="login">
|
||||||
<view class="cu-avatar header-img round " :style="{ backgroundImage: 'url(' + headerImg + ')' }">
|
<view class="cu-avatar header-img round " @click="settingHeadImg()" :style="{ backgroundImage: 'url(' + headerImg + ')' }">
|
||||||
</view>
|
</view>
|
||||||
<view class="userinfo-nickname margin-top">
|
<view class="userinfo-nickname margin-top">
|
||||||
<text class="username">{{ userName }}</text>
|
<text class="username">{{ userName }}</text>
|
||||||
@ -55,6 +55,7 @@
|
|||||||
const factory = context.factory; //获取app实例
|
const factory = context.factory; //获取app实例
|
||||||
const constant = context.constant;
|
const constant = context.constant;
|
||||||
import conf from '@/conf/config.js';
|
import conf from '@/conf/config.js';
|
||||||
|
import * as TanslateImage from '../../lib/java110/utils/translate-image.js';
|
||||||
import {queryOwnerAccount,queryUserIntegral} from '@/api/user/userApi.js';
|
import {queryOwnerAccount,queryUserIntegral} from '@/api/user/userApi.js';
|
||||||
import {
|
import {
|
||||||
getCouponUsers
|
getCouponUsers
|
||||||
@ -90,6 +91,70 @@
|
|||||||
authOwnerDialog
|
authOwnerDialog
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//上传人脸
|
||||||
|
settingHeadImg: function() {
|
||||||
|
var _that = this;
|
||||||
|
wx.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['compressed'],
|
||||||
|
sourceType: ['album', 'camera'],
|
||||||
|
success: function(res) {
|
||||||
|
// console.log(res)
|
||||||
|
wx.showToast({
|
||||||
|
title: '正在上传',
|
||||||
|
icon: 'loading',
|
||||||
|
mask: true,
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
var tempFilePaths = res.tempFilePaths
|
||||||
|
console.log('头像地址', tempFilePaths);
|
||||||
|
TanslateImage.translate(this,tempFilePaths, (_baseInfo) => {
|
||||||
|
_that.headerImg = _baseInfo;
|
||||||
|
_that._uploadOwnerHeaderImg();
|
||||||
|
wx.hideLoading()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
_uploadOwnerHeaderImg: function() {
|
||||||
|
let _that = this;
|
||||||
|
context.getOwner(function(_owner) {
|
||||||
|
let _memberId = _owner.memberId;
|
||||||
|
let _communityId = _owner.communityId;
|
||||||
|
let obj = {
|
||||||
|
memberId: _memberId,
|
||||||
|
communityId: _communityId,
|
||||||
|
photo: _that.headerImg
|
||||||
|
};
|
||||||
|
context.request({
|
||||||
|
url: constant.url.uploadOwnerPhoto,
|
||||||
|
header: context.getHeaders(),
|
||||||
|
method: "POST",
|
||||||
|
data: obj, //动态数据
|
||||||
|
success: function(res) {
|
||||||
|
console.log(res);
|
||||||
|
if (res.statusCode != 200) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '头像上传失败',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_that.loadOwnerHeaderImg();
|
||||||
|
},
|
||||||
|
fail: function(e) {
|
||||||
|
wx.showToast({
|
||||||
|
title: "服务器异常了",
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
//切换小区
|
//切换小区
|
||||||
_changeCommunity: function() {
|
_changeCommunity: function() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user