diff --git a/api/common.js b/api/common.js
index c5388a5..f32f023 100644
--- a/api/common.js
+++ b/api/common.js
@@ -1,5 +1,12 @@
import request from './request'
let app = getApp();
+let token;
+wx.getStorage({
+ key:'accessToken',
+ success:(res)=>{
+ token = res.data;
+ }
+})
export default {
community:{
@@ -30,5 +37,20 @@ export default {
},
station:{
list:(community_id)=>request.get('/api/station',{community_id})
+ },
+ uploadImg(file){
+ // const formData = new formData();
+ // return request.post('/api/upload/image',{file:file});
+ wx.uploadFile({
+ filePath: file.tempFilePath,
+ name: 'name',
+ header:{
+ Authorization: `Bearer ${token}`
+ },
+ formData:{
+ file:file
+ },
+ url: request.baseUrl+'/api/upload/image',
+ })
}
}
\ No newline at end of file
diff --git a/api/request.js b/api/request.js
index 0479448..8a11fb2 100644
--- a/api/request.js
+++ b/api/request.js
@@ -8,6 +8,7 @@ wx.getStorage({
})
const sendRequest = (options)=>{
+ console.log(options.data?options.data.file:1,12121212);
return new Promise((rs,rj)=>{
wx.request({
url: `${baseUrl}${options.url}`,
@@ -18,11 +19,12 @@ const sendRequest = (options)=>{
rj(result.data)
}
},
+
method:options.method,
data:options.data,
- params:options.params,
header:{
- Authorization: `Bearer ${token}`
+ Authorization: `Bearer ${token}`,
+ "content-type":options.data&&options.data.file?'application/x-www-form-urlencoded':'application/json'
},
fail:rj
})
@@ -30,6 +32,7 @@ const sendRequest = (options)=>{
}
export default {
+ baseUrl:baseUrl,
get(url,data){
return sendRequest({url,method:'get',data});
},
diff --git a/api/user.js b/api/user.js
index 1c011f1..8d0fc58 100644
--- a/api/user.js
+++ b/api/user.js
@@ -39,6 +39,7 @@ export default {
friend:{
list:()=>request.get('/api/user/referrals')
},
+ updateUser:(data)=>request.put('/api/user/update',data),
createPayment(order_id,order_type){
return request.post('/api/wechat/create-payment',{order_id,order_type});
}
diff --git a/app.js b/app.js
index 8e86360..03b2b91 100644
--- a/app.js
+++ b/app.js
@@ -17,6 +17,10 @@ App({
url: '/pages/login/login',
})
},
+ forceGetUserInfo(){
+ this.globalData.userInfoGetTime = null;
+ return this.getUserInfo();
+ },
async getUserInfo(){
if(this.globalData.userInfoGetTime&&
this.globalData.userInfo&&
diff --git a/pages/my/index/index.js b/pages/my/index/index.js
index a297244..fc7eb81 100644
--- a/pages/my/index/index.js
+++ b/pages/my/index/index.js
@@ -42,7 +42,11 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
-
+ app.getUserInfo().then((data)=>{
+ this.setData({
+ userInfo:data
+ });
+ })
},
/**
diff --git a/pages/my/index/index.wxml b/pages/my/index/index.wxml
index 558984c..d3614c8 100644
--- a/pages/my/index/index.wxml
+++ b/pages/my/index/index.wxml
@@ -24,8 +24,9 @@
-
+
邀请邻友
+ 邻友下单赠送 1 张跑腿卷
diff --git a/pages/my/index/index.wxss b/pages/my/index/index.wxss
index 2c9dcff..5d55f66 100644
--- a/pages/my/index/index.wxss
+++ b/pages/my/index/index.wxss
@@ -14,6 +14,8 @@
}
.user-info .content .avatar{
width:112rpx;height:112rpx;
+ border: 2px solid #FFFFFF;
+ border-radius: 50%;
}
.user-info .content .name{
font-size: 36rpx;
@@ -53,4 +55,22 @@
}
.property .item .value{
font-size:56rpx;
+}
+
+.invite-cell{
+ display:flex;
+ justify-content: space-between;
+}
+.invite-cell .spec{
+ font-size: 26rpx;
+ position: relative;
+ color:var(--main-color);
+}
+.invite-cell .spec::before{
+ content:'';
+ position: absolute;
+ bottom: -16rpx;
+ background: rgba(153, 153, 153, 0.2);
+ width:100%;
+ height: 8rpx;
}
\ No newline at end of file
diff --git a/pages/my/setting/index.js b/pages/my/setting/index.js
index 4a5aea7..28fa8d0 100644
--- a/pages/my/setting/index.js
+++ b/pages/my/setting/index.js
@@ -1,20 +1,52 @@
-// pages/my/setting/index.js
+const app = getApp();
+import userApi from '../../../api/user';
+import commonApi from '../../../api/common';
+
Page({
/**
* 页面的初始数据
*/
data: {
-
+ isShowPopup:false,
+ name:app.globalData.userInfo.nickname,
+ inputName:app.globalData.userInfo.nickname
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
-
},
-
+ saveName(){
+ userApi.updateUser({
+ nickname:this.data.inputName
+ }).then((data)=>{
+ this.setData({
+ name:data.nickname
+ });
+ wx.showToast({
+ title: '更新成功',
+ });
+ wx.navigateBack();
+ app.forceGetUserInfo();
+ })
+ },
+ chooseImage(){
+ wx.chooseMedia({
+ count:1,
+ mediaType:'image',
+ success:(res)=>{
+ console.log(res);
+ commonApi.uploadImg(res.tempFiles[0]);
+ }
+ });
+ },
+ modifyName(){
+ this.setData({
+ isShowPopup:true
+ });
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/my/setting/index.json b/pages/my/setting/index.json
index 8835af0..e8c2c06 100644
--- a/pages/my/setting/index.json
+++ b/pages/my/setting/index.json
@@ -1,3 +1,4 @@
{
- "usingComponents": {}
+ "usingComponents": {},
+ "navigationBarTitleText": "设置"
}
\ No newline at end of file
diff --git a/pages/my/setting/index.wxml b/pages/my/setting/index.wxml
index 5c24266..e97c0bd 100644
--- a/pages/my/setting/index.wxml
+++ b/pages/my/setting/index.wxml
@@ -1,13 +1,13 @@
-
+
修改头像
-
+
修改昵称
- 西瓜
+ {{name}}
@@ -20,4 +20,14 @@
用户协议
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/my/setting/index.wxss b/pages/my/setting/index.wxss
index bb20e5a..1f514e4 100644
--- a/pages/my/setting/index.wxss
+++ b/pages/my/setting/index.wxss
@@ -1,3 +1,19 @@
.cell .avatar{
width:80rpx;height:80rpx;
+}
+.content{
+ height:100vh;
+ overflow: hidden;
+}
+.input-area{
+ background-color: #fff;
+ margin-top:20rpx;
+ display: flex;
+ align-items: center;
+ padding:0 20rpx;
+}
+.input-area .input{
+ height:88rpx;
+ line-height: 88rpx;
+ flex: 1;
}
\ No newline at end of file