提交头像
This commit is contained in:
parent
5eb282a80f
commit
ec45edf43f
2
app.json
2
app.json
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
|
"pages/center/center",
|
||||||
"pages/index/index",
|
"pages/index/index",
|
||||||
"pages/volunteerRegister/volunteerRegister",
|
"pages/volunteerRegister/volunteerRegister",
|
||||||
"pages/volunteer/volunteer",
|
"pages/volunteer/volunteer",
|
||||||
@ -13,7 +14,6 @@
|
|||||||
"pages/newTeam/newTeam",
|
"pages/newTeam/newTeam",
|
||||||
"pages/volunteerTeam/volunteerTeam",
|
"pages/volunteerTeam/volunteerTeam",
|
||||||
"pages/venue/venue",
|
"pages/venue/venue",
|
||||||
"pages/center/center",
|
|
||||||
"pages/cultureDetail/cultureDetail",
|
"pages/cultureDetail/cultureDetail",
|
||||||
"pages/activitySign/activitySign",
|
"pages/activitySign/activitySign",
|
||||||
"pages/activityDetail/activityDetail",
|
"pages/activityDetail/activityDetail",
|
||||||
|
@ -1,18 +1,72 @@
|
|||||||
// pages/center/center.js
|
// pages/center/center.js
|
||||||
|
var app = getApp()
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
userAvatar: '',
|
||||||
|
token: ''
|
||||||
},
|
},
|
||||||
|
changeAvatar: function () {
|
||||||
|
var self = this
|
||||||
|
wx.showActionSheet({
|
||||||
|
itemList: ['从相册中选择','拍照'],
|
||||||
|
success: function (res) {
|
||||||
|
if (!res.cancel) {
|
||||||
|
if (res.tapIndex == 0) {
|
||||||
|
self.chooseAvatar('album')
|
||||||
|
} else {
|
||||||
|
self.chooseAvatar('camera')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
chooseAvatar: function (type) {
|
||||||
|
var self = this
|
||||||
|
wx.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['original', 'compressed'],
|
||||||
|
sourceType: [type],
|
||||||
|
success: function (res) {
|
||||||
|
var avatar = res.tempFilePaths[0];
|
||||||
|
console.log(avatar)
|
||||||
|
app.restAjax.post(app.restAjax.path('{usercenterUrl}/app/file/uploadimage', [app.usercenterUrl]), {
|
||||||
|
image: avatar
|
||||||
|
}, {
|
||||||
|
headers: {
|
||||||
|
token: self.data.token
|
||||||
|
}
|
||||||
|
}, function (code, data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
}, function (code, data) {
|
||||||
|
console.log(data)
|
||||||
|
})
|
||||||
|
self.setData({
|
||||||
|
userAvatar: avatar
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getToken: function () {
|
||||||
|
var self = this
|
||||||
|
wx.getStorage({
|
||||||
|
key: 'token',
|
||||||
|
success: function(res) {
|
||||||
|
self.setData({
|
||||||
|
token: res.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
|
this.getToken()
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="page-container">
|
<view class="page-container">
|
||||||
<view class="person">
|
<view class="person">
|
||||||
<view class="user-avatar">
|
<view class="user-avatar" bindtap="changeAvatar">
|
||||||
<image src="../../images/user-avatar.png"></image>
|
<image src="{{userAvatar}}"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-name">杜若无心</view>
|
<view class="user-name">杜若无心</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"enhance": false,
|
|
||||||
"postcss": true,
|
"postcss": true,
|
||||||
"preloadBackgroundData": false,
|
"preloadBackgroundData": false,
|
||||||
"minified": true,
|
"minified": true,
|
||||||
"newFeature": true,
|
"newFeature": true,
|
||||||
"coverView": true,
|
|
||||||
"nodeModules": false,
|
|
||||||
"autoAudits": false,
|
"autoAudits": false,
|
||||||
|
"coverView": true,
|
||||||
"showShadowRootInWxmlPanel": true,
|
"showShadowRootInWxmlPanel": true,
|
||||||
"scopeDataCheck": false,
|
"scopeDataCheck": false,
|
||||||
|
"enhance": false,
|
||||||
|
"nodeModules": false,
|
||||||
"uglifyFileName": false,
|
"uglifyFileName": false,
|
||||||
"checkInvalidKey": true,
|
"checkInvalidKey": true,
|
||||||
"checkSiteMap": true,
|
"checkSiteMap": true,
|
||||||
|
@ -223,4 +223,5 @@ module.exports.put = putJson;
|
|||||||
module.exports.get = getForm;
|
module.exports.get = getForm;
|
||||||
module.exports.params = getParamsArg;
|
module.exports.params = getParamsArg;
|
||||||
module.exports.path = buildPath;
|
module.exports.path = buildPath;
|
||||||
module.exports.escape = escape;
|
module.exports.escape = escape;
|
||||||
|
module.exports.file = postFile;
|
Loading…
Reference in New Issue
Block a user