| xqd
@@ -10,35 +10,16 @@
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
<view>头像</view>
|
|
|
<view class="avatar-box" @click.stop='uploadpic'>
|
|
|
- <image mode="aspectFill" :src="userinfo.avatar?userinfo.avatar:'/static/images/head.jpg'">
|
|
|
+ <image mode="aspectFill" :src="userinfo.head?userinfo.head:'/static/images/head.jpg'">
|
|
|
</image>
|
|
|
</view>
|
|
|
- <!-- #ifdef MP-WEIXIN -->
|
|
|
- <button style="padding: 0;" class="getbutton" open-type="chooseAvatar"
|
|
|
- @chooseavatar="onChooseAvatar"></button>
|
|
|
- <!-- #endif -->
|
|
|
</view>
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
<view>昵称</view>
|
|
|
- <view class='input'><input type='nickname' name='nickname' placeholder="请输入昵称"
|
|
|
- :value='userinfo.nickname'></input>
|
|
|
+ <view class='input'><input type='nickname' name='nick' placeholder="请输入昵称"
|
|
|
+ :value='userinfo.nick' v-model="userinfo.nick"></input>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view v-if="userinfo.id_number" class='item acea-row row-between-wrapper'>
|
|
|
- <view>ID号</view>
|
|
|
- <view class='input acea-row row-between-wrapper'>
|
|
|
- <input type='text' :value='userinfo.id_number' disabled='true' class='id'></input>
|
|
|
- <u-icon name="lock" size="22" color="#868686"></u-icon>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <!-- #ifdef MP -->
|
|
|
- <view class='item acea-row row-between-wrapper'>
|
|
|
- <view>权限设置</view>
|
|
|
- <view class="input" @click="Setting">
|
|
|
- 点击管理<u-icon name="arrow-right" size="17" color="#868686" top="1"></u-icon>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <!-- #endif -->
|
|
|
</view>
|
|
|
<button class='modifyBnt' style="background: linear-gradient(to right, #00ca88, #00BCD4);"
|
|
|
hover-class="hoversubmit" formType="submit">保存修改</button>
|
| xqd
@@ -64,6 +45,13 @@
|
|
|
apiurl
|
|
|
} from '@/common/request/request';
|
|
|
// import Header from '@/components/header.vue';
|
|
|
+ import {
|
|
|
+ userInfo,
|
|
|
+ updateUserInfo
|
|
|
+ } from '@/api/my/index.js'
|
|
|
+ import
|
|
|
+ uploadImgUrl
|
|
|
+ from '@/common/config.js';
|
|
|
export default {
|
|
|
// components: {
|
|
|
// Header
|
| xqd
@@ -89,15 +77,23 @@
|
|
|
computed: {
|
|
|
...mapGetters(['appInfo', 'isLogin', 'userInfo'])
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ async onLoad() {
|
|
|
let that = this;
|
|
|
- that.userinfo = that.userInfo
|
|
|
+ // that.userinfo = that.userInfo
|
|
|
if (this.platform == 'wxMiniProgram') {
|
|
|
var menumtop = uni.getMenuButtonBoundingClientRect().top - uni.getSystemInfoSync().statusBarHeight;
|
|
|
var paddingtop = uni.getSystemInfoSync().statusBarHeight + menumtop;
|
|
|
this.tobheight = menumtop + paddingtop + uni.getMenuButtonBoundingClientRect().height;
|
|
|
}
|
|
|
|
|
|
+ let res = await userInfo()
|
|
|
+
|
|
|
+ if (res.code == 0) {
|
|
|
+ this.userinfo = res.msg
|
|
|
+ }
|
|
|
+ console.log('修改用户信息-用户信息返回值:', res);
|
|
|
+ // console.log('上传图片路径:', uploadImgUrl.baseImgUrl);
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['logout']),
|
| xqd
@@ -225,34 +221,29 @@
|
|
|
*/
|
|
|
outLogin: function() {
|
|
|
let that = this;
|
|
|
- if (that.loginType == 'h5') {
|
|
|
- uni.showModal({
|
|
|
- confirmColor: '#26B3A0',
|
|
|
- title: '提示',
|
|
|
- content: '确认退出登录?',
|
|
|
- success: function(res) {
|
|
|
- if (res.confirm) {
|
|
|
- // getLogout()
|
|
|
- // .then(res => {
|
|
|
- // console.log(res.code);
|
|
|
- // uni.clearStorage()
|
|
|
- that.logout();
|
|
|
- // that.$store.commit("LOGOUT");
|
|
|
- // uni.navigateBack({})
|
|
|
- uni.redirectTo({
|
|
|
+ uni.showModal({
|
|
|
+ confirmColor: '#26B3A0',
|
|
|
+ title: '提示',
|
|
|
+ content: '确认退出登录?',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.removeStorageSync('token')
|
|
|
+
|
|
|
+ if (uni.getStorageSync('timer')) {
|
|
|
+ console.log('logout-timer', Number(uni.getStorageSync('timer')));
|
|
|
+ clearInterval(Number(uni.getStorageSync('timer')))
|
|
|
+ uni.removeStorageSync('timer')
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.reLaunch({
|
|
|
url: '/pages/user/signin'
|
|
|
})
|
|
|
- // uni.reLaunch({
|
|
|
- // url: '/pages/index/index'
|
|
|
- // })
|
|
|
- // })
|
|
|
- // .catch(err => {});
|
|
|
- } else if (res.cancel) {
|
|
|
- console.log('用户点击取消');
|
|
|
- }
|
|
|
+ }, 1500)
|
|
|
+ } else if (res.cancel) {
|
|
|
+ console.log('用户点击取消');
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
/**
|
| xqd
@@ -269,16 +260,18 @@
|
|
|
const tempFilePaths = res.tempFilePaths;
|
|
|
//上传服务器将服务器;
|
|
|
uni.uploadFile({
|
|
|
- url: apiurl('common/upload'),
|
|
|
+ url: uploadImgUrl.baseImgUrl,
|
|
|
filePath: tempFilePaths[0],
|
|
|
name: 'file',
|
|
|
formData: {
|
|
|
- accept: 'image'
|
|
|
+ accept: 'image',
|
|
|
+ upload_type: 'ali-oss'
|
|
|
},
|
|
|
success: res2 => {
|
|
|
let a = JSON.parse(res2.data);
|
|
|
+ console.log('上传图片返回值:', a.data.path);
|
|
|
if (a.code == 0) {
|
|
|
- that.userinfo.avatar = a.data.path
|
|
|
+ that.userinfo.head = a.data.path.trim()
|
|
|
that.ifimg = true
|
|
|
} else {
|
|
|
uni.showToast({
|
| xqd
@@ -296,38 +289,68 @@
|
|
|
/**
|
|
|
* 提交修改
|
|
|
*/
|
|
|
- formSubmit: function(e) {
|
|
|
+ async formSubmit(e) {
|
|
|
let that = this,
|
|
|
value = e.detail.value;
|
|
|
|
|
|
- if (!that.ifimg && !that.userInfo.avatar) return that.$u.toast('保存失败,请上传头像');
|
|
|
- if (value.nickname == that.userinfo.nickname && !that.userInfo.nickname) return that.$u.toast(
|
|
|
- '保存失败,请填写昵称');
|
|
|
- if (value.nickname == that.userinfo.nickname && !that.ifimg) return that.$u.toast('保存失败,您并没有修改');
|
|
|
- that.$http('user.profile', {
|
|
|
- nickname: value.nickname,
|
|
|
- avatar: that.userinfo.avatar
|
|
|
- }).then(res => {
|
|
|
- if (res.code == 0) {
|
|
|
+ if (!that.userinfo.head) return that.$u.toast('请上传头像');
|
|
|
+ if (!that.userinfo.nick) return that.$u.toast(
|
|
|
+ '请填写昵称');
|
|
|
+ // if (value.nick == that.userinfo.nick && !that.ifimg) return that.$u.toast('保存失败,您并没有修改');
|
|
|
+ console.log('修改用户信息传递的参数:', {
|
|
|
+ nick: value.nick,
|
|
|
+ head: that.userinfo.head
|
|
|
+ });
|
|
|
+ // return
|
|
|
+ let res = await updateUserInfo({
|
|
|
+ nick: value.nick,
|
|
|
+ head: that.userinfo.head
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ console.log('修改用户信息返回值:', res);
|
|
|
+
|
|
|
+ if (res.code == 0) {
|
|
|
+ setTimeout(function() {
|
|
|
uni.showToast({
|
|
|
- title: '保存中...',
|
|
|
+ title: '修改成功',
|
|
|
duration: 1000,
|
|
|
- icon: 'loading',
|
|
|
})
|
|
|
- that.$store.dispatch('getUserInfo')
|
|
|
setTimeout(function() {
|
|
|
- uni.showToast({
|
|
|
- title: '保存成功',
|
|
|
- duration: 1000,
|
|
|
- })
|
|
|
- setTimeout(function() {
|
|
|
- uni.navigateBack()
|
|
|
- }, 1000);
|
|
|
+ uni.navigateBack()
|
|
|
}, 1000);
|
|
|
- } else {
|
|
|
- that.$u.toast('保存失败,请重试');
|
|
|
- }
|
|
|
- })
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ duration: 1000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // that.$http('user.profile', {
|
|
|
+ // nickname: value.nickname,
|
|
|
+ // avatar: that.userinfo.avatar
|
|
|
+ // }).then(res => {
|
|
|
+ // if (res.code == 0) {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '保存中...',
|
|
|
+ // duration: 1000,
|
|
|
+ // icon: 'loading',
|
|
|
+ // })
|
|
|
+ // that.$store.dispatch('getUserInfo')
|
|
|
+ // setTimeout(function() {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '保存成功',
|
|
|
+ // duration: 1000,
|
|
|
+ // })
|
|
|
+ // setTimeout(function() {
|
|
|
+ // uni.navigateBack()
|
|
|
+ // }, 1000);
|
|
|
+ // }, 1000);
|
|
|
+ // } else {
|
|
|
+ // that.$u.toast('保存失败,请重试');
|
|
|
+ // }
|
|
|
+ // })
|
|
|
}
|
|
|
}
|
|
|
}
|