diff --git a/common/js/api.js b/common/js/api.js index 0d65af0..e3f348e 100644 --- a/common/js/api.js +++ b/common/js/api.js @@ -126,4 +126,8 @@ export default { productqueryShopIdByTableCode(data) { //通过桌码获取shopId return uni.api.get("/product/queryShopIdByTableCode", data); }, + // 修改头像和昵称 + upUserInfo(data) { + return uni.api.post("/login/upUserInfo", data); + }, } \ No newline at end of file diff --git a/pages/user/information.vue b/pages/user/information.vue index 0230f61..41a68d3 100644 --- a/pages/user/information.vue +++ b/pages/user/information.vue @@ -5,21 +5,22 @@ - + 昵称 - + 手机号 - + - + 保存 @@ -33,6 +34,11 @@ components: { navseat }, + onLoad() { + this.userInfo = uni.cache.get('userInfo') + this.userName = this.userInfo.nickName + this.userHeadImg = this.userInfo.headImg + }, data() { return { titlename: '完善信息', @@ -44,8 +50,11 @@ other: '', //附近1KM 1选中 0不选中 page: 1, //页数 size: 10, //页容量 - status: 'loadmore' + status: 'loadmore', }, + userInfo: uni.cache.get('userInfo'), + userHeadImg: "", + userName: '' }; }, onPageScroll(e) { @@ -55,6 +64,48 @@ this.opacitys = true } }, + methods: { + uploadImg() { + let _this = this + uni.chooseImage({ + crop: { + width: 200, + height: 200 + }, + success: (chooseImageRes) => { + const tempFilePaths = chooseImageRes.tempFilePaths; + uni.uploadFile({ + url: uni.conf.baseUrl + '/common/upload', + filePath: tempFilePaths[0], + header: { + environment: 'app', + type: 'android', + version: '1.7.3', + }, + name: "file", + formData: { + file: chooseImageRes.tempFiles[0], + }, + success: (uploadFileRes) => { + let { + data + } = JSON.parse(uploadFileRes.data) + this.userHeadImg = data + }, + }); + }, + }) + }, + async sumbit() { + let res = await this.api.upUserInfo({ + headImg: this.userHeadImg, + nickName: this.userName + }) + if(res.code == 0){ + uni.navigateBack() + } + } + }, computed: { HeighT() { //手机类型的尺寸 return this.$store.getters.is_BarHeight @@ -95,13 +146,15 @@ .onecontentboxitem { padding: 24rpx 0; - .onecontentboxitemtext{ + + .onecontentboxitemtext { font-family: PingFang SC, PingFang SC; font-weight: bold; font-size: 32rpx; color: #333333; } - .onecontentboxiteminput{ + + .onecontentboxiteminput { text-align: right; flex: auto; font-family: PingFang SC, PingFang SC; @@ -112,7 +165,8 @@ } } } - .onecontentboxitemnamber{ + + .onecontentboxitemnamber { margin-top: 84rpx; text-align: center; width: 100%; diff --git a/pages/user/user.vue b/pages/user/user.vue index 0642c12..9198f2c 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -2,15 +2,15 @@