个人中心更新 user
This commit is contained in:
parent
2ab1b6df53
commit
df410f1142
@ -1,5 +1,12 @@
|
|||||||
import request from './request'
|
import request from './request'
|
||||||
let app = getApp();
|
let app = getApp();
|
||||||
|
let token;
|
||||||
|
wx.getStorage({
|
||||||
|
key:'accessToken',
|
||||||
|
success:(res)=>{
|
||||||
|
token = res.data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
community:{
|
community:{
|
||||||
@ -30,5 +37,20 @@ export default {
|
|||||||
},
|
},
|
||||||
station:{
|
station:{
|
||||||
list:(community_id)=>request.get('/api/station',{community_id})
|
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',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,6 +8,7 @@ wx.getStorage({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const sendRequest = (options)=>{
|
const sendRequest = (options)=>{
|
||||||
|
console.log(options.data?options.data.file:1,12121212);
|
||||||
return new Promise((rs,rj)=>{
|
return new Promise((rs,rj)=>{
|
||||||
wx.request({
|
wx.request({
|
||||||
url: `${baseUrl}${options.url}`,
|
url: `${baseUrl}${options.url}`,
|
||||||
@ -18,11 +19,12 @@ const sendRequest = (options)=>{
|
|||||||
rj(result.data)
|
rj(result.data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
method:options.method,
|
method:options.method,
|
||||||
data:options.data,
|
data:options.data,
|
||||||
params:options.params,
|
|
||||||
header:{
|
header:{
|
||||||
Authorization: `Bearer ${token}`
|
Authorization: `Bearer ${token}`,
|
||||||
|
"content-type":options.data&&options.data.file?'application/x-www-form-urlencoded':'application/json'
|
||||||
},
|
},
|
||||||
fail:rj
|
fail:rj
|
||||||
})
|
})
|
||||||
@ -30,6 +32,7 @@ const sendRequest = (options)=>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
baseUrl:baseUrl,
|
||||||
get(url,data){
|
get(url,data){
|
||||||
return sendRequest({url,method:'get',data});
|
return sendRequest({url,method:'get',data});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export default {
|
|||||||
friend:{
|
friend:{
|
||||||
list:()=>request.get('/api/user/referrals')
|
list:()=>request.get('/api/user/referrals')
|
||||||
},
|
},
|
||||||
|
updateUser:(data)=>request.put('/api/user/update',data),
|
||||||
createPayment(order_id,order_type){
|
createPayment(order_id,order_type){
|
||||||
return request.post('/api/wechat/create-payment',{order_id,order_type});
|
return request.post('/api/wechat/create-payment',{order_id,order_type});
|
||||||
}
|
}
|
||||||
|
|||||||
4
app.js
4
app.js
@ -17,6 +17,10 @@ App({
|
|||||||
url: '/pages/login/login',
|
url: '/pages/login/login',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
forceGetUserInfo(){
|
||||||
|
this.globalData.userInfoGetTime = null;
|
||||||
|
return this.getUserInfo();
|
||||||
|
},
|
||||||
async getUserInfo(){
|
async getUserInfo(){
|
||||||
if(this.globalData.userInfoGetTime&&
|
if(this.globalData.userInfoGetTime&&
|
||||||
this.globalData.userInfo&&
|
this.globalData.userInfo&&
|
||||||
|
|||||||
@ -42,7 +42,11 @@ Page({
|
|||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow() {
|
onShow() {
|
||||||
|
app.getUserInfo().then((data)=>{
|
||||||
|
this.setData({
|
||||||
|
userInfo:data
|
||||||
|
});
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,8 +24,9 @@
|
|||||||
<view class="cell-hd">
|
<view class="cell-hd">
|
||||||
<image class="icon" src="/assets/icon/my/share@2x.png"></image>
|
<image class="icon" src="/assets/icon/my/share@2x.png"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell-bd">
|
<view class="cell-bd invite-cell">
|
||||||
<view>邀请邻友</view>
|
<view>邀请邻友</view>
|
||||||
|
<view class="spec">邻友下单赠送 1 张跑腿卷</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell-ft"></view>
|
<view class="cell-ft"></view>
|
||||||
</navigator>
|
</navigator>
|
||||||
|
|||||||
@ -14,6 +14,8 @@
|
|||||||
}
|
}
|
||||||
.user-info .content .avatar{
|
.user-info .content .avatar{
|
||||||
width:112rpx;height:112rpx;
|
width:112rpx;height:112rpx;
|
||||||
|
border: 2px solid #FFFFFF;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
.user-info .content .name{
|
.user-info .content .name{
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
@ -54,3 +56,21 @@
|
|||||||
.property .item .value{
|
.property .item .value{
|
||||||
font-size:56rpx;
|
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;
|
||||||
|
}
|
||||||
@ -1,20 +1,52 @@
|
|||||||
// pages/my/setting/index.js
|
const app = getApp();
|
||||||
|
import userApi from '../../../api/user';
|
||||||
|
import commonApi from '../../../api/common';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
isShowPopup:false,
|
||||||
|
name:app.globalData.userInfo.nickname,
|
||||||
|
inputName:app.globalData.userInfo.nickname
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
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
|
||||||
|
});
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {}
|
"usingComponents": {},
|
||||||
|
"navigationBarTitleText": "设置"
|
||||||
}
|
}
|
||||||
@ -1,13 +1,13 @@
|
|||||||
<view class="cells">
|
<view class="cells">
|
||||||
<view class="cell">
|
<view class="cell" bind:tap="chooseImage">
|
||||||
<view class="cell-bd">修改头像</view>
|
<view class="cell-bd">修改头像</view>
|
||||||
<view class="cell-ft">
|
<view class="cell-ft">
|
||||||
<image src="/assets/imgs/for_test/avatar.png" class="avatar"/>
|
<image src="/assets/imgs/for_test/avatar.png" class="avatar"/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell">
|
<view class="cell" bind:tap="modifyName">
|
||||||
<view class="cell-bd">修改昵称</view>
|
<view class="cell-bd">修改昵称</view>
|
||||||
<view class="cell-ft">西瓜</view>
|
<view class="cell-ft">{{name}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -21,3 +21,13 @@
|
|||||||
<view class="cell-ft"></view>
|
<view class="cell-ft"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<page-container show="{{isShowPopup}}" close-on-slide-down>
|
||||||
|
<view class="content">
|
||||||
|
<view class="input-area">
|
||||||
|
<input class="input" model:value="{{inputName}}"/>
|
||||||
|
<button type="primary" size="mini" class="button"
|
||||||
|
disabled="{{name==inputName}}" bind:tap="saveName">保存</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</page-container>
|
||||||
@ -1,3 +1,19 @@
|
|||||||
.cell .avatar{
|
.cell .avatar{
|
||||||
width:80rpx;height:80rpx;
|
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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user