From 3ac7ee1737ec2d6a34e9f212d9689253fc99b1d9 Mon Sep 17 00:00:00 2001 From: JING Date: Fri, 26 Jul 2024 16:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E4=BC=A0=E5=B0=81?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 12 +- config/api.js | 12 +- config/request.js | 2 +- pages/user/account/index.vue | 260 ++++++++++++++++++++++++++--------- pages/user/index.vue | 60 +++++--- 5 files changed, 245 insertions(+), 101 deletions(-) diff --git a/App.vue b/App.vue index e6e2877..9320541 100644 --- a/App.vue +++ b/App.vue @@ -53,13 +53,13 @@ // #ifdef H5 post.login_type = 'official_account'; // #endif - _this.$api.post('/api/login', post,function(res){ - console.log(res); - _this.$user.session('userInfo',res); - _this.$user.session('user_id',res.id); - if(!_this.$com.isNull(res.token)) + _this.$api.post('api/login', post,function(rs){ + console.log(rs); + _this.$user.session('userInfo',rs); + _this.$user.session('user_id',rs.id); + if(!_this.$com.isNull(rs.token)) { - _this.$user.session('token',res.token); + _this.$user.session('token',rs.token); } }); }, diff --git a/config/api.js b/config/api.js index b50e9bc..dc052a9 100644 --- a/config/api.js +++ b/config/api.js @@ -22,8 +22,9 @@ var api = { /** * oss上传图片 * - * @param string fileBaseUrl url地址 - * @param string scene //对应文件配置file->file_type列表类型 + + * @param {object} data 数据对象 {filePath:'',fileType:'image',scene:'user_small'} + * scene //对应文件配置file->file_type列表类型 * "back_icon": "后端图标", "back_small": "后端小图", "back_centre": "后端中图", @@ -32,15 +33,14 @@ var api = { "user_centre": "用户端中图", "user_max": "用户端大图", "user_portrait": "用户面部模型" - * @param {object} data 数据对象 {filePath:'',fileType:'image'} * @param function thenFun then回调 * @param function catchFun catch回调 */ - ossUpload:function(fileBaseUrl,scene,data,ossthenFun,osscatchFun){ + ossUpload:function(data,ossthenFun,osscatchFun){ //从http://tmp/IX45zGr8kI1Tb1fd2c2b3045e9bfce734869d2024805.png 中 //提取 IX45zGr8kI1Tb1fd2c2b3045e9bfce734869d2024805.png 文件名 - var fileNameArr = fileBaseUrl.split('//tmp/'); + var fileNameArr = data.filePath.split('//tmp/'); console.log(fileNameArr); //获取文件名 var fileName = fileNameArr[1]; @@ -49,7 +49,7 @@ var api = { var suffix = suffixArr[1]; //先获取oss签名 api.post('api/aliSignature',{ - scene:scene, + scene:data.scene, appoint:1, filename:fileName, },function(res){ diff --git a/config/request.js b/config/request.js index dc578a1..489b6d8 100644 --- a/config/request.js +++ b/config/request.js @@ -63,7 +63,7 @@ module.exports = (vm) => { // 响应拦截 uni.$u.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/ - console.log('请求返回',response); + //console.log('请求返回',response); //这里只针对阿里云oss上传没有返回值的时候做个处理 if(response.header.Server == "AliyunOSS" && response.errMsg == "uploadFile:ok" && uni.$u.test.isEmpty(response.data)) { diff --git a/pages/user/account/index.vue b/pages/user/account/index.vue index 24d0957..14af0e6 100644 --- a/pages/user/account/index.vue +++ b/pages/user/account/index.vue @@ -50,6 +50,8 @@ color="#999999" maxlength="10" v-model="info.nick_name" + @focus="showEdit" + @change="nameChange" > @@ -65,7 +67,7 @@ - + 协议与说明 @@ -108,6 +110,38 @@ + + + + 协议与说明 + + + + + + + 我了解啦 + + + + + + + + 修改昵称 + + + + + + + 取消 + 确认 + + + + + @@ -123,10 +157,20 @@ }, uploadImg: [], + //弹窗 + show: false, + content:'', + style: { + // 字符串的形式 + p: 'font-weight: 400;font-size: 28rpx;color: #555555;line-height: 60rpx;', + + }, + //修改 + name_show:false, } }, - onLoad(option) { + onShow(option) { var _this = this; _this.getUserInfo(); @@ -136,7 +180,6 @@ //获取用户信息 getUserInfo() { - var _this =this; var _this =this; var userInfo = _this.$user.session('userInfo'); if(_this.$com.isNull(userInfo.nick_name) ) @@ -147,9 +190,16 @@ { userInfo.avatar = '/static/img/user/avatar.png'; + _this.uploadImg =[{url:userInfo.avatar}]; + _this.info = userInfo; } - _this.info = userInfo; - _this.uploadImg =[{url:userInfo.avatar}]; + else + { + _this.uploadImg =[{url:_this.$api.ossurl(userInfo.avatar)}]; + _this.info = userInfo; + } + + }, // 删除图片 @@ -167,12 +217,14 @@ { //上传 - var upData = {filePath:edetail,fileType:'image'}; - _this.$api.ossUpload(edetail,'user_small',upData,function(res){ + var upData = {filePath:edetail,fileType:'image',scene:'user_small'}; + _this.$api.ossUpload(upData,function(res){ console.log('ossUpload success',res); var d = res.data; _this.info.avatar = d.file_url; - _this.uploadImg = [{url:_this.$api.ossurl(d.file_url)}];; + _this.uploadImg = [{url:_this.$api.ossurl(d.file_url)}]; + _this.updateUserInfo(); + },function(err){ console.log('ossUpload fail',err); }); @@ -182,76 +234,46 @@ } }, - uploadFilePromise(url) { - - }, - loadData(){ - - }, - getPhoneNumber(e){ - var _this =this; - var detail = e.detail; - console.log(detail); - if (detail.errMsg === 'getPhoneNumber:ok') { - - _this.getPhoneApi(detail); - } else { - _this.$com.alert('授权失败') - } - }, - getPhoneApi(detail){ - var _this = this; - - var post ={ - - code: detail.code, - }; - _this.$api.post('ycl/user/wx-phone',post,function(rs){ - console.log(rs); - _this.info.phoneNumber = rs; - },function(err){ - console.log(err); - }); - + //名称改变 + nameChange(e) + { + console.log(e); + this.updateUserInfo(); }, - - //提交表单 - add(){ - var _this =this; + //更新用户信息 + updateUserInfo() + { + var _this = this; var info = _this.info; - - if(_this.$com.isNull(info.nick_name)) - { - _this.$com.showError('请输入昵称'); - return; - } - if(_this.$com.isNull(info.avatar) && _this.$com.isNull(info.imgBase64)) + if(_this.$com.isNull(info.avatar)) { - _this.$com.showError('请上传头像'); + _this.$com.showError('用户头像必须'); return; } - if(_this.$com.isNull(info.phoneNumber)) + if(_this.$com.isNull(info.nick_name)) { - _this.$com.showError('手机号必须'); + _this.$com.showError('用户昵称必须'); return; } - _this.btn_loading = true; - _this.btn_disabled = true; var post = info; - _this.$api.put('ycl/user/wx-update',post,function(rs){ - console.log('更新token'); - _this.$user.session('token',rs.token); - _this.$com.alert('更新成功'); - setTimeout(function(){ - uni.$u.route({ - type:'navigateBack', - delta:1, - }); - },1000); + _this.$api.post('api/userInfoEdit', post,function(rs){ + console.log(rs); + + }); + }, + //协议 + agreement(){ + var _this = this; + var post = { + type:'user_protocol', + }; + _this.$api.get('api/treatyInfo',post,function(rs){ + console.log('协议',rs); + _this.content = rs.content; + _this.show = true; + },function(err){ + console.log(err); }); - //按钮还原 - _this.btn_loading = false; - _this.btn_disabled = false; }, //注销 @@ -261,7 +283,27 @@ url:'/pages/user/account/logout' }) }, + open() { + console.log('open'); + }, + close() { + this.show = false; + }, + yes(){ + this.close(); + }, + showEdit(){ + var _this = this; + _this.name_show = true; + }, + open1() { + console.log('open'); + }, + close1() { + this.name_show = false; + + }, } } @@ -311,5 +353,87 @@ border-radius: 15rpx; margin: 0rpx auto; color:#3D3D3D;} ::v-deep .btn-big .u-button--info{ background-color: transparent !important; border: none !important; color: #FFFFFF !important; } +.popupBox{ + width: 600rpx; + height: auto; + border-radius: 24rpx; + background-color: #FFFFFF; +} +.popupTop{ + width: 600rpx; + height: 140rpx; + background: linear-gradient(to bottom, #D3D5FF 20%, #FFFFFF 50%); + border-radius: 24rpx 24rpx 0rpx 0rpx; + line-height: 140rpx; + text-align: center; + font-weight: 700; + font-size: 30rpx; + color: #333333; +} +.popupDesc{ + width:480rpx; + font-weight: 400; + font-size: 28rpx; + color: #555555; + height: 900rpx; + overflow-x:hidden; + overflow-y: scroll; + padding: 0rpx 60rpx; +} + +.popupBtn{ width: 100%; height: auto; + display: flex; flex-wrap: wrap; + justify-content: space-around; /* 使子元素在容器中均匀分布 */ + align-items: center; /* 如果需要垂直居中子元素 */ +} +.sbtnBox{ + margin: 30rpx auto; + width: 478rpx; + height: 80rpx; + font-weight: 700; + font-size: 30rpx; + line-height: 80rpx; + border: 2rpx solid #4D94FF; + text-align: center; + border-radius: 44rpx; + + +} + +.popupDesc1{ + width:480rpx; + font-weight: 400; + font-size: 28rpx; + color: #555555; + height: auto; + padding: 0rpx 60rpx; +} + + +.sbtnBox1{ + margin: 30rpx auto; + width: 226rpx; + height: 80rpx; + font-weight: 700; + font-size: 30rpx; + line-height: 80rpx; + border: 2rpx solid #4D94FF; + text-align: center; + border-radius: 44rpx; + +} + +.a1{ + background: linear-gradient( 270deg, rgba(46,87,241,0.15) 0%, rgba(131,88,246,0.15) 100%); + color:#7A74F0; +} +.a2{ + background: linear-gradient( 270deg, #2E57F1 0%, #8358F6 100%); + color:#FFFFFF; +} +.a3{ + background: linear-gradient( 270deg, #2E57F1 0%, #8358F6 100%); + color:#FFFFFF; +} diff --git a/pages/user/index.vue b/pages/user/index.vue index b33cd58..4abd6fd 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -13,10 +13,10 @@ - + - {{userInfo.nick_name}} + {{info.nick_name}} @@ -160,12 +160,13 @@