|
@@ -5,22 +5,29 @@
|
|
|
<view class="bg_box">
|
|
|
<view class="top_box" @click="modifyShow = true">
|
|
|
<view class="img_box" style="display: flex">
|
|
|
- <image class="img" :src="mainBodyUserInfo.avatar? mainBodyUserInfo.avatar:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'"></image>
|
|
|
+ <image
|
|
|
+ class="img"
|
|
|
+ :src="
|
|
|
+ mainBodyUserInfo.avatar
|
|
|
+ ? mainBodyUserInfo.avatar
|
|
|
+ : 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
|
|
+ "
|
|
|
+ ></image>
|
|
|
|
|
|
<view class="">
|
|
|
- <view v-if="mainBodyUserInfo.nickname=='微信用户'" class="name">{{ mainBodyUserInfo.nickname}}{{mainBodyUserInfo.id}}</view>
|
|
|
- <view v-else class="name">{{ mainBodyUserInfo.nickname}}</view>
|
|
|
- <view class="" style="display: flex;align-items: center;">
|
|
|
- <view style="margin-left: 32rpx; font-size: 28rpx; color: rgba(68, 68, 68, 0.6)">总积分:{{mainBodyUserInfo.score}}</view>
|
|
|
- <view style="margin-left: 32rpx; font-size: 28rpx; color: rgba(68, 68, 68, 0.6)">id:{{mainBodyUserInfo.id}}</view>
|
|
|
+ <view v-if="mainBodyUserInfo.nickname == '微信用户'" class="name">{{ mainBodyUserInfo.nickname }}{{ mainBodyUserInfo.id }}</view>
|
|
|
+ <view v-else class="name">{{ mainBodyUserInfo.nickname }}</view>
|
|
|
+ <view class="" style="display: flex; align-items: center">
|
|
|
+ <view style="margin-left: 32rpx; font-size: 28rpx; color: rgba(68, 68, 68, 0.6)">总积分:{{ mainBodyUserInfo.score }}</view>
|
|
|
+ <view style="margin-left: 32rpx; font-size: 28rpx; color: rgba(68, 68, 68, 0.6)">id:{{ mainBodyUserInfo.id }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="">
|
|
|
+ <view class="">
|
|
|
<image style="width: 40rpx; height: 40rpx" src="/static/img/more.png"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view>
|
|
|
|
|
|
<!-- -->
|
|
|
<view class="btm_box">
|
|
@@ -51,16 +58,22 @@
|
|
|
<view>
|
|
|
<text>点击以下头像获取微信默认头像</text>
|
|
|
<button open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
|
|
- <image style="width: 150rpx; height: 150rpx; margin-top: 20rpx" :src="mainBodyUserInfo.avatar? mainBodyUserInfo.avatar:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'"></image>
|
|
|
+ <image
|
|
|
+ style="width: 150rpx; height: 150rpx; margin-top: 20rpx"
|
|
|
+ :src="
|
|
|
+ mainBodyUserInfo.avatar
|
|
|
+ ? mainBodyUserInfo.avatar
|
|
|
+ : 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
|
|
+ "
|
|
|
+ ></image>
|
|
|
</button>
|
|
|
</view>
|
|
|
<view style="margin-top: 20rpx">
|
|
|
<input class="ipt" @change="blurname" v-model="wxnickname" type="nickname" placeholder="请输入昵称" />
|
|
|
-
|
|
|
</view>
|
|
|
- <view style="margin-top: 40rpx">
|
|
|
+ <!-- <view style="margin-top: 40rpx">
|
|
|
<input placeholder="请输入邮箱(非必填)" border="surround" v-model="mailbox"></input>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
</view>
|
|
@@ -80,7 +93,7 @@ export default {
|
|
|
},
|
|
|
avatarUrl: '',
|
|
|
wxnickname: '',
|
|
|
- mailbox:"",/*邮箱 */
|
|
|
+ mailbox: '' /*邮箱 */,
|
|
|
getFace: false,
|
|
|
userdata: {
|
|
|
friendsLists: [],
|
|
@@ -127,8 +140,8 @@ export default {
|
|
|
onShow() {
|
|
|
/* 调用userInfo()从本地获取用户信息 */
|
|
|
this.user = this.$common.userInfo();
|
|
|
-
|
|
|
- if (this.user && this.user.nickname.indexOf('微信') >= 0) {
|
|
|
+
|
|
|
+ if (this.user && this.user.nickname.indexOf('微信') >= 0) {
|
|
|
this.getFace = true;
|
|
|
}
|
|
|
},
|
|
@@ -136,7 +149,7 @@ export default {
|
|
|
/* 来到我的页面判断用户是否登录 */
|
|
|
_this = this;
|
|
|
this.user = this.$common.userInfo();
|
|
|
- this.mainBodyUserInfo= this.$db.get('mainBodyUserInfo');
|
|
|
+ this.mainBodyUserInfo = this.$db.get('mainBodyUserInfo');
|
|
|
// console.log(this.user);
|
|
|
if (this.user === 'undefined' || this.user === '' || this.user === [] || this.user === null) {
|
|
|
/* 跳转到登录页 */
|
|
@@ -145,8 +158,7 @@ export default {
|
|
|
/* 刷新 */
|
|
|
this.$api.refreshUser(
|
|
|
{
|
|
|
- main_body_id: 1,
|
|
|
-
|
|
|
+ main_body_id: 1
|
|
|
},
|
|
|
(val) => {
|
|
|
console.log(val, 999);
|
|
@@ -159,22 +171,21 @@ export default {
|
|
|
this.auth = val.data.auth;
|
|
|
this.$db.set('user', val.data.user);
|
|
|
this.$db.set('auth', val.data.auth);
|
|
|
- _this.$db.set('mainBodyUserInfo',val.data.mainBodyUserInfo);
|
|
|
- this.mainBodyUserInfo= this.$db.get('mainBodyUserInfo');
|
|
|
+ _this.$db.set('mainBodyUserInfo', val.data.mainBodyUserInfo);
|
|
|
+ this.mainBodyUserInfo = this.$db.get('mainBodyUserInfo');
|
|
|
}
|
|
|
);
|
|
|
-
|
|
|
}
|
|
|
// this.getMainBodyUser()
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
-// getMainBodyUser(){
|
|
|
+ // getMainBodyUser(){
|
|
|
|
|
|
-// this.$api.getMainBodyUser({main_body_id:1,main_body_user_id:this.mainBodyUserInfo.},function(res){
|
|
|
-// console.log(res,78787878)
|
|
|
-// })
|
|
|
-// },
|
|
|
+ // this.$api.getMainBodyUser({main_body_id:1,main_body_user_id:this.mainBodyUserInfo.},function(res){
|
|
|
+ // console.log(res,78787878)
|
|
|
+ // })
|
|
|
+ // },
|
|
|
myList(i) {
|
|
|
uni.navigateTo({
|
|
|
url: this.items[i].path
|
|
@@ -182,7 +193,7 @@ export default {
|
|
|
},
|
|
|
// 获取头像
|
|
|
onChooseAvatar(e) {
|
|
|
- this.mainBodyUserInfo.avatar=e.detail.avatarUrl
|
|
|
+ this.mainBodyUserInfo.avatar = e.detail.avatarUrl;
|
|
|
// this.avatarUrl = e.detail.avatarUrl;
|
|
|
},
|
|
|
// 获取昵称
|
|
@@ -190,105 +201,109 @@ export default {
|
|
|
this.wxnickname = e.detail.value;
|
|
|
this.mainBodyUserInfo.nickname = e.detail.value;
|
|
|
},
|
|
|
- isOk() {
|
|
|
- this.modifyShow = false;
|
|
|
- let userToken = '';
|
|
|
- let auth = this.$db.get('auth');
|
|
|
- userToken = auth.token;
|
|
|
-
|
|
|
- // 准备formData,无论filePath是否存在都添加
|
|
|
- let formData = {
|
|
|
- nickname: this.wxnickname
|
|
|
- };
|
|
|
-
|
|
|
- // 如果有图片路径,则准备上传
|
|
|
- let uploadPromise = Promise.resolve();
|
|
|
- if (this.mainBodyUserInfo.avatar) {
|
|
|
- uploadPromise = new Promise((resolve, reject) => {
|
|
|
- uni.uploadFile({
|
|
|
- url: this.$config.baseUrl + 'api/common/upload?token=' + userToken,
|
|
|
- filePath: this.mainBodyUserInfo.avatar,
|
|
|
- fileType: 'image',
|
|
|
- name: 'file',
|
|
|
- headers: {
|
|
|
- Accept: 'application/json',
|
|
|
- 'Content-Type': 'multipart/form-data'
|
|
|
- },
|
|
|
- formData: formData,
|
|
|
- success: (uploadFileRes) => {
|
|
|
- var dataimg = JSON.parse(uploadFileRes.data);
|
|
|
- formData.avatar = dataimg.data.fullurl; // 若上传成功,更新formData中的avatar
|
|
|
- resolve(); // 成功后调用resolve
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- console.error('图片上传失败', err);
|
|
|
- reject(err); // 失败后调用reject,但后续操作仍会执行
|
|
|
- },
|
|
|
- complete: () => {
|
|
|
- // 无论成功还是失败,都继续执行编辑用户信息的API调用
|
|
|
- _this.$api.editMainBodyUser({
|
|
|
- avatar: formData.avatar || '', // 确保有值,即使上传失败也尝试提交
|
|
|
- main_body_id: 1,
|
|
|
- main_body_user_id: this.mainBodyUserInfo.id,
|
|
|
- nickname: this.wxnickname
|
|
|
- }, (data) => {
|
|
|
- _this.$common.successToShow('修改成功');
|
|
|
- if (formData.avatar) {
|
|
|
- // 只有上传成功才更新
|
|
|
- _this.mainBodyUserInfo.avatar = formData.avatar;
|
|
|
- }
|
|
|
- _this.mainBodyUserInfo.nickname = _this.wxnickname;
|
|
|
- _this.$db.set('mainBodyUserInfo', _this.mainBodyUserInfo);
|
|
|
- console.log(_this.mainBodyUserInfo,56456456);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- // isOk() {
|
|
|
-
|
|
|
- // this.modifyShow = false;
|
|
|
- // let userToken = '';
|
|
|
- // let auth = this.$db.get('auth');
|
|
|
- // userToken = auth.token;
|
|
|
- // uni.uploadFile({
|
|
|
- // url: this.$config.baseUrl + 'api/common/upload?token=' + userToken,
|
|
|
- // filePath: this.mainBodyUserInfo.avatar,
|
|
|
- // fileType: 'image',
|
|
|
- // name: 'file',
|
|
|
- // headers: {
|
|
|
- // Accept: 'application/json',
|
|
|
- // 'Content-Type': 'multipart/form-data'
|
|
|
- // },
|
|
|
- // formData: { nickname: this.wxnickname },
|
|
|
- // success: (uploadFileRes) => {
|
|
|
- // console.log(9999)
|
|
|
- // // console.log(JSON.parse(uploadFileRes.data), 6666);
|
|
|
- // var dataimg = JSON.parse(uploadFileRes.data);
|
|
|
- // // console.log(dataimg.data.fullurl, 6666);
|
|
|
- // _this.$api.editMainBodyUser(
|
|
|
- // {
|
|
|
- // avatar: dataimg.data.fullurl,
|
|
|
- // main_body_id: 1,
|
|
|
- // main_body_user_id: this.mainBodyUserInfo.id,
|
|
|
- // nickname: this.wxnickname
|
|
|
- // },
|
|
|
- // (data) => {
|
|
|
- // _this.$common.successToShow('修改成功');
|
|
|
- // _this.mainBodyUserInfo.avatar =dataimg.data.fullurl;
|
|
|
- // _this.mainBodyUserInfo.nickname = _this.wxnickname;
|
|
|
- // _this.$db.set('mainBodyUserInfo', _this.mainBodyUserInfo);
|
|
|
- // console.log(_this.mainBodyUserInfo,56456456)
|
|
|
- // }
|
|
|
- // );
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ isOk() {
|
|
|
+ if (this.wxnickname == '' || this.wxnickname == undefined) {
|
|
|
+ this.$common.errorToShow('请输入昵称');
|
|
|
+ } else {
|
|
|
+ this.modifyShow = false;
|
|
|
+ let userToken = '';
|
|
|
+ let auth = this.$db.get('auth');
|
|
|
+ userToken = auth.token;
|
|
|
+
|
|
|
+ // 准备formData,无论filePath是否存在都添加
|
|
|
+ let formData = {
|
|
|
+ nickname: this.wxnickname
|
|
|
+ };
|
|
|
+
|
|
|
+ // 如果有图片路径,则准备上传
|
|
|
+ let uploadPromise = Promise.resolve();
|
|
|
+ if (this.mainBodyUserInfo.avatar) {
|
|
|
+ uploadPromise = new Promise((resolve, reject) => {
|
|
|
+ uni.uploadFile({
|
|
|
+ url: this.$config.baseUrl + 'api/common/upload?token=' + userToken,
|
|
|
+ filePath: this.mainBodyUserInfo.avatar,
|
|
|
+ fileType: 'image',
|
|
|
+ name: 'file',
|
|
|
+ headers: {
|
|
|
+ Accept: 'application/json',
|
|
|
+ 'Content-Type': 'multipart/form-data'
|
|
|
+ },
|
|
|
+ formData: formData,
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ var dataimg = JSON.parse(uploadFileRes.data);
|
|
|
+ formData.avatar = dataimg.data.fullurl; // 若上传成功,更新formData中的avatar
|
|
|
+ resolve(); // 成功后调用resolve
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('图片上传失败', err);
|
|
|
+ reject(err); // 失败后调用reject,但后续操作仍会执行
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ // 无论成功还是失败,都继续执行编辑用户信息的API调用
|
|
|
+ _this.$api.editMainBodyUser(
|
|
|
+ {
|
|
|
+ avatar: formData.avatar || '', // 确保有值,即使上传失败也尝试提交
|
|
|
+ main_body_id: 1,
|
|
|
+ main_body_user_id: this.mainBodyUserInfo.id,
|
|
|
+ nickname: this.wxnickname
|
|
|
+ },
|
|
|
+ (data) => {
|
|
|
+ _this.$common.successToShow('修改成功');
|
|
|
+ if (formData.avatar) {
|
|
|
+ // 只有上传成功才更新
|
|
|
+ _this.mainBodyUserInfo.avatar = formData.avatar;
|
|
|
+ }
|
|
|
+ _this.mainBodyUserInfo.nickname = _this.wxnickname;
|
|
|
+ _this.$db.set('mainBodyUserInfo', _this.mainBodyUserInfo);
|
|
|
+ // console.log(_this.mainBodyUserInfo,56456456);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // isOk() {
|
|
|
+
|
|
|
+ // this.modifyShow = false;
|
|
|
+ // let userToken = '';
|
|
|
+ // let auth = this.$db.get('auth');
|
|
|
+ // userToken = auth.token;
|
|
|
+ // uni.uploadFile({
|
|
|
+ // url: this.$config.baseUrl + 'api/common/upload?token=' + userToken,
|
|
|
+ // filePath: this.mainBodyUserInfo.avatar,
|
|
|
+ // fileType: 'image',
|
|
|
+ // name: 'file',
|
|
|
+ // headers: {
|
|
|
+ // Accept: 'application/json',
|
|
|
+ // 'Content-Type': 'multipart/form-data'
|
|
|
+ // },
|
|
|
+ // formData: { nickname: this.wxnickname },
|
|
|
+ // success: (uploadFileRes) => {
|
|
|
+ // console.log(9999)
|
|
|
+ // // console.log(JSON.parse(uploadFileRes.data), 6666);
|
|
|
+ // var dataimg = JSON.parse(uploadFileRes.data);
|
|
|
+ // // console.log(dataimg.data.fullurl, 6666);
|
|
|
+ // _this.$api.editMainBodyUser(
|
|
|
+ // {
|
|
|
+ // avatar: dataimg.data.fullurl,
|
|
|
+ // main_body_id: 1,
|
|
|
+ // main_body_user_id: this.mainBodyUserInfo.id,
|
|
|
+ // nickname: this.wxnickname
|
|
|
+ // },
|
|
|
+ // (data) => {
|
|
|
+ // _this.$common.successToShow('修改成功');
|
|
|
+ // _this.mainBodyUserInfo.avatar =dataimg.data.fullurl;
|
|
|
+ // _this.mainBodyUserInfo.nickname = _this.wxnickname;
|
|
|
+ // _this.$db.set('mainBodyUserInfo', _this.mainBodyUserInfo);
|
|
|
+ // console.log(_this.mainBodyUserInfo,56456456)
|
|
|
+ // }
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
@@ -356,11 +371,11 @@ button {
|
|
|
.item_tit {
|
|
|
margin-left: 20rpx;
|
|
|
font-size: 32rpx;
|
|
|
-
|
|
|
+
|
|
|
font-weight: 900;
|
|
|
line-height: 48rpx;
|
|
|
background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
|
|
|
-webkit-background-clip: text;
|
|
|
-webkit-text-fill-color: transparent;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|