头像昵称存储

dev
Tuzki 2 years ago
parent 9dac8c3822
commit 87c8b4f6f7
  1. 1
      common/config.js
  2. 55
      pages/personcenter/EditProfile/EditProfile.vue
  3. 94
      pages/personcenter/personcenter.vue
  4. 2
      static/css/common.css

@ -91,6 +91,7 @@ module.exports = {
getScenicListFormFilter: REAUEST_ROOTPATH + "/mobile/scenic/getScenicListFormFilter" ,//查询景区列表(暂用在热门景区,所返回字段只有目的地详情中热门景区字段)
getWeather: REAUEST_ROOTPATH + "/mobile/weather/getweather",//天气
saveUser: REAUEST_ROOTPATH + "/mobile/weixin/saveUserInfo" ,//APP保存微信用户信息
getUser: REAUEST_ROOTPATH + "/mobile/weixin/getUserByOpenId" ,//获取微信用户信息
getUserInterest: REAUEST_ROOTPATH + "/mobile/interest/getUserInterest.do" ,//根据用户uniid查询用户关注选择的推送数据
addUserInterest: REAUEST_ROOTPATH + "/mobile/interest/addUserInterest.do" ,//保存用户关注选择的推送数据
selectControlListFormFilter : REAUEST_ROOTPATH + "/mobile/complaint/selectControlListFormFilter" ,//投诉列表

@ -26,7 +26,8 @@ export default {
data() {
return {
username: '',
url: ''
url: '',
pic:'',
};
},
onShow() {
@ -37,9 +38,39 @@ export default {
},
methods: {
onChooseAvatar(e) {
console.log(e)
let this_ = this;
const avatarUrl = e.detail.avatarUrl;
this_.url = avatarUrl;
uni.uploadFile({
url: this_.$config.fileUpload,
filePath: avatarUrl,
name: 'file',
success(res) {
console.log(res,'山川了')
if (res.statusCode != 200) {
uni.showToast({
title: '上传失败',
icon: 'none'
});
}
var obj = JSON.parse(res.data);
var flag = this_.$util.isSuccess(obj);
if (!flag) {
return;
}
obj = obj.data;
this_.pic = obj.path
console.log(this_.pic,';')
},
fail(res) {
console.log('失败了',res)
uni.showToast({
title: '上传失败',
icon: 'none'
});
}
});
},
blurname(e) {
let this_ = this;
@ -47,9 +78,29 @@ export default {
},
saveProfile() {
let this_ = this;
uni.setStorageSync('headimgurl', this_.url);
if(this_.pic&&this_.pi!=''){
uni.setStorageSync('headimgurl', this_.$config.ROOTPATH+this_.pic);
}
uni.setStorageSync('nickname', this_.username);
uni.setStorageSync('oauthTime', new Date().getTime());
const obj = {
headimgurl:this_.$config.ROOTPATH+this_.pic,
openid:uni.getStorageSync('unionid'),
nickname:this_.username
}
console.log(obj,'请求参数')
var data = {
"data": JSON.stringify(obj),
userkey:this_.$param.userkey
}
this_.$Request.post(this_.$config.saveUser,data).then(res => {
var flag = this_.$util.isSuccess(res);
if (!flag) {
return;
}
var userid = res.data;
console.log(userid,'保存返回')
})
uni.showToast({
icon: 'success',
title: '保存成功!',

@ -4,7 +4,7 @@
<view class="dzhi_top">
<!-- <image src="" class="dzhi_t_bg" mode="aspectFill"></image> -->
<view class="mode_com mode_coms">
<view class="dly_flex person_inf">
<view class="dly_flex person_inf" @click="oauthUser()">
<view class="pers_box">
<view class="pes_img">
<button class="btn_dzhi">
@ -15,7 +15,7 @@
</button> -->
</view>
</view>
<view class="pes_inf aml_30" @click="oauthUser()">
<view class="pes_inf aml_30" >
<!-- 用户昵称 -->
<view class="t_adm_box">
<!-- <text class="t_nic">{{nickname}}阳光夏~小葵</text> -- 已登录状态 显示用户昵称 -->
@ -142,6 +142,7 @@ export default {
onShow() {
if (!uni.getStorageSync('unionid') || uni.getStorageSync('unionid') == '' || uni.getStorageSync('unionid') == null) {
this.isLogin = false;
this.headimgurl = ''
}else{
this.nickname = uni.getStorageSync('nickname')
this.headimgurl = uni.getStorageSync('headimgurl')
@ -247,7 +248,6 @@ export default {
setTimeout(function () {
wx.login({
success: (res) => {
console.log(res, '登录获取的code');
var datas = {
code: res.code
};
@ -257,8 +257,28 @@ export default {
method: 'post',
success: function (res) {
const obj = JSON.parse(res.data.msg);
console.log(obj.openid);
this_.isLogin = true;
const da = {
userkey:this_.$param.userkey,
openid:obj.openid
}
this_.$Request.post(this_.$config.getUser,da).then((res)=>{
if(res.data == null){
uni.setStorageSync('nickname', '微信用户');
uni.setStorageSync('headimgurl', 'https://www.lbgjtoa.com/appImg/icon-person-01.png');
uni.setStorageSync('oauthTime', new Date().getTime());
this_.nickname = '微信用户';
this_.headimgurl = 'https://www.lbgjtoa.com/appImg/icon-person-01.png';
this_.$forceUpdate();
}else{
uni.setStorageSync('nickname', res.data.wxNickname);
uni.setStorageSync('headimgurl', res.data.wxHeadimgurl);
uni.setStorageSync('oauthTime', new Date().getTime());
this_.nickname = res.data.wxNickname;
this_.headimgurl = res.data.wxHeadimgurl;
this_.$forceUpdate();
}
})
uni.setStorageSync('unionid', obj.openid);
},
fail: function (err) {
@ -271,25 +291,7 @@ export default {
console.log('login failed ' + error);
}
});
wx.getUserInfo({
provider: 'weixin',
success: (res) => {
uni.setStorageSync('nickname', '微信用户');
uni.setStorageSync('headimgurl', 'https://www.lbgjtoa.com/appImg/icon-person-01.png');
uni.setStorageSync('oauthTime', new Date().getTime());
this_.nickname = '微信用户';
this_.$forceUpdate();
this_.headimgurl = 'https://www.lbgjtoa.com/appImg/icon-person-01.png';
},
fail: function (error) {
console.log('login failed ' + error);
}
});
// uni.showToast({
// title:","+that.nickname+"",
// icon:"none",
// duration: 1500
// })
this_.$forceUpdate();
uni.hideLoading();
}, 3000);
@ -299,6 +301,46 @@ export default {
// #endif
},
saveProfile:function(){
let this_ = this
// wx.getUserInfo({
// provider: 'weixin',
// success: (res) => {
// uni.setStorageSync('nickname', '');
// uni.setStorageSync('headimgurl', 'https://www.lbgjtoa.com/appImg/icon-person-01.png');
// uni.setStorageSync('oauthTime', new Date().getTime());
// this_.nickname = '';
// this_.headimgurl = 'https://www.lbgjtoa.com/appImg/icon-person-01.png';
// this_.$forceUpdate();
const obj = {
headimgurl:this_.headimgurl,
openid:uni.getStorageSync('unionid'),
nickname:this_.nickname
}
console.log(obj,'请求参数')
var data = {
"data": JSON.stringify(obj),
userkey:this_.$param.userkey
}
this_.$Request.post(this_.$config.saveUser,data).then(res => {
var flag = this_.$util.isSuccess(res);
if (!flag) {
return;
}
var userid = res.data;
console.log(userid,'保存返回')
})
// },
// fail: function (error) {
// console.log('login failed ' + error);
// }
// });
// uni.showToast({
// title:","+that.nickname+"",
// icon:"none",
// duration: 1500
// })
},
callBackMethod: function () {
// clearTimeout(timer);
this.isLogin = true;
@ -398,7 +440,7 @@ export default {
content: '确定退出登录?',
success: function (res) {
if (res.confirm) {
that.deleteUserApp();
// that.deleteUserApp();
(this.scenicGZType = 'NO'), (this.lineGZType = 'NO'), (this.foodGZType = 'NO'), (this.methodGZType = 'NO'), uni.removeStorageSync('nickname');
uni.removeStorageSync('headimgurl');
uni.removeStorageSync('nickname');
@ -406,7 +448,7 @@ export default {
uni.removeStorageSync('openid');
uni.removeStorageSync('unionid');
that.nickname = '点击授权';
that.headimgurl = '';
that.headimgurl = 'https://www.lbgjtoa.com/appImg/icon-person-01.png';
that.isLogin = false;
} else if (res.cancel) {
}
@ -492,7 +534,7 @@ export default {
}
}
}
};
}
</script>
<style>

@ -759,7 +759,7 @@ page{ background: #f5f5f5;}
.t_hi{font-size: 54rpx; color: #222; font-weight: 700;}
.t_nic{font-size: 32rpx; color: #444;}
.pers_box{width: 120rpx; height: 120rpx; border-radius: 50%;}
.pes_img{width: 120rpx; height: 120rpx; background: #13cdba; border-radius: 120rpx; box-shadow: rgba(0,0,0,.1) 0 5rpx 20rpx;}
.pes_img{width: 120rpx; height: 120rpx; background: #dedede; border-radius: 120rpx; box-shadow: rgba(0,0,0,.1) 0 5rpx 20rpx;}
.pes_img > .pers_box{ border-radius: 120rpx;}
.pers_lst{ padding: 80rpx 0 0rpx 0;}
.pers_lst .kou_top3{ width: 40rpx; height: 40rpx; margin-right: 10rpx;}

Loading…
Cancel
Save