【个人信息的修改】

1、完成接入
pull/1/MERGE
YunaiV 2023-08-19 17:47:46 +08:00
parent 5e4a9f8cc2
commit ea89482012
4 changed files with 59 additions and 105 deletions

6
api/member/auth.js Normal file
View File

@ -0,0 +1,6 @@
import request from "@/utils/request.js";
// 登出系统
export function logout() {
return request.post('app-api/member/auth/logout');
}

View File

@ -1,6 +1,11 @@
import request from "@/utils/request.js"; import request from "@/utils/request.js";
// 获得用户收件地址 // 获得基本信息
export function getUserInfo() { export function getUserInfo() {
return request.get('app-api/member/user/get'); return request.get('app-api/member/user/get');
} }
// 修改基本信息
export function updateUser(data) {
return request.put('app-api/member/user/update', data);
}

View File

@ -12,36 +12,22 @@
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
<view>昵称</view> <view>昵称</view>
<view class='input'><input type='text' name='nickname' :value='userInfo.nickname'></input> <view class='input'>
</view> <input type='text' name='nickname' :value='userInfo.nickname' />
</view>
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
<view>手机号码</view> <view>手机号码</view>
<navigator url="/pages/users/app_login/index" hover-class="none" class="input" <navigator url="/pages/users/app_login/index" hover-class="none" class="input"
v-if="!userInfo.phone"> v-if="!userInfo.mobile">
点击绑定手机号<text class="iconfont icon-xiangyou"></text> 点击绑定手机号 <text class="iconfont icon-xiangyou" />
</navigator> </navigator>
<navigator url="/pages/users/user_phone/index" hover-class="none" class="input" v-else> <navigator url="/pages/users/user_phone/index" hover-class="none" class="input" v-else>
<view class='input acea-row row-between-wrapper'> <view class='input acea-row row-between-wrapper'>
<input type='text' disabled='true' name='phone' :value='userInfo.phone' <input type='text' disabled='true' name='phone' :value='userInfo.mobile' class='id' />
class='id'></input>
<text class='iconfont icon-xiangyou'></text> <text class='iconfont icon-xiangyou'></text>
</view> </view>
</navigator> </navigator>
<!-- <navigator url="/pages/users/user_phone/index" hover-class="none" class="input" v-if="!memberInfo.phone">
点击绑定手机号<text class="iconfont icon-xiangyou"></text>
</navigator>
<view class='input acea-row row-between-wrapper' v-else>
<input type='text' disabled='true' name='phone' :value='memberInfo.phone' class='id'></input>
<text class='iconfont icon-suozi'></text>
</view> -->
</view>
<view class='item acea-row row-between-wrapper'>
<view>ID号</view>
<view class='input acea-row row-between-wrapper'>
<input type='text' :value='uid' disabled='true' class='id'></input>
<text class='iconfont icon-suozi'></text>
</view>
</view> </view>
<!-- #ifdef MP --> <!-- #ifdef MP -->
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
@ -51,7 +37,7 @@
</view> </view>
</view> </view>
<!-- #endif --> <!-- #endif -->
<view class="item acea-row row-between-wrapper" v-if="userInfo.phone"> <view class="item acea-row row-between-wrapper" v-if="userInfo.mobile">
<view>密码</view> <view>密码</view>
<navigator url="/pages/users/user_pwd_edit/index" hover-class="none" class="input"> <navigator url="/pages/users/user_pwd_edit/index" hover-class="none" class="input">
点击修改密码<text class="iconfont icon-xiangyou"></text> 点击修改密码<text class="iconfont icon-xiangyou"></text>
@ -65,57 +51,30 @@
<!-- #endif --> <!-- #endif -->
</view> </view>
</form> </form>
<!-- #ifdef MP -->
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
<!-- #endif -->
</view> </view>
</template> </template>
<script> <script>
import { import { toLogin } from '@/libs/login.js';
userEdit, import { mapGetters } from "vuex";
getLogout import * as UserApi from '@/api/member/user.js';
} from '@/api/user.js'; import * as AuthUtil from '@/api/member/auth.js';
import { export default {
switchH5Login components: {},
} from '@/api/api.js';
import {
toLogin
} from '@/libs/login.js';
import {
mapGetters
} from "vuex";
import dayjs from "@/plugin/dayjs/dayjs.min.js";
// #ifdef MP
import authorize from '@/components/Authorize';
// #endif
export default {
components: {
// #ifdef MP
authorize
// #endif
},
data() { data() {
return { return {
memberInfo: {}, memberInfo: {},
loginType: 'h5', //app.globalData.loginType loginType: 'h5', //app.globalData.loginType
userIndex: 0,
newAvatar: '', newAvatar: '',
isAuto: false, //
isShowAuth: false //
}; };
}, },
computed: mapGetters(['isLogin', 'uid', 'userInfo']), computed: mapGetters(['isLogin', 'userInfo']),
onLoad() { onLoad() {
if (!this.isLogin) { if (!this.isLogin) {
toLogin(); toLogin();
} }
}, },
methods: { methods: {
//
authColse: function(e) {
this.isShowAuth = e
},
/** /**
* 小程序设置 * 小程序设置
*/ */
@ -128,85 +87,71 @@
}, },
/** /**
* 退出登录 * 退出登录
*
*/ */
outLogin: function() { outLogin: function() {
let that = this; if (this.loginType === 'h5') {
if (that.loginType == 'h5') {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确认退出登录?', content: '确认退出登录?',
success: function(res) { success: res => {
if (res.confirm) { if (!res.confirm) {
getLogout() console.log('用户点击取消');
.then(res => { return
that.$store.commit("LOGOUT"); }
uni.reLaunch({ AuthUtil.logout().then(res => {
url: '/pages/index/index' this.$store.commit("LOGOUT");
}); uni.reLaunch({
}) url: '/pages/index/index'
.catch(err => { });
console.log(err); }).catch(err => {
}); console.log(err);
} else if (res.cancel) { });
console.log('用户点击取消');
}
} }
}); });
} }
}, },
/** /**
* 上传文件 * 上传文件
*
*/ */
uploadpic: function() { uploadpic: function() {
let that = this; this.$util.uploadImageOne({}, res => {
that.$util.uploadImageOne({ this.newAvatar = res.data;
url: 'user/upload/image', });
name: 'multipart',
model: "maintain",
pid: 0
}, function(res) {
that.newAvatar = res.data.url;
});
}, },
/** /**
* 提交修改 * 提交修改
*/ */
formSubmit: function(e) { formSubmit: function(e) {
let that = this, const formData = e.detail.value
value = e.detail.value if (!formData.nickname) {
if (!value.nickname) return that.$util.Tips({ return this.$util.Tips({
title: '用户姓名不能为空' title: '用户姓名不能为空'
}); });
value.avatar = that.newAvatar?that.newAvatar:that.userInfo.avatar; }
userEdit(value).then(res => { UserApi.updateUser({
that.$store.commit("changInfo", { nickname: formData.nickname,
amount1: 'avatar', avatar: this.newAvatar ? this.newAvatar : this.userInfo.avatar
amount2: that.newAvatar }).then(res => {
}); //
return that.$util.Tips({ this.$store.dispatch('USERINFO');
title: '更换头像已成功', //
return this.$util.Tips({
title: '保存成功',
icon: 'success' icon: 'success'
}, { }, {
tab: 3, tab: 3,
url: 1 url: 1
}); });
}).catch(msg => { }).catch(msg => {
return that.$util.Tips({ return this.$util.Tips({
title: msg || '保存失败,您并没有修改' title: msg || '保存失败,您并没有修改'
}, {
tab: 3,
url: 1
}); });
}); });
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.personal-data .wrapper { .personal-data .wrapper {
margin: 10rpx 0; margin: 10rpx 0;

View File

@ -1,6 +1,4 @@
import { TOKENNAME } from '../config/app.js';
import { HTTP_REQUEST_URL } from '@/config/app.js'; import { HTTP_REQUEST_URL } from '@/config/app.js';
import store from '../store';
export default { export default {