加入头像设置

This commit is contained in:
wuxw 2020-02-06 20:38:08 +08:00
parent 9803a10e4e
commit 83003c4324
8 changed files with 118 additions and 17 deletions

View File

@ -3,15 +3,15 @@
<cover-view >
<cover-image class="img" src="../../images/camera.png" style="width:100%; height:800rpx"/>
</cover-view>
<cover-view class="cf_text_na">拿起手机,设置头像</cover-view>
<cover-view class="cf_text_na">拿起手机,面向手机</cover-view>
</camera>
<view class="cf_btn">
<view class="cf_btn_v" wx:if="{{uploadFlag == false}}">
<van-button type="primary" block bind:click="takePhoto">头像上传</van-button>
<van-button type="primary" block bind:click="takePhoto">采集人脸</van-button>
</view>
<view class="cf_btn_v" wx:else>
<van-button loading type="primary" block loading-text="头像上传中..."/>
<van-button loading type="primary" block loading-text="人脸上传中..."/>
</view>
</view>

View File

@ -1,13 +1,15 @@
/** index.js **/
const context = require('../../context/Java110Context.js');
const factory = context.factory;
const constant = context.constant;
//获取app实例
const app = getApp();
Page({
data: {
userInfo: {}, // 用户信息
ownerFlag: false // 是否有业主信息 标记 如果有为 true 没有为false
ownerFlag: false, // 是否有业主信息 标记 如果有为 true 没有为false
headerImg:''
},
onLoad: function() {
let _that = this;
@ -17,7 +19,9 @@ Page({
});
//查询用户信息
_that.loadOwenrInfo();
});
},
onShow: function() {
@ -28,8 +32,22 @@ Page({
_that.setData({
userInfo: context.getUserInfo()
});
console.log('查询头像');
_that.loadOwnerHeaderImg();
},
/**
* 查询业主头像
*/
loadOwnerHeaderImg: function () {
let _that = this;
context.getOwner(function (_owner) {
let _headerImg = constant.url.getOwnerPhotoPath + "?objId=" + _owner.memberId + "&communityId=" + _owner.communityId + "&fileTypeCd=10000&time=" + new Date();
_that.setData({
headerImg: _headerImg
});
});
},
bindingOwner: function() {
wx.navigateTo({
url: '../bindOwner/bindOwner',
@ -77,6 +95,5 @@ Page({
wx.navigateTo({
url: '/pages/settings/settings',
});
}
})

View File

@ -9,7 +9,10 @@
</block> -->
<!-- wx:else -->
<block>
<view class="userinfo-avatar">
<view wx:if="{{headerImg !=''}}">
<van-image width="6rem" height="6rem" round fit="cover" src="{{headerImg}}" />
</view>
<view class="userinfo-avatar" wx:else>
<open-data type="userAvatarUrl" lang="zh_CN" />
</view>
<view class="userinfo-nickname">

View File

@ -31,14 +31,18 @@
text="访客钥匙"
/>
</van-grid>
<!--
<van-grid clickable column-num="2">
<van-grid-item
icon="home-o"
link-type="navigateTo"
url="/pages/viewHeadImg/viewHeadImg"
text="采集人脸"
/>
<!-- <van-grid-item
icon="home-o"
link-type="navigateTo"
url="/pages/applicationKey/applicationKey"
text="二维码开门"
/>
/> -->
</van-grid>
-->
</view>

View File

@ -1,18 +1,22 @@
// pages/settings/settings.js
const context = require("../../context/Java110Context.js");
const constant = context.constant;
const factory = context.factory;
Page({
/**
* 页面的初始数据
*/
data: {
headerImg: null,
imageList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.loadOwnerHeaderImg();
},
/**
@ -64,9 +68,80 @@ Page({
},
settingHeadImg:function(){
wx.navigateTo({
url: '/pages/viewHeadImg/viewHeadImg',
var _that = this;
wx.chooseImage({
count: 1,
sizeType: ['original', '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);
factory.base64.urlTobase64(tempFilePaths[0]).then(function (_baseInfo) {
_that.setData({
headerImg: _baseInfo
});
_that._uploadOwnerHeaderImg();
wx.hideLoading()
});
}
})
},
/**
* 查询业主头像
*/
loadOwnerHeaderImg: function () {
let _that = this;
context.getOwner(function (_owner) {
let _headerImg = constant.url.getOwnerPhotoPath + "?objId=" + _owner.memberId + "&communityId=" + _owner.communityId + "&fileTypeCd=10000&time=" + new Date();
_that.setData({
headerImg: _headerImg
});
});
},
_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.data.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;
}
},
fail: function (e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
});
}
});
});
}
})

View File

@ -1,9 +1,11 @@
<view>
<van-cell-group>
<van-cell title="设置头像" value="" bind:click = "settingHeadImg" is-link/>
<van-cell title="我的头像" center bind:click="settingHeadImg" is-link>
<van-image width="4rem" height="4rem" round fit="cover" src="{{headerImg}}" />
</van-cell>
</van-cell-group>
<view class="group_black"></view>
<van-cell-group>
<van-cell title="版本号" value="V0.1.0"/>
<van-cell title="版本号" value="V0.1.0" />
</van-cell-group>
</view>

View File

@ -8,7 +8,7 @@ Page({
*/
data: {
headerImg:null,
btnValue:"上传头像"
btnValue:"上传人脸"
},
/**

View File

@ -3,7 +3,7 @@
<view class="vpf_row_black">
</view>
<view class="vpf_row_title">
<text>头像信息</text>
<text>人脸信息</text>
</view>
<view class="vpf_row_black_01"/>