From ec45edf43f390eaca4d4c4d4df8a0ba432ca33ba Mon Sep 17 00:00:00 2001 From: dong_bo0602 <358256383@qq.com> Date: Fri, 26 Jun 2020 15:00:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 2 +- pages/center/center.js | 58 ++++++++++++++++++++++++++++++++++++++-- pages/center/center.wxml | 4 +-- project.config.json | 6 ++--- utils/restAjax.js | 3 ++- 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app.json b/app.json index 6788cc1..0b259bb 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/center/center", "pages/index/index", "pages/volunteerRegister/volunteerRegister", "pages/volunteer/volunteer", @@ -13,7 +14,6 @@ "pages/newTeam/newTeam", "pages/volunteerTeam/volunteerTeam", "pages/venue/venue", - "pages/center/center", "pages/cultureDetail/cultureDetail", "pages/activitySign/activitySign", "pages/activityDetail/activityDetail", diff --git a/pages/center/center.js b/pages/center/center.js index 98689e9..3af7adc 100644 --- a/pages/center/center.js +++ b/pages/center/center.js @@ -1,18 +1,72 @@ // pages/center/center.js +var app = getApp() Page({ /** * 页面的初始数据 */ 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) { - + this.getToken() }, /** diff --git a/pages/center/center.wxml b/pages/center/center.wxml index f2d30b9..69f3b71 100644 --- a/pages/center/center.wxml +++ b/pages/center/center.wxml @@ -3,8 +3,8 @@ - - + + 杜若无心 diff --git a/project.config.json b/project.config.json index 451ba67..c0536ba 100644 --- a/project.config.json +++ b/project.config.json @@ -6,16 +6,16 @@ "setting": { "urlCheck": false, "es6": true, - "enhance": false, "postcss": true, "preloadBackgroundData": false, "minified": true, "newFeature": true, - "coverView": true, - "nodeModules": false, "autoAudits": false, + "coverView": true, "showShadowRootInWxmlPanel": true, "scopeDataCheck": false, + "enhance": false, + "nodeModules": false, "uglifyFileName": false, "checkInvalidKey": true, "checkSiteMap": true, diff --git a/utils/restAjax.js b/utils/restAjax.js index 24ea122..c818e8d 100644 --- a/utils/restAjax.js +++ b/utils/restAjax.js @@ -223,4 +223,5 @@ module.exports.put = putJson; module.exports.get = getForm; module.exports.params = getParamsArg; module.exports.path = buildPath; -module.exports.escape = escape; \ No newline at end of file +module.exports.escape = escape; +module.exports.file = postFile; \ No newline at end of file